Calculate GPS coordinates to form a radius of given size(计算 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 坐标以形成给定大小的半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:计算 GPS 坐标以形成给定大小的半径
基础教程推荐
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
