]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-xml.php
more generalized javascript_renderData
[nominatim.git] / lib / template / address-xml.php
1 <?php
2         header("content-type: text/xml; charset=UTF-8");
3         header("Access-Control-Allow-Origin: *");
4
5         echo "<";
6         echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
7         echo ">\n";
8
9         echo "<reversegeocode";
10         echo " timestamp='".date(DATE_RFC822)."'";
11         echo " attribution='Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.'";
12         echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
13         echo ">\n";
14
15         if (!sizeof($aPlace))
16         {
17                 if ($sError)
18                         echo "<error>$sError</error>";
19                 else
20                         echo "<error>Unable to geocode</error>";
21         }
22         else
23         {
24                 echo "<result";
25                 if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
26                 if ($aPlace['osm_type'] && $aPlace['osm_id']) echo ' osm_type="'.($aPlace['osm_type']=='N'?'node':($aPlace['osm_type']=='W'?'way':'relation')).'"'.' osm_id="'.$aPlace['osm_id'].'"';
27                 if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
28                 if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
29                 if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
30                 echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
31
32         if ($bShowAddressDetails) {
33                         echo "<addressparts>";
34                         foreach($aAddress as $sKey => $sValue)
35                         {
36                                 $sKey = str_replace(' ','_',$sKey);
37                                 echo "<$sKey>";
38                                 echo htmlspecialchars($sValue);
39                                 echo "</$sKey>";
40                         }
41                         echo "</addressparts>";
42         }
43         }
44         
45         echo "</reversegeocode>";