PHP page template (basics)
We will use a PHP script to make the routing query and send the result back to the web client.
The following steps are necessary:
- Retrieve the start and end point coordinates.
- Find the closest edge to start/end point.
- Take either the start or end vertex of this edge (for Dijkstra/ A-Star) or the complete edge (Shooting-Star) as start of the route and end respectively.
- Make the Shortest Path database query.
- Transform the query result to XML and send it back to the web client.
<?php
// Database connection settings
define("PG_DB" , "routing");
define("PG_HOST", "localhost");
define("PG_USER", "postgres");
define("PG_PORT", "5432");
define("TABLE", "victoria");
$counter = $pathlength = 0;
// Retrieve start point
$start = split(' ',$_REQUEST['startpoint']);
$startPoint = array($start[0], $start[1]);
// Retrieve end point
$end = split(' ',$_REQUEST['finalpoint']);
$endPoint = array($end[0], $end[1]);
/* ... */
Next: Select closest edge
