Example #1
0
def test_geom_within():
    result = parse('''
    <fes:Filter xmlns:fes="http://www.opengis.net/fes/2.0"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema-datatypes">
      <fes:Within>
        <fes:ValueReference>attr</fes:ValueReference>
        <gml:Envelope xmlns:gml="http://www.opengis.net/gml">
          <gml:lowerCorner>0.0 1.0</gml:lowerCorner>
          <gml:upperCorner>2.0 3.0</gml:upperCorner>
        </gml:Envelope>
      </fes:Within>
    </fes:Filter>
    ''')
    assert result == ast.GeometryWithin(
        ast.Attribute('attr'),
        values.Geometry({
            'type':
            'Polygon',
            'coordinates': [
                [
                    (0.0, 1.0),
                    (0.0, 3.0),
                    (2.0, 3.0),
                    (2.0, 1.0),
                    (0.0, 1.0),
                ],
            ]
        }))
Example #2
0
def test_within_multipolygon_attr():
    result = parse('WITHIN(MULTIPOLYGON(((1 1,2 2,0 3,1 1))), geometry)')
    assert result == ast.GeometryWithin(
        values.Geometry(
            geometry.MultiPolygon(
                [geometry.Polygon([(1, 1), (2, 2), (0, 3),
                                   (1, 1)])]).__geo_interface__, ),
        ast.Attribute('geometry'),
    )
Example #3
0
def test_within_multipolygon_attr():
    result = parse([
        'within',
        {
            'type': 'MultiPolygon',
            'coordinates': [[[[1, 1], [2, 2], [0, 3], [1, 1]]]],
            'bbox': [0.0, 1.0, 2.0, 3.0]
        },
        ['geometry'],
    ])
    assert result == ast.GeometryWithin(
        values.Geometry(
            normalize_geom(
                geometry.MultiPolygon(
                    [geometry.Polygon([(1, 1), (2, 2), (0, 3),
                                       (1, 1)])]).__geo_interface__), ),
        ast.Attribute('geometry'),
    )
Example #4
0
def test_within_multipolygon_attr():
    result = parse({
        "within": [
            {
                "type": "MultiPolygon",
                "coordinates": [
                    [[[1, 1], [2, 2], [0, 3], [1, 1]]]
                ],
                'bbox': [0.0, 1.0, 2.0, 3.0]
            },
            {"property": "geometry"},
        ]
    })
    assert result == ast.GeometryWithin(
        values.Geometry(
            normalize_geom(
                geometry.MultiPolygon([
                    geometry.Polygon([(1, 1), (2, 2), (0, 3), (1, 1)])
                ]).__geo_interface__
            ),
        ),
        ast.Attribute('geometry'),
    )