当前位置: 首页>>代码示例>>Python>>正文


Python Multipoint._bbox_overlap方法代码示例

本文整理汇总了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]
开发者ID:ivn888,项目名称:karta,代码行数:70,代码来源:geometry_tests.py

示例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
开发者ID:fortyninemaps,项目名称:karta,代码行数:7,代码来源:geometry_tests.py

示例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
开发者ID:jmjak86,项目名称:karta,代码行数:70,代码来源:geometry_tests.py


注:本文中的karta.vector.geometry.Multipoint._bbox_overlap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。