spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2013
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  ARTICLES  


Reverse Geocoding, Pt. III

Walt Cygan, a frequent contributor of late, submits this solution for tackling reverse geocoding

My code to do reverse geocoding was intended to answer the need to able to find an address near a location virtually all of the time. Compared with Gilles Kohl's approach in http://www.mp2kmag.com/articles.asp?ArticleID=47, mine is more brute force in nature. I use the ObjectsFromPoint method repeatedly at slightly different locations to attempt to find an address.

In the code I use data on a SQL Server 2000 database where I have lat and lon stored. The steps I go through to get the address are:

  1. Use the GetLocation method with the database lat and lon.
  2. Check the Location object from step 1 with the ObjectsFromPoint method to see if the best match has a street address. If so, I'm done. If not, move on.
  3. Round the database lat/lon to 4 digits after the decimal and get use those coordinates with GetLocation
  4. Check the Location object from step 3 with the ObjectsFromPoint method to see if the best match has a street address. If so, I'm done. If not, move on.

Now is where the fun starts: I start working outward in squares (spherical rectangles really) each 1-ten thousandth of point of latitude and longitude larger that the one before. The center point is the location found after rounding to 4 digits. The first square has 8 points, the next has 16, then 24, 32, etc. I have the code set to do 10 squares before giving up, giving a total of 442 attempts, including the one with the original latitude and longitude. The idea here was to find the nearest possible address without ever testing the same point twice.

For each point the same process as in steps 1-4 is followed: GetLocation followed by ObjectsFromPoint.

I tested this code on 22 locations in and around Minneapolis and St. Paul, Minnesota. Most of these points had been moved slightly to more accurately place their pushpin on the map before getting their latitudes and longitudes that were stored on the database. Addresses were found for all 22 locations in just over a minute using the ActiveX control in a VB app. The majority of this time was used to find 2 of the addresses, 1 in a more rural area, 1 next to a golf course (therefore fewer available nearby streets and addresses). 10 addresses were found on the first attempt; 18 were found in 7 or fewer attempts; the rest in 18, 39, 112 and 403 attempts. When run only with the 18 addresses that were found in fewer than 10 attempts, the process ran in about 10 seconds.

The code is as follows (Note to folks who saw a preview of this: I made a small change adding "Exit For" statements for each inner loop for the sides of the "squares"):

Discuss this story in the forum.

Author: Walt Cygan
Email: wcygan(AT)macrogroup.net
URL: http://www.macrogroup.net
Walt is a consultant for The MACRO GROUP, Inc. in Minneapolis, Minnesota. The MACRO GROUP, Inc. is an information systems consulting firm whose customers include public, private and non-profit organizations of all sizes.



Google
 
MP2Kmag Internet


 Recent Discussion
-GCPowerStation v17.2
-GCPowerStation v17.2
-Gaussian 09W v8.0 Rev B.01 SMP
-Gaussian 09 E.01 Linux64
-Atmel Studio v.7.0.1931
-Steinberg Cubase Elements v9.5.40 WiN
-Nero Platinum 2019 Suite 20.0.05900 Multilingual
-Serif DrawPlus X8 14.0.0.19
-PROMT Master 19 Final + PROMT 19 Dictionary Collection
-Apple Logic Pro X v.10.4.2 Multilanguage (MacOSX)
-PROMT Expert 19 Final + PROMT 19 Dictionary Collection
-Waves Complete v2018.10.16 WiN by R2R
-VMware Fusion Pro 10.1.1 MacOSX
-Foxit Phantompdf Business v.9.3.0.10826 Multilanguage
-Bluestacks v4.31.56.2510 Multilingual
-Xara Web Designer Premium 16.0.0.55162 (x64) Portable
-Adobe Bridge CC 6.1.1.10 Update 3 by m0nkrus
-Garmin MapSource v5.4
-Alien Skin Exposure X4 Bundle 4.0.2.43 | macOS
-Unity Asset Cubebrush - Scrap City Assets 1.0 x64
-Magix Samplitude Pro X3 Suite v.14.4.0.518 Multilanguage
-Waves Complete v2018.10.16
-Oxygen XML Editor 18.0 (Win/Mac/Lnx)
-Steinberg Cubase Elements v9.5.40 WiN
-The Foundry Nuke Studio 11.2v4 Win x64
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Columbia, MO Real Estate


Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.