mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
make PlaceLookup::lookup() accept multiple results
This commit is contained in:
@@ -133,17 +133,16 @@ class PlaceLookup
|
|||||||
return null;
|
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) {
|
if (!sizeof($aResults)) {
|
||||||
return null;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$aResults = array($oResult->iId => $oResult);
|
|
||||||
|
|
||||||
$aSubSelects = array();
|
$aSubSelects = array();
|
||||||
|
|
||||||
$sPlaceIDs = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
|
$sPlaceIDs = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
|
||||||
@@ -381,7 +380,7 @@ class PlaceLookup
|
|||||||
if (CONST_Debug) var_dump($aSubSelects);
|
if (CONST_Debug) var_dump($aSubSelects);
|
||||||
|
|
||||||
if (!sizeof($aSubSelects)) {
|
if (!sizeof($aSubSelects)) {
|
||||||
return null;
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$aPlaces = chksql(
|
$aPlaces = chksql(
|
||||||
@@ -389,12 +388,6 @@ class PlaceLookup
|
|||||||
"Could not lookup place"
|
"Could not lookup place"
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!sizeof($aPlaces)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CONST_Debug) var_dump($aPlaces);
|
|
||||||
|
|
||||||
foreach ($aPlaces as &$aPlace) {
|
foreach ($aPlaces as &$aPlace) {
|
||||||
if ($this->bAddressDetails) {
|
if ($this->bAddressDetails) {
|
||||||
// to get addressdetails for tiger data, the housenumber is needed
|
// to get addressdetails for tiger data, the housenumber is needed
|
||||||
@@ -437,7 +430,7 @@ class PlaceLookup
|
|||||||
|
|
||||||
if (CONST_Debug) var_dump($aPlaces);
|
if (CONST_Debug) var_dump($aPlaces);
|
||||||
|
|
||||||
return reset($aPlaces);
|
return $aPlaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAddressDetails($iPlaceID, $bAll, $sHousenumber)
|
private function getAddressDetails($iPlaceID, $bAll, $sHousenumber)
|
||||||
|
|||||||
@@ -59,7 +59,12 @@ if ($sOsmType && $iOsmId > 0) {
|
|||||||
$oLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
$oLookup = $oReverseGeocode->lookup($fLat, $fLon);
|
||||||
if (CONST_Debug) var_dump($oLookup);
|
if (CONST_Debug) var_dump($oLookup);
|
||||||
|
|
||||||
$aPlace = $oPlaceLookup->lookup($oLookup);
|
if ($oLookup) {
|
||||||
|
$aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup));
|
||||||
|
if (sizeof($aPlaces)) {
|
||||||
|
$aPlace = reset($aPlaces);
|
||||||
|
}
|
||||||
|
}
|
||||||
} elseif ($sOutputFormat != 'html') {
|
} elseif ($sOutputFormat != 'html') {
|
||||||
userError("Need coordinates or OSM object to lookup.");
|
userError("Need coordinates or OSM object to lookup.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user