Skip to content

Commit 4307c3e

Browse files
author
Remco Meeuwissen
committed
Updated the other spatial queries to also use the transform and removed the unneeded cast
1 parent 4e1f916 commit 4307c3e

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

tipg/filter/filters.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from buildpg.funcs import AND as and_
1111
from buildpg.funcs import NOT as not_
1212
from buildpg.funcs import OR as or_
13-
from buildpg.funcs import any, cast
13+
from buildpg.funcs import any
1414
from buildpg.logic import Func
1515
from geojson_pydantic.geometries import Polygon, parse_geometry_obj
1616

@@ -61,18 +61,44 @@ class Operator:
6161
"INTERSECTS": lambda f, a: Func(
6262
"st_intersects",
6363
f,
64-
Func("st_transform", cast(a, "geometry"), Func("st_srid", f)),
64+
Func("st_transform", a, Func("st_srid", f)),
65+
),
66+
"DISJOINT": lambda f, a: Func(
67+
"st_disjoint", f, Func("st_transform", a, Func("st_srid", f))
68+
),
69+
"CONTAINS": lambda f, a: Func(
70+
"st_contains", f, Func("st_transform", a, Func("st_srid", f))
71+
),
72+
"WITHIN": lambda f, a: Func(
73+
"st_within", f, Func("st_transform", a, Func("st_srid", f))
74+
),
75+
"TOUCHES": lambda f, a: Func(
76+
"st_touches", f, Func("st_transform", a, Func("st_srid", f))
77+
),
78+
"CROSSES": lambda f, a: Func(
79+
"st_crosses",
80+
f,
81+
Func("st_transform", a, Func("st_srid", f)),
82+
),
83+
"OVERLAPS": lambda f, a: Func(
84+
"st_overlaps",
85+
f,
86+
Func("st_transform", a, Func("st_srid", f)),
87+
),
88+
"EQUALS": lambda f, a: Func(
89+
"st_equals",
90+
f,
91+
Func("st_transform", a, Func("st_srid", f)),
92+
),
93+
"RELATE": lambda f, a, pattern: Func(
94+
"st_relate", f, Func("st_transform", a, Func("st_srid", f)), pattern
95+
),
96+
"DWITHIN": lambda f, a, distance: Func(
97+
"st_dwithin", f, Func("st_transform", a, Func("st_srid", f)), distance
98+
),
99+
"BEYOND": lambda f, a, distance: ~Func(
100+
"st_dwithin", f, Func("st_transform", a, Func("st_srid", f)), distance
65101
),
66-
"DISJOINT": lambda f, a: Func("st_disjoint", f, a),
67-
"CONTAINS": lambda f, a: Func("st_contains", f, a),
68-
"WITHIN": lambda f, a: Func("st_within", f, a),
69-
"TOUCHES": lambda f, a: Func("st_touches", f, a),
70-
"CROSSES": lambda f, a: Func("st_crosses", f, a),
71-
"OVERLAPS": lambda f, a: Func("st_overlaps", f, a),
72-
"EQUALS": lambda f, a: Func("st_equals", f, a),
73-
"RELATE": lambda f, a, pattern: Func("st_relate", f, a, pattern),
74-
"DWITHIN": lambda f, a, distance: Func("st_dwithin", f, a, distance),
75-
"BEYOND": lambda f, a, distance: ~Func("st_dwithin", f, a, distance),
76102
"+": lambda f, a: f + a,
77103
"-": lambda f, a: f - a,
78104
"*": lambda f, a: f * a,

0 commit comments

Comments
 (0)