geojson_utils.py 文件源码

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

项目:geojson-python-utils 作者: brandonxiang 项目源码 文件源码
def destination_point(point, brng, dist):
    """
    Calculate a destination Point base on a base point and a distance

    Keyword arguments:
    pt   -- polygon geojson object
    brng -- an angle in degrees
    dist -- distance in Kilometer between destination and base point

    return destination point object

    """
    dist = float(dist) / 6371  # convert dist to angular distance in radians
    brng = number2radius(brng)

    lon1 = number2radius(point['coordinates'][0])
    lat1 = number2radius(point['coordinates'][1])

    lat2 = math.asin(math.sin(lat1) * math.cos(dist) +
                     math.cos(lat1) * math.sin(dist) * math.cos(brng))
    lon2 = lon1 + math.atan2(math.sin(brng) * math.sin(dist) *
                             math.cos(lat1), math.cos(dist) - math.sin(lat1) * math.sin(lat2))
    lon2 = (lon2 + 3 * math.pi) % (2 * math.pi) - math.pi  # normalise to -180 degree +180 degree

    return {'type': 'Point', 'coordinates': [number2degree(lon2), number2degree(lat2)]}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号