]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/search-xml.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / template / search-xml.php
index 3d011b39c4d65708d59e484da5571a739f36cbf7..aa029d2bb142bcd9fc4b16660e512c4f63063c85 100644 (file)
-<?php\r
-       header("content-type: text/xml; charset=UTF-8");\r
-       header("Access-Control-Allow-Origin: *");\r
-\r
-       echo "<";\r
-       echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";\r
-       echo ">\n";\r
-\r
-       echo "<searchresults";\r
-       echo " timestamp='".date(DATE_RFC822)."'";\r
-       echo " attribution='Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.'";\r
-       echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";\r
-       if ($sViewBox) echo " viewbox='".htmlspecialchars($sViewBox, ENT_QUOTES)."'";\r
-       echo " polygon='".($bShowPolygons?'true':'false')."'";\r
-       if (sizeof($aExcludePlaceIDs))\r
-       {\r
-               echo " exclude_place_ids='".htmlspecialchars(join(',',$aExcludePlaceIDs))."'";\r
-       }\r
-       if ($sMoreURL)\r
-       {\r
-               echo " more_url='".htmlspecialchars($sMoreURL)."'";\r
-       }\r
-       echo ">\n";\r
-\r
-       foreach($aSearchResults as $iResNum => $aResult)\r
-       {\r
-               echo "<place place_id='".$aResult['place_id']."'";\r
-               $sOSMType = ($aResult['osm_type'] == 'N'?'node':($aResult['osm_type'] == 'W'?'way':($aResult['osm_type'] == 'R'?'relation':'')));\r
-               if ($sOSMType)\r
-               {\r
-                       echo " osm_type='$sOSMType'";\r
-                       echo " osm_id='".$aResult['osm_id']."'";\r
-               }\r
-\r
-               if (isset($aResult['aBoundingBox']))\r
-               {\r
-                       echo ' boundingbox="';\r
-                       echo $aResult['aBoundingBox'][0];\r
-                       echo ','.$aResult['aBoundingBox'][1];\r
-                       echo ','.$aResult['aBoundingBox'][2];\r
-                       echo ','.$aResult['aBoundingBox'][3];\r
-                       echo '"';\r
-\r
-                       if ($bShowPolygons)\r
-                       {\r
-                               echo ' polygonpoints=\'';\r
-                               echo javascript_renderData($aResult['aPolyPoints']);\r
-                               echo '\'';\r
-                       }\r
-               }\r
-\r
-               if (isset($aResult['zoom']))\r
-               {\r
-                       echo " zoom='".$aResult['zoom']."'";\r
-               }\r
-\r
-               echo " lat='".$aResult['lat']."'";\r
-               echo " lon='".$aResult['lon']."'";\r
-               echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";\r
-\r
-               echo " class='".htmlspecialchars($aResult['class'])."'";\r
-               echo " type='".htmlspecialchars($aResult['type'])."'";\r
-               if ($aResult['icon'])\r
-               {\r
-                       echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";\r
-               }\r
-\r
-               if (isset($aResult['address']))\r
-               {\r
-                       echo ">";\r
-                       foreach($aResult['address'] as $sKey => $sValue)\r
-                       {\r
-                               $sKey = str_replace(' ','_',$sKey);\r
-                               echo "<$sKey>";\r
-                               echo htmlspecialchars($sValue);\r
-                               echo "</$sKey>";\r
-                       }\r
-\r
-                       echo "</place>";\r
-               }\r
-               else\r
-               {\r
-                       echo "/>";\r
-               }\r
-       }\r
-       \r
-       echo "</searchresults>";\r
+<?php
+       header("content-type: text/xml; charset=UTF-8");
+
+       echo "<";
+       echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
+       echo ">\n";
+
+       echo "<searchresults";
+       echo " timestamp='".date(DATE_RFC822)."'";
+       echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
+       echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
+       if (isset($sViewBox)) echo " viewbox='".htmlspecialchars($sViewBox, ENT_QUOTES)."'";
+       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=\'';
+                               echo json_encode($aResult['aPolyPoints']);
+                               echo '\'';
+                       }
+               }
+
+               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 '\'';
+               }
+
+               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'])."'";
+               if (isset($aResult['icon']) && $aResult['icon'])
+               {
+                       echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
+               }
+
+               if (isset($aResult['address']) || isset($aResult['askml']))
+               {
+                       echo ">";
+               }
+
+               if (isset($aResult['askml']))
+               {
+                       echo "\n<geokml>";
+                       echo $aResult['askml'];
+                       echo "</geokml>";
+               }
+
+               if (isset($aResult['address']))
+               {
+                       echo "\n";
+                       foreach($aResult['address'] as $sKey => $sValue)
+                       {
+                               $sKey = str_replace(' ','_',$sKey);
+                               echo "<$sKey>";
+                               echo htmlspecialchars($sValue);
+                               echo "</$sKey>";
+                       }
+               }
+
+               if (isset($aResult['address']) || isset($aResult['askml']))
+               {
+                       echo "</place>";
+               }
+               else
+               {
+                       echo "/>";
+               }
+       }
+       
+       echo "</searchresults>";