- $aLookup = $oReverseGeocode->lookup($fLat, $fLon);
- if (CONST_Debug) var_dump($aLookup);
-
- $aPlace = $oPlaceLookup->lookup((int)$aLookup['place_id'],
- $aLookup['type'], $aLookup['fraction']);
-}
-else if ($sOutputFormat != 'html')
-{
- userError("Need coordinates or OSM object to lookup.");
+if ($sOsmType && $iOsmId > 0) {
+ $aPlace = $oPlaceLookup->lookupOSMID($sOsmType, $iOsmId);
+} elseif ($fLat !== false && $fLon !== false) {
+ $oReverseGeocode = new Nominatim\ReverseGeocode($oDB);
+ $oReverseGeocode->setZoom($iZoom);
+
+ $oLookup = $oReverseGeocode->lookup($fLat, $fLon);
+ if (CONST_Debug) var_dump($oLookup);
+
+ if ($oLookup) {
+ $aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup));
+ if (!empty($aPlaces)) {
+ $aPlace = reset($aPlaces);
+ }
+ }
+} elseif ($sOutputFormat != 'html') {
+ userError('Need coordinates or OSM object to lookup.');