X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/bf77b444bf9f18be6bc98c05c8dfc6d796ab30fa..f56bac350b70e1d68733411faaf6a71e36dd05aa:/utils/query.php diff --git a/utils/query.php b/utils/query.php old mode 100755 new mode 100644 index 85ec8737..956bb566 --- a/utils/query.php +++ b/utils/query.php @@ -1,7 +1,5 @@ -#!/usr/bin/php -Cq connect(); + +if (isset($aCMDResult['nodedupe'])) $aCMDResult['dedupe'] = 'false'; + $oParams = new Nominatim\ParameterParser($aCMDResult); -if ($oParams->getBool('search')) { - if (isset($aCMDResult['nodedupe'])) $aCMDResult['dedupe'] = 'false'; +$aSearchParams = array( + 'search', + 'amenity', + 'street', + 'city', + 'county', + 'state', + 'country', + 'postalcode' + ); - $oGeocode = new Nominatim\Geocode($oDB); +if (!$oParams->hasSetAny($aSearchParams)) { + showUsage($aCMDOptions, true); + return 1; +} - $oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false)); - $oGeocode->loadParamArray($oParams); - $oGeocode->setQuery($aCMDResult['search']); +$oGeocode = new Nominatim\Geocode($oDB); - $aSearchResults = $oGeocode->lookup(); +$oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false)); +$oGeocode->loadParamArray($oParams); - 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"; - } +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";