# pylint: disable=all
-class PlacexGeometryReverseLookuppolygon(sa.sql.functions.GenericFunction[bool]):
+class PlacexGeometryReverseLookuppolygon(sa.sql.functions.GenericFunction[Any]):
""" Check for conditions that allow partial index use on
'idx_placex_geometry_reverse_lookupPolygon'.
Needs to be constant, so that the query planner picks them up correctly
in prepared statements.
"""
- type = sa.Boolean()
name = 'PlacexGeometryReverseLookuppolygon'
inherit_cache = True
" AND placex.linked_place_id is null)")
-class IntersectsReverseDistance(sa.sql.functions.GenericFunction[bool]):
- type = sa.Boolean()
+class IntersectsReverseDistance(sa.sql.functions.GenericFunction[Any]):
name = 'IntersectsReverseDistance'
inherit_cache = True
def default_reverse_place_diameter(element: SaColumn,
compiler: 'sa.Compiled', **kw: Any) -> str:
table = element.tablename
- return f"{table}.rank_address between 4 and 25"\
+ return f"({table}.rank_address between 4 and 25"\
f" AND {table}.type != 'postcode'"\
f" AND {table}.name is not null"\
f" AND {table}.linked_place_id is null"\
f" AND {table}.osm_type = 'N'" + \
- " AND ST_Buffer(%s, reverse_place_diameter(%s)) && %s" % \
+ " AND ST_Buffer(%s, reverse_place_diameter(%s)) && %s)" % \
tuple(map(lambda c: compiler.process(c, **kw), element.clauses))
geom1, rank, geom2 = list(element.clauses)
table = element.tablename
- return (f"{table}.rank_address between 4 and 25"\
+ return (f"({table}.rank_address between 4 and 25"\
f" AND {table}.type != 'postcode'"\
f" AND {table}.name is not null"\
f" AND {table}.linked_place_id is null"\
" (SELECT place_id FROM placex_place_node_areas"\
" WHERE ROWID IN (SELECT ROWID FROM SpatialIndex"\
" WHERE f_table_name = 'placex_place_node_areas'"\
- " AND search_frame = %s))") % (
+ " AND search_frame = %s)))") % (
compiler.process(geom1, **kw),
compiler.process(geom2, **kw),
compiler.process(rank, **kw),
compiler.process(geom2, **kw))
-class IsBelowReverseDistance(sa.sql.functions.GenericFunction[bool]):
- type = sa.Boolean()
+class IsBelowReverseDistance(sa.sql.functions.GenericFunction[Any]):
name = 'IsBelowReverseDistance'
inherit_cache = True
f" AND {table}.osm_type = 'N'")
-class IsAddressPoint(sa.sql.functions.GenericFunction[bool]):
- type = sa.Boolean()
+class IsAddressPoint(sa.sql.functions.GenericFunction[Any]):
name = 'IsAddressPoint'
inherit_cache = True
compiler.process(name, **kw))
-class CrosscheckNames(sa.sql.functions.GenericFunction[bool]):
+class CrosscheckNames(sa.sql.functions.GenericFunction[Any]):
""" Check if in the given list of names in parameters 1 any of the names
from the JSON array in parameter 2 are contained.
"""
- type = sa.Boolean()
name = 'CrosscheckNames'
inherit_cache = True
return "COALESCE(Distance(%s, true), 0.0)" % compiler.process(element.clauses, **kw)
-class Geometry_IsLineLike(sa.sql.expression.FunctionElement[bool]):
+class Geometry_IsLineLike(sa.sql.expression.FunctionElement[Any]):
""" Check if the geometry is a line or multiline.
"""
- type = sa.Boolean()
name = 'Geometry_IsLineLike'
inherit_cache = True
compiler.process(element.clauses, **kw)
-class Geometry_IsAreaLike(sa.sql.expression.FunctionElement[bool]):
+class Geometry_IsAreaLike(sa.sql.expression.FunctionElement[Any]):
""" Check if the geometry is a polygon or multipolygon.
"""
- type = sa.Boolean()
name = 'Geometry_IsLineLike'
inherit_cache = True
compiler.process(element.clauses, **kw)
-class Geometry_IntersectsBbox(sa.sql.expression.FunctionElement[bool]):
+class Geometry_IntersectsBbox(sa.sql.expression.FunctionElement[Any]):
""" Check if the bounding boxes of the given geometries intersect.
"""
- type = sa.Boolean()
name = 'Geometry_IntersectsBbox'
inherit_cache = True
@compiles(Geometry_IntersectsBbox, 'sqlite') # type: ignore[no-untyped-call, misc]
def _sqlite_intersects(element: SaColumn,
compiler: 'sa.Compiled', **kw: Any) -> str:
- return "MbrIntersects(%s)" % compiler.process(element.clauses, **kw)
+ return "MbrIntersects(%s) = 1" % compiler.process(element.clauses, **kw)
-class Geometry_ColumnIntersectsBbox(sa.sql.expression.FunctionElement[bool]):
+class Geometry_ColumnIntersectsBbox(sa.sql.expression.FunctionElement[Any]):
""" Check if the bounding box of the geometry intersects with the
given table column, using the spatial index for the column.
The index must exist or the query may return nothing.
"""
- type = sa.Boolean()
name = 'Geometry_ColumnIntersectsBbox'
inherit_cache = True
def spatialite_intersects_column(element: SaColumn,
compiler: 'sa.Compiled', **kw: Any) -> str:
arg1, arg2 = list(element.clauses)
- return "MbrIntersects(%s, %s) and "\
+ return "MbrIntersects(%s, %s) = 1 and "\
"%s.ROWID IN (SELECT ROWID FROM SpatialIndex "\
"WHERE f_table_name = '%s' AND f_geometry_column = '%s' "\
"AND search_frame = %s)" %(
compiler.process(arg2, **kw))
-class Geometry_ColumnDWithin(sa.sql.expression.FunctionElement[bool]):
+class Geometry_ColumnDWithin(sa.sql.expression.FunctionElement[Any]):
""" Check if the geometry is within the distance of the
given table column, using the spatial index for the column.
The index must exist or the query may return nothing.
"""
- type = sa.Boolean()
name = 'Geometry_ColumnDWithin'
inherit_cache = True
_add_function_alias(*alias)
-class ST_DWithin(sa.sql.functions.GenericFunction[bool]):
- type = sa.Boolean()
+class ST_DWithin(sa.sql.functions.GenericFunction[Any]):
name = 'ST_DWithin'
inherit_cache = True