Beispiel #1
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)
Beispiel #2
0
 def _get_ring(self, i):
     return shapely.get_interior_ring(self.__p__, i)
Beispiel #3
0
def test_get_interior_ring():
    actual = shapely.get_interior_ring(polygon_with_hole, [0, -1, 1, -2])
    assert_geometries_equal(actual[0], actual[1])
    assert shapely.is_missing(actual[2:4]).all()
Beispiel #4
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)
Beispiel #5
0
def test_get_interior_ring_non_polygon(geom):
    actual = shapely.get_interior_ring(geom, [0, 2, -1])
    assert shapely.is_missing(actual).all()