0

I have been trying to use a rest API to query my OSM data that I have already uploaded in my postgres DB. I have been trying to write a small javascript program, which makes use of a restful API (Like API 0.7 of OSM, XAPI, Overpass API - I do not know which is the best of these 3).

I would want to make queries to my postgres DB via an XHR from Javascript using some thin API on the server (which is either one among those 3). I have searched high and low on the internet, but there are no tutorials on this.

I have been thinking of using the overpass API, but I guess I might have to use the Overpass query language for this. How about using XPath for parsing these postgres queries?

Edit - I do not want to use any of the mapping libraries like leaflet, mapnik, etc. that already can produce tiled information. I am trying to produce map tiles on my own. Hence, as a first step,I need to know how to use a rest API to query for osm data on my postgres db.

Edit 2- My queries are something like getting all the places of interest within a bounding box. For example, i wrote a select query for postgres that returns the places through which a particular highway passes through, within a bounding box of lat and long.

Also, how can i use javascript to plot these points on a web browser?

vasupradha
  • 35
  • 10
  • Usually Overpass API would be the best for querying OSM data but it requires its own database. The regular API and XAPI on the other end don't allow to run complex queries. Can you tell use which type of queries you want to run? – scai Feb 23 '15 at 08:34
  • If you want to query your own database you should build a server side script which queries the DB via PostGIS functions and answers with the format you like to the javascript... – sabas Feb 23 '15 at 09:37
  • My queries are something like getting all the places of interest within a bounding box. For example, i wrote a select query for postgres that returns the places through which a particular highway passes through, within a bounding box of lat and long. – vasupradha Feb 23 '15 at 19:57
  • You can dump the result in geojson and display it with leaflet. http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html – sabas Feb 24 '15 at 08:37

0 Answers0