Routing Query
Previous: Select closest edge
// Select the routing algorithm switch($_REQUEST['method']) {
For Shortest Path Dijkstra
case 'SPD' : // Shortest Path Dijkstra $sql = "SELECT rt.gid, AsText(rt.the_geom) AS wkt, length(rt.the_geom) AS length, ".TABLE.".id FROM ".TABLE.", (SELECT gid, the_geom FROM dijkstra_sp_delta( '".TABLE."', ".$startEdge['source'].", ".$endEdge['target'].", 3000) ) as rt WHERE ".TABLE.".gid=rt.gid;"; break;
For Shortest Path A-Star
case 'SPA' : // Shortest Path A* $sql = "SELECT rt.gid, AsText(rt.the_geom) AS wkt, length(rt.the_geom) AS length, ".TABLE.".id FROM ".TABLE.", (SELECT gid, the_geom FROM astar_sp_delta( '".TABLE."', ".$startEdge['source'].", ".$endEdge['target'].", 3000) ) as rt WHERE ".TABLE.".gid=rt.gid;"; break;
For Shortest Path Shooting-Star
case 'SPS' : // Shortest Path Shooting* $sql = "SELECT rt.gid, AsText(rt.the_geom) AS wkt, length(rt.the_geom) AS length, ".TABLE.".id FROM ".TABLE.", (SELECT gid, the_geom FROM shootingstar_sp( '".TABLE."', ".$startEdge['gid'].", ".$endEdge['gid'].", 5000, 'length', true, true) ) as rt WHERE ".TABLE.".gid=rt.gid;"; break;
Query database
} // close switch // Connect to database $dbcon = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER); // Perform database query $query = pg_query($dbcon,$sql);
Next: XML output