[pgrouting-users] Shortest Path TRSP
Stephen Woodbridge
woodbri at swoodbridge.com
Mon Feb 27 17:03:11 EST 2012
On 2/27/2012 4:42 PM, "Christophe Damour (SIGéal)" wrote:
> Hi,
>
> I am trying to use trsp shortest path function, but get a "Source Not
> Found" error.
> Here is my query :
> SELECT edge_id FROM turn_restrict_shortest_path(
> 'SELECT id_tron as id, source::integer, target::integer,
> cost::double precision as cost, rev_cost::double precision as
> reverse_cost FROM reseau_global',
> 15326,
> 8756,
> true,
> true,
> 'SELECT to_cost::double precision, target_id::integer, via_path::text
> FROM reseau_global_rest'
> ), reseau_global
> WHERE edge_id = id_tron;
>
> reseau_global is my network table, and reseau_global_rest is my turn
> restriction table.
> In the latter, target_id column contains destination edges ids and
> via_path a list of forbidden origin edges.
>
> What am I doing wrong ?
>
> Thank for any hints,
>
Typically this means that you are probably entering edge_ids for source
and target and not node_ids.
Also, there is another version of the API that does take edge_ids for
the start and end of the route rather than node_ids. You would call it
like this:
SELECT edge_id FROM turn_restrict_shortest_path(
'SELECT id_tron as id, source::integer, target::integer,
cost::double precision as cost, rev_cost::double precision as
reverse_cost FROM reseau_global',
15326, -- start edge_id
0.5. -- percent along start edge
8756, -- end edge_id
0.5 -- percent along end edge
true,
true,
'SELECT to_cost::double precision, target_id::integer, via_path::text
FROM reseau_global_rest'
), reseau_global
WHERE edge_id = id_tron;
Using the edge + percent is better because it allow you to take into
account restrictions and onewayness of the start and end edges that can
not be done with the version you are using. This was a recent update to
git so you might want to pull an updated versions.
-Steve W
More information about the Pgrouting-users
mailing list