Ejemplo n.º 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(
            shapely.GEOSException,
            match="CoverageUnion cannot process incorrectly noded inputs.",
    ):
        shapely.coverage_union(
            polygon, Geometry("POLYGON ((1 0, 0.9 1, 2 1, 2 0, 1 0))"))
Ejemplo n.º 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 = [
        shapely.box(0, 0, 1, 1),
        shapely.box(1, 0, 2, 1),
        shapely.box(2, 0, 3, 1),
    ]
    actual = shapely.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 = shapely.coverage_union(expected, test_data[i])
    assert_geometries_equal(actual, expected, normalize=True)
Ejemplo n.º 3
0
def test_coverage_union_non_polygon_inputs(geom_1, geom_2):
    # Non polygon geometries raise an error
    with pytest.raises(shapely.GEOSException,
                       match="Unhandled geometry type in CoverageUnion."):
        shapely.coverage_union(geom_1, geom_2)