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


Python Multipoint._subset方法代码示例

本文整理汇总了Python中karta.vector.geometry.Multipoint._subset方法的典型用法代码示例。如果您正苦于以下问题:Python Multipoint._subset方法的具体用法?Python Multipoint._subset怎么用?Python Multipoint._subset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在karta.vector.geometry.Multipoint的用法示例。


在下文中一共展示了Multipoint._subset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_multipoint_subset

# 需要导入模块: from karta.vector.geometry import Multipoint [as 别名]
# 或者: from karta.vector.geometry.Multipoint import _subset [as 别名]
 def test_multipoint_subset(self):
     mp = Multipoint(self.vertices, data=self.data)
     line = Line(self.vertices)
     ss1 = mp._subset(range(2,7))
     ss2 = line._subset(range(2,7))
     self.assertTrue(isinstance(ss1, Multipoint))
     self.assertTrue(isinstance(ss2, Line))
     return
开发者ID:fortyninemaps,项目名称:karta,代码行数:10,代码来源:geometry_tests.py

示例2: TestGeometry

# 需要导入模块: from karta.vector.geometry import Multipoint [as 别名]
# 或者: from karta.vector.geometry.Multipoint import _subset [as 别名]
class TestGeometry(unittest.TestCase):
    """ Tests for manipulating Geometry objects (indexing, iteration, equality,
    etc.)
    """

    def setUp(self):
        self.point = Point((1.0, 2.0, 3.0),
                           properties={"type": "apple", "color": (43,67,10)})

        self.vertices = [(2.0, 9.0, 9.0), (4.0, 1.0, 9.0), (4.0, 1.0, 5.0),
                         (2.0, 8.0, 0.0), (9.0, 8.0, 4.0), (1.0, 4.0, 6.0),
                         (7.0, 3.0, 4.0), (2.0, 5.0, 3.0), (1.0, 6.0, 6.0),
                         (8.0, 1.0, 0.0), (5.0, 5.0, 1.0), (4.0, 5.0, 7.0),
                         (3.0, 3.0, 5.0), (9.0, 0.0, 9.0), (6.0, 3.0, 8.0),
                         (4.0, 5.0, 7.0), (9.0, 9.0, 4.0), (1.0, 4.0, 7.0),
                         (1.0, 7.0, 8.0), (9.0, 1.0, 6.0)]

        self.data = [99.0, 2.0, 60.0, 75.0, 71.0, 34.0, 1.0, 49.0, 4.0, 36.0,
                     47.0, 58.0, 65.0, 72.0, 4.0, 27.0, 52.0, 37.0, 95.0, 17.0]

        self.mp = Multipoint(self.vertices, data=self.data)
        self.line = Line(self.vertices)
        self.poly = Polygon([(0.0, 8.0), (0.0, 5.0), (6.0, 1.0)])
        self.poly3 = Polygon([(0.0, 8.0, 0.5), (0.0, 5.0, 0.8), (6.0, 1.0, 0.6)])
        self.ring = Polygon([(2.0, 2.0), (4.0, 2.0), (3.0, 6.0)])
        self.ringed_poly = Polygon([(0.0, 0.0), (10, 0.0),
                                    (10.0, 10.0), (0.0, 10.0)],
                                   subs=[self.ring])
        self.unitsquare = Polygon([(0.0,0.0), (1.0,0.0), (1.0,1.0), (0.0,1.0)])
        return

    def test_point_equality(self):
        pt1 = Point((3.0, 4.0))
        pt2 = Point((3.0, 4.0, 5.0))
        pt3 = Point((3.0, 4.0, 5.0), properties={"species":"T. officianale", "density":"high"})
        self.assertFalse(pt1 == pt2)
        self.assertFalse(pt1 == pt3)
        self.assertFalse(pt2 == pt3)
        return

    def test_point_vertex(self):
        self.assertEqual(self.point.get_vertex(), (1.0, 2.0, 3.0))
        return

    def test_point_coordsxy(self):
        self.assertEqual(self.point.coordsxy(), (1.0, 2.0))
        self.assertEqual(self.point[0], 1.0)
        self.assertEqual(self.point[1], 2.0)
        return

    def test_point_add(self):
        ptA = Point((1, 2), crs=SphericalEarth)
        ptB = Point((3, 4), crs=LonLatWGS84)
        res = ptA + ptB
        self.assertTrue(isinstance(res, Multipoint))
        self.assertEqual(len(res), 2)
        self.assertEqual(res.crs, SphericalEarth)
        return

    def test_line_add(self):
        lineA = Line([(1, 2), (2, 3)], crs=SphericalEarth)
        lineB = Line([(3, 4), (4, 5)], crs=LonLatWGS84)
        res = lineA + lineB
        self.assertTrue(isinstance(res, Multiline))
        self.assertEqual(len(res), 2)
        self.assertEqual(res.crs, SphericalEarth)
        return

    def test_polygon_add(self):
        polyA = Polygon([(1, 2), (2, 3), (5, 4)], crs=SphericalEarth)
        polyB = Polygon([(3, 4), (4, 5), (6, 5)], crs=LonLatWGS84)
        res = polyA + polyB
        self.assertTrue(isinstance(res, Multipolygon))
        self.assertEqual(len(res), 2)
        self.assertEqual(res.crs, SphericalEarth)
        return

    def test_empty_multipoint(self):
        mp = Multipoint([], crs=LonLatWGS84)
        self.assertEqual(mp.vertices.rank, 0)
        return

    def test_multipoint_zip_init(self):
        x = range(-10, 10)
        y = [_x**2 for _x in x]
        Line(zip(x, y))
        return

    def test_multipoint_subset(self):
        ss1 = self.mp._subset(range(2,7))
        ss2 = self.line._subset(range(2,7))
        self.assertTrue(isinstance(ss1, Multipoint))
        self.assertTrue(isinstance(ss2, Line))
        return

    def test_multipoint_get(self):
        point = Point(self.vertices[0], properties={"value": 99.0})
        self.assertEqual(self.mp[0], point)
        return

#.........这里部分代码省略.........
开发者ID:ivn888,项目名称:karta,代码行数:103,代码来源:geometry_tests.py

示例3: TestGeometry

# 需要导入模块: from karta.vector.geometry import Multipoint [as 别名]
# 或者: from karta.vector.geometry.Multipoint import _subset [as 别名]

#.........这里部分代码省略.........
        other = Point((1e5, -9e5), crs=NSIDCNorth)
        self.assertAlmostEqual(point.azimuth(other), 45.036973, places=6)
        return

    def test_point_shift(self):
        point = Point((-3.0, 5.0, 2.5), data={"color":(43,67,10)},
                      properties="apple")
        point.shift((4.0, -3.0, 0.5))
        self.assertEqual(self.point, point)
        return

    def test_nearest_to(self):
        self.assertEqual(self.mp.nearest_point_to(self.point), self.mp[12])
        return

    def test_empty_multipoint(self):
        mp = Multipoint([], crs=LonLatWGS84)
        self.assertEqual(len(mp), 0)
        return

    def test_multipoint_zip_init(self):
        x = range(-10, 10)
        y = [_x**2 for _x in x]
        Line(zip(x, y))
        return

    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.shift((1, -2, 0.5))
        self.assertEqual(mp, self.mp)
        return

    def test_multipoint_subset(self):
        ss1 = self.mp._subset(range(2,7))
        ss2 = self.line._subset(range(2,7))
        self.assertTrue(isinstance(ss1, Multipoint))
        self.assertTrue(isinstance(ss2, Line))
        return

    def test_multipoint_get(self):
        self.assertEqual(self.mp[0], Point(self.vertices[0],
                                           data=self.mp.data[0],
                                           properties=self.mp.properties))
        return

    def test_multipoint_set(self):
        mp1 = Multipoint([(3.0, 3.0), (5.0, 1.0), (3.0, 1.0),
                         (4.0, 4.0), (0.0, 1.0)],
                         data=["rankin", "corbet", "arviat",
                               "severn", "churchill"])
        mp2 = Multipoint([(3.0, 3.0), (5.0, 1.0), (4.0, 5.0),
                         (4.0, 4.0), (0.0, 1.0)],
                         data=["rankin", "corbet", "umiujaq",
                               "severn", "churchill"])
        mp1[2] = (4.0, 5.0)
        self.assertNotEqual(mp1, mp2)
        mp1[2] = Point((4.0, 5.0), data=["umiujaq"])
        self.assertEqual(mp1, mp2)
        return

    def test_multipoint_iterator(self):
        mp = Multipoint([(3.0, 3.0), (5.0, 1.0), (3.0, 1.0),
                         (4.0, 4.0), (0.0, 1.0)],
                         data=["rankin", "corbet", "arviat",
                               "severn", "churchill"])
开发者ID:jmjak86,项目名称:karta,代码行数:70,代码来源:geometry_tests.py


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