From 26e78efbb911f8f6b1988c80b4dd616e14211966 Mon Sep 17 00:00:00 2001 From: alfmarcua Date: Thu, 6 Jul 2023 08:52:41 +0200 Subject: [PATCH] Parameterise the search only within countries --- lib-php/ReverseGeocode.php | 5 +++++ nominatim/tools/refresh.py | 1 + settings/env.defaults | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/lib-php/ReverseGeocode.php b/lib-php/ReverseGeocode.php index fddad60d..1777288a 100644 --- a/lib-php/ReverseGeocode.php +++ b/lib-php/ReverseGeocode.php @@ -85,6 +85,11 @@ class ReverseGeocode protected function lookupLargeArea($sPointSQL, $iMaxRank) { + if(CONST_Search_WithinCountries + and $this->lookupInCountry($sPointSQL, $iMaxRank) == null){ + return null; + } + if ($iMaxRank > 4) { $aPlace = $this->lookupPolygon($sPointSQL, $iMaxRank); if ($aPlace) { diff --git a/nominatim/tools/refresh.py b/nominatim/tools/refresh.py index c6df9982..43e5b1eb 100644 --- a/nominatim/tools/refresh.py +++ b/nominatim/tools/refresh.py @@ -120,6 +120,7 @@ PHP_CONST_DEFS = ( ('Search_NameOnlySearchFrequencyThreshold', 'SEARCH_NAME_ONLY_THRESHOLD', str), ('Use_US_Tiger_Data', 'USE_US_TIGER_DATA', bool), ('MapIcon_URL', 'MAPICON_URL', str), + ('Search_WithinCountries', 'SEARCH_WITHIN_COUNTRIES', bool), ) diff --git a/settings/env.defaults b/settings/env.defaults index f9f590da..c4739e78 100644 --- a/settings/env.defaults +++ b/settings/env.defaults @@ -214,6 +214,12 @@ NOMINATIM_SERVE_LEGACY_URLS=yes # of connections _per worker_. NOMINATIM_API_POOL_SIZE=10 +# Search elements just within countries +# If, despite not finding a point within the static grid of countries, it +# finds a geometry of a region, do not return the geometry. Return "Unable +# to geocode" instead. +NOMINATIM_SEARCH_WITHIN_COUNTRIES=False + ### Log settings # # The following options allow to enable logging of API requests.