]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #3159 from lonvia/fix-name-lookup-for-housenames
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 20 Aug 2023 13:52:20 +0000 (15:52 +0200)
committerGitHub <noreply@github.com>
Sun, 20 Aug 2023 13:52:20 +0000 (15:52 +0200)
Fix name lookup for housenames

lib-sql/functions/utils.sql
nominatim/api/reverse.py
nominatim/api/search/db_searches.py
test/python/api/test_api_reverse.py

index f5be7b61262532d462044ff7657a4bf69ee7ae58..b2771ba18eecf8db6276bf71a503cecbf7b29cb5 100644 (file)
@@ -273,8 +273,8 @@ BEGIN
   END IF;
 
   RETURN ST_Envelope(ST_Collect(
-                     ST_Project(geom, radius, 0.785398)::geometry,
-                     ST_Project(geom, radius, 3.9269908)::geometry));
+                     ST_Project(geom::geography, radius, 0.785398)::geometry,
+                     ST_Project(geom::geography, radius, 3.9269908)::geometry));
 END;
 $$
 LANGUAGE plpgsql IMMUTABLE;
index 4a5f9c03a86adb1adff5276bc3bcfa3165cefb41..63836b4924f18589ddec07b52bc78ff11f942e64 100644 (file)
@@ -87,7 +87,7 @@ def _locate_interpolation(table: SaFromClause) -> SaLabel:
 def _is_address_point(table: SaFromClause) -> SaColumn:
     return sa.and_(table.c.rank_address == 30,
                    sa.or_(table.c.housenumber != None,
-                          table.c.name.has_key('housename')))
+                          table.c.name.has_key('addr:housename')))
 
 
 def _get_closest(*rows: Optional[SaRow]) -> Optional[SaRow]:
index 115f32fad4d7e307eada70cd02080901fbcacbd6..34a4037a356b466fbb03b1e73c39583243620af7 100644 (file)
@@ -111,7 +111,7 @@ def _filter_by_layer(table: SaFromClause, layers: DataLayer) -> SaColumn:
         orexpr.append(table.c.rank_address.between(1, 29))
         orexpr.append(sa.and_(table.c.rank_address == 30,
                               sa.or_(table.c.housenumber != None,
-                                     table.c.address.has_key('housename'))))
+                                     table.c.address.has_key('addr:housename'))))
     elif layers & DataLayer.POI:
         orexpr.append(sa.and_(table.c.rank_address == 30,
                               table.c.class_.not_in(('place', 'building'))))
index 3296e98fdd6055ad0beb2571e4da2877b6d37f7d..d9ab2cb87efbc945059339935838cd3924d716c5 100644 (file)
@@ -60,7 +60,8 @@ def test_reverse_ignore_unindexed(apiobj):
                                               (0.7, napi.DataLayer.RAILWAY, 226),
                                               (0.7, napi.DataLayer.NATURAL, 227),
                                               (0.70003, napi.DataLayer.MANMADE | napi.DataLayer.RAILWAY, 225),
-                                              (0.70003, napi.DataLayer.MANMADE | napi.DataLayer.NATURAL, 225)])
+                                              (0.70003, napi.DataLayer.MANMADE | napi.DataLayer.NATURAL, 225),
+                                              (5, napi.DataLayer.ADDRESS, 229)])
 def test_reverse_rank_30_layers(apiobj, y, layer, place_id):
     apiobj.add_placex(place_id=223, class_='place', type='house',
                       housenumber='1',
@@ -83,6 +84,11 @@ def test_reverse_rank_30_layers(apiobj, y, layer, place_id):
                       rank_address=0,
                       rank_search=30,
                       centroid=(1.3, 0.70005))
+    apiobj.add_placex(place_id=229, class_='place', type='house',
+                      name={'addr:housename': 'Old Cottage'},
+                      rank_address=30,
+                      rank_search=30,
+                      centroid=(1.3, 5))
 
     assert apiobj.api.reverse((1.3, y), layers=layer).place_id == place_id