]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/PlaceLookup.php
make PlaceLookup::lookup() accept multiple results
[nominatim.git] / lib / PlaceLookup.php
index 5fb88062473ba5176a8952c2fe6cbad766860c51..6af559004c9f00495a44858ae9c0f395d2b7ba71 100644 (file)
@@ -133,17 +133,16 @@ class PlaceLookup
             return null;
         }
 
-        return $this->lookup(new Result($iPlaceID));
+        $aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID)));
+
+        return sizeof($aResults) ? reset($aResults) : null;
     }
 
-    public function lookup($oResult, $iMinRank = 0, $iMaxRank = 30)
+    public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
     {
-        if ($oResult === null) {
-            return null;
+        if (!sizeof($aResults)) {
+            return array();
         }
-
-        $aResults = array($oResult->iId => $oResult);
-
         $aSubSelects = array();
 
         $sPlaceIDs = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
@@ -381,7 +380,7 @@ class PlaceLookup
         if (CONST_Debug) var_dump($aSubSelects);
 
         if (!sizeof($aSubSelects)) {
-            return null;
+            return array();
         }
 
         $aPlaces = chksql(
@@ -389,12 +388,6 @@ class PlaceLookup
             "Could not lookup place"
         );
 
-        if (!sizeof($aPlaces)) {
-            return null;
-        }
-
-        if (CONST_Debug) var_dump($aPlaces);
-
         foreach ($aPlaces as &$aPlace) {
             if ($this->bAddressDetails) {
                 // to get addressdetails for tiger data, the housenumber is needed
@@ -437,7 +430,7 @@ class PlaceLookup
 
         if (CONST_Debug) var_dump($aPlaces);
 
-        return reset($aPlaces);
+        return $aPlaces;
     }
 
     private function getAddressDetails($iPlaceID, $bAll, $sHousenumber)