【问题标题】:how i can count lat and lon in radius ten or twenty kilometres from center我如何计算距离中心十或二十公里的经度和纬度
【发布时间】:2023-03-17 10:50:01
【问题描述】:

我需要在距离中心 10 公里和 20 公里的范围内随机计算纬度和经度,我有哪些绳索。

例如:

    location_center = {
            "lat": 5.0123,
            "lon": 40.712
}

半径 10 公里内的随机绳索:

    location_center = {
        "lat": 6.246,
        "lon": 45.678

}

半径 20 公里内的随机绳索:

    location_center = {
        "lat": 7.368,
        "lon": 50.678

}

我怎么数?

将不胜感激。

【问题讨论】:

  • 这里的“计数”不是很清楚。此外,纬度和经度不取决于球体的大小,它们是角度。

标签: math geolocation geometry radius


【解决方案1】:

在 0..2*Pi 范围内生成随机角度

使用this page 中的Destination point given distance and bearing from start point 部分,计算所需距离d 处的点(以公里为单位)(地球半径为R=6378.13 km)

brng = random() * 2 * Math.pi
lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) +
                  Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1),
                        Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));

【讨论】:

    猜你喜欢
    • 2010-11-18
    • 2013-01-17
    • 2015-10-18
    • 1970-01-01
    • 1970-01-01
    • 2011-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多