I have a road network data where roads(edges) are specified with 3 values to identify the category of road(one way).
- Road with value 0 can be routed in both direction.
- Road with value 1 can be routed in the directed way.
- Road with value -1 can be routed in opposite direction.
As seen in above picture. Blue edges can be routed in both direction, green edges should directed in the same direction how they are digitised and edges with red colors should be directed in opposite direction of the arrow.
I am trying to get route from one node to another using pgRouting
on the above data.
pgRouting works fine if it is given as undirected graph with bellow query.
select seq, node, edge, pt.cost, agg_cost, st_astext(the_geom) as geom from pgr_dijkstra('select id as id, source, target,cost from ways_noded', 60414, 68634, directed := false) as pt join ways_noded rd on pt.edge = rd.id;
But I am facing problem with routing with one ways in directed graph. Above query with directed:=true
considers the edges which are directed towards same direction. I am not able to direct with the edges which are mentioned as two ways(0) also.
OSM data also has a one_way field and this link says 0 for both ways, 1 for one way and -1 for reverse way and they also have an additional value 2 for specifying 2 way roads.
Can anyone help me in routing through one way and reverse ways? I found this link but didn't get much info on directed graph.