]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/Geocode.php
errors in structured queries
[nominatim.git] / lib / Geocode.php
index 7eab3678563464042c986f42c2d3e5990dc38519..d660e8b3b2f926a0ed217b6989d00e4d22c4c57a 100644 (file)
 
                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?)
                        }
 
                        $aSearchResults = array();
-                       if ($sQuery || $aStructuredQuery)
+                       if ($sQuery || $this->aStructuredQuery)
                        {
                                // Start with a blank search
                                $aSearches = array(
                                // Commas are used to reduce the search space by indicating where phrases split
                                if ($this->aStructuredQuery)
                                {
-                                       $aPhrases = $aStructuredQuery;
+                                       $aPhrases = $this->aStructuredQuery;
                                        $bStructuredPhrases = true;
                                }
                                else
                                                $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);
                        {
                                // 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
                                                        $aResult['lat'] = $aPointPolygon['centrelat'];
                                                        $aResult['lon'] = $aPointPolygon['centrelon'];
                                                }
+
                                                if ($this->bIncludePolygonAsPoints)
                                                {
                                                        // Translate geometary string to point array