问题描述
我在地图 [x1,y1] 中有一个给定的中心.从那个中心我画一个半径为 1 英里的圆.我需要在圆周围再生成 8 个点,各个点到中心的距离应该是 1 英里,所以它们在圆的边界上.我确实知道得到 x2, y2 的公式,但问题是它不适用于地球地图,因为它不是一个完美的球体.
I have a given center in the map [x1,y1]. From that center I am drawing a circle with a 1 mile radius. I need to generate 8 more points around the circle, the distance between the individual points to center should be 1 mile, so they are on the circle bounds. I do know the formulas to get x2, y2 but the problem is it doesn't apply to earth's map since it isn't a perfect sphere.
我尝试过使用 this,但没有成功.
I've tried using this, but with no luck.
谁能指出我的某个地方,或者我弄错了?
Could anyone point me somewhere or maybe I got this wrong ?
已解决!
所以仔细阅读整个 Movable Type Scripts 我发现了这个(为了我的使用稍微修改了):
So reading carefully throughout Movable Type Scripts I found this (slightly modified for my use):
let getPoint = (distance, bearing, center) => {
let δ = Number(distance) / 6371e3;
let θ = Number(bearing).toRadians();
let φ1 = center[0].toRadians();
let λ1 = center[1].toRadians();
let sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1);
let sinδ = Math.sin(δ), cosδ = Math.cos(δ);
let sinθ = Math.sin(θ), cosθ = Math.cos(θ);
let sinφ2 = sinφ1*cosδ + cosφ1*sinδ*cosθ;
let φ2 = Math.asin(sinφ2);
let y = sinθ * sinδ * cosφ1;
let x = cosδ - sinφ1 * sinφ2;
let λ2 = λ1 + Math.atan2(y, x);
return [φ2.toDegrees(), (λ2.toDegrees()+540)%360-180];
};
它确实解决了我的问题.
It did solved my problem.
推荐答案
您正在尝试解决所谓的 第一个(或直接的)大地测量问题.知道这个名字会让你的研究更容易.
You are trying to solve what is known as the first (or direct) geodetic problem. Knowing this name will make your research easier.
正如如何使用 Leaflet" 和 "在给定起始坐标、方位角和距离的情况下查找目的地坐标",您在 javascript 中解决此问题的主要选项是 cheap-ruler 用于小(ish)区域和 greographiclib 适合远距离.
As pointed out by the answers to "How to draw polyline perpendicular to another polyline using Leaflet" and "Find destination coordinates given starting coodinates, bearing, and distance", your main options to approach this problem in javascript are cheap-ruler for small(ish) areas and greographiclib for large distances.
cheap-ruler 往往非常快但不准确,geographiclib 往往较慢但非常准确.
cheap-ruler tends to be very fast but inaccurate, and geographiclib tends to be slower but very accurate.
您可能会发现其他实现,每个都有自己的妥协.大地测量学很难,所以 没有一种真正的方法"来计算距离或方位角.
You might find other implementations, each with its own compromises. Geodesy is hard, so there is no "one true way" to calculate distances or azimuths.
这篇关于生成给定距离的坐标,距中心的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!