Ejemplo n.º 1
0
def test_polygon_with_none_hole():
    actual = shapely.polygons(
        shapely.linearrings(box_tpl(0, 0, 10, 10)),
        [
            shapely.linearrings(box_tpl(1, 1, 2, 2)),
            None,
            shapely.linearrings(box_tpl(3, 3, 4, 4)),
        ],
    )
    assert shapely.area(actual) == 98.0
Ejemplo n.º 2
0
 def area(self):
     """Unitless area of the geometry (float)"""
     return float(shapely.area(self))
Ejemplo n.º 3
0
def test_2_polygons_with_different_holes():
    actual = shapely.polygons(
        [box_tpl(0, 0, 10, 10), box_tpl(0, 0, 5, 5)],
        [[box_tpl(1, 1, 3, 3)], [box_tpl(1, 1, 2, 2)]],
    )
    assert shapely.area(actual).tolist() == [96.0, 24.0]
Ejemplo n.º 4
0
def test_2_polygons_with_2_same_holes():
    actual = shapely.polygons(
        [box_tpl(0, 0, 10, 10), box_tpl(0, 0, 5, 5)],
        [box_tpl(1, 1, 2, 2), box_tpl(3, 3, 4, 4)],
    )
    assert shapely.area(actual).tolist() == [98.0, 23.0]
Ejemplo n.º 5
0
def test_2_polygons_with_same_hole():
    actual = shapely.polygons(
        [box_tpl(0, 0, 10, 10), box_tpl(0, 0, 5, 5)], [box_tpl(1, 1, 2, 2)])
    assert shapely.area(actual).tolist() == [99.0, 24.0]
Ejemplo n.º 6
0
def test_polygon_with_2_holes():
    actual = shapely.polygons(
        box_tpl(0, 0, 10, 10),
        [box_tpl(1, 1, 2, 2), box_tpl(3, 3, 4, 4)])
    assert shapely.area(actual) == 98.0
Ejemplo n.º 7
0
def test_polygon_with_1_hole():
    actual = shapely.polygons(box_tpl(0, 0, 10, 10), [box_tpl(1, 1, 2, 2)])
    assert shapely.area(actual) == 99.0
Ejemplo n.º 8
0
def test_area():
    actual = shapely.area([polygon, polygon_with_hole, multi_polygon])
    assert actual.tolist() == [4.0, 96.0, 1.01]
Ejemplo n.º 9
0
def test_area_non_polygon(geom):
    assert shapely.area(geom) == 0.0