]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 31 Jul 2023 08:21:34 +0000 (10:21 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 31 Jul 2023 08:21:34 +0000 (10:21 +0200)
nominatim/api/search/db_searches.py
nominatim/db/sqlalchemy_types.py

index 5c1d98c9a60b611b38d96b0c6cb636132f0b4715..85dc30193f8991aaaafa02cc3031c819c609ec21 100644 (file)
@@ -287,10 +287,11 @@ class NearSearch(AbstractSearch):
             # radius for the lookup.
             sql = sql.join(table, t.c.place_id == table.c.place_id)\
                      .join(tgeom,
-                           sa.case((sa.and_(tgeom.c.rank_address < 9,
-                                            tgeom.c.geometry.is_area()),
-                                    tgeom.c.geometry.ST_Contains(table.c.centroid)),
-                                   else_ = tgeom.c.centroid.ST_DWithin(table.c.centroid, 0.05)))\
+                           table.c.centroid.ST_CoveredBy(
+                               sa.case((sa.and_(tgeom.c.rank_address < 9,
+                                                tgeom.c.geometry.is_area()),
+                                        tgeom.c.geometry),
+                                       else_ = tgeom.c.centroid.ST_Expand(0.05))))\
                      .order_by(tgeom.c.centroid.ST_Distance(table.c.centroid))
 
         sql = sql.where(t.c.rank_address.between(MIN_RANK_PARAM, MAX_RANK_PARAM))
index f31966cd60093a4bc09095a8fff83cbf33743219..7d3789aa0d3b44854583aeb09686d8edaa1c421e 100644 (file)
@@ -74,7 +74,11 @@ class Geometry(types.UserDefinedType): # type: ignore[type-arg]
 
 
         def ST_Contains(self, other: SaColumn) -> SaColumn:
-            return sa.func.ST_Contains(self, other, type_=sa.Float)
+            return sa.func.ST_Contains(self, other, type_=sa.Boolean)
+
+
+        def ST_CoveredBy(self, other: SaColumn) -> SaColumn:
+            return sa.func.ST_CoveredBy(self, other, type_=sa.Boolean)
 
 
         def ST_ClosestPoint(self, other: SaColumn) -> SaColumn: