geo_util.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:Deploy_XXNET_Server 作者: jzp820927 项目源码 文件源码
def __sub__(self, other):
    """Subtraction.

    Args:
      other: the LatLng which this LatLng is subtracted by.

    Returns:
      the great circle distance between two LatLng objects as computed
      by the Haversine formula.
    """

    assert isinstance(other, LatLng)

    lat_rad = math.radians(self._lat)
    lng_rad = math.radians(self._lng)
    other_lat_rad = math.radians(other.latitude)
    other_lng_rad = math.radians(other.longitude)

    dlat = lat_rad - other_lat_rad
    dlng = lng_rad - other_lng_rad
    a1 = math.sin(dlat / 2)**2
    a2 = math.cos(lat_rad) * math.cos(other_lat_rad) * math.sin(dlng / 2)**2
    return 2 * self._EARTH_RADIUS_METERS * math.asin(math.sqrt(a1 + a2))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号