X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c29ffc38e6cef4bb99fd40060be8243ea70e5939..8e212a3d0c5df2cd6af04f8b7af1f74ca158aa0e:/nominatim/db/sqlalchemy_types.py diff --git a/nominatim/db/sqlalchemy_types.py b/nominatim/db/sqlalchemy_types.py index 7d3789aa..7b959036 100644 --- a/nominatim/db/sqlalchemy_types.py +++ b/nominatim/db/sqlalchemy_types.py @@ -66,7 +66,16 @@ class Geometry(types.UserDefinedType): # type: ignore[type-arg] def ST_DWithin(self, other: SaColumn, distance: SaColumn) -> SaColumn: - return sa.func.ST_DWithin(self, other, distance, type_=sa.Float) + return sa.func.ST_DWithin(self, other, distance, type_=sa.Boolean) + + + def ST_DWithin_no_index(self, other: SaColumn, distance: SaColumn) -> SaColumn: + return sa.func.ST_DWithin(sa.func.coalesce(sa.null(), self), + other, distance, type_=sa.Boolean) + + + def ST_Intersects_no_index(self, other: SaColumn) -> 'sa.Operators': + return sa.func.coalesce(sa.null(), self).op('&&')(other) def ST_Distance(self, other: SaColumn) -> SaColumn: