2

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:

  1. Added reverse cost column and assigned an arbitrary high value for the ONE WAY links (Geometry LINESTRING)
  2. Used the ST_ClosestPoint function to get the nearest source node from the start position, and the nearest target node from the final destination.
  3. 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
    

QUESTION:

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 :) ?

P.A. Thanks!

enter image description here

1

I believe this is more a problem of user interaction than GIS. IMHO I would:

  1. warn the user if the desired start/end point is further away from the nearest point on the graph of, say 30m and offer her a choice to move them or keep them where they are

  2. for distances less than 30m perhaps you could simply move the desired start/end point to the nearest point without warning or choice, but I wouldn't recommend it

  • This is what i did, if the start/end is further away (100m). Just wanted to understand one thing: u see the marker with the green point on the map, it is my final destination. The closest point should be somewhere near there, in fact he draws the whole line (LINK) from the returned closed target node, right? Is there a way to draw only the partial Linestring, to extract only the points which are very closed to the closest target point? – user12282 May 25 '13 at 16:44
  • See: gis.stackexchange.com/a/2082/3895 – unicoletti May 25 '13 at 17:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.