Example #1
0
def test_contains_attr_polygon():
    result = parse('CONTAINS(geometry, POLYGON((1 1,2 2,0 3,1 1)))')
    assert result == ast.GeometryContains(
        ast.Attribute('geometry'),
        values.Geometry(
            geometry.Polygon([(1, 1), (2, 2), (0, 3),
                              (1, 1)]).__geo_interface__, ),
    )
Example #2
0
def test_geom_contains():
    result = parse('''
    <fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes">
      <fes:Contains>
        <fes:ValueReference>attr</fes:ValueReference>
        <georss:polygon xmlns:georss="http://www.georss.org/georss">
            1.0 0.5 2.0 0.5 2.0 1.5 1.0 1.5 1.0 0.5
        </georss:polygon>
      </fes:Contains>
    </fes:Filter>
    ''')
    assert result == ast.GeometryContains(
        ast.Attribute('attr'),
        values.Geometry({
            'type':
            'Polygon',
            'coordinates': [[(0.5, 1.0), (0.5, 2.0), (1.5, 2.0), (1.5, 1.0),
                             (0.5, 1.0)]]
        }))
Example #3
0
def test_contains_attr_polygon():
    result = parse({
        "contains": [
            {"property": "geometry"},
            {
                "type": "Polygon",
                "coordinates": [
                    [[1, 1], [2, 2], [0, 3], [1, 1]]
                ],
                'bbox': [0.0, 1.0, 2.0, 3.0]
            },
        ]
    })
    assert result == ast.GeometryContains(
        ast.Attribute('geometry'),
        values.Geometry(
            normalize_geom(
                geometry.Polygon(
                    [(1, 1), (2, 2), (0, 3), (1, 1)]
                ).__geo_interface__
            ),
        ),
    )