gpt4 book ai didi

javascript - 查找距初始 GPS 点集 10 英尺的点

转载 作者:行者123 更新时间:2023-12-02 17:03:13 25 4
gpt4 key购买 nike

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

所以我要做的就是向其中添加一个 float ,当前是 parseFloat("0.00002");我生成的点我希望看起来像底部的东西,无论是北、南、东还是西。但我得到的是一个多英里的点列表。

这是我正在寻找的示例:

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

有人知道我如何实现这一目标吗?

最佳答案

我翻译了一个 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));
}

关于javascript - 查找距初始 GPS 点集 10 英尺的点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25499330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com