Here are the things I have done till now
So, I have a DB with 5 tables i.e. planet_osm_point, planet_osm_line, planet_osm_polygon, planet_osm_roads, and spatial_ref_sys. I have identified the node of interest via following SQL queries. For 1st node, SELECT * FROM planet_osm_point WHERE name = 'bits pilani' and for second SELECT * FORM ppanet_osm_polygon WHERE tags::text like = '%Shamshabad Airport%' The final aim of the project is to output the best possible route between these two nodes using an algorithm on a graph of nodes. I want to know how to find the neighbouring nodes(4 or 5) of a node such that they are all connected via some highway, roads, street etc. How to query the DB for this? Please help. asked 08 Apr '20, 11:20 Ayush Porwal |
osm2pgsql is designed for importing data for rendering, not for routing. It's a "lossy" import that doesn't preserve the topology required for routing. (Strictly speaking you could do this if you've imported in slim mode, but it's not the intention.) For routing, you need to use an importer/pre-processor that will create a routable graph from the OSM data. Routing engines such as OSRM and Graphhopper will do this as part of their preparation process. If you want to write your own routing engine, but are looking for something that will create a graph for you, https://github.com/Tristramg/osm4routing2 is probably the easiest tool to use. (If you're determined to do it in Postgres, check out https://pgrouting.org/docs/tools/osm2pgrouting.html .) answered 08 Apr '20, 12:26 Richard ♦ Hi Richard It looks like osm4routing tool will work for me. Can you please let me know how to convert .osm file to .pbf file and what is the command line to use in osm4routing to finally get the .csv file? Edit: used osmconvert to convert .osm file to .pbf file via command osmconvert map.osm --out-pbf -o=map_01.pbf. I still need help with using osm4routing tool.
(08 Apr '20, 15:34)
Ayush Porwal
This will then output edges.csv and nodes.csv in the same directory. The .csv files have a header row, see the osm4routing2 source code if you want to know more.
(08 Apr '20, 16:20)
Richard ♦
1
Ayush, this site is "help with OpenStreetMap" not "do people's homework for them". I'm guessing you've been given this assignment so that you understand how a path-finding algorithm works. If I were to tell you how to do it, you'd not learn anything. Just google A* algorithm, there are countless sites that explain it.
(09 Apr '20, 11:07)
Richard ♦
|