From: Sarah Hoffmann Date: Tue, 5 Sep 2023 15:00:31 +0000 (+0200) Subject: Merge pull request #3190 from lonvia/fix-internal-server-errors X-Git-Tag: v4.3.0~6 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/d6960c72e48cf83b8f5806ea751609b02cf4fd3d?hp=b529e054cf682ad53d16234752df9bbcc85cd396 Merge pull request #3190 from lonvia/fix-internal-server-errors Fix more failing queries --- diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 48de6e0d..1d34ed1a 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true 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/nominatim/api/v1/helpers.py b/nominatim/api/v1/helpers.py index 325e5bc6..6a646e4f 100644 --- a/nominatim/api/v1/helpers.py +++ b/nominatim/api/v1/helpers.py @@ -136,10 +136,10 @@ def _deg(axis:str) -> str: return f"(?P<{axis}_deg>\\d+\\.\\d+)°?" def _deg_min(axis: str) -> str: - return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>[\\d.]+)?[′']*" + return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>[\\d.]+)[′']*" def _deg_min_sec(axis: str) -> str: - return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>\\d+)[′'\\s]+(?P<{axis}_sec>[\\d.]+)?[\"″]*" + return f"(?P<{axis}_deg>\\d+)[°\\s]+(?P<{axis}_min>\\d+)[′'\\s]+(?P<{axis}_sec>[\\d.]+)[\"″]*" COORD_REGEX = [re.compile(r'(?:(?P
.*?)\s+)??' + r + r'(?:\s+(?P.*))?') for r in (
     r"(?P[NS])\s*" + _deg('lat') + r"[\s,]+" + r"(?P[EW])\s*" + _deg('lon'),
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)
diff --git a/test/python/api/test_helpers_v1.py b/test/python/api/test_helpers_v1.py
index 45f538de..e4862b0d 100644
--- a/test/python/api/test_helpers_v1.py
+++ b/test/python/api/test_helpers_v1.py
@@ -11,7 +11,11 @@ import pytest
 
 import nominatim.api.v1.helpers as helper
 
-@pytest.mark.parametrize('inp', ['', 'abc', '12 23', 'abc -78.90, 12.456 def'])
+@pytest.mark.parametrize('inp', ['',
+                                 'abc',
+                                 '12 23',
+                                 'abc -78.90, 12.456 def',
+                                 '40 N 60 W'])
 def test_extract_coords_no_coords(inp):
     query, x, y = helper.extract_coords_from_query(inp)