[postgis-users] Nearest Aid station to accident
William Temperley
willtemperley at gmail.com
Fri Apr 25 01:45:17 PDT 2008
Hi Matthew,
>What I am finding hard to implement is the part where to find the shortest
>distance on the road network. It is taking more or a less a minute there.
>Any idea how I can improve it please?
Any way in which you can cut down the size of the graph PGRouting
works on will give you a faster calculation - just pass a query
representing a subset of your street data to the shortest path
function, e.g.
SELECT edge_id FROM shortest_path_astar(''
SELECT gid AS id,
source::int4,
target::int4,
to_cost as cost,
reverse_cost,
x1, y1, x2, y2
FROM '||table_name||' where
(
(the_geom
&& <something to cut down the result set>)
)
''
,'||start_node.node_id||','||end_node.node_id||', true, true
)
A while ago I was attempting to precalculate routes between strongly
connected nodes and keeping these in the routing table, then selecting
only streets near the start and end points, plus the relevant
pre-calculated routes and passing these to the A* function, but this
never really got past proof of concept, there being a lot of
complications with the precalculation itself. This way I think you
could get sub-second queries on any sized network.
Also- I think Shooting* is the slowest method and the only extra you
get over A* is right turn restrictions.
Hope this helps
Will
Hope this helps
More information about the postgis-users
mailing list