计算GPS坐标,以形成给定尺寸的一个半径 [英] Calculate GPS coordinates to form a radius of given size
问题描述
我来了,需要一个协调的方法和范围(英里),返回形成围绕原点的坐标圈的名单。我似乎已经和它的一些进步,但我有越来越范围内的部分下降的问题。
I've come up with a method that takes a coordinate and a range (in miles) and return a list of coordinates that form a circle around the origin. I seem to have made some progress with it, but I have an issue with getting the range part down.
private const Double LAT_MILE = 0.0144839;
private const Double LONG_MILE = 0.0190693;
public static List<Gps.Coordinate> GetRadius(Double OriginLatitude, Double OriginLongitude, Double Range, int Points)
{
List<Gps.Coordinate> Result = new List<Coordinate>();
//insert a new point
for (int i = 0; i < Points; i++)
{
Result.Add(new Gps.Coordinate()
{
Latitude = ((Range * LAT_MILE) * System.Math.Cos(i)) + OriginLatitude,
Longitude = ((Range * LONG_MILE) * System.Math.Sin(i)) + OriginLongitude
});
}
//sort using nearest neighbor
return SortCoords(ref Result);
}
我发现的问题是,我使用的是告诉不变?在英里根据位置的变化程度的距离..没有人有任何建议,完全解决这个问题,还是一个更好的捕鼠器
The issue I've found is that the constant I'm using to tell the distance in miles to degrees changes depending on location.. Does anyone have any suggestions for resolving this issue, or a better mousetrap altogether?
编辑:
我应该注意到,我在可怕的数学:)
I should note, I'm horrible at math :)
推荐答案
看看这个(包括示例代码)的 http://www.movable-type.co.uk/scripts/latlong.html
have a look at this (includes example code): http://www.movable-type.co.uk/scripts/latlong.html
余弦球法给你两个坐标之间的距离。它应该是可以修改这个给你身边指定中心和指定的半径(距离)的坐标。
the "Spherical Law of Cosines" gives you the distance between two coordinates. it should be possible to modify this to give you the coordinates around a specified center and a specified radius (distance).
这篇关于计算GPS坐标,以形成给定尺寸的一个半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!