Friday, 11 November 2016

postgis - From pgRouting shortest_path back to osm node id


I'm successfully performing path finding queries like shortest_path on data imported with osm2pgrouting.


The tables I have inside my pgrouting DB are the following:


               List of relations
Schema | Name | Type | Owner
--------+---------------------+----------+-------
public | classes | table | user
public | geography_columns | view | user

public | geometry_columns | table | user
public | nodes | table | user
public | spatial_ref_sys | table | user
public | types | table | user
public | vertices_tmp | table | user
public | vertices_tmp_id_seq | sequence | user
public | ways | table | user

I get the way of a given path between a source and dest node this way:


SELECT * FROM ways 

JOIN
(SELECT * FROM
shortest_path('SELECT gid AS id, source::int4 AS source, target::int4 AS target, length::double precision AS cost FROM ways',3,7,false,false))
AS route ON ways.gid=route.edge_id;

ways's table has the following structure:


 Table "public.ways"
Column | Type | Modifiers
--------------+------------------+-----------
gid | integer | not null

class_id | integer |
length | double precision |
name | character(200) |
x1 | double precision |
y1 | double precision |
x2 | double precision |
y2 | double precision |
reverse_cost | double precision |
rule | text |
to_cost | double precision |

the_geom | geometry |
source | integer |
target | integer |

Now gid, source and target values aren't original osm node's ids (the node's ids contained in the .osm file from which the table has been filled). I suppose that pgRouting create custom ids in order to index ways and edges. From what I can understand the original ids of nodes contained in the .osm files are the ones listed into nodes table.


I would like, given a row of ways table, recover the original osm id of source and target.


How can I do that?is it possible?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...