【问题标题】:random lat lng coordinates within x km's of another lat lng另一个 lat lng x 公里内的随机 lat lng 坐标
【发布时间】:2016-02-01 22:00:29
【问题描述】:

我们有一个由 lat & lng 指定的位置

我们想在这个位置 20 公里范围内生成一些其他随机纬度和经度位置

有没有人有一个很好的公式来解决这个问题

【问题讨论】:

    标签: geometry geo


    【解决方案1】:

    0..1范围内生成两个均匀随机值rFi
    计算距离为d = Radius * Sqrt(r) (description here for plane circle)
    计算方位为Theta=2 * Pi * Fi
    查找给定中心点的纬度/经度坐标,并在 Destination point given distance and bearing from start point 部分中将 d 和 Theta 计算为 described here

    JavaScript:
    (all angles 
    in radians)
    var φ2 = Math.asin( Math.sin(φ1)*Math.cos(d/R) +
                        Math.cos(φ1)*Math.sin(d/R)*Math.cos(θ) );
    var λ2 = λ1 + Math.atan2(Math.sin(θ)*Math.sin(d/R)*Math.cos(φ1),
                             Math.cos(d/R)-Math.sin(φ1)*Math.sin(φ2));
    
    where   φ is latitude, λ is longitude, 
    θ is the bearing (clockwise from north), d being the distance travelled, 
    R the earth’s radius
    

    【讨论】:

      猜你喜欢
      • 2013-04-13
      • 2018-02-19
      • 1970-01-01
      • 2014-10-16
      • 1970-01-01
      • 1970-01-01
      • 2018-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多