X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/5464dec0570c2451d8607bc739c6f2b6f298bb75..e20defeebd988ff4db62b75e3036b332da78e795:/utils/query.php diff --git a/utils/query.php b/utils/query.php old mode 100755 new mode 100644 index a3f51f74..6068c7c0 --- a/utils/query.php +++ b/utils/query.php @@ -1,55 +1,72 @@ -#!/usr/bin/php -Cq connect(); - if ($oParams->getBool('search')) - { - if (isset($aCMDResult['nodedupe'])) $aCMDResult['dedupe'] = 'false'; +if (isset($aCMDResult['nodedupe'])) $aCMDResult['dedupe'] = 'false'; - $oGeocode = new Geocode($oDB); +$oParams = new Nominatim\ParameterParser($aCMDResult); - $oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false)); - $oGeocode->loadParamArray($oParams); - $oGeocode->setQuery($aCMDResult['search']); +$aSearchParams = array( + 'search', + 'amenity', + 'street', + 'city', + 'county', + 'state', + 'country', + 'postalcode' + ); - $aSearchResults = $oGeocode->lookup(); +if (!$oParams->hasSetAny($aSearchParams)) { + showUsage($aCMDOptions, true); + return 1; +} - if (version_compare(phpversion(), "5.4.0", '<')) - echo json_encode($aSearchResults); - else - echo json_encode($aSearchResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n"; - } - else - { - showUsage($aCMDOptions, true); - } +$oGeocode = new Nominatim\Geocode($oDB); +$oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false)); +$oGeocode->setReverseInPlan(true); +$oGeocode->loadParamArray($oParams); +if ($oParams->getBool('search')) { + $oGeocode->setQuery($aCMDResult['search']); +} else { + $oGeocode->setQueryFromParams($oParams); +} +$aSearchResults = $oGeocode->lookup(); + +echo json_encode($aSearchResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n";