给定lat/long中的现有点,(以KM表示)和方位(以度数转换为弧度)的距离,我想计算新的纬度/经度.这个网站反复出现,但我无法让这个公式为我工作.
采用上述链接的公式为:
lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(?))
lon2 = lon1 + atan2(sin(?)*sin(d/R)*cos(lat1), cos(d/R)?sin(lat1)*sin(lat2))
Run Code Online (Sandbox Code Playgroud)
上述公式适用于MSExcel,其中 -
asin = arc sin()
d = distance (in any unit)
R = Radius of the earth (in the same unit as above)
and hence d/r = is the angular distance (in radians)
atan2(a,b) = arc tan(b/a)
? is the bearing (in radians, clockwise from north);
Run Code Online (Sandbox Code Playgroud)
这是我在Python中获得的代码.
import math
R = 6378.1 #Radius of the Earth
brng = 1.57 #Bearing is 90 degrees converted …Run Code Online (Sandbox Code Playgroud) 我正在使用以下函数从种子点生成指定半径内的随机地理坐标:
function randomGeo(center, 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);
var xp = x / Math.cos(y0);
return {
'latitude': y + y0,
'longitude': xp + x0
};
}
Run Code Online (Sandbox Code Playgroud)
我使用2000米半径和以下种子点在循环中多次执行此操作:
location: { // Oxford
latitude: 51.73213,
longitude: -1.20631 …Run Code Online (Sandbox Code Playgroud)