astar (#17) - Generated path is not shortest path ...?!?! (#398) - Message List
Id like to ask you for advice where could be problem with my dataset or procedure.
I have roads with length, to_cost, reverse_cost columns with same values equals to length of the_geom.
I used this query :
INSERT INTO route(the_geom, source, target) SELECT roads5.the_geom, roads5.source, roads5.target FROM roads5, (SELECT * FROM shortest_path_astar('SELECT gid AS id, source, target, to_cost AS cost, reverse_cost, x1, y1, x2, y2 FROM roads5',".$startEdge['source'].",".$endEdge['target'].", true, true)) as rt where roads5.gid = rt.edge_id;
and result is here:
http://www.imgplace.com/viewimg215/9978/55test.png
Aparently this generated route is not shortest.
When I set to cost and reverse cost to same value I would expect that algorithm will not consider any oneway restriction and find shortest route. Am I right?
please advice me where could be a problem.
-
Message #1738
Would it be possible to add information about the direction of your oneway streets (and where the oneway streets are) to the map?
I suppose that if you set all costs to length, it will not take oneway streets into account. to_cost by the way is only used for turn restrictions in Shooting Star.
daniel11/02/10 00:01:16 (3 weeks ago)-
Message #1744
Daniel, can I ask you what should happened if I set to_cost or reverse_cost to -1 ?
thank in advance for answer
Dzouzeph11/05/10 00:21:47 (2 weeks ago) -
Message #1739
here I put picture where with green lines are shown oneway roads a purple is restricted roads. Red one is route generated by previous sql query.
http://www.imgplace.com/viewimg576/8242/18test2.png
...and here is shown route on google where you can see direction of oneways :
http://www.imgplace.com/viewimg215/1420/66test4.png
....here is route what should be generated like shortest one ...becasue all cost was set up to length of the segment so oneway roads should not be considered.
http://www.imgplace.com/viewing576/6193/23test3.pngDzouzeph11/02/10 01:05:36 (3 weeks ago) -
Message #1740
and when I just change sql query to (on same dataset):
SELECT rt.gid AS id, ST_AsGeoJSON(rt.the_geom) AS geojson, length(rt.the_geom) AS length, roads5.on AS nazov, roads5.gid FROM roads5,(SELECT gid, the_geom FROM astar_sp_directed('roads5',".$startEdge['source'].",".$endEdge['target'].",true, true)) as rt WHERE roads5.gid=rt.gid;
...I got quite nice result ..I mean this route look very shortest one....
http://www.imgplace.com/viewimg401/6527/21test5.pngDzouzeph11/02/10 01:16:38 (3 weeks ago)
-