At my wits end with mappoint & ImportTerritories() with VB.NET

a_jam_sandwich
09-25-2007, 11:51 AM
Hi,

I'm attempting to create a program that imports a set of postal sectors into mappoint as a territory code below.


Private Sub ImportDataTableInvoke(ByVal DataTable As DataTable)
mobjMapPoint.NewMap(GeoMapRegion.geoMapEurope)
mobjMapPoint.Visible = False
Try
' TempFile
Dim stmTempFile As New IO.StreamWriter(mstrFilename, False)
' Headings
stmTempFile.WriteLine("Name, PostcodeSector")
' Loop though the record set
For Each rowDataRow As DataRow In DataTable.Rows
stmTempFile.WriteLine(CStr(rowDataRow("Territory")) & "," & CStr(rowDataRow("PostcodeSector")).ToLower)
Next
' Close file
stmTempFile.Close()

Dim Fields(,) As Object = { _
{"Name", GeoFieldType.geoFieldTerritory}, _
{"PostcodeSector", GeoFieldType.geoFieldPostal3} _
}

Dim objDataset As MapPoint.DataSet

objDataset = mobjMapPoint.ActiveMap.DataSets.ImportTerritories( mstrFilename, Fields, GeoCountry.geoCountryUnitedKingdom, GeoDelimiter.geoDelimiterComma, )
' Set the map style
mobjMapPoint.ActiveMap.MapStyle = GeoMapStyle.geoMapStyleData
' Zoom in
objDataset.ZoomTo()
' Success
mblnImportFailed = False
Catch ex As Exception
Debug.WriteLine(ex.ToString)
mblnImportFailed = True
End Try
End SubThe above returns the error message 'The territory set was empty, so territories were not created on the map and the set was deleted.' I have no idea what that means?

The other weird and strange thing is if I let mappoint decide whats best by importing using the code below


objDataset = mobjMapPoint.ActiveMap.DataSets.ImportTerritories( mstrFilename, System.Reflection.Missing.Value, GeoCountry.geoCountryUnitedKingdom, GeoDelimiter.geoDelimiterComma, )Mappoint will draw the map but on a few datasets it returns 'No matching method defined for these fields.' I'm taking this to be that mappoint doesn't know where that postcode sector is? if so how do I get around this error?

Thanks

Andy

davidb
09-26-2007, 10:20 AM
Hi Andy. This will probably be of no help whatsoever as I know nothing about programming in vb.net. However I have set up various territories definitions in the UK based on postal geography both manually and using vba in excel. I used to get lots of error messages and incorrect plotting of sectors until it became apparent that there is a casing problem in MPE2006 and that the only way to get around this is to read the sector names in lower case rather than upper case eg kt17 4 instead of KT17 4. Not sure if your frustrations could be wound up with this but it might be worth giving it a try.

Rgds

a_jam_sandwich
09-26-2007, 11:55 AM
Thanks for your reply and have found that problem with the uppercase before, and at the time that caused a headacke.

I have solved my problem by;

Creating a MapPoint file with the territory dataset linked to a file and opening that file within my application as a template. The territory file is updated within my application and eachtime the territory dataset gets updated using 'mobjMapPoint.ActiveMap.DataSets.Item(1).UpdateLin k()'. Much to my amazement not even that always works and sometimes produces a COM error stating that the dataset has failed to be updated (always the same files). But even more amazing is if I call that above function for a second time the file links correctly. I also tried this updating within mappoint and the same happens.


My conculsion is that MapPoint is pap! It's a peice of software that just about works :(

Arh well.

Thanks

Andy

 
Web mp2kmag.com
mapforums.com