Handling the Leeds/Reichenbach problem (Geocoding Disambiguation)
Developers of web mapping applications often hit an unexpected issue with geocoding (searching for the lat/lon of places). You expect a geocodong request to return a single Lat/Lon pair (e.g. when searching for London, UK) but sometimes multiple locations are returned (and this may crash your app with an unexpected result) So why does this happen?
Well unfortunately the world is a bit messy and there are lots of places with the same (or very similar names). So for example there are two places called Leeds in the UK (one if Yorkshire and one in Kent). A more extreme example is that there are 108 towns in Germany with “Reichenbach” in their name!
So you can see this in action by using the following Multimap API Geocoding Web Service requests:
- This geocoding searches for places in the UK called Leeds: http://clients.multimap.com/API/geocode/1.2/src_test?city=Leeds&countryCode=GB
- A normal search (where there is only 1 place name match) looks like this: http://clients.multimap.com/API/search/1.2/src_test?&city=London&countryCode=GB (in this situation there are no ’stores’ in London so the recordset is empty)
- But when there is more that one possible place matching the name it does this: http://clients.multimap.com/API/search/1.2/src_test?&city=Leeds&countryCode=GB Note that this returns the error code errorCode=”MM_GEOCODE_MULTIPLE_MATCHES“
The process of handling this scenario we call Disambiguation.
You can see an example of how to do this at: http://www.multimap.com/apidocs/1.2/demos/u singgeocoder.htm (search for the city of Leeds in the UK to see how it prompts the user).
For another example of combining disambiguation and searching see http://www.multimap.com/apidocs/1.2/demos/search.htm . Both these examples have code samples.
