2012-03-04 19:41:43 +04:00
|
|
|
<?php
|
|
|
|
header("content-type: text/xml; charset=UTF-8");
|
|
|
|
header("Access-Control-Allow-Origin: *");
|
|
|
|
|
|
|
|
echo "<";
|
|
|
|
echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
|
|
|
|
echo ">\n";
|
|
|
|
|
|
|
|
echo "<searchresults";
|
|
|
|
echo " timestamp='".date(DATE_RFC822)."'";
|
2012-09-12 21:14:28 +04:00
|
|
|
echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
|
2012-03-04 19:41:43 +04:00
|
|
|
echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
|
2012-05-26 01:45:59 +04:00
|
|
|
if (isset($sViewBox)) echo " viewbox='".htmlspecialchars($sViewBox, ENT_QUOTES)."'";
|
2012-03-04 19:41:43 +04:00
|
|
|
echo " polygon='".($bShowPolygons?'true':'false')."'";
|
|
|
|
if (sizeof($aExcludePlaceIDs))
|
|
|
|
{
|
|
|
|
echo " exclude_place_ids='".htmlspecialchars(join(',',$aExcludePlaceIDs))."'";
|
|
|
|
}
|
|
|
|
if ($sMoreURL)
|
|
|
|
{
|
|
|
|
echo " more_url='".htmlspecialchars($sMoreURL)."'";
|
|
|
|
}
|
|
|
|
echo ">\n";
|
|
|
|
|
|
|
|
foreach($aSearchResults as $iResNum => $aResult)
|
|
|
|
{
|
|
|
|
echo "<place place_id='".$aResult['place_id']."'";
|
|
|
|
$sOSMType = ($aResult['osm_type'] == 'N'?'node':($aResult['osm_type'] == 'W'?'way':($aResult['osm_type'] == 'R'?'relation':'')));
|
|
|
|
if ($sOSMType)
|
|
|
|
{
|
|
|
|
echo " osm_type='$sOSMType'";
|
|
|
|
echo " osm_id='".$aResult['osm_id']."'";
|
|
|
|
}
|
|
|
|
echo " place_rank='".$aResult['rank_search']."'";
|
|
|
|
|
|
|
|
if (isset($aResult['aBoundingBox']))
|
|
|
|
{
|
|
|
|
echo ' boundingbox="';
|
|
|
|
echo $aResult['aBoundingBox'][0];
|
|
|
|
echo ','.$aResult['aBoundingBox'][1];
|
|
|
|
echo ','.$aResult['aBoundingBox'][2];
|
|
|
|
echo ','.$aResult['aBoundingBox'][3];
|
|
|
|
echo '"';
|
|
|
|
|
|
|
|
if ($bShowPolygons && isset($aResult['aPolyPoints']))
|
|
|
|
{
|
|
|
|
echo ' polygonpoints=\'';
|
2012-07-01 19:24:27 +04:00
|
|
|
echo json_encode($aResult['aPolyPoints']);
|
2012-03-04 19:41:43 +04:00
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-06 04:08:01 +04:00
|
|
|
if (isset($aResult['asgeojson']))
|
|
|
|
{
|
|
|
|
echo ' geojson=\'';
|
|
|
|
echo $aResult['asgeojson'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($aResult['assvg']))
|
|
|
|
{
|
|
|
|
echo ' geosvg=\'';
|
|
|
|
echo $aResult['assvg'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($aResult['astext']))
|
|
|
|
{
|
|
|
|
echo ' geotext=\'';
|
|
|
|
echo $aResult['astext'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
|
2012-03-04 19:41:43 +04:00
|
|
|
if (isset($aResult['zoom']))
|
|
|
|
{
|
|
|
|
echo " zoom='".$aResult['zoom']."'";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo " lat='".$aResult['lat']."'";
|
|
|
|
echo " lon='".$aResult['lon']."'";
|
|
|
|
echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
|
|
|
|
|
|
|
|
echo " class='".htmlspecialchars($aResult['class'])."'";
|
|
|
|
echo " type='".htmlspecialchars($aResult['type'])."'";
|
2012-11-02 21:42:05 +04:00
|
|
|
if (isset($aResult['icon']) && $aResult['icon'])
|
2012-03-04 19:41:43 +04:00
|
|
|
{
|
|
|
|
echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
|
|
|
|
}
|
|
|
|
|
2012-11-06 04:08:01 +04:00
|
|
|
if (isset($aResult['address']) || isset($aResult['askml']))
|
2012-03-04 19:41:43 +04:00
|
|
|
{
|
|
|
|
echo ">";
|
2012-11-06 04:08:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($aResult['askml']))
|
|
|
|
{
|
|
|
|
echo "\n";
|
|
|
|
echo $aResult['askml'];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($aResult['address']))
|
|
|
|
{
|
|
|
|
echo "\n";
|
2012-03-04 19:41:43 +04:00
|
|
|
foreach($aResult['address'] as $sKey => $sValue)
|
|
|
|
{
|
|
|
|
$sKey = str_replace(' ','_',$sKey);
|
|
|
|
echo "<$sKey>";
|
|
|
|
echo htmlspecialchars($sValue);
|
|
|
|
echo "</$sKey>";
|
|
|
|
}
|
2012-11-06 04:08:01 +04:00
|
|
|
}
|
2012-03-04 19:41:43 +04:00
|
|
|
|
2012-11-06 04:08:01 +04:00
|
|
|
if (isset($aResult['address']) || isset($aResult['askml']))
|
|
|
|
{
|
2012-03-04 19:41:43 +04:00
|
|
|
echo "</place>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo "/>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "</searchresults>";
|