]> git.openstreetmap.org Git - nominatim.git/commitdiff
return actual centroid lat,lon of reverse geocoding result
authorBrian Quinion <openstreetmap@brian.quinion.co.uk>
Thu, 7 Apr 2011 15:57:57 +0000 (15:57 +0000)
committerBrian Quinion <openstreetmap@brian.quinion.co.uk>
Thu, 7 Apr 2011 15:57:57 +0000 (15:57 +0000)
lib/template/address-json.php
lib/template/address-jsonv2.php
lib/template/address-xml.php
website/reverse.php

index 4ae41116e42ba792710b722f01bacd78305dd182..29e6e90176c29937bd6d348f76b1444ecec79b5a 100644 (file)
@@ -21,6 +21,8 @@
                         $aFilteredPlaces['osm_type'] = $sOSMType;\r
                         $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];\r
                 }\r
+                if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];\r
+                if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];\r
                $aFilteredPlaces['display_name'] = $aPlace['langaddress'];\r
                $aFilteredPlaces['address'] = $aAddress;\r
        }\r
index b6fa58fee398484b10e8b8ee58b189880d7183ab..f9592d8b746663a6b11ba44b71a72b812025acb0 100644 (file)
@@ -21,6 +21,8 @@
                         $aFilteredPlaces['osm_type'] = $sOSMType;\r
                         $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];\r
                 }\r
+               if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];\r
+               if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];\r
                 $aFilteredPlaces['category'] = $aPlace['class'];\r
                 $aFilteredPlaces['type'] = $aPlace['type'];\r
                 $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);\r
index dc9f054855354e10ec556a301403978950f35752..d6061e3df4fff930595df754eb8b4edd045b0958 100644 (file)
@@ -25,6 +25,8 @@
                if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';\r
                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'].'"';\r
                if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';\r
+               if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';\r
+               if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';\r
                echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";\r
 \r
                echo "<addressparts>";\r
index b0205d2249771b28befcbdfbf1252b39d004157f..f569ffac1abbf6ba9dc82ad33ddcc7acb1f1500f 100755 (executable)
                // The point we found might be too small - use the address to find what it is a child of
                if ($iPlaceID)
                {
-                       $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = $iPlaceID order by cached_rank_address desc,isaddress desc,distance desc";
+                       $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = $iPlaceID order by cached_rank_address desc,isaddress desc,distance desc limit 1";
+//var_dump($sSQL);
                        $iPlaceID = $oDB->getOne($sSQL);
                        if (PEAR::IsError($iPlaceID))
                        {
                        if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28)
                        {
                                $sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = ".$aPlace['place_id']." order by cached_rank_address desc,isaddress desc,distance desc";
+//var_dump($sSQL);
                                $iPlaceID = $oDB->getOne($sSQL);
                                if (PEAR::IsError($iPlaceID))
                                {
                $sSQL = "select placex.*,";
                $sSQL .= " get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
                $sSQL .= " get_name_by_language(name, $sLanguagePrefArraySQL) as placename,";
-               $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref";
+               $sSQL .= " get_name_by_language(name, ARRAY['ref']) as ref,";
+               $sSQL .= " st_y(st_centroid(geometry)) as lat, st_x(st_centroid(geometry)) as lon";
                $sSQL .= " from placex where place_id = $iPlaceID ";
+//var_dump($sSQL);
                $aPlace = $oDB->getRow($sSQL);
 
                if ($bShowAddressDetails)
                {
                        $aAddress = getAddressDetails($oDB, $sLanguagePrefArraySQL, $iPlaceID, $aPlace['country_code']);
                }
-
                $aClassType = getClassTypes();
                 $sAddressType = '';
                 if (isset($aClassType[$aPlace['class'].':'.$aPlace['type'].':'.$aPlace['admin_level']]))