X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/cf39e07dba72373302e2d1a48de3083339d0decb..2db751700e6b1872fd9f65fa725b59d00ee993c2:/utils/query.php?ds=sidebyside diff --git a/utils/query.php b/utils/query.php old mode 100755 new mode 100644 index 05875d64..6068c7c0 --- a/utils/query.php +++ b/utils/query.php @@ -1,7 +1,5 @@ -#!/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; +} + +$oGeocode = new Nominatim\Geocode($oDB); - $aSearchResults = $oGeocode->lookup(); +$oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false)); +$oGeocode->setReverseInPlan(true); +$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";