예제 #1
0
def test_coverage_union_overlapping_inputs():
    polygon = Geometry("POLYGON ((1 1, 1 0, 0 0, 0 1, 1 1))")

    # Overlapping polygons raise an error
    with pytest.raises(
            pygeos.GEOSException,
            match="CoverageUnion cannot process incorrectly noded inputs."):
        pygeos.coverage_union(
            polygon, Geometry("POLYGON ((1 0, 0.9 1, 2 1, 2 0, 1 0))"))
예제 #2
0
def test_coverage_union_reduce_1dim(n):
    """
    This is tested seperately from other set operations as it differs in two ways:
      1. It expects only non-overlapping polygons
      2. It expects GEOS 3.8.0+
    """
    test_data = [
        pygeos.box(0, 0, 1, 1),
        pygeos.box(1, 0, 2, 1),
        pygeos.box(2, 0, 3, 1),
    ]
    actual = pygeos.coverage_union_all(test_data[:n])
    # perform the reduction in a python loop and compare
    expected = test_data[0]
    for i in range(1, n):
        expected = pygeos.coverage_union(expected, test_data[i])
    assert pygeos.equals(actual, expected)
예제 #3
0
def test_coverage_union_non_polygon_inputs(geom_1, geom_2):
    # Non polygon geometries raise an error
    with pytest.raises(pygeos.GEOSException,
                       match="Unhandled geometry type in CoverageUnion."):
        pygeos.coverage_union(geom_1, geom_2)