From 7e3701b64a3b989adab0775363b109d5a13ab168 Mon Sep 17 00:00:00 2001 From: Sandor Nagy Date: Tue, 15 Mar 2022 07:50:47 +0100 Subject: [PATCH 1/9] Fix typo in log message on replication initialisation --- nominatim/tools/replication.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nominatim/tools/replication.py b/nominatim/tools/replication.py index cbbf0585..fbd33e39 100644 --- a/nominatim/tools/replication.py +++ b/nominatim/tools/replication.py @@ -47,7 +47,7 @@ def init_replication(conn, base_url): status.set_status(conn, date=date, seq=seq) - LOG.warning("Updates intialised at sequence %s (%s)", seq, date) + LOG.warning("Updates initialised at sequence %s (%s)", seq, date) def check_for_updates(conn, base_url): From ef98a85b05f02068ada85dd50b15f2e960ca35bc Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 16 Mar 2022 11:19:09 +0100 Subject: [PATCH 2/9] correctly handle single-point interpolations in reverse Lookup in location_property_osmline needs to be special cased for startnumber = endnumber. Also adds tests for the case. Fixes #2680. --- lib-php/ReverseGeocode.php | 4 +- test/bdd/db/query/interpolation.feature | 58 +++++++++++++++++++++++++ test/bdd/steps/http_responses.py | 11 ++++- test/bdd/steps/steps_api_queries.py | 16 ++++++- 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 test/bdd/db/query/interpolation.feature diff --git a/lib-php/ReverseGeocode.php b/lib-php/ReverseGeocode.php index 646c592b..35103aeb 100644 --- a/lib-php/ReverseGeocode.php +++ b/lib-php/ReverseGeocode.php @@ -64,7 +64,9 @@ class ReverseGeocode { Debug::newFunction('lookupInterpolation'); $sSQL = 'SELECT place_id, parent_place_id, 30 as rank_search,'; - $sSQL .= ' (endnumber - startnumber) * ST_LineLocatePoint(linegeo,'.$sPointSQL.') as fhnr,'; + $sSQL .= ' (CASE WHEN endnumber != startnumber'; + $sSQL .= ' THEN (endnumber - startnumber) * ST_LineLocatePoint(linegeo,'.$sPointSQL.')'; + $sSQL .= ' ELSE startnumber END) as fhnr,'; $sSQL .= ' startnumber, endnumber, step,'; $sSQL .= ' ST_Distance(linegeo,'.$sPointSQL.') as distance'; $sSQL .= ' FROM location_property_osmline'; diff --git a/test/bdd/db/query/interpolation.feature b/test/bdd/db/query/interpolation.feature new file mode 100644 index 00000000..602ac434 --- /dev/null +++ b/test/bdd/db/query/interpolation.feature @@ -0,0 +1,58 @@ +@DB +Feature: Query of address interpolations + Tests that interpolated addresses can be queried correctly + + Background: + Given the grid + | 1 | | 2 | | 3 | + | 10 | | 12 | | 13 | + | 7 | | 8 | | 9 | + + Scenario: Find interpolations with single number + Given the places + | osm | class | type | name | geometry | + | W10 | highway | primary | Nickway | 10,12,13 | + And the places + | osm | class | type | addr+interpolation | geometry | + | W1 | place | houses | odd | 1,3 | + And the places + | osm | class | type | housenr | geometry | + | N1 | place | house | 1 | 1 | + | N3 | place | house | 5 | 3 | + And the ways + | id | nodes | + | 1 | 1,3 | + When importing + When sending jsonv2 reverse point 2 + Then results contain + | ID | display_name | + | 0 | 3, Nickway | + When sending search query "Nickway 3" + Then results contain + | osm | display_name | + | W1 | 3, Nickway | + + + Scenario: Find interpolations with multiple numbers + Given the places + | osm | class | type | name | geometry | + | W10 | highway | primary | Nickway | 10,12,13 | + And the places + | osm | class | type | addr+interpolation | geometry | + | W1 | place | houses | even | 1,3 | + And the places + | osm | class | type | housenr | geometry | + | N1 | place | house | 2 | 1 | + | N3 | place | house | 16 | 3 | + And the ways + | id | nodes | + | 1 | 1,3 | + When importing + When sending jsonv2 reverse point 2 + Then results contain + | ID | display_name | centroid | + | 0 | 10, Nickway | 2 | + When sending search query "Nickway 10" + Then results contain + | osm | display_name | centroid | + | W1 | 10, Nickway | 2 | diff --git a/test/bdd/steps/http_responses.py b/test/bdd/steps/http_responses.py index fa6ab7fb..fa841d25 100644 --- a/test/bdd/steps/http_responses.py +++ b/test/bdd/steps/http_responses.py @@ -62,6 +62,8 @@ 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) @@ -128,7 +130,7 @@ class GenericResponse: "\nBad value for row {} field '{}' in address. Expected: {}, got: {}.\nFull address: {}"""\ .format(idx, field, value, address[field], json.dumps(address, indent=4)) - def match_row(self, row): + def match_row(self, row, context=None): """ Match the result fields against the given behave table row. """ if 'ID' in row.headings: @@ -151,7 +153,12 @@ class GenericResponse: assert self.result[i]['osm_type'] in (OSM_TYPE[value[0]], value[0]), \ BadRowValueAssert(self, i, 'osm_type', value) elif name == 'centroid': - lon, lat = value.split(' ') + if ' ' in value: + lon, lat = value.split(' ') + elif context is not None: + lon, lat = context.osm.grid_node(int(value)) + else: + raise RuntimeError("Context needed when using grid coordinates") self.assert_field(i, 'lat', float(lat)) self.assert_field(i, 'lon', float(lon)) else: diff --git a/test/bdd/steps/steps_api_queries.py b/test/bdd/steps/steps_api_queries.py index 0fda8f08..22517338 100644 --- a/test/bdd/steps/steps_api_queries.py +++ b/test/bdd/steps/steps_api_queries.py @@ -153,6 +153,20 @@ def website_reverse_request(context, fmt, lat, lon): context.response = ReverseResponse(outp, fmt or 'xml', status) +@when(u'sending (?P\S+ )?reverse point (?P.+)') +def website_reverse_request(context, fmt, nodeid): + params = {} + if fmt and fmt.strip() == 'debug': + params['debug'] = '1' + params['lon'], params['lat'] = (f'{c:f}' for c in context.osm.grid_node(int(nodeid))) + + + outp, status = send_api_query('reverse', params, fmt, context) + + context.response = ReverseResponse(outp, fmt or 'xml', status) + + + @when(u'sending (?P\S+ )?details query for (?P.*)') def website_details_request(context, fmt, query): params = {} @@ -238,7 +252,7 @@ def step_impl(context): context.execute_steps("then at least 1 result is returned") for line in context.table: - context.response.match_row(line) + context.response.match_row(line, context=context) @then(u'result (?P\d+ )?has (?Pnot )?attributes (?P.*)') def validate_attributes(context, lid, neg, attrs): From be8f5778a1d4c5a7a8506c8f5383f02ca78b0bb9 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 16 Mar 2022 12:05:58 +0100 Subject: [PATCH 3/9] use https protocol for cloning from github Does not need authentication. --- docs/admin/Installation.md | 2 +- vagrant/Install-on-Centos-8.sh | 2 +- vagrant/Install-on-Ubuntu-18.sh | 2 +- vagrant/Install-on-Ubuntu-20.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/admin/Installation.md b/docs/admin/Installation.md index 19ad2dbb..00c7ca29 100644 --- a/docs/admin/Installation.md +++ b/docs/admin/Installation.md @@ -129,7 +129,7 @@ If you want to install latest development version from github, make sure to also check out the osm2pgsql subproject: ``` -git clone --recursive git://github.com/openstreetmap/Nominatim.git +git clone --recursive https://github.com/openstreetmap/Nominatim.git ``` The development version does not include the country grid. Download it separately: diff --git a/vagrant/Install-on-Centos-8.sh b/vagrant/Install-on-Centos-8.sh index 4877e0ad..c9278f9e 100755 --- a/vagrant/Install-on-Centos-8.sh +++ b/vagrant/Install-on-Centos-8.sh @@ -125,7 +125,7 @@ fi #DOCS: # if [ "x$1" == "xyes" ]; then #DOCS: :::sh cd $USERHOME - git clone --recursive git://github.com/openstreetmap/Nominatim.git + git clone --recursive https://github.com/openstreetmap/Nominatim.git cd Nominatim else #DOCS: cd $USERHOME/Nominatim #DOCS: diff --git a/vagrant/Install-on-Ubuntu-18.sh b/vagrant/Install-on-Ubuntu-18.sh index a1a1fe30..40ee7ba8 100755 --- a/vagrant/Install-on-Ubuntu-18.sh +++ b/vagrant/Install-on-Ubuntu-18.sh @@ -105,7 +105,7 @@ fi #DOCS: # if [ "x$1" == "xyes" ]; then #DOCS: :::sh cd $USERHOME - git clone --recursive git://github.com/openstreetmap/Nominatim.git + git clone --recursive https://github.com/openstreetmap/Nominatim.git cd Nominatim else #DOCS: cd $USERHOME/Nominatim #DOCS: diff --git a/vagrant/Install-on-Ubuntu-20.sh b/vagrant/Install-on-Ubuntu-20.sh index 1fbabf24..68bd6b04 100755 --- a/vagrant/Install-on-Ubuntu-20.sh +++ b/vagrant/Install-on-Ubuntu-20.sh @@ -99,7 +99,7 @@ fi #DOCS: # if [ "x$1" == "xyes" ]; then #DOCS: :::sh cd $USERHOME - git clone --recursive git://github.com/openstreetmap/Nominatim.git + git clone --recursive https://github.com/openstreetmap/Nominatim.git cd Nominatim else #DOCS: cd $USERHOME/Nominatim #DOCS: From 42cd021d0406970d6c96c029ab83d08dfbe02792 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 16 Mar 2022 16:38:52 +0100 Subject: [PATCH 4/9] save differing linked polace names in extra fields This keeps the names tracable and ensures that all names are searchable when they differ. Do not keep names when they are exactly the same to save some space. Linked names are cleaned out before relinking. --- lib-sql/functions/placex_triggers.sql | 19 ++++++++++++++++--- test/bdd/db/query/linking.feature | 20 ++++++++++++++++++++ test/bdd/steps/steps_db_ops.py | 1 + 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 1eae353e..e6f083c8 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -26,6 +26,7 @@ CREATE OR REPLACE FUNCTION placex_indexing_prepare(p placex) DECLARE location RECORD; result prepare_update_info; + extra_names HSTORE; BEGIN -- For POI nodes, check if the address should be derived from a surrounding -- building. @@ -58,8 +59,11 @@ BEGIN END LOOP; END IF; + -- remove internal and derived names result.address := result.address - '_unlisted_place'::TEXT; - result.name := p.name; + SELECT hstore(array_agg(key), array_agg(value)) INTO result.name + FROM each(p.name) WHERE key not like '\_%'; + result.class := p.class; result.type := p.type; result.country_code := p.country_code; @@ -72,8 +76,17 @@ BEGIN IF location.place_id is not NULL THEN result.linked_place_id := location.place_id; - IF NOT location.name IS NULL THEN - result.name := location.name || result.name; + IF location.name is not NULL THEN + {% if debug %}RAISE WARNING 'Names original: %, location: %', result.name, location.name;{% endif %} + -- Add all names from the place nodes that deviate from the name + -- in the relation with the prefix '_place_'. Deviation means that + -- either the value is different or a given key is missing completely + SELECT hstore(array_agg('_place_' || key), array_agg(value)) INTO extra_names + FROM each(location.name - result.name); + {% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %} + + result.name := location.name || result.name || extra_names; + {% 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 4e6c47d8..d11ba31f 100644 --- a/test/bdd/db/query/linking.feature +++ b/test/bdd/db/query/linking.feature @@ -20,3 +20,23 @@ Feature: Searching linked places Then results contain | osm | | R13 | + + + Scenario: Differing names from linked places are searchable + Given the places + | osm | class | type | admin | name | geometry | + | R13 | boundary | administrative | 6 | Garbo | poly-area:0.1 | + Given the places + | osm | class | type | admin | name | geometry | + | N2 | place | hamlet | 15 | Vario | 0.006 0.00001 | + And the relations + | id | members | tags+type | + | 13 | N2:label | boundary | + When importing + Then placex contains + | object | linked_place_id | + | N2 | R13 | + When sending search query "Vario" + Then results contain + | osm | + | R13 | diff --git a/test/bdd/steps/steps_db_ops.py b/test/bdd/steps/steps_db_ops.py index 8df5d617..e02cad8f 100644 --- a/test/bdd/steps/steps_db_ops.py +++ b/test/bdd/steps/steps_db_ops.py @@ -93,6 +93,7 @@ def add_data_to_planet_ways(context): def import_and_index_data_from_place_table(context): """ Import data previously set up in the place table. """ + context.nominatim.run_nominatim('refresh', '--functions') context.nominatim.run_nominatim('import', '--continue', 'load-data', '--index-noanalyse', '-q') From 17da5f45be95420139ce94adf6e76db8dd5d9c99 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 16 Mar 2022 21:44:02 +0100 Subject: [PATCH 5/9] fix return code for PHP exceptions These have returned a 0 until now. --- lib-php/init-website.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib-php/init-website.php b/lib-php/init-website.php index 770c245d..60367503 100644 --- a/lib-php/init-website.php +++ b/lib-php/init-website.php @@ -26,7 +26,7 @@ function userError($sMsg) function exception_handler_json($exception) { - http_response_code($exception->getCode()); + http_response_code($exception->getCode() == 0 ? 500 : $exception->getCode()); header('Content-type: application/json; charset=utf-8'); include(CONST_LibDir.'/template/error-json.php'); exit(); @@ -34,7 +34,7 @@ function exception_handler_json($exception) function exception_handler_xml($exception) { - http_response_code($exception->getCode()); + http_response_code($exception->getCode() == 0 ? 500 : $exception->getCode()); header('Content-type: text/xml; charset=utf-8'); echo ''."\n"; include(CONST_LibDir.'/template/error-xml.php'); From 524dc64ab77afc08ecaa5bc92e4237c89fb4bc86 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 16 Mar 2022 21:44:52 +0100 Subject: [PATCH 6/9] make sure outputs take into account linked place names --- lib-php/ParameterParser.php | 23 ++++++++------ lib-sql/functions/placex_triggers.sql | 5 ++- test/bdd/db/query/linking.feature | 18 ++++++++--- test/bdd/db/update/linked_places.feature | 39 +++++++++++++++++++++++- test/bdd/steps/http_responses.py | 11 +++---- 5 files changed, 75 insertions(+), 21 deletions(-) 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): From e133476c355c07dd08a4203dd3f85e96c03105ff Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 17 Mar 2022 11:02:02 +0100 Subject: [PATCH 7/9] merge linked names correctly into namedetails Convert the '_place_*' entries back to normal entries before returning them in the 'namedetails' section. If the name field is duplicated, kept the '_place_*' notation. This preserves the previous behaviour before _place_ names were introduces but adds the additional names from the linked place for reference. --- lib-php/PlaceLookup.php | 35 ++++++++++++++++++++++++------- test/bdd/db/query/linking.feature | 12 +++++++---- test/bdd/steps/http_responses.py | 3 +++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/lib-php/PlaceLookup.php b/lib-php/PlaceLookup.php index 120f5543..715f1ced 100644 --- a/lib-php/PlaceLookup.php +++ b/lib-php/PlaceLookup.php @@ -452,11 +452,7 @@ class PlaceLookup } if ($this->bNameDetails) { - if ($aPlace['names']) { - $aPlace['sNameDetails'] = json_decode($aPlace['names']); - } else { - $aPlace['sNameDetails'] = (object) array(); - } + $aPlace['sNameDetails'] = $this->extractNames($aPlace['names']); } $aPlace['addresstype'] = ClassTypes\getLabelTag( @@ -479,6 +475,33 @@ class PlaceLookup return $aResults; } + + private function extractNames($sNames) + { + if (!$sNames) { + return (object) array(); + } + + $aFullNames = json_decode($sNames); + $aNames = array(); + + foreach ($aFullNames as $sKey => $sValue) { + if (strpos($sKey, '_place_') === 0) { + $sSubKey = substr($sKey, 7); + if (array_key_exists($sSubKey, $aFullNames)) { + $aNames[$sKey] = $sValue; + } else { + $aNames[$sSubKey] = $sValue; + } + } else { + $aNames[$sKey] = $sValue; + } + } + + return $aNames; + } + + /* returns an array which will contain the keys * aBoundingBox * and may also contain one or more of the keys @@ -489,8 +512,6 @@ class PlaceLookup * lat * lon */ - - public function getOutlines($iPlaceID, $fLon = null, $fLat = null, $fRadius = null, $fLonReverse = null, $fLatReverse = null) { diff --git a/test/bdd/db/query/linking.feature b/test/bdd/db/query/linking.feature index cf1fa20c..bd8e1da0 100644 --- a/test/bdd/db/query/linking.feature +++ b/test/bdd/db/query/linking.feature @@ -17,9 +17,11 @@ Feature: Searching linked places | object | linked_place_id | | N2 | R13 | When sending search query "Vario" + | namedetails | + | 1 | Then results contain - | osm | display_name | - | R13 | Garbo | + | osm | display_name | namedetails | + | R13 | Garbo | "name": "Garbo", "name:it": "Vario" | When sending search query "Vario" | accept-language | | it | @@ -43,9 +45,11 @@ Feature: Searching linked places | object | linked_place_id | | N2 | R13 | When sending search query "Vario" + | namedetails | + | 1 | Then results contain - | osm | display_name | - | R13 | Garbo | + | osm | display_name | namedetails | + | R13 | Garbo | "name": "Garbo", "_place_name": "Vario" | When sending search query "Garbo" Then results contain | osm | display_name | diff --git a/test/bdd/steps/http_responses.py b/test/bdd/steps/http_responses.py index 035838a5..3b9f59eb 100644 --- a/test/bdd/steps/http_responses.py +++ b/test/bdd/steps/http_responses.py @@ -102,6 +102,9 @@ class GenericResponse: elif value.startswith("^"): assert re.fullmatch(value, self.result[idx][field]), \ BadRowValueAssert(self, idx, field, value) + elif isinstance(self.result[idx][field], OrderedDict): + assert self.result[idx][field] == eval('{' + value + '}'), \ + BadRowValueAssert(self, idx, field, value) else: assert str(self.result[idx][field]) == str(value), \ BadRowValueAssert(self, idx, field, value) From ce149649431bd0c1a4bc4f04533b305674a4529d Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 17 Mar 2022 11:05:32 +0100 Subject: [PATCH 8/9] fix linting --- lib-php/ParameterParser.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib-php/ParameterParser.php b/lib-php/ParameterParser.php index e70b47be..98b95388 100644 --- a/lib-php/ParameterParser.php +++ b/lib-php/ParameterParser.php @@ -129,7 +129,8 @@ class ParameterParser return $aLangPrefOrder; } - private function addNameTag(&$aLangPrefOrder, $sTag) { + private function addNameTag(&$aLangPrefOrder, $sTag) + { $aLangPrefOrder[$sTag] = $sTag; $aLangPrefOrder['_place_'.$sTag] = '_place_'.$sTag; } From 23de4c7aca63f87db7f2ee003fda0982ac9f2196 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 17 Mar 2022 11:45:05 +0100 Subject: [PATCH 9/9] adapt ParameterParser tests to new key list --- test/php/Nominatim/ParameterParserTest.php | 65 +++++++--------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/test/php/Nominatim/ParameterParserTest.php b/test/php/Nominatim/ParameterParserTest.php index 57cf5f35..1488c987 100644 --- a/test/php/Nominatim/ParameterParserTest.php +++ b/test/php/Nominatim/ParameterParserTest.php @@ -184,75 +184,48 @@ class ParameterParserTest extends \PHPUnit\Framework\TestCase $oParams = new ParameterParser(array('accept-language' => '')); $this->assertSame(array( 'name:default' => 'name:default', + '_place_name:default' => '_place_name:default', 'name' => 'name', - 'brand' => 'brand', - 'official_name:default' => 'official_name:default', - 'short_name:default' => 'short_name:default', - 'official_name' => 'official_name', - 'short_name' => 'short_name', - 'ref' => 'ref', - 'type' => 'type' - ), $oParams->getPreferredLanguages('default')); + '_place_name' => '_place_name' + ), array_slice($oParams->getPreferredLanguages('default'), 0, 4)); $oParams = new ParameterParser(array('accept-language' => 'de,en')); $this->assertSame(array( 'name:de' => 'name:de', + '_place_name:de' => '_place_name:de', 'name:en' => 'name:en', + '_place_name:en' => '_place_name:en', 'name' => 'name', - 'brand' => 'brand', - 'official_name:de' => 'official_name:de', - 'short_name:de' => 'short_name:de', - 'official_name:en' => 'official_name:en', - 'short_name:en' => 'short_name:en', - 'official_name' => 'official_name', - 'short_name' => 'short_name', - 'ref' => 'ref', - 'type' => 'type' - ), $oParams->getPreferredLanguages('default')); + '_place_name' => '_place_name' + ), array_slice($oParams->getPreferredLanguages('default'), 0, 6)); $oParams = new ParameterParser(array('accept-language' => 'fr-ca,fr;q=0.8,en-ca;q=0.5,en;q=0.3')); $this->assertSame(array( 'name:fr-ca' => 'name:fr-ca', + '_place_name:fr-ca' => '_place_name:fr-ca', 'name:fr' => 'name:fr', + '_place_name:fr' => '_place_name:fr', 'name:en-ca' => 'name:en-ca', + '_place_name:en-ca' => '_place_name:en-ca', 'name:en' => 'name:en', + '_place_name:en' => '_place_name:en', 'name' => 'name', - 'brand' => 'brand', - 'official_name:fr-ca' => 'official_name:fr-ca', - 'short_name:fr-ca' => 'short_name:fr-ca', - 'official_name:fr' => 'official_name:fr', - 'short_name:fr' => 'short_name:fr', - 'official_name:en-ca' => 'official_name:en-ca', - 'short_name:en-ca' => 'short_name:en-ca', - 'official_name:en' => 'official_name:en', - 'short_name:en' => 'short_name:en', - 'official_name' => 'official_name', - 'short_name' => 'short_name', - 'ref' => 'ref', - 'type' => 'type', - ), $oParams->getPreferredLanguages('default')); + '_place_name' => '_place_name' + ), array_slice($oParams->getPreferredLanguages('default'), 0, 10)); $oParams = new ParameterParser(array('accept-language' => 'ja_rm,zh_pinyin')); $this->assertSame(array( 'name:ja_rm' => 'name:ja_rm', + '_place_name:ja_rm' => '_place_name:ja_rm', 'name:zh_pinyin' => 'name:zh_pinyin', + '_place_name:zh_pinyin' => '_place_name:zh_pinyin', 'name:ja' => 'name:ja', + '_place_name:ja' => '_place_name:ja', 'name:zh' => 'name:zh', + '_place_name:zh' => '_place_name:zh', 'name' => 'name', - 'brand' => 'brand', - 'official_name:ja_rm' => 'official_name:ja_rm', - 'short_name:ja_rm' => 'short_name:ja_rm', - 'official_name:zh_pinyin' => 'official_name:zh_pinyin', - 'short_name:zh_pinyin' => 'short_name:zh_pinyin', - 'official_name:ja' => 'official_name:ja', - 'short_name:ja' => 'short_name:ja', - 'official_name:zh' => 'official_name:zh', - 'short_name:zh' => 'short_name:zh', - 'official_name' => 'official_name', - 'short_name' => 'short_name', - 'ref' => 'ref', - 'type' => 'type', - ), $oParams->getPreferredLanguages('default')); + '_place_name' => '_place_name' + ), array_slice($oParams->getPreferredLanguages('default'), 0, 10)); } public function testHasSetAny()