Community of VE/MapPoint Users and Developers
This is a discussion on Underlying Street Address of POI within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Can anyone provide a solution for this? Using the MapPoint Control both MP2K2 and MP2K4 return a street address 'underlying' ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Using the MapPoint Control both MP2K2 and MP2K4 return a street address 'underlying' a point of interest e.g. Riverside Cafe, Burbank CA returns 1221 W Riverside Drive, Burbank CA (which is indeed correct). However MP2K6's control (i.e. programmatic access) returns nothing whereas the MP2K6 application manages to display the address in the balloon. How can I 'persuade' MP2K6's control to provide the street address just like MapPoint app?
__________________ Adrian Sheard |
| |||
|
This is a known issue with MapPoint 2006 and has occasionally even been noted with MapPoint 2004. Perhaps it is due in part to licensing agreements with the POI Data Providers. The best solution I've come up with is to employ reverse-geocoding techniques to find the nearest address to the POI item. Here's a VB.Net module which I use to get around it. The module is based on a very convoluted mixture of the reverse-geocoding articles on mp2kmag.com's website which were originally authored by Walt Cygan and Gilles Kohl. Just pass the POI Location to the function "GetNearestLocationAddress" and you'll get something usable back '------BEGIN CODE------------- Module modAdvancedAddressFuncs Public Function GetNearestLocationAddress(ByRef objMap As MapPoint.Map, ByVal OriginalLocation As MapPoint.Location) As MapPoint.Location 'Gets an address for a Location object using reverse-geocoding brute-force 'This code is loosely cased on Walt Cygan's article from mp2kmag.com Dim objLoc As MapPoint.Location Dim objResults As MapPoint.FindResults 'Attempt to find an address at (approximately) this SAME position. 'Note this might not actually be the same position, since the current map Altitude ' has an increasing effect on the ObjectsFromPoint() method. OriginalLocation.GoTo() objMap.Altitude = 0.01D objResults = objMap.ObjectsFromPoint(objMap.LocationToX(Origina lLocation), objMap.LocationToY(OriginalLocation)) For Each Result As MapPoint.Location In objResults If Not (Result.Location.StreetAddress Is Nothing) Then Return Result.Location Exit Function End If Next Result 'Nothing was found, so recursively attempt to find a "near match." 'Search at points spiralling outward from the original location. 'We search at points in the order of North, South, East, West, NE, SE, NW, SW ' since nearby roads will most likely be "hit" in those locations. Dim ThisLoc As MapPoint.Location For DeltaOfs As Double = 0.001D To 0.1D Step 0.001D For OctagonPosition As Integer = 1 To 8 ThisLoc = TryDeltaLoc(objMap, OriginalLocation, OctagonPosition, DeltaOfs) If Not (ThisLoc.StreetAddress Is Nothing) Then 'we found a nearby address, so use Routing to find the start address Return FindAddressByRoute(objMap, OriginalLocation, ThisLoc) Exit Function End If Next OctagonPosition Next DeltaOfs noneFound: 'if we got this far, then we haven't gotten any hits, so return nothing Return Nothing Exit Function End Function Private Function TryDeltaLoc(ByRef objMap As MapPoint.Map, ByVal CenterLoc As MapPoint.Location, ByVal OctagonPosition As Integer, ByVal Offset As Double) As MapPoint.Location 'Try to geocode at a Delta-ed location by octagon position (rotated coordinate quadrant) Dim Lat, Lng As Double Lat = CenterLoc.Latitude Lng = CenterLoc.Longitude Dim DeltaLoc As MapPoint.Location Select Case OctagonPosition Case 1 'north DeltaLoc = objMap.GetLocation(Lat, Lng + Offset) Case 2 'south DeltaLoc = objMap.GetLocation(Lat, Lng - Offset) Case 3 'east DeltaLoc = objMap.GetLocation(Lat + Offset, Lng) Case 4 'west DeltaLoc = objMap.GetLocation(Lat - Offset, Lng) Case 5 'NorthEast DeltaLoc = objMap.GetLocation(Lat + Offset, Lng + Offset) Case 6 'SouthEast DeltaLoc = objMap.GetLocation(Lat - Offset, Lng + Offset) Case 7 'NorthWest DeltaLoc = objMap.GetLocation(Lat + Offset, Lng - Offset) Case 8 'SouthWest DeltaLoc = objMap.GetLocation(Lat - Offset, Lng - Offset) End Select 'now attempt to reverse geocode at THIS location DeltaLoc.GoTo() objMap.Altitude = 0.01D Dim objResults As MapPoint.FindResults = objMap.ObjectsFromPoint(objMap.LocationToX(DeltaLo c), objMap.LocationToY(DeltaLoc)) For Each Result As MapPoint.Location In objResults If Not (Result.Location.StreetAddress Is Nothing) Then Return Result.Location Exit Function End If Next Result 'if we got nothing, still need to return a valid location object, ' so return the original Return CenterLoc End Function Private Function FindAddressByRoute(ByRef objMap As MapPoint.Map, ByVal StartLoc As MapPoint.Location, ByVal NearbyLoc As MapPoint.Location) As MapPoint.Location Dim Rte As MapPoint.Route = objMap.ActiveRoute 'clear any current route data If Not (Rte Is Nothing) Then Rte.Clear() 'create the route from the point we're attempting to geocode to a known-good nearby address Rte.Waypoints.Add(StartLoc) Rte.Waypoints.Add(NearbyLoc) Rte.Calculate() 'call a single recursion of the original routine Return GetNearestLocationAddress(objMap, Rte.Directions.Item(1).Location) End Function End Module '------END CODE------------- HTH Paul |
![]() |
| Tags |
| address, poi, street, underlying |
| ||||
| Posted By | For | Type | Date | |
| Using MapPoint and Excel for Supply Chain Management - MapPoint Articles - MP2K Magazine | This thread | Refback | 01-21-2007 09:15 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| street address from lat/lon... VB style | Anonymous | MapPoint 2006/2009 Discussion | 3 | 06-09-2005 01:12 PM |
| Getting 'second' street address | Anonymous | MapPoint 2006/2009 Discussion | 1 | 05-06-2004 09:31 AM |
| GeoRoadType from Street Address | Anonymous | MapPoint 2006/2009 Discussion | 0 | 01-25-2004 05:22 AM |
| street address limit | bob | MapPoint 2006/2009 Discussion | 5 | 11-04-2003 07:51 AM |
| Thoughts on War – GPS Precision Vs. Underlying Data | Anonymous2000 | MapPoint 2006/2009 Discussion | 2 | 04-02-2003 01:22 PM |
Val d'Isere
For a ski holiday destination renowned for combining great skiing with a vibrant nightlife, book a holiday to Val d'Isere. Holiday Hypermarket brings you the latest great deals.
Honeymoon Holidays
Book your Honeymoon holiday with Travel Counsellors. A personal advisor will help you plan the perfect honeymoon holiday.
Italy Holiday
An Italy Holiday is full of interesting stuff for the casual tourist and even more for the educated visitor. Check out the latest great deals at dealchecker.co.uk.
Mauritius Holidays
Mauritis holidays are a sun drenched, sense tingling experience of a lifetime. You will find bargain deals on many holidays with us!
Cheap Egypt Holidays
Pick up a bargain cheap Egypt holiday online when you visit ulookubook.com. Just check out our tips to make sure you book at the right time to get a great holiday for a great price. Finding cheap Egypt holidays can be simple when you know how.
Holiday
For the holiday of your life, that is easy to plan, visit Travel.co.uk to see all the options.
Cheap Holidays in Lanzarote
Now's the time to get up and go visit the Canary Islands! View cheap holidays in Lanzarote only at On The Beach.