]> 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 dd02b7c7a2364c87ed18a10854dbd6644c4300a5..80414fce6829be2f18534e06431aabbb2b9f8db3 100644 (file)
 <?php
 <?php
-       header("content-type: text/xml; charset=UTF-8");
-
-       echo "<";
-       echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
-       echo ">\n";
-
-       echo "<";
-       echo (isset($sXmlRootTag)?$sXmlRootTag:'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 ($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 = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':
-               ($aPointDetails['osm_type'] == 'T'?'tiger':($aPointDetails['osm_type'] == 'I'?'interpolation':'')))));
-               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 join(',',$aResult['aBoundingBox']);
-                       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'], ENT_QUOTES)."'";
-               echo " importance='".htmlspecialchars($aResult['importance'])."'";
-               if (isset($aResult['icon']) && $aResult['icon'])
-               {
-                       echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
-               }
-
-               $bHasDelim = false;
-
-               if (isset($aResult['askml']))
-               {
-                       if (!$bHasDelim)
-                       {
-                               $bHasDelim = true;
-                               echo ">";
-                       }
-                       echo "\n<geokml>";
-                       echo $aResult['askml'];
-                       echo "</geokml>";
-               }
-
-               if (isset($aResult['sExtraTags']))
-               {
-                       if (!$bHasDelim)
-                       {
-                               $bHasDelim = true;
-                               echo ">";
-                       }
-                       echo "\n<extratags>";
-                       foreach ($aResult['sExtraTags'] as $sKey => $sValue)
-                       {
-                               echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
-                       }
-                       echo "</extratags>";
-               }
-
-               if (isset($aResult['sNameDetails']))
-               {
-                       if (!$bHasDelim)
-                       {
-                               $bHasDelim = true;
-                               echo ">";
-                       }
-                       echo "\n<namedetails>";
-                       foreach ($aResult['sNameDetails'] as $sKey => $sValue)
-                       {
-                               echo '<name desc="'.htmlspecialchars($sKey).'">';
-                               echo htmlspecialchars($sValue);
-                               echo "</name>";
-                       }
-                       echo "</namedetails>";
-               }
-
-               if (isset($aResult['address']))
-               {
-                       if (!$bHasDelim)
-                       {
-                               $bHasDelim = true;
-                               echo ">";
-                       }
-                       echo "\n";
-                       foreach($aResult['address'] as $sKey => $sValue)
-                       {
-                               $sKey = str_replace(' ','_',$sKey);
-                               echo "<$sKey>";
-                               echo htmlspecialchars($sValue);
-                               echo "</$sKey>";
-                       }
-               }
-
-               if ($bHasDelim)
-               {
-                       echo "</place>";
-               }
-               else
-               {
-                       echo "/>";
-               }
-       }
-       
-       echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";
+header("content-type: text/xml; charset=UTF-8");
+
+echo "<";
+echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
+echo ">\n";
+
+echo "<";
+echo (isset($sXmlRootTag)?$sXmlRootTag:'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($aMoreParams['viewbox'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
+echo " polygon='".(isset($aMoreParams['polygon'])?'true':'false')."'";
+if (isset($aMoreParams['exclude_place_ids']))
+{
+    echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
+}
+echo " more_url='".htmlspecialchars($sMoreURL)."'";
+echo ">\n";
+
+foreach($aSearchResults as $iResNum => $aResult)
+{
+    echo "<place place_id='".$aResult['place_id']."'";
+    $sOSMType = formatOSMType($aResult['osm_type']);
+    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 join(',',$aResult['aBoundingBox']);
+        echo '"';
+
+        if (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'], ENT_QUOTES)."'";
+    echo " importance='".htmlspecialchars($aResult['importance'])."'";
+    if (isset($aResult['icon']) && $aResult['icon'])
+    {
+        echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
+    }
+
+    $bHasDelim = false;
+
+    if (isset($aResult['askml']))
+    {
+        if (!$bHasDelim)
+        {
+            $bHasDelim = true;
+            echo ">";
+        }
+        echo "\n<geokml>";
+        echo $aResult['askml'];
+        echo "</geokml>";
+    }
+
+    if (isset($aResult['sExtraTags']))
+    {
+        if (!$bHasDelim)
+        {
+            $bHasDelim = true;
+            echo ">";
+        }
+        echo "\n<extratags>";
+        foreach ($aResult['sExtraTags'] as $sKey => $sValue)
+        {
+            echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
+        }
+        echo "</extratags>";
+    }
+
+    if (isset($aResult['sNameDetails']))
+    {
+        if (!$bHasDelim)
+        {
+            $bHasDelim = true;
+            echo ">";
+        }
+        echo "\n<namedetails>";
+        foreach ($aResult['sNameDetails'] as $sKey => $sValue)
+        {
+            echo '<name desc="'.htmlspecialchars($sKey).'">';
+            echo htmlspecialchars($sValue);
+            echo "</name>";
+        }
+        echo "</namedetails>";
+    }
+
+    if (isset($aResult['address']))
+    {
+        if (!$bHasDelim)
+        {
+            $bHasDelim = true;
+            echo ">";
+        }
+        echo "\n";
+        foreach($aResult['address'] as $sKey => $sValue)
+        {
+            $sKey = str_replace(' ','_',$sKey);
+            echo "<$sKey>";
+            echo htmlspecialchars($sValue);
+            echo "</$sKey>";
+        }
+    }
+
+    if ($bHasDelim)
+    {
+        echo "</place>";
+    }
+    else
+    {
+        echo "/>";
+    }
+}
+
+echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";