[pgrouting-users] Re: Pgrouting-users Digest, Vol 40, Issue 2

Stephen Woodbridge woodbri at swoodbridge.com
Mon Jan 9 20:55:49 EST 2012

On 1/9/2012 8:26 PM, Steve Horn wrote:
>      > Hello all!
>      >
>      > I am creating drive time radii (or isochrones) by allowing the
>     user to
>      > click on a map surface and entering a number of minutes.
>      >
>      > Using the driving_distance function in pgrouting I am able to get
>     very
>      > close to a good solution, but it is somewhat limited in that you can
>      > only route from node to node (vertex to vertex). In order to
>     improve the
>      > accuracy, I thought I would try to insert a new node/vertex as
>     close as
>      > possible to the coordinates that my user clicked. That way my
>     start node
>      > would always be as accurate as it can be.
>      >
>      > Has anyone done this? I'm not sure I understand the assign_vertex_id
>      > function and how the graph is constructed well enough to come up
>     with a
>      > solution myself.
>      >
>      > Any help or direction is appreciated!
>     What you would want to do in this case is:
>     1. take you position and find the nearest edge to that location (EID,
>     2. compute the ratio of distance along that edge (RATIO)
>     3. then add a create a temporary node at that location (NEWNODE)

Right as Daniel noted, so the NEWNODE is just a number that would be 
MAX_NODE_ID+1 If you have the vertices_tmp then you can get this number with

select max(id)+1 as newnode from vertices_tmp;

>     4. then add edges from the temp node to each of the end points to that
>     edge, paying attention to oneway-ness of that edge and assigning costs
>     as a ratio of the original cost.
>     So select edges for your query might look like and you would pass
>     NEWNODE as the starting node.
>     select gid, source, target, cost, reverse_cost from roads where the_geom && <bbox>
>     union all
>     union all

This query is providing all the edges in the "roads" table and adding 
two additional edges for the split nearest edge with NEWNODE at you 


>     -Steve
> I get lost on your 3rd step: "Create a temporary node"
> How do you insert just a node? The "roads" table is made up of edges, so
> wouldn't I need to insert an edge?
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-users

More information about the Pgrouting-users mailing list