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


Python Point.distance方法代码示例

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


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

示例1: TestGeometryProj

# 需要导入模块: from karta.vector.geometry import Point [as 别名]
# 或者: from karta.vector.geometry.Point import distance [as 别名]
class TestGeometryProj(unittest.TestCase):

    def setUp(self):
        self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84)
        self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84)
        self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84)
        return

    def test_greatcircle(self):
        d1 = self.vancouver.distance(self.ottawa)
        d2 = self.vancouver.distance(self.whitehorse)
        d3 = self.whitehorse.distance(self.ottawa)
        d4 = self.whitehorse.distance(self.vancouver)
        self.assertTrue(abs(d1 - 3549030.70541) < 1e-5)
        self.assertTrue(abs(d2 - 1483327.53922) < 1e-5)
        self.assertTrue(abs(d3 - 4151366.88185) < 1e-5)
        self.assertTrue(abs(d4 - 1483327.53922) < 1e-5)
        return

    def test_azimuth_lonlat(self):
        """ Verify with
        echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f"
        """
        az1 = self.vancouver.azimuth(self.ottawa)
        az2 = self.vancouver.azimuth(self.whitehorse)
        self.assertAlmostEqual(az1, 78.483344, places=6)
        self.assertAlmostEqual(az2, -26.135827, places=6)
        return

    def test_walk_lonlat(self):
        start = Point((-132.14, 54.01), crs=LonLatWGS84)
        dest = start.walk(5440.0, 106.8)
        self.assertAlmostEqual(dest.x, -132.0605910876)
        self.assertAlmostEqual(dest.y, 53.99584742821)
        return
开发者ID:ivn888,项目名称:karta,代码行数:37,代码来源:geometry_tests.py

示例2: test_distance

# 需要导入模块: from karta.vector.geometry import Point [as 别名]
# 或者: from karta.vector.geometry.Point import distance [as 别名]
    def test_distance(self):
        for crs in (SphericalEarth, LonLatWGS84):
            pt0 = Point((0.0, 0.0), crs=crs)
            pt1 = Point((-1.0, 1.0), crs=crs)

            pt2 = Point((-179.5, 0.0), crs=crs)
            pt3 = Point((179.5, 1.0), crs=crs)
            self.assertAlmostEqual(pt0.distance(pt1), pt2.distance(pt3), places=8)
开发者ID:ivn888,项目名称:karta,代码行数:10,代码来源:geometry_tests.py

示例3: test_greatcircle_projected

# 需要导入模块: from karta.vector.geometry import Point [as 别名]
# 或者: from karta.vector.geometry.Point import distance [as 别名]
    def test_greatcircle_projected(self):
        van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
        whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
        ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)

        d1 = van.distance(ott, projected=False)
        d2 = van.distance(whi, projected=False)
        d3 = whi.distance(ott, projected=False)
        d4 = whi.distance(van, projected=False)
        self.assertAlmostEqual(d1, 3549030.70541, places=3)
        self.assertAlmostEqual(d2, 1483327.53922, places=3)
        self.assertAlmostEqual(d3, 4151366.88185, places=3)
        self.assertAlmostEqual(d4, 1483327.53922, places=3)
        return
开发者ID:fortyninemaps,项目名称:karta,代码行数:16,代码来源:geometry_tests.py

示例4: TestGeometryProj

# 需要导入模块: from karta.vector.geometry import Point [as 别名]
# 或者: from karta.vector.geometry.Point import distance [as 别名]
class TestGeometryProj(unittest.TestCase):

    def setUp(self):
        self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84)
        self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84)
        self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84)
        return

    def test_greatcircle(self):
        d1 = self.vancouver.distance(self.ottawa)
        d2 = self.vancouver.distance(self.whitehorse)
        d3 = self.whitehorse.distance(self.ottawa)
        d4 = self.whitehorse.distance(self.vancouver)
        self.assertAlmostEqual(d1, 3549030.70541, places=5)
        self.assertAlmostEqual(d2, 1483327.53922, places=5)
        self.assertAlmostEqual(d3, 4151366.88185, places=5)
        self.assertAlmostEqual(d4, 1483327.53922, places=5)
        return

    def test_greatcircle_projected(self):
        van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
        whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)
        ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea)

        d1 = van.distance(ott, projected=False)
        d2 = van.distance(whi, projected=False)
        d3 = whi.distance(ott, projected=False)
        d4 = whi.distance(van, projected=False)
        self.assertAlmostEqual(d1, 3549030.70541, places=3)
        self.assertAlmostEqual(d2, 1483327.53922, places=3)
        self.assertAlmostEqual(d3, 4151366.88185, places=3)
        self.assertAlmostEqual(d4, 1483327.53922, places=3)
        return

    def test_azimuth_lonlat(self):
        """ Verify with
        echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f"
        """
        az1 = self.vancouver.azimuth(self.ottawa)
        az2 = self.vancouver.azimuth(self.whitehorse)
        self.assertAlmostEqual(az1, 78.483344, places=6)
        self.assertAlmostEqual(az2, -26.135827, places=6)
        return

    def test_walk_lonlat(self):
        start = Point((-132.14, 54.01), crs=LonLatWGS84)
        dest = start.walk(5440.0, 106.8)
        self.assertAlmostEqual(dest.x, -132.0605910876)
        self.assertAlmostEqual(dest.y, 53.99584742821)
        return
开发者ID:fortyninemaps,项目名称:karta,代码行数:52,代码来源:geometry_tests.py


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