Please keep the queries on the list.
No, I have no idea, I've never seen anything like that before.
What does this query return?
select count(*) from japan where cost_car=0;
-Steve
On 8/20/2012 7:26 AM, Tao Romera Martinez wrote:
Dear Stephen,
I have been trying to use your function for turn restricted shortest
path routing.
I installed the postgresql functions, prepared a table with the turn
costs, and now I am able to route through a network using turn
restrictions. Well, almost.When I launch a request, the column "cost" contains 0 values except
for the rows where there is a turn (the cost is the one set for
turns).
The request is:SELECT * FROM turn_restrict_shortest_path(
'SELECT id AS id, source::integer, target::integer, cost_car AS cost
FROM japan WHERE japan.geom_way && ST_MakeEnvelope(139.675, 35.729,
139.705, 35.762)',
284867, -- node_id of start
282034, -- node_id of end
false, -- directed graph?
false, -- has_reverse_cost?
'SELECT to_cost::double precision, teid::integer AS target_id,
feid||coalesce('',''||via,'''') AS via_path FROM turn_costs WHERE teid
IN (select id FROM japan WHERE japan.geom_way &&
ST_MakeEnvelope(139.675, 35.729, 139.705, 35.762)) ');The ST_MakeEnvelope is just to create a window and limit the otherwise
huge amount of ways.The table "japan" looks like:
id | osm_id | osm_name | osm_source_id | osm_target_id | clazz |
flags | source | target | km | kmh | cost | reverse_cost | x1 | y1 |
x2 | y2 | geom_way | cost_car
----+---------+----------+---------------+---------------+-------+-------+--------+--------+-----------+-----+-----------+--------------+----------+------------+-------------+------------+----------------------------
1 | 4847506 | | 31236733 | 31236584 | 11 |
1 | 24690 | 24758 | 1.6335903 | 1 | 6.5343612 | 1.6335903 |
139.7578 | 35.6437952 | 139.7688252 | 35.6349433 | <snip> | 3.2671806And the table "turn_costs" looks like:
rid | to_cost | teid | feid | via
-----+---------+--------+------+-----
1 | 0.15 | 22 | 10 |
2 | 0.15 | 21 | 10 |
3 | 0.15 | 163 | 10 |
4 | 0.15 | 27 | 10 |
5 | 0.15 | 26 | 10 |
6 | 0.15 | 27 | 11 |
7 | 0.15 | 26 | 11 |
8 | 0.15 | 229 | 11 |
9 | 0.15 | 232698 | 11 |
10 | 0.15 | 229 | 12 |The result of the query looks like:
vertex_id | edge_id | cost
-----------+---------+-------------
284867 | 211472 | 0
284794 | 211471 | 0
134058 | 205895 | 0.15
284826 | 205894 | 0
131290 | 205893 | 0
127938 | 201505 | 0
132923 | 201504 | 0
<...>
282198 | 425307 | 0
282197 | 795399 | 0.021921627
282276 | 795400 | 0.05221079
282035 | 425170 | 0.15
282034 | -1 | 0Do you have an idea about why the "cost" values are 0?
Thank you very much for your help,
Tao