Using Nominatim (Search engine for OpenStreetMap data)

Share your advanced knowledge/code with the community.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Using Nominatim (Search engine for OpenStreetMap data)

Post by Peter »

Hello,

Nominatim is a search engine for OpenStreetMap data.

Here's a simple snippet how to use it:

Code: Select all

EnableExplicit

Structure sResult
  place_id.s
  licence.s
  osm_type.s
  osm_id.s
  boundingbox.i
  lat.s
  lon.s
  display_name.s
  class.s
  type.s
  importance.s
  icon.s
  polygonpoints.s
  geojson.i
EndStructure

Global NewList Results.sResult()

Procedure NominatimCallback(Result.s)
  
  ParseJSON(0, Result)
  
  ExtractJSONList(JSONValue(0), Results())
  
  If ListSize(Results()) > 0
    
    ForEach Results()
      
      Debug "Displayname: " + Results()\display_name
      Debug "Class: "       + Results()\class
      Debug "Latitude: "    + Results()\lat
      Debug "Longitude: "   + Results()\lon
      Debug "-----"
      
    Next
    
  Else
    
    Debug "no results..."
    
  EndIf
  
EndProcedure

Procedure Nominatim(Address.s, Callback)
  
  ! $.get(location.protocol + '//nominatim.openstreetmap.org/search?polygon_geojson=1&format=json&q='+v_address, function(result) {
  !   v_callback(JSON.stringify(result));
  ! });
  
EndProcedure

CompilerIf #PB_Compiler_Debugger = 1
  Nominatim("London", @NominatimCallback())
CompilerElse
  ! alert("please enable the debugger!");
CompilerEndIf
And here is another demo: http://spiderbytes.tuebben.de/demos/Nominatim/

Greetings ... Peter
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by T4r4ntul4 »

Nice!

But can you post the source how to use it with the GUI you used in your demo?: http://spiderbytes.tuebben.de/demos/Nominatim/
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Peter »

T4r4ntul4 wrote:But can you post the source how to use it with the GUI you used in your demo?: http://spiderbytes.tuebben.de/demos/Nominatim/
currently i'm working on a Leaflet-Wrapper, which is the core part of the demo.

When I'm done, I'll publish it.

Greetings ... Peter
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Dirk Geppert »

Hello Peter, what's the status of your Leaflet Wrapper? I'm just thinking about going on with Pb2Web for a project or switching to Spiderbasic and Leaflet...
Ciao Dirk
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Peter »

Hello Dirk,
what's the status of your Leaflet Wrapper?
take a look: https://github.com/spiderbytes/Leaflet

Perhaps it fits your needs.

Greetings ... Peter
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Dirk Geppert »

Hi Peter,
thank you very much - that's allready a great implementation!
The code for BindMarkerEvent() seems to be missing. Please could you give me a hint, how the events of the markers are recognized?

Ciao Dirk
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Dirk Geppert »

Inside Procedure BindGadget(Gadget) is L not defined.

Code: Select all

!	map = L.map(dijitContentPane[0]).setView([0, 0], 1);
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Dirk Geppert »

Hello Peter, if you are still working on your great Leaflet wrapper: it would be nice if there would be a DeleteMarker() function to delete single elements and if there would be a Cluster function. :)

Ciao Dirk
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Dirk Geppert »

Hi Peter, seems that clustering is not a part of the leaflet framework itself and need to use a plugin. e.g. https://github.com/Leaflet/Leaflet.markercluster
What is your current planning? Otherwise, I would try to get it into somehow... :-)

Ciao Dirk
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Using Nominatim (Search engine for OpenStreetMap data)

Post by Peter »

Hi Dirk,

my current plan is to move from beautiful North Rhine-Westphalia to the more beautiful Lower Saxony within the next two weeks. During this time I won't have the chance to work on the Leaflet-Lib.

Nevertheless, there is no reason why you shouldn't try to implement the required features on your own. :)

Greetings ... Peter
Post Reply