X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/f05ea577f42c5ad4a62ff25ec62fbb60c550ee26..c611d49941e8a097116dfb6f6d08e5491a85dcee:/utils/query.php?ds=sidebyside diff --git a/utils/query.php b/utils/query.php old mode 100755 new mode 100644 index 0c95145d..956bb566 --- a/utils/query.php +++ b/utils/query.php @@ -1,50 +1,71 @@ -#!/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->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";