【问题标题】:Find points that are 10 ft away from an initial set of GPS points查找距离一组初始 GPS 点 10 英尺的点
【发布时间】:2014-08-26 06:24:36
【问题描述】:

所以我有一个点 [40.894375,-74.172555],我想在它周围创建一个边框。

所以我要做的是向它添加一个浮点数,目前是 parseFloat("0.00002"); 我生成的点希望看起来像从北、南、东或西底部向下的点。 但我得到的是一个多英里的积分列表。

这是我正在寻找的一个例子:

                                            ^
                                            |
                                          5-10 ft 
                                            |
               <--- 5-10 ft ---- [40.894375,-74.172555] ---- 5-10 ft --->
                                            |
                                          5-10 ft
                                            |
                                            v

有没有人知道我该如何做到这一点?

【问题讨论】:

  • 那么为什么要在位置上添加 0.00002?
  • 您要创建方形边框吗?
  • 0.00002 没有真正的原因,我只是想离起点有一小段距离。而 Afsa 目前只应该看起来像上面的示例。

标签: javascript gps


【解决方案1】:

我已经翻译了一个 php 函数 (link),如果你给它一个起点、长度(公里)和方位,它会计算一个 GPS 点。

要查找您的积分,请使用该功能

geoDestination([40.894375,-74.172555], 0.003048, 0); //Point 10 ft north
geoDestination([40.894375,-74.172555], 0.003048, 90); //Point 10 ft east
geoDestination([40.894375,-74.172555], 0.003048, 180); //Point 10 ft south
geoDestination([40.894375,-74.172555], 0.003048, 270); //Point 10 ft west

翻译后的php函数

//start is a array [lat, long]
//dist in km
//brng in degrees
function geoDestination(start, dist, brng){
   lat1 = toRad(start[0]);
   lon1 = toRad(start[1]);
   dist = dist/6371.01; //Earth's radius in km
   brng = toRad(brng);

   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 = fmod((lon2+3*Math.PI),(2*Math.PI)) - Math.PI;  

   return [toDeg(lat2),toDeg(lon2)];
}

function toRad(deg){
   return deg * Math.PI / 180;
}

function toDeg(rad){
   return rad * 180 / Math.PI;
}

function fmod(a, b) {
   return Number((a - (Math.floor(a / b) * b)).toPrecision(8));
}

【讨论】:

  • 谢谢,有机会我会去看看的。
  • 我使用了这个函数并修改了它给我30分来增加我的边框的准确性。谢谢。
【解决方案2】:

一分钟经度 (NS) 是 1 NM(海里)= 6076.12 英尺,因此 10 英尺是一分钟经度的 0,00164 NM (1/6076.12*10) 或 0,00164,或 (/60) 2,752e-5 度的 longutide。因此,您需要在 longutide 上加/减 2,752e-5 以加减 10 英尺。这是大约。您在问题中提到的数字。 对于赤道上的纬度 (WE) 1 分钟 ia 1 海里,对于较高纬度,距离变得更短(按纬度的余弦)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多