From 467deed7a02740eedd5f20c57068e542ec0da34c Mon Sep 17 00:00:00 2001 From: Jan Kaniuka Date: Sat, 29 Aug 2026 17:59:57 +0200 Subject: [PATCH 1/4] feat: added s_dwithin predicate --- pygeofilter/cql2.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pygeofilter/cql2.py b/pygeofilter/cql2.py index 53cf0ec..ceaf503 100644 --- a/pygeofilter/cql2.py +++ b/pygeofilter/cql2.py @@ -32,6 +32,7 @@ "s_overlaps": ast.GeometryOverlaps, "s_crosses": ast.GeometryCrosses, "s_contains": ast.GeometryContains, + "s_dwithin": ast.DistanceWithin, } TEMPORAL_PREDICATES_MAP: Dict[str, Type[ast.TemporalPredicate]] = { From 20cd7bc2bf5626adcb97386470e8ad58542a97b0 Mon Sep 17 00:00:00 2001 From: Jan Kaniuka Date: Tue, 15 Sep 2026 15:41:17 +0200 Subject: [PATCH 2/4] test: added test_dwithin_attr_polygon() --- tests/parsers/cql_json/test_parser.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/parsers/cql_json/test_parser.py b/tests/parsers/cql_json/test_parser.py index 5d45142..04da2fe 100644 --- a/tests/parsers/cql_json/test_parser.py +++ b/tests/parsers/cql_json/test_parser.py @@ -597,18 +597,18 @@ def test_overlaps_attr_multilinestring(): # # dwithin/beyond -# def test_dwithin_attr_polygon(): -# result = parse('DWITHIN(geometry, POLYGON((1 1,2 2,0 3,1 1)), 5, feet)') -# print(get_repr(result)) -# assert result == ast.SpatialDistancePredicateNode( -# ast.Attribute('geometry'), -# ast.LiteralExpression( -# geometry.Polygon([(1, 1), (2, 2), (0, 3), (1, 1)]) -# ), -# ast.SpatialDistanceOp('DWITHIN'), -# distance=5, -# units='feet', -# ) + +def test_dwithin_attr_polygon(): + result = parse("DWITHIN(geometry, POLYGON((1 1,2 2,0 3,1 1)), 5, feet)") + assert result == ast.SpatialDistancePredicateNode( + ast.Attribute("geometry"), + ast.LiteralExpression( + geometry.Polygon([(1, 1), (2, 2), (0, 3), (1, 1)]) + ), + ast.SpatialDistanceOp("DWITHIN"), + distance=5, + units="feet", + ) # def test_beyond_attr_polygon(): From 553e805592dbfe708a82f3def24f2573eada35c7 Mon Sep 17 00:00:00 2001 From: Jan Kaniuka Date: Tue, 15 Sep 2026 16:00:52 +0200 Subject: [PATCH 3/4] test_dwithin_attr_polygon fix attempt --- tests/parsers/cql_json/test_parser.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/parsers/cql_json/test_parser.py b/tests/parsers/cql_json/test_parser.py index 04da2fe..78644af 100644 --- a/tests/parsers/cql_json/test_parser.py +++ b/tests/parsers/cql_json/test_parser.py @@ -599,7 +599,9 @@ def test_overlaps_attr_multilinestring(): def test_dwithin_attr_polygon(): - result = parse("DWITHIN(geometry, POLYGON((1 1,2 2,0 3,1 1)), 5, feet)") + result = parse( + """ { "op": "DWithin", "args": [ {"property": "geometry"}, { "type": "Polygon", "coordinates": [[[1, 1], [2, 2], [0, 3], [1, 1]]] }, 5, "feet" ] } """ + ) assert result == ast.SpatialDistancePredicateNode( ast.Attribute("geometry"), ast.LiteralExpression( From d8630867a7c51ad3d0810cc2957cf2e35464c974 Mon Sep 17 00:00:00 2001 From: Jan Kaniuka Date: Wed, 23 Sep 2026 14:34:45 +0200 Subject: [PATCH 4/4] test: fixed test_dwithin_attr_polygon() --- tests/parsers/cql_json/test_parser.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/parsers/cql_json/test_parser.py b/tests/parsers/cql_json/test_parser.py index 78644af..04da2fe 100644 --- a/tests/parsers/cql_json/test_parser.py +++ b/tests/parsers/cql_json/test_parser.py @@ -599,9 +599,7 @@ def test_overlaps_attr_multilinestring(): def test_dwithin_attr_polygon(): - result = parse( - """ { "op": "DWithin", "args": [ {"property": "geometry"}, { "type": "Polygon", "coordinates": [[[1, 1], [2, 2], [0, 3], [1, 1]]] }, 5, "feet" ] } """ - ) + result = parse("DWITHIN(geometry, POLYGON((1 1,2 2,0 3,1 1)), 5, feet)") assert result == ast.SpatialDistancePredicateNode( ast.Attribute("geometry"), ast.LiteralExpression(