X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/cdd129de702dda5608a07ea81b4ffa8ddaeb477a..624e135a83ced039b620ce0077d1f8ddbdabce7a:/lib/Geocode.php diff --git a/lib/Geocode.php b/lib/Geocode.php index 7eab3678..d660e8b3 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -218,6 +218,8 @@ function getDetails($aPlaceIDs, $iMinAddressRank = 0, $iMaxAddressRank = 30, $aAddressRankList = false, $sAllowedTypesSQLList = false, $bDeDupe = false) { + if (sizeof($aPlaceIDs) == 0) return array(); + $sLanguagePrefArraySQL = "ARRAY[".join(',',array_map("getDBQuoted",$this->aLangPrefOrder))."]"; // Get the details for display (is this a redundant extra step?) @@ -391,7 +393,7 @@ } $aSearchResults = array(); - if ($sQuery || $aStructuredQuery) + if ($sQuery || $this->aStructuredQuery) { // Start with a blank search $aSearches = array( @@ -463,7 +465,7 @@ // Commas are used to reduce the search space by indicating where phrases split if ($this->aStructuredQuery) { - $aPhrases = $aStructuredQuery; + $aPhrases = $this->aStructuredQuery; $bStructuredPhrases = true; } else @@ -1315,10 +1317,10 @@ $sSQL = "select place_id from placex where place_id in (".join(',',$aResultPlaceIDs).") "; $sSQL .= "and (placex.rank_address between $this->iMinAddressRank and $this->iMaxAddressRank "; if (14 >= $this->iMinAddressRank && 14 <= $this->iMaxAddressRank) $sSQL .= " OR (extratags->'place') = 'city'"; - if ($aAddressRankList) $sSQL .= " OR placex.rank_address in (".join(',',$aAddressRankList).")"; + if ($this->aAddressRankList) $sSQL .= " OR placex.rank_address in (".join(',',$this->aAddressRankList).")"; $sSQL .= ") UNION select place_id from location_property_tiger where place_id in (".join(',',$aResultPlaceIDs).") "; $sSQL .= "and (30 between $this->iMinAddressRank and $this->iMaxAddressRank "; - if ($aAddressRankList) $sSQL .= " OR 30 in (".join(',',$aAddressRankList).")"; + if ($this->aAddressRankList) $sSQL .= " OR 30 in (".join(',',$this->aAddressRankList).")"; $sSQL .= ")"; if (CONST_Debug) var_dump($sSQL); $aResultPlaceIDs = $this->oDB->getCol($sSQL); @@ -1341,7 +1343,10 @@ { // Just interpret as a reverse geocode $iPlaceID = geocodeReverse((float)$this->aNearPoint[0], (float)$this->aNearPoint[1]); - $aSearchResults = $this->getDetails(array($iPlaceID)); + if ($iPlaceID) + $aSearchResults = $this->getDetails(array($iPlaceID)); + else + $aSearchResults = array(); } // No results? Done @@ -1389,6 +1394,7 @@ $aResult['lat'] = $aPointPolygon['centrelat']; $aResult['lon'] = $aPointPolygon['centrelon']; } + if ($this->bIncludePolygonAsPoints) { // Translate geometary string to point array