【问题标题】:Find latitude and longitude of a location查找位置的纬度和经度
【发布时间】:2017-11-10 23:08:43
【问题描述】:

对于我正在开发的应用程序,对于给定的纬度和经度,我需要在距离它 ​​500 米处找到一个新的纬度和经度(任何方向,即北、南、东、西都可以)。 我在堆栈交换上找到了一堆响应并尝试了它们,但老实说,在这一点上我真的很沮丧和疲倦。 有人可以帮我解释一下我该如何实现这一目标吗?

附:我的应用程序需要小于 500 米的小距离

【问题讨论】:

    标签: gis latitude-longitude


    【解决方案1】:

    在 java 脚本中,您生成随机经纬度的函数将是

    function randomGeo(center_latitude,center_longitude, radius) {
        var y0 = center_latitude;
        var x0 = center_longitude;
        var rd = radius / 111300; 
    
        var u = Math.random();
        var v = Math.random();
    
        var w = rd * Math.sqrt(u);
        var t = 2 * Math.PI * v;
        var x = w * Math.cos(t);
        var y = w * Math.sin(t);
    
        //Adjust the x-coordinate for the shrinking of the east-west distances
        var xp = x / Math.cos(y0);
    
        var newlat = y + y0;
        var newlon = x + x0;
    console.log(newlat+","+newlon);
    }
    

    参数半径以米为单位。像

    这样测试这些功能
     randomGeo(22.541161, 88.355040,50);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-06
      • 1970-01-01
      • 2012-08-14
      • 2012-11-08
      • 1970-01-01
      相关资源
      最近更新 更多