コード例 #1
0
ファイル: test_prepared.py プロジェクト: zware/Shapely
 def test_prepared_predicates(self):
     # check prepared predicates give the same result as regular predicates
     polygon1 = geometry.Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
     polygon2 = geometry.Polygon([(0.5, 0.5), (1.5, 0.5), (1.0, 1.0),
                                  (0.5, 0.5)])
     point2 = geometry.Point(0.5, 0.5)
     polygon_empty = geometry.Polygon()
     prepared_polygon1 = prepared.PreparedGeometry(polygon1)
     for geom2 in (polygon2, point2, polygon_empty):
         self.assertTrue(
             polygon1.disjoint(geom2) == prepared_polygon1.disjoint(geom2))
         self.assertTrue(
             polygon1.touches(geom2) == prepared_polygon1.touches(geom2))
         self.assertTrue(
             polygon1.intersects(geom2) == prepared_polygon1.intersects(
                 geom2))
         self.assertTrue(
             polygon1.crosses(geom2) == prepared_polygon1.crosses(geom2))
         self.assertTrue(
             polygon1.within(geom2) == prepared_polygon1.within(geom2))
         self.assertTrue(
             polygon1.contains(geom2) == prepared_polygon1.contains(geom2))
         self.assertTrue(
             polygon1.overlaps(geom2) == prepared_polygon1.overlaps(geom2))
コード例 #2
0
 def test_prepared(self):
     polygon = geometry.Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
     p = prepared.PreparedGeometry(polygon)
     self.assertTrue(p.contains(geometry.Point(0.5, 0.5)))
     self.assertFalse(p.contains(geometry.Point(0.5, 1.5)))
コード例 #3
0
 def test_predicate_not_allowed(self):
     p = prepared.PreparedGeometry(geometry.Point(0.0, 0.0).buffer(1.0))
     self.assertRaises(ValueError, geometry.Point(0.0, 0.0).contains, p)
コード例 #4
0
 def test_op_not_allowed(self):
     p = prepared.PreparedGeometry(geometry.Point(0.0, 0.0).buffer(1.0))
     self.assertRaises(ValueError, geometry.Point(0.0, 0.0).union, p)
コード例 #5
0
ファイル: test_prepared.py プロジェクト: mausvt/shapely-
 def test_prepared(self):
     p = prepared.PreparedGeometry(geometry.Point(0.0, 0.0))