From: Sarah Hoffmann Date: Tue, 5 Sep 2023 09:41:41 +0000 (+0200) Subject: restrict range for interpolated housenumbers X-Git-Tag: v4.3.0~6^2~1 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/c284df2dc9df442de4fce9d524314ab2fa4bfd44 restrict range for interpolated housenumbers Interpolations are only supported up to 2^32 by the database. Limit to 8 digits, which is still more than should be needed. --- diff --git a/nominatim/api/search/db_searches.py b/nominatim/api/search/db_searches.py index e9df3bee..1f7eb009 100644 --- a/nominatim/api/search/db_searches.py +++ b/nominatim/api/search/db_searches.py @@ -685,7 +685,8 @@ class PlaceSearch(AbstractSearch): if self.qualifiers: place_sql = place_sql.where(self.qualifiers.sql_restrict(thnr)) - numerals = [int(n) for n in self.housenumbers.values if n.isdigit()] + numerals = [int(n) for n in self.housenumbers.values + if n.isdigit() and len(n) < 8] interpol_sql: SaColumn tiger_sql: SaColumn if numerals and \ diff --git a/test/python/api/search/test_search_places.py b/test/python/api/search/test_search_places.py index df369b81..8d17ec2d 100644 --- a/test/python/api/search/test_search_places.py +++ b/test/python/api/search/test_search_places.py @@ -267,6 +267,26 @@ class TestStreetWithHousenumber: assert all(geom.name.lower() in r.geometry for r in results) +def test_very_large_housenumber(apiobj): + apiobj.add_placex(place_id=93, class_='place', type='house', + parent_place_id=2000, + housenumber='2467463524544', country_code='pt') + apiobj.add_placex(place_id=2000, class_='highway', type='residential', + rank_search=26, rank_address=26, + country_code='pt') + apiobj.add_search_name(2000, names=[1,2], + search_rank=26, address_rank=26, + country_code='pt') + + lookup = FieldLookup('name_vector', [1, 2], 'lookup_all') + + results = run_search(apiobj, 0.1, [lookup], [], hnrs=['2467463524544'], + details=SearchDetails()) + + assert results + assert [r.place_id for r in results] == [93, 2000] + + class TestInterpolations: @pytest.fixture(autouse=True)