计算 GPS 坐标以形成给定大小的半径 [英] Calculate GPS coordinates to form a radius of given size

查看:24
本文介绍了计算 GPS 坐标以形成给定大小的半径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆