Ejemplo n.º 1
0
def test_get_rings(geom):
    if (shapely.get_type_id(geom) !=
            shapely.GeometryType.POLYGON) or shapely.is_empty(geom):
        rings = shapely.get_rings(geom)
        assert len(rings) == 0
    else:
        rings = shapely.get_rings(geom)
        assert len(rings) == 1
        assert rings[0] == shapely.get_exterior_ring(geom)
Ejemplo n.º 2
0
def test_get_rings_return_index():
    geom = np.array([polygon, None, empty_polygon, polygon_with_hole])
    expected_parts = []
    expected_index = []
    for i, g in enumerate(geom):
        if g is None or shapely.is_empty(g):
            continue
        expected_parts.append(shapely.get_exterior_ring(g))
        expected_index.append(i)
        for j in range(0, shapely.get_num_interior_rings(g)):
            expected_parts.append(shapely.get_interior_ring(g, j))
            expected_index.append(i)

    parts, index = shapely.get_rings(geom, return_index=True)
    assert len(parts) == len(expected_parts)
    assert_geometries_equal(parts, expected_parts)
    assert np.array_equal(index, expected_index)
Ejemplo n.º 3
0
def test_get_rings_holes():
    rings = shapely.get_rings(polygon_with_hole)
    assert len(rings) == 2
    assert rings[0] == shapely.get_exterior_ring(polygon_with_hole)
    assert rings[1] == shapely.get_interior_ring(polygon_with_hole, 0)