my problem is regarding routing. I have a network based on bicycle graph links (SRID: 4326), with bidirected and directed ways. I want to give the user the functionality to draw a route (shortest path) from a given point to a certain location (the input parameters are sent from my app, as two geometric POINTS).
So to approach this problem i did the following steps:
- Added reverse cost column and assigned an arbitrary high value for the ONE WAY links (Geometry LINESTRING)
- Used the ST_ClosestPoint function to get the nearest source node from the start position, and the nearest target node from the final destination.
Once i have my source node and target_node i launched the Dijkstra Shortest Path function of pgrouting (taking account the reverse_cost for ONE WAY links):
SELECT bz_bike_graph_line.* FROM bz_bike_graph_line JOIN (SELECT * FROM shortest_path('SELECT gid as id, start_node::int4 as source, end_node::int4 as target, distance::double precision AS cost, reverse_cost::double precision AS reverse_cost FROM bz_bike_graph_line' ,source_node, target_node, true, true)) AS route ON bz_bike_graph_line.gid = route.edge_id
All seems to be working in the right way BUT when returning the route the starting point and the starting route node never coincides (idem target and final dest.), obviously i should say, due the fact we return the closest points. Is there a way to resolve it or solve the task in other way? Some GIS expert here :) ?