From: Sarah Hoffmann Date: Wed, 16 Mar 2022 20:44:52 +0000 (+0100) Subject: make sure outputs take into account linked place names X-Git-Tag: v4.1.0~70^2~3 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/524dc64ab77afc08ecaa5bc92e4237c89fb4bc86 make sure outputs take into account linked place names --- diff --git a/lib-php/ParameterParser.php b/lib-php/ParameterParser.php index dd637722..e70b47be 100644 --- a/lib-php/ParameterParser.php +++ b/lib-php/ParameterParser.php @@ -114,21 +114,26 @@ class ParameterParser } foreach ($aLanguages as $sLanguage => $fLanguagePref) { - $aLangPrefOrder['name:'.$sLanguage] = 'name:'.$sLanguage; + $this->addNameTag($aLangPrefOrder, 'name:'.$sLanguage); } - $aLangPrefOrder['name'] = 'name'; - $aLangPrefOrder['brand'] = 'brand'; + $this->addNameTag($aLangPrefOrder, 'name'); + $this->addNameTag($aLangPrefOrder, 'brand'); foreach ($aLanguages as $sLanguage => $fLanguagePref) { - $aLangPrefOrder['official_name:'.$sLanguage] = 'official_name:'.$sLanguage; - $aLangPrefOrder['short_name:'.$sLanguage] = 'short_name:'.$sLanguage; + $this->addNameTag($aLangPrefOrder, 'official_name:'.$sLanguage); + $this->addNameTag($aLangPrefOrder, 'short_name:'.$sLanguage); } - $aLangPrefOrder['official_name'] = 'official_name'; - $aLangPrefOrder['short_name'] = 'short_name'; - $aLangPrefOrder['ref'] = 'ref'; - $aLangPrefOrder['type'] = 'type'; + $this->addNameTag($aLangPrefOrder, 'official_name'); + $this->addNameTag($aLangPrefOrder, 'short_name'); + $this->addNameTag($aLangPrefOrder, 'ref'); + $this->addNameTag($aLangPrefOrder, 'type'); return $aLangPrefOrder; } + private function addNameTag(&$aLangPrefOrder, $sTag) { + $aLangPrefOrder[$sTag] = $sTag; + $aLangPrefOrder['_place_'.$sTag] = '_place_'.$sTag; + } + public function hasSetAny($aParamNames) { foreach ($aParamNames as $sName) { diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index e6f083c8..9463bb27 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -85,7 +85,10 @@ BEGIN FROM each(location.name - result.name); {% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %} - result.name := location.name || result.name || extra_names; + IF extra_names is not null THEN + result.name := result.name || extra_names; + END IF; + {% if debug %}RAISE WARNING 'Final names: %', result.name;{% endif %} END IF; END IF; diff --git a/test/bdd/db/query/linking.feature b/test/bdd/db/query/linking.feature index d11ba31f..cf1fa20c 100644 --- a/test/bdd/db/query/linking.feature +++ b/test/bdd/db/query/linking.feature @@ -18,8 +18,14 @@ Feature: Searching linked places | N2 | R13 | When sending search query "Vario" Then results contain - | osm | - | R13 | + | osm | display_name | + | R13 | Garbo | + When sending search query "Vario" + | accept-language | + | it | + Then results contain + | osm | display_name | + | R13 | Vario | Scenario: Differing names from linked places are searchable @@ -38,5 +44,9 @@ Feature: Searching linked places | N2 | R13 | When sending search query "Vario" Then results contain - | osm | - | R13 | + | osm | display_name | + | R13 | Garbo | + When sending search query "Garbo" + Then results contain + | osm | display_name | + | R13 | Garbo | diff --git a/test/bdd/db/update/linked_places.feature b/test/bdd/db/update/linked_places.feature index 7a0fa21a..99614b7f 100644 --- a/test/bdd/db/update/linked_places.feature +++ b/test/bdd/db/update/linked_places.feature @@ -117,8 +117,10 @@ Feature: Updates of linked places | 1 | N3:label | When importing Then placex contains - | object | linked_place_id | name+name:de | + | object | linked_place_id | name+_place_name:de | | R1 | - | pnt | + And placex contains + | object | linked_place_id | name+name:de | | N3 | R1 | pnt | When updating places | osm | class | type | name+name:de | admin | geometry | @@ -126,8 +128,43 @@ Feature: Updates of linked places Then placex contains | object | linked_place_id | name+name:de | | N3 | R1 | newname | + And placex contains + | object | linked_place_id | name+_place_name:de | | R1 | - | newname | + Scenario: Update linking relation when linkee name is deleted + Given the places + | osm | class | type | name | admin | geometry | + | R1 | boundary | administrative | rel | 8 | poly-area:0.1 | + And the places + | osm | class | type | name | admin | geometry | + | N3 | place | city | pnt | 30 | 0.00001 0 | + And the relations + | id | members | + | 1 | N3:label | + When importing + Then placex contains + | object | linked_place_id | name+_place_name | name+name | + | R1 | - | pnt | rel | + And placex contains + | object | linked_place_id | name+name | + | N3 | R1 | pnt | + When sending search query "pnt" + Then results contain + | osm | + | R1 | + When updating places + | osm | class | type | name+name:de | admin | geometry | + | N3 | place | city | depnt | 30 | 0.00001 0 | + Then placex contains + | object | linked_place_id | name+name:de | + | N3 | R1 | depnt | + And placex contains + | object | linked_place_id | name+_place_name:de | name+name | + | R1 | - | depnt | rel | + When sending search query "pnt" + Then exactly 0 results are returned + Scenario: Updating linkee extratags keeps linker's extratags Given the named places | osm | class | type | extra+wikidata | admin | geometry | diff --git a/test/bdd/steps/http_responses.py b/test/bdd/steps/http_responses.py index fa841d25..035838a5 100644 --- a/test/bdd/steps/http_responses.py +++ b/test/bdd/steps/http_responses.py @@ -62,8 +62,6 @@ class GenericResponse: if errorcode == 200 and fmt != 'debug': getattr(self, '_parse_' + fmt)() - else: - print("Bad response: ", page) def _parse_json(self): m = re.fullmatch(r'([\w$][^(]*)\((.*)\)', self.page) @@ -74,13 +72,14 @@ class GenericResponse: self.header['json_func'] = m.group(1) self.result = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(code) if isinstance(self.result, OrderedDict): - self.result = [self.result] + if 'error' in self.result: + self.result = [] + else: + self.result = [self.result] def _parse_geojson(self): self._parse_json() - if 'error' in self.result[0]: - self.result = [] - else: + if self.result: self.result = list(map(_geojson_result_to_json_result, self.result[0]['features'])) def _parse_geocodejson(self):