X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6b1f2cb2bc9771f2c65ff3f44855e6bfdf778d90..de978c9987ddbb6595029b23b5dfd2823fc4ea3f:/lib/PlaceLookup.php diff --git a/lib/PlaceLookup.php b/lib/PlaceLookup.php index e0016337..6da82fd8 100644 --- a/lib/PlaceLookup.php +++ b/lib/PlaceLookup.php @@ -46,10 +46,15 @@ $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 .= " st_y(centroid) as lat, st_x(centroid) as lon"; + $sSQL .= " (case when centroid is null then st_y(st_centroid(geometry)) else st_y(centroid) end) as lat,"; + $sSQL .= " (case when centroid is null then st_x(st_centroid(geometry)) else st_x(centroid) end) as lon"; $sSQL .= " from placex where place_id = ".(int)$this->iPlaceID; $aPlace = $this->oDB->getRow($sSQL); + if (PEAR::IsError($aPlace)) + { + failInternalError("Could not lookup place.", $sSQL, $aPlace); + } if (!$aPlace['place_id']) return null; if ($this->bAddressDetails)