astar (#17) - Problem with A* and own data (#11) - Message List

Problem with A* and own data

Dear list,

I have downloaded the code for the routing as in  http://demo.orkney.jp/routing/ and try to test the Shortest Path using A* on Windows XP.

With the kanagawa-data this works without any problems.:-)

I try now to use my own data in the UMN MapServer. I loaded these data successfully in PostGIS and produced x1,x2,y1,y2-data and the length. The source and target-value I have as well (I got them by: SELECT assign_vertex_id('fridastreets', 0.3); ).

In the MapServer the streets are visualized correctly. But now comes the problem:

In the PHP-Mascript-File (sp_os.phtml) I wrote:

function changeVal(typer) { ..... .....

} else {

switch( sel ) {

case 1:

valX = 3436399.4; valY = 5791415.09545; break;

case 2:

valX = 3436631.78; valY = 5791605.22455; break;

default:

valX = 0; valY = 0;

}

The coordinates are correct vertex-coordinates of street-segments.

Later on I wrote:

<form name="routing" method="get" action="sp_os.phtml"> <input type=hidden name="cx1" value=0> <input type=hidden name="cy1" value=0> <input type=hidden name="cx2" value=0> <input type=hidden name="cy2" value=0>

<select name=start onChange="changeVal(1);">

<option value=0 >Choose...</option> <option value=8516 >Punkt 1 OS</option> <option value=8529 >Punkt 2 OS</option>

If I want to get a route from Punkt 1 OS to Punkt 2 OS

I always get the following PostGIS-error-message:

Warning: Error: msPOSTGISLayerWhichShapes(): Error executing POSTGIS SQL statement (in FETCH ALL): DECLARE mycursor BINARY CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text from (select gid, the_geom from shortest_path_astar2_as_geometry_internal_id('fridastreets', 8516, 8529, 3436399.39999, 5791415.09545, 3436631.78001, 5791605.22455)) as g WHERE the_geom && setSRID('BOX3D(3436399.39999444 5791415.09545,3436631.78000556 5791605.22455)'::BOX3D, -1 ) -ERROR: Start vertex was not found. CONTEXT: PL/pgSQL function "shortest_path_astar2_as_geometry_internal_id_directed" line 47 at for over execute statement PL/pgSQL function "shortest_path_astar2_as_geometry_internal_id" line 21 at for over execute statement in C:\ms4w\Apache\htdocs\routing\phtmls\sp_os.phtml on line 79

Has anybody an idea? Thank you very much, Kai

  • Message #32

    Kai,

    We need the boundary box (which is set by two last parameters of shortest_path_astar2_as_geometry_internal_id) to reduce the number of edges to load. It looks like you have specified EXACT coordinates of your start and end points as coners of the box. That's why the function cannot find a start vertex - it lays at the border of the boundary box!

    Try to specify the coordinates which are a little bit more far from your points or use shortest_path_astar1_as_geometry_internal_id instead where you need only a distance between your start/end point and a border of the boundary box.

    • Message #46

      Hi anton, thank you again very much, merci beaucoup :-) I will check this out.

      • Message #49

        I changed the coordinates and set them far away (2000 meters) from the start and end-vertices, so the bounding-box is much bigger now, but I get the same error-message. Might it have something to do with the way to calculate the source and target_id? I use "SELECT assign_vertex_id('fridastreets', 5);"

        The values are written in the database and a new table "vertices_tmp" (with single coordinates) is written. Is that table needed somehow?