[pgrouting-users] Strange results using pgr_kdijkstraCost
António M. Rodrigues
amcrgrodrigues at gmail.com
Wed Oct 1 08:11:55 PDT 2014
Hi all,
I'm using osm data to calculate time distances from one source node to
multiple destinations. For this I'm using pgr_kdijkstraCost. Because I
found a few results strange, I used pgr_dijkstra (and pgr_astar) to test
total distances between a few nodes.
Given one source and one destination, I used this code to calculate total
cost between two nodes
-----test1
select sum(cost) from
(SELECT seq, id1 AS node, id2 AS edge, cost FROM pgr_dijkstra('
SELECT gid AS id,
source::integer,
target::integer,
length::double precision AS cost
FROM ways',
97972,342392, false, false)) as foo;
----------
*column "custo" was calculated using: custo = (60 * length) /
(maxspeed_forward)
The result for test1 is 115 minutes.
----------
Using pgr_kdijkstraCost with only one target (node 342392), the code is:
-----test2
SELECT seq, id1 AS source, id2 AS target, cost FROM pgr_kdijkstraCost($$
SELECT gid AS id,
source::integer,
target::integer,
custo::double precision AS cost
FROM ways, classes c
WHERE class_id = c.id
$$,
97972, array[342392], false, false);
----------
The result of test2 is 66388 minutes!
Using the same code with over 2 thousand targets, it runs smoothly, with a
few strange results - as this one.
------------------------------------------------------------------
Perhaps there's something obvious I'm missing.
Thanks in advance for any help.
António
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgrouting-users/attachments/20141001/d22b7395/attachment-0001.html>
More information about the Pgrouting-users
mailing list