[pgrouting-users] FW: Multiple queries in a row

Iñigo Vázquez ivgwildchild666 at hotmail.com
Wed Nov 21 02:23:01 PST 2012

Thanks for your reply, but in my case the shortest path doesn`t interest me. I need the shortest paths from one given node to each others beacuse then I want to calculate a path taking into account a given time limit. 

Something like in the "Traveling Salesman Problem" but with Time Window.

From: gunnar at tradlosetrondheim.no
Date: Wed, 21 Nov 2012 11:08:03 +0100
Subject: Re: [pgrouting-users] Multiple queries in a row
To: pgrouting-users at lists.osgeo.org
CC: ivgwildchild666 at hotmail.com


I do not know the answer to you question, but I might know an workarround if you are only interrested in the shortest of them.
We use a hack to find the path to the closest node of a set of nodes.

Basically we tweak the query which builds the graph to rename all nodes which are applicable to some id which cannot be found in the graph elsewere (e.g. -1), and the search for the path to this node.

(NB: this could/would give strange beahviour if used with astar)

Best regards Gunnar

2012/11/21 Iñigo Vázquez <ivgwildchild666 at hotmail.com>

Dear all,

I need to obtain a set of nearest nodes from a given location (maybe 30 or 40). Then I need to calculate the shortest path from the given node from each others. It means to execute shortes_path query multiple times in a row, wich takes about 2 seconds (1 query 2 seconds: 30 queries 60 -> too long).

SELECT * FROM shortest_path('
   SELECT id AS id,
          source::int4 AS source,
          target::int4 AS target,
          cost::float8 AS cost
   FROM tt_2po_4pgr',

What would be the best way to do this in a reasonable time?

Thank in advance!

Pd: excuse my english 		 	   		  


Pgrouting-users mailing list

Pgrouting-users at lists.osgeo.org



    Gunnar Rangøy
    System developer
    Trådløse Trondheim / Wireless Trondheim

    +47 99 36 06 99


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20121121/3bc75692/attachment-0001.html>

More information about the Pgrouting-users mailing list