本文整理匯總了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)
)
示例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