X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/f05ea577f42c5ad4a62ff25ec62fbb60c550ee26..2db751700e6b1872fd9f65fa725b59d00ee993c2:/utils/query.php diff --git a/utils/query.php b/utils/query.php old mode 100755 new mode 100644 index 0c95145d..6068c7c0 --- a/utils/query.php +++ b/utils/query.php @@ -1,50 +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' + ); + +if (!$oParams->hasSetAny($aSearchParams)) { + showUsage($aCMDOptions, true); + return 1; +} - $aSearchResults = $oGeocode->lookup(); +$oGeocode = new Nominatim\Geocode($oDB); - 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"; - } +$oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false)); +$oGeocode->setReverseInPlan(true); +$oGeocode->loadParamArray($oParams); + +if ($oParams->getBool('search')) { + $oGeocode->setQuery($aCMDResult['search']); } else { - showUsage($aCMDOptions, true); + $oGeocode->setQueryFromParams($oParams); } + +$aSearchResults = $oGeocode->lookup(); + +echo json_encode($aSearchResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n";