$Latitude, 'Longitude' => $Longitude, 'BoundingBox' => $BoundingBox, 'Zoom' => $Zoom);
}
function Route($TextPathItems)
{
$this->Points = array();
foreach ($TextPathItems as $TextPathItem)
{
$Result = $this->Geolocate($TextPathItem);
$this->Points[] = array('Longitude' => $Result['Longitude'],
'Latitude' => $Result['Latitude']);
}
$WayPoints = array();
foreach ($this->Points as $Point)
{
$WayPoints[] = $Point['Longitude'];
$WayPoints[] = $Point['Latitude'];
}
// http://wiki.openstreetmap.org/wiki/OpenRouteService#OpenRouteService_API
$this->Key = 'ee0b8233adff52ce9fd6afc2a2859a28';
$URL = 'http://openls.geog.uni-heidelberg.de/route?api_key='.
$this->Key.'&start='.implode(',', $this->Points[0]).'&end='.implode(',', $this->Points[count($this->Points) - 1]).
'&via='.implode(',', $WayPoints).'&lang=en&distunit=M&routepref=Car&weighting=Fastest&avoidAreas='.
'&useTMC=false&noMotorways=false&noTollways=false&noUnpavedroads=false&noSteps=false'.
'&noFerries=false&elevation=false&surface=false&instructions=false';
$Result = file_get_contents($URL);
echo($Result);
$Separator = '') - 1);
$Separator = 'PT2H3M48S';
$Result = substr($Result, strpos($Result, $Separator) + strlen($Separator));
$TotalTime = substr($Result, 0, strpos($Result, '"/>') - 1);
$Points = array();
$Separator = '';
while (strpos($Result, $Separator) !== false)
{
$Result = substr($Result, strpos($Result, $Separator) + strlen($Separator));
$Pos = substr($Result, 0, strpos($Result, '') - 1);
$PosParts = explode(' ', $Pos);
$Points[] = array('Longitude' => $PosParts[0], 'Latitude' => $PosParts[1]);
}
return array('TotalDistance' => $TotalDistance, 'TotalTime' => $TotalTime,
'Points' => $Points);
}
function Show()
{
$WayPoints = array();
foreach ($this->Points as $Point)
{
$WayPoints[] = $Point['Longitude'];
$WayPoints[] = $Point['Latitude'];
}
$Output = '';
/* $Latitude = $this->Pos['Latitude'];
$Longitude = $this->Pos['Longitude'];
$Zoom = $this->Zoom;
$BoundingBox = array($Longitude - 1 / $Zoom, $Latitude - 1 / $Zoom, $Longitude + 1 / $Zoom, $Latitude + 1 / $Zoom);
$Output = ''.
'View Larger Map
';
*/
return $Output;
}
}