<?php
include("xmlrpc.inc");
// Connect to the OSM-Server via XMLRPC
$c=new xmlrpc_client("/api/xml.jsp", "www.openstreetmap.org", 80);
$c->setDebug(0);
$bs=500;
$ls=500;
if(!isSet($b)) $b=51.525451110839843;
if(!isSet($l)) $l=-0.14846370166540146;
if(!isSet($s)) $s=0.008;
$b1=$b+$s;
$l1=$l-$s;
$b2=$b-$s;
$l2=$l+$s;
// Get all the Streets ...
$f=new xmlrpcmsg('openstreetmap.getStreets');
$f->addParam(new xmlrpcval("applet"));
$f->addParam(new xmlrpcval($b1,"double"));
$f->addParam(new xmlrpcval($l1,"double"));
$f->addParam(new xmlrpcval($b2,"double"));
$f->addParam(new xmlrpcval($l2,"double"));
$getStreet_response=$c->send($f);
$getStreet_value=$getStreet_response->value();
$getStreet_scalarval=$getStreet_value->scalarval();
$linescount = count($getStreet_scalarval)/5;
for($i=0;$i<$linescount;$i++) {
// WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING
// THIS IS NOT THE CORECT TRANSALTION FROM COORDIANTES TO PIXELS !!!!!!!!
// WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING +++ WARNING
// TODO: CORECT IT !
$lines_l1[$i] =(($getStreet_scalarval[$i*5+1]->scalarval())-$l1)/($l2-$l1)*$ls;
$lines_b1[$i] =(($getStreet_scalarval[$i*5+2]->scalarval())-$b1)/($b2-$b1)*$bs;
$lines_l2[$i] =(($getStreet_scalarval[$i*5+3]->scalarval())-$l1)/($l2-$l1)*$ls;
$lines_b2[$i] =(($getStreet_scalarval[$i*5+4]->scalarval())-$b1)/($b2-$b1)*$bs;
}
header("Content-type: image/svg-xml");
echo '<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>';
?>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
height="500"
width="500"
>
<title>SVG</title>
<?php
echo "<!-- Lines: ".$linescount."-->\n";
// Paint all the black lines ...
for($i=0;$i<$linescount;$i++) echo ' <line x1="'.$lines_l1[$i].'" y1="'.$lines_b1[$i].'" x2="'.$lines_l2[$i].'" y2="'.$lines_b2[$i].'" style="stroke: #000; stroke-width: 4px; stroke-linecap:round; fill-rule:evenodd; stroke-linejoin:round;"/>'."\n";
// Paint all the white lines
for($i=0;$i<$linescount;$i++) echo ' <line x1="'.$lines_l1[$i].'" y1="'.$lines_b1[$i].'" x2="'.$lines_l2[$i].'" y2="'.$lines_b2[$i].'" style="stroke: #FFF; stroke-width: 2px; stroke-linecap:round; fill-rule:evenodd; stroke-linejoin:round;"/>'."\n";
//for($i=0;$i<$nodescount;$i++) echo ' <circle cx="'.$nodes_b[$i].'" cy="'.$nodes_l[$i].'" r="4" style="fill: #FFF"/>'."\n";
?>
</svg>