本文整理匯總了Python中karta.vector.geometry.Multipoint._bbox_overlap方法的典型用法代碼示例。如果您正苦於以下問題:Python Multipoint._bbox_overlap方法的具體用法?Python Multipoint._bbox_overlap怎麽用?Python Multipoint._bbox_overlap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類karta.vector.geometry.Multipoint
的用法示例。
在下文中一共展示了Multipoint._bbox_overlap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestGeometryAnalysis
# 需要導入模塊: from karta.vector.geometry import Multipoint [as 別名]
# 或者: from karta.vector.geometry.Multipoint import _bbox_overlap [as 別名]
#.........這裏部分代碼省略.........
vertices = [(a-1,b+2,c-0.5) for (a,b,c) in self.vertices]
mp = Multipoint(vertices, data=self.data)
mp.shift((1, -2, 0.5), inplace=True)
self.assertEqual(mp, self.mp)
def test_multipoint_shift(self):
vertices = [(a-1,b+2,c-0.5) for (a,b,c) in self.vertices]
mp = Multipoint(vertices, data=self.data)
mp_shifted = mp.shift((1, -2, 0.5))
self.assertEqual(mp_shifted, self.mp)
return
def test_multipoint_bbox(self):
bbox = (1.0, 0.0, 9.0, 9.0)
self.assertEqual(self.mp.bbox, bbox)
return
def test_multiline_bbox(self):
geom = Multiline([[(1,2), (3,4), (3,2)],
[(6,8),(2,6),(3,0)],
[(-3,-4), (7, -1), (3, 2), (2, -3)]],
crs=LonLatWGS84)
self.assertEqual(geom.bbox, (-3, -4, 7, 8))
return
def test_multipolygon_bbox(self):
geom = Multipolygon([[[(1,2), (3,4), (3,2)]],
[[(6,8),(2,6),(3,0)]],
[[(-3,-4), (7, -1), (3, 2), (2, -3)]]],
crs=LonLatWGS84)
self.assertEqual(geom.bbox, (-3, -4, 7, 8))
return
def test_multipoint_bbox_overlap(self):
self.assertTrue(self.mp._bbox_overlap(self.poly))
return
def test_multipoint_within_radius(self):
vertices = [(float(x),float(y)) for x in range(-10,11)
for y in range(-10,11)]
ans = [v for v in vertices if math.sqrt(v[0]**2 + v[1]**2) < 5.0]
mp = Multipoint(vertices)
sub = mp.within_radius(Point((0,0)), 5.0)
self.assertEqual(sub, Multipoint(ans))
return
def test_multipoint_within_bbox(self):
vertices = [(float(x),float(y)) for x in range(-10,11)
for y in range(-10,11)]
ans = [v for v in vertices if (-5.0<v[0]<5.0) and (-4.0<v[1]<6.0)]
mp = Multipoint(vertices)
sub = mp.within_bbox((-5.0, -4.0, 5.0, 6.0))
self.assertEqual(sub, Multipoint(ans))
return
def test_multipoint_within_polygon(self):
np.random.seed(42)
x = (np.random.random(100) - 0.5) * 180.0
y = (np.random.random(100) - 0.5) * 30.0
xp = [-80, -50, 20, 35, 55, -45, -60]
yp = [0, -10, -8, -17, 15, 18, 12]
poly = Polygon(zip(xp, yp), crs=LonLatWGS84)
mp = Multipoint(zip(x, y), crs=LonLatWGS84)
subset = mp.within_polygon(poly)
excluded = [pt for pt in mp if pt not in subset]
示例2: test_multipoint_bbox_overlap
# 需要導入模塊: from karta.vector.geometry import Multipoint [as 別名]
# 或者: from karta.vector.geometry.Multipoint import _bbox_overlap [as 別名]
def test_multipoint_bbox_overlap(self):
poly = Polygon([(0.0, 8.0), (0.0, 5.0), (6.0, 1.0)])
mp = Multipoint(self.vertices, data=self.data)
self.assertTrue(mp._bbox_overlap(poly))
return
示例3: TestGeometry
# 需要導入模塊: from karta.vector.geometry import Multipoint [as 別名]
# 或者: from karta.vector.geometry.Multipoint import _bbox_overlap [as 別名]
#.........這裏部分代碼省略.........
data=["rankin", "corbet", "arviat",
"severn", "churchill"])
for i, pt in enumerate(mp):
self.assertEqual(mp[i], pt)
return
def test_multipoint_get_data_fields(self):
mp = Multipoint([(3.0, 3.0), (5.0, 1.0), (3.0, 1.0),
(4.0, 4.0), (0.0, 1.0)],
data={"location": ["rankin", "corbet", "arviat",
"severn", "churchill"]})
pt = mp[3]
self.assertEqual(pt.data.fields, ("location",))
self.assertEqual(pt.data[0], ("severn",))
return
def test_multipoint_slicing(self):
submp = Multipoint(self.vertices[5:10], data=self.data[5:10])
self.assertEqual(self.mp[5:10], submp)
submp = Multipoint(self.vertices[5:], data=self.data[5:])
self.assertEqual(self.mp[5:], submp)
return
def test_multipoint_negative_index(self):
self.assertEqual(self.mp[len(self.mp)-1], self.mp[-1])
return
def test_multipoint_bbox(self):
bbox = (1.0, 0.0, 9.0, 9.0)
self.assertEqual(self.mp.bbox, bbox)
return
def test_multipoint_bbox_overlap(self):
self.assertTrue(self.mp._bbox_overlap(self.poly))
return
def test_multipoint_within_radius(self):
vertices = [(float(x),float(y)) for x in range(-10,11)
for y in range(-10,11)]
ans = [v for v in vertices if math.sqrt(v[0]**2 + v[1]**2) <= 5.0]
mp = Multipoint(vertices)
sub = mp.within_radius(Point((0,0)), 5.0)
self.assertEqual(sub, Multipoint(ans))
return
def test_multipoint_within_bbox(self):
vertices = [(float(x),float(y)) for x in range(-10,11)
for y in range(-10,11)]
ans = [v for v in vertices if (-5.0<=v[0]<=5.0) and (-4.0<=v[1]<=6.0)]
mp = Multipoint(vertices)
sub = mp.within_bbox((-5.0, -4.0, 5.0, 6.0))
self.assertEqual(sub, Multipoint(ans))
return
def test_multipoint_convex_hull(self):
vertices = [(953, 198), (986, 271), (937, 305), (934, 464), (967, 595),
(965, 704), (800, 407), (782, 322), (863, 979), (637, 689),
(254, 944), (330, 745), (363, 646), (27, 990), (127, 696),
(286, 352), (436, 205), (88, 254), (187, 85)]
mp = Multipoint(vertices)
ch = mp.convex_hull()
hull_vertices = [(187, 85), (953, 198), (986, 271), (965, 704), (863,
979), (27, 990), (88, 254)]
self.assertEqual(ch.vertices, hull_vertices)
return