[pgrouting-users] Re: Pgrouting-users Digest, Vol 40, Issue 2
daniel at georepublic.de
Mon Jan 9 20:36:15 EST 2012
On Tue, Jan 10, 2012 at 10:26 AM, Steve Horn <steve at stevehorn.cc> 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,
>> ESOURCE, ETARGET, ECOST, EREVERSE_COST)
>> 2. compute the ratio of distance along that edge (RATIO)
>> 3. then add a create a temporary node at that location (NEWNODE)
>> 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
>> union all
>> select maxgid+1, ESOURCE, NEWNODE, ECOST*RATIO, EREVERSE_COST*(1-RATIO)
>> union all
>> select maxgid+2, NEWNODE, ETARGET, ECOST*(1-RATIO), EREVERSE_COST*RATIO
> 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?
You "create" a node, that you know the "source" and "target" ID of the
edge. This ID may not exist yet.
Georepublic UG & Georepublic Japan
eMail: daniel.kastl at georepublic.de
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pgrouting-users