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:

       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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.