A littel exercise in MapBasic and C#: Reverse Geocoding

610 views
Skip to first unread message

e.j.h.polle

unread,
Feb 21, 2013, 11:36:54 AM2/21/13
to mapi...@googlegroups.com
Hi List,


For all of you who are playing/struggling with MapBasic: please have a look at this one:
http://www.twiav.nl/php/tools.php#rgec

This reverse geocoding tool takes input from the user - a click on the map - and asks Nominatim to provide some address details.

For a sample xml response try the request below:
http://nominatim.openstreetmap.org/reverse?format=xml&lat=48.860383&lon=2.352338

A .Net Assembly is used to process the Nominatim request.

And - as always - the source code is included.

Please note: you do not need Visual Studio to have a look-and-feel of the *.cs file. Just a good text editor will do, and you can compile the file with csc.exe, your local copy of the Visual C# 2008 Compiler. (Yes, it is available on your machine as this csc.exe is part of the Microsoft .Net Framework version 3.5, which you need to run MapInfo Professional...)

In a command prompt, just type: csc /t:library OSMNominatim.cs to recompile the file.

HTH,

Egge-Jan

Nesh P.

unread,
May 8, 2014, 7:05:25 PM5/8/14
to mapi...@googlegroups.com
I have tried it and its great!
I did use your code and make some minor changes (to get different language and cyrilic characters).

I am very interested in how to make a geocoding tool and to integrate it in Mapinfo via some docked window.
For example: in that window you have to type street name in it and then get line into MapInfo (something like this

This would be cool ! :)

Rosario C

unread,
Oct 15, 2014, 10:47:52 AM10/15/14
to mapi...@googlegroups.com
Egge-Jan,

I use this tool often, and appreciate you making it available. For the past few days it's no longer returning any information when clicking on map. The ReverseGeocoding table returns "no match found"..

Regards,.

Rosario

Egge-Jan Pollé

unread,
Oct 15, 2014, 12:08:20 PM10/15/14
to mapi...@googlegroups.com
Hi Rosario,

Hmmm, strange. The first question the helpdesk would ask is: please tell us what did change between the moment that the tool did still work - you have been using it often - and now that the tool does not return any information anymore. Something has changed, for sure, because before it did return information.

I have had a look in the code and the return value is set to "No match found" before contacting nominatim. So, it looks like you can't access the website.

Please try this in your browser:
 http://nominatim.openstreetmap.org/reverse?format=xml&lat=52.373156&lon=4.891599

(This should return Koninklijk Paleis op de Dam, i.e. the Royal Palace in Amsterdam)

Please contact your IT guys to see why you don't have access no more. All source code is included, so if they have any additional questions they can have a look there.

HTH,

Egge-Jan

Op woensdag 15 oktober 2014 16:47:52 UTC+2 schreef Rosario C:

Rosario C

unread,
Oct 15, 2014, 4:12:55 PM10/15/14
to mapi...@googlegroups.com
Egge-Jan,


I really don't know what,  if anything changed from whence the tool worked and now is not working. Clicking on the link in your replay returns the following; highlighted in yellow below... I have no problem accessing http://nominatim.openstreetmap.org/ so its strange why your tool is not working.

My IT department will not support anything related to these tools, and my MB skills are novice at best, so I'm relying on your gratuitous support... :) 

Thanks again for your kind consideration.

Rosario

<?xml version="1.0" encoding="UTF-8"?>

-<reversegeocode querystring="format=xml&lat=52.373156&lon=4.891599" attribution="Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright" timestamp="Wed, 15 Oct 14 20:02:14 +0000">

<result lon="4.89134373837929" lat="52.37319065" ref="Koninklijk Paleis op de Dam" osm_id="3580875" osm_type="relation" place_id="159145007">Koninklijk Paleis op de Dam, 147, Nieuwezijds Voorburgwal, Amsterdam, Centrum, Amsterdam, Stadsregio Amsterdam, North Holland, Kingdom of the Netherlands, 1012 RJ, The Netherlands</result>


-<addressparts>

<attraction>Koninklijk Paleis op de Dam</attraction>

<house_number>147</house_number>

<road>Nieuwezijds Voorburgwal</road>

<suburb>Amsterdam</suburb>

<city_district>Centrum</city_district>

<city>Amsterdam</city>

<county>Stadsregio Amsterdam</county>

<state>North Holland</state>

<postcode>1012 RJ</postcode>

<country>The Netherlands</country>

<country_code>nl</country_code>

</addressparts>

</reversegeocode>
Reply all
Reply to author
Forward
0 new messages