Community of VE/MapPoint Users and Developers
This is a discussion on appending census tract to a pushpoint within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; I am trying to find a way to take data (street address) in mass and assign census tract #'s to ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| VB.Net Code
Here is some code I wrote to assist with something like that with MapPoint 2004. This code is provided AS IS, so use it at your own risk: I don't have all the bugs worked out. You need to decode the artifical line breaks from the posting, if any, yourself (sorry). Note: though you can run this without starting mappoint, don't. I used MSDN's example for ""MapPoint Get MSAs Add-in" as a base and tweaked it accordingly. Call it from some form: Dim objCTF as MyClass.CensusTrackFindfer = New MyClass.CensusTrackFinder MsgBox(objCTF.CensusTrack("1 Main Street, Big City, CA 90001")) The Class: Public Class CensusTrackFinder Private App As MapPoint.Application Private Map As MapPoint.Map Private NewApp As Boolean Private MapStyle As MapPoint.GeoMapStyle Private MapAltitude As String Private MapLocation As MapPoint.Location Private BlockMapStyle As Boolean ' If true, don't active swtich the map style after each find Public Sub New() NewApp = False Try App = GetObject(, "MapPoint.Application") Catch ex As System.Exception NewApp = True App = New MapPoint.Application End Try Map = App.ActiveMap BlockMapStyle = False End Sub Protected Overrides Sub Finalize() If NewApp Then App = Nothing MyBase.Finalize() End Sub Public WriteOnly Property LockMapStyle() As Boolean Set(ByVal Value As Boolean) If Value And Not BlockMapStyle Then ' If off and turned on, record the current map style BlockMapStyle = True MapStyle = Map.MapStyle MapAltitude = Map.Altitude.ToString MapLocation = Map.Location Map.MapStyle = MapPoint.GeoMapStyle.geoMapStyleData Map.Altitude = "15" ElseIf Not Value And BlockMapStyle Then ' If on and turned off, revert to the old map style BlockMapStyle = False Map.MapStyle = MapStyle Map.Altitude = MapAltitude MapLocation.GoTo() End If End Set End Property Public Function CensusTrack(ByVal Address As String) As String With Map.ParseStreetAddress(Address) Return FindCensusTrack(Map.FindAddressResults(.Street, .City, , , .PostalCode, .Country)(1)) End With End Function Public Function CensusTrack(ByVal Street As String, ByVal City As String, ByVal State As String, ByVal Zip As String) As String Return FindCensusTrack(Map.FindAddressResults(Street, City, , , Zip, "USA")(1)) End Function Private Function FindCensusTrack(ByVal Location As MapPoint.Location) As String Dim Result As String Dim FindResults As MapPoint.FindResults Dim OldMapStyle As MapPoint.GeoMapStyle Dim OldAltitude As String Dim OldLocation As MapPoint.Location With Map If Not BlockMapStyle Then OldMapStyle = .MapStyle ' Not Block, so record current map style OldAltitude = .Altitude.ToString OldLocation = .Location If (OldMapStyle <> MapPoint.GeoMapStyle.geoMapStyleData) Then .MapStyle = MapPoint.GeoMapStyle.geoMapStyleData If (OldAltitude <> "15") Then .Altitude = "15" End If Location.GoTo() FindResults = .ObjectsFromPoint(.LocationToX(Location), .LocationToY(Location)) If FindResults.Count > 0 Then For Each Loc As Object In FindResults If Loc.Name.Trim.Length > 0 Then Result = Loc.Name Exit For End If Next Else Result = "" End If If Not BlockMapStyle Then If (OldMapStyle <> MapPoint.GeoMapStyle.geoMapStyleData) Then .MapStyle = OldMapStyle If (OldAltitude <> "15") Then .Altitude = OldAltitude OldLocation.GoTo() End If End With Return Result End Function End Class vbnet@grahamlower.com |
![]() |
| Tags |
| appending, census, pushpoint, tract |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Getting Census Tract from a pushpin | Anonymous | MapPoint 2006/2009 Discussion | 2 | 06-06-2005 12:09 PM |
| trying to automate lat long (pushpin) to census tract mappin | Anonymous | MapPoint 2006/2009 Discussion | 2 | 02-02-2005 12:54 PM |
| census tract format | Anonymous | MapPoint 2006/2009 Discussion | 1 | 10-17-2003 08:03 PM |
| Census Tract Input Field | Jim Grace | MapPoint 2006/2009 Discussion | 2 | 06-03-2003 06:38 PM |
| MapPoint 2003 and census 2000 tract boundaries | Anonymous | MapPoint 2006/2009 Discussion | 2 | 04-20-2003 07:03 AM |