]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/template/search-xml.php
Remove interpolation lines from placex and save them in an extra table.
[nominatim.git] / lib / template / search-xml.php
index 693330bb52cfce29fba95d3ce1c45415085b4b99..dd02b7c7a2364c87ed18a10854dbd6644c4300a5 100644 (file)
@@ -5,7 +5,8 @@
        echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
        echo ">\n";
 
-       echo "<searchresults";
+       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)."'";
@@ -24,7 +25,8 @@
        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':'')));
+               $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'";
                if (isset($aResult['aBoundingBox']))
                {
                        echo ' boundingbox="';
-                       echo $aResult['aBoundingBox'][0];
-                       echo ','.$aResult['aBoundingBox'][1];
-                       echo ','.$aResult['aBoundingBox'][2];
-                       echo ','.$aResult['aBoundingBox'][3];
+                       echo join(',',$aResult['aBoundingBox']);
                        echo '"';
 
                        if ($bShowPolygons && isset($aResult['aPolyPoints']))
                        echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
                }
 
-               if (isset($aResult['address']) || isset($aResult['askml']))
-               {
-                       echo ">";
-               }
+               $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)
                        {
                        }
                }
 
-               if (isset($aResult['address']) || isset($aResult['askml']))
+               if ($bHasDelim)
                {
                        echo "</place>";
                }
                }
        }
        
-       echo "</searchresults>";
+       echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";