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]] = { 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():