计算 GPS 坐标以形成给定大小的半径半径、坐标、大小、GPS

2023-09-07 04:30:21 作者:谈什么未来

我想出了一个方法,它接受一个坐标和一个范围(以英里为单位)并返回一个围绕原点形成一个圆的坐标列表.我似乎在这方面取得了一些进展,但我在降低范围部分时遇到了问题.

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).