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

Using Nominatim (Search engine for OpenStreetMap data)

by Peter Wed May 31, 2017 3:39 pm

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: 110
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands

Re: Using Nominatim (Search engine for OpenStreetMap data)

by T4r4ntul4 Wed May 31, 2017 7:33 pm

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: 447
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: Using Nominatim (Search engine for OpenStreetMap data)

by Peter Thu Jun 01, 2017 11:55 am

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
Return to Tricks 'n' Tips

Who is online

Users browsing this forum: No registered users and 1 guest