Exemple #1
0
 def test_init(self):
     assert MultiPolygon(None) == MultiPolygon([])
     polygon1 = Polygon([[1.0, 4.0], [2.0, 3.7], [7.0, 4.0]])
     polygon2 = Polygon([[5.0, 7.0], [6.0, 7.0], [9.0, 8.0]])
     assert MultiPolygon([[[1.0, 4.0], [2.0, 3.7], [7.0, 4.0]],
                          [[5.0, 7.0], [6.0, 7.0],
                           [9.0,
                            8.0]]]) == MultiPolygon([polygon1, polygon2])
 def test_init(self):
     assert MultiPolygon(None) == MultiPolygon([])
     polygon1 = Polygon([[1.0, 4.0], [2.0, 3.7], [7.0, 4.0]])
     polygon2 = Polygon([[5.0, 7.0], [6.0, 7.0], [9.0, 8.0]])
     sequence = [[[1.0, 4.0], [2.0, 3.7], [7.0, 4.0]],
                 [[5.0, 7.0], [6.0, 7.0], [9.0, 8.0]]]
     assert MultiPolygon(sequence) == MultiPolygon([polygon1, polygon2])
     assert MultiPolygon(np.array(sequence)) == MultiPolygon(
         [polygon1, polygon2])
Exemple #3
0
 def test_loads(self):
     polygon = Polygon.loads(_DATA_POLYGON)
     assert polygon._data == [
         Vector2D(1.0, 1.0),
         Vector2D(2.0, 2.0),
         Vector2D(2.0, 3.0)
     ]
Exemple #4
0
 def test_loads(self):
     multipolygon = MultiPolygon.loads(_DATA_MULTIPOLYGON)
     assert multipolygon._data == [
         Polygon([[1.0, 4.0], [2.0, 3.7], [7.0, 4.0]]),
         Polygon([[5.0, 7.0], [6.0, 7.0], [9.0, 8.0]]),
     ]
Exemple #5
0
 def test_bounds(self):
     polygon = Polygon([[1, 2], [2, 4], [2, 3]])
     assert polygon.bounds() == Box2D(1, 2, 2, 4)
Exemple #6
0
 def test_area(self):
     polygon = Polygon([[1, 2], [2, 2], [2, 3]])
     assert polygon.area() == 0.5
Exemple #7
0
 def test_dumps(self):
     polygon = Polygon([[1, 1], [2, 2], [2, 3]])
     assert polygon.dumps() == _DATA_POLYGON
Exemple #8
0
 def test_eq(self):
     polygon_1 = Polygon([[1, 2], [2, 3], [2, 2]])
     polygon_2 = Polygon([[1, 2], [2, 3], [2, 2]])
     polygon_3 = Polygon([[1, 2], [3, 4], [2, 2]])
     assert (polygon_1 == polygon_2) == True
     assert (polygon_1 == polygon_3) == False
Exemple #9
0
 def test_init(self):
     sequence = [[1, 2], [2, 3], [2, 2]]
     assert Polygon(None) == Polygon([])
     assert Polygon(sequence) == Polygon(
         [Vector2D(1, 2), Vector2D(2, 3),
          Vector2D(2, 2)])
 def test_init(self):
     sequence = [[1, 2], [2, 3], [2, 2]]
     assert Polygon(None) == Polygon([])
     result = Polygon([Vector2D(1, 2), Vector2D(2, 3), Vector2D(2, 2)])
     assert Polygon(sequence) == result
     assert Polygon(np.array(sequence)) == result