I'm writing a shortest route script in Python using geospatial data from a Postgres DB with PostGIS extension and pgRouting to make the points from OSM data.
I have a path of OSM IDs by points. I got this from downloading OSM XML data from a particular region, importing the data into a database using osm2pgrouting, calculating the shortest route in my script, and using the OSM ID as the main point of identification. This all being stored in a PostGIS database.
If I had an array of, in order from 0-n for the path, the OSM IDs of all the points for the shortest route, how could I create a line to line up with the roads in OSM for the path?
I've looked at ST_MakeLine, but my worry with that is it will output like the picture below, and not connecting the actual roads. I want the path to actually map with the actual roads and not just create a line between points where a road doesn't exist.
What should I do?