
Yancho
By: a guest on Dec 7th, 2007 | syntax:
PHP | size: 1.93 KB | hits: 240 | expires: Never
<?
include 'db.php';
$ep = $_REQUEST['finalpoint'];
$choice = $_REQUEST['method'];
// print_r ($_REQUEST);
$end = "'POINT(".$ep.")'" ;
$start = "select near_accident ($end,'$choice')";
//echo $start;
$con = pg_connect("dbname=".$db." host=".$dbhost." user=".$dbuser." password=".$dbpass)
//echo $query;
$source = $row[0];
}
// echo $source;
$target = "select give_source('$source',1000,200)";
$source = "select give_target('POINT(".$ep.")',1000,200)" ;
$sql = "
SELECT gid, astext(the_geom) as wkt, length(the_geom) AS length
FROM shootingstar_sp
('streets',
(
select gid from streets where
source = ( $source )
limit 1
)
,
(
select gid from streets where
target = ( $target )
limit 1
)
,
5000,
'length',
true,
true
);
";
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'."\n";
$xml .= "<route>\n";
$query2 = pg_query($sql);
// Add edges to XML file
while($edge=pg_fetch_assoc($query2)) {
$pathlength += $edge['length'];
$xml .= "\t<edge id='".++$counter."'>\n";
$xml .= "\t\t<id>".$edge['gid']."</id>\n";
$xml .= "\t\t<wkt>".$edge['wkt']."</wkt>\n";
$xml .= "\t\t<length>".round(($pathlength/1000),3)."</length>\n";
$xml .= "\t</edge>\n";
}
$xml .= "</route>\n";
pg_close($con);
// Return routing result
header('Content-type: text/xml',true);
echo $xml;
?>