[pgrouting-users] Shortest Route Search Not Working

Hello,

I am trying to have routing working for city of Toronto data. But,nothing shows up and a problem is seen in the FindNearestEdge() method.

One example request sent to the routing php is as follows: routing.php?startpoint=-8837720.7293944 5412947.799546&finalpoint=-8836963.525083 5412307.6394342&method=SPD&srid=900913

My understanding is that projection for the pgRouting database is 4326 and for the tiles displayed in OpenLayers it is 900913. (In the code both the html and php projection values are set to 900913. However I am not clear as to how to make the projection changes – whether modify the pgRouting database or change OpenLayers HTML page).

Further details are below


  • The tiles were rendered through generate_tiles.py script of postgis database for Toronto routes. I found Ontario.osm and then extracted city of Toronto osm data. Then, created the pgRouting database. Now my map displays the tiles correctly in 900913 projection.

  • I am not sure but maybe the pgRouting database is 4326 projection, because for A* search the x1,y1… are shown in latlng. …?

The HTML page is very similar to: http://pgrouting.postlbs.org/wiki/Workshop-RoutingRequest Except that instead of 54004 projection, I use 9000913 projection.

The php page is same as http://pgrouting.postlbs.org/wiki/Workshop-ClosestEdge Again I have set projection to 900913 here.

Code snippet:

$sql = "SELECT gid, source, target, the_geom,astext(the_geom),

distance(the_geom, GeometryFromText?(

‘POINT(“.$lonlat[0].” “.$lonlat[1].”)’, 900913)) AS dist

FROM “.TABLE.” WHERE the_geom && setsrid(

'BOX3D(“.($lonlat[0]-200).”

“.($lonlat[1]-200).”, “.($lonlat[0]+200).” “.($lonlat[1]+200).”)'::box3d, 900913)

ORDER BY dist LIMIT 1";

The problem is when the php script runs, findNearestEdge() method doesn’t work and one warning as followed shown:

PHP Warning: pg_fetch_result(): Unable to jump to row 0 on PostgreSQL result index 3 …

I am not sure of the problem. Please, if you have ideas let me know.

Hi,

Which Tutorial do you use?
In case you tried Workshop “FOSS4G2007” it’s better to take a look at http://pgrouting.postlbs.org/wiki/WorkshopOL2.7andOSM
Kai Behncke rewrote the workshop because since 2007 a couple of things changed with OpenLayers. For example there was no 900913 that time.

Daniel

2010/7/16 Yasir Shoaib <yasirshoa@gmail.com>

Hello,

I am trying to have routing working for city of Toronto data. But,nothing shows up and a problem is seen in the FindNearestEdge() method.

One example request sent to the routing php is as follows: routing.php?startpoint=-8837720.7293944 5412947.799546&finalpoint=-8836963.525083 5412307.6394342&method=SPD&srid=900913

My understanding is that projection for the pgRouting database is 4326 and for the tiles displayed in OpenLayers it is 900913. (In the code both the html and php projection values are set to 900913. However I am not clear as to how to make the projection changes – whether modify the pgRouting database or change OpenLayers HTML page).

Further details are below


  • The tiles were rendered through generate_tiles.py script of postgis database for Toronto routes. I found Ontario.osm and then extracted city of Toronto osm data. Then, created the pgRouting database. Now my map displays the tiles correctly in 900913 projection.

  • I am not sure but maybe the pgRouting database is 4326 projection, because for A* search the x1,y1… are shown in latlng. …?

The HTML page is very similar to: http://pgrouting.postlbs.org/wiki/Workshop-RoutingRequest Except that instead of 54004 projection, I use 9000913 projection.

The php page is same as http://pgrouting.postlbs.org/wiki/Workshop-ClosestEdge Again I have set projection to 900913 here.

Code snippet:

$sql = "SELECT gid, source, target, the_geom,astext(the_geom),

distance(the_geom, GeometryFromText?(

‘POINT(“.$lonlat[0].” “.$lonlat[1].”)’, 900913)) AS dist

FROM “.TABLE.” WHERE the_geom && setsrid(

'BOX3D(“.($lonlat[0]-200).”

“.($lonlat[1]-200).”, “.($lonlat[0]+200).” “.($lonlat[1]+200).”)'::box3d, 900913)

ORDER BY dist LIMIT 1";

The problem is when the php script runs, findNearestEdge() method doesn’t work and one warning as followed shown:

PHP Warning: pg_fetch_result(): Unable to jump to row 0 on PostgreSQL result index 3 …

I am not sure of the problem. Please, if you have ideas let me know.


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users