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
-numeca fine
-AutoColor
-SolidThinking Inspire v2016.1.5559 x64-BEAN (17/8)
-Auto FX PhotoGraphic Edges Ultimate Bundle Gen2 v9.6.0 (17/8)
-Mentor Graphics FloEFD 14.2-SSQ (17/8)
-Dlubal RFEM 5.06 (x64) Multilanguage (17/8)
-Bluebeam Revu eXtreme 2018.1 v18.x Multilingual (17/8)
-Autodesk Maya 2018.4 (17/8)
-Adobe Bridge CC 2018 (v8.1) x86-x64 Multilingual Update 2 (17/8)
-Simufact.Welding 4.0.1 (17/8)
-ANSYS Discovery Enterprise 19.1.1 (17/8)
-Aurora SPARK3D v2018
-ANSYS Electromagnetics Suite 17.1 (17/8)
-Solidthinking Inspire v2018.3.0.10526 Multilingual (x64) (17/8)
-Adobe Acrobat Pro DC 2018.011.20058 Multilingual (17/8)
-ANSYS Electromagnetics Suite 17.0 (x64) (17/8)
-GibbsCAM 12.0.29.0 (x64) Multilingual (17/8)
-Autodesk Autocad Mechanical 2019.1 by m0nkrus (17/8)
-Adobe Bridge CC 2018 v8.1 (x86/x64) Update 2 Multilingual (17/8)
-Autodesk AutoCAD Electrical 2019.1 (17/8)
-DS V5R22 CATIA-DELMIA-ENOVIA last hotfixes for all SP (17/8)
-VMware Fusion Pro 10.1.3 Build 9472307 (17/8)
-MAGIX Fotostory easy 2.0.0.35 Germany + English (17/8)
-Ds Simulia Abaqus v6.14-4 (17/8)
-Paragon Drive Copy 15 Professional 10.1.25.779 (x86/x64) (17/8)
 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.