當前位置: 首頁>>代碼示例>>Python>>正文


Python Point.distance方法代碼示例

本文整理匯總了Python中openquake.hazardlib.geo.point.Point.distance方法的典型用法代碼示例。如果您正苦於以下問題:Python Point.distance方法的具體用法?Python Point.distance怎麽用?Python Point.distance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在openquake.hazardlib.geo.point.Point的用法示例。


在下文中一共展示了Point.distance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: assert_mesh_is

# 需要導入模塊: from openquake.hazardlib.geo.point import Point [as 別名]
# 或者: from openquake.hazardlib.geo.point.Point import distance [as 別名]
def assert_mesh_is(testcase, surface, expected_mesh):
    mesh = surface.get_mesh()
    testcase.assertIs(mesh, surface.get_mesh())

    expected_mesh = list(itertools.chain(*expected_mesh))
    testcase.assertEqual(len(mesh), len(expected_mesh))
    testcase.assertIsInstance(mesh, Mesh)

    for i, point in enumerate(mesh):
        expected_point = Point(*expected_mesh[i])
        distance = expected_point.distance(point) * 1e3

        testcase.assertAlmostEqual(
            0, distance, delta=2, # allow discrepancy of 2 meters
            msg="point %d is off: %s != %s (distance is %.3fm)"
                % (i, point, expected_point, distance)
        )
開發者ID:gem,項目名稱:oq-hazardlib,代碼行數:19,代碼來源:_utils.py

示例2: getLength

# 需要導入模塊: from openquake.hazardlib.geo.point import Point [as 別名]
# 或者: from openquake.hazardlib.geo.point.Point import distance [as 別名]
    def getLength(self):
        """
        Compute length of rupture (km). For EdgeRupture, we compute the length
        as the length of the top edge projected to the surface.

        Returns:
            float: Rupture length in km.
        """
        lons = self._toplons
        lats = self._toplats
        seg = self._group_index
        groups = np.unique(seg)
        ng = len(groups)
        rlength = 0
        for i in range(ng):
            group_segments = np.where(groups[i] == seg)[0]
            nseg = len(group_segments) - 1
            for j in range(nseg):
                ind = group_segments[j]
                P0 = Point(lons[ind], lats[ind])
                P1 = Point(lons[ind + 1], lats[ind + 1])
                dist = P0.distance(P1)
                rlength = rlength + dist
        return rlength
開發者ID:ynthdhj,項目名稱:shakemap,代碼行數:26,代碼來源:edge_rupture.py


注:本文中的openquake.hazardlib.geo.point.Point.distance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。