【发布时间】:2010-07-30 18:58:53
【问题描述】:
有谁知道我在哪里可以找到将纬度/经度位置转换为Military Grid Reference System (MGRS) 的代码库?如果可能,我正在寻找 C# 实现。
【问题讨论】:
-
您可以考虑在gis.stackexchange.com上提出这些形式的问题
标签: c# math gis coordinates coordinate-systems
有谁知道我在哪里可以找到将纬度/经度位置转换为Military Grid Reference System (MGRS) 的代码库?如果可能,我正在寻找 C# 实现。
【问题讨论】:
标签: c# math gis coordinates coordinate-systems
我们最终使用了GeoTrans,并从代码中创建了一个 DLL,并使用 PInvoke 来调用这些函数。 我们从源代码中提取了以下内容,以防有人想知道(最小的解决方案):
我们使用的 PInvoke 签名:
[DllImport("mgrs.dll")]
public static extern int Convert_Geodetic_To_MGRS(
double Latitude,
double Longitude,
int Precision, // 1 to 5, we used 4 (10 square meters)
StringBuilder MGRS);
在mgrs.h中对应这个函数:
MGRSDLL_API long __stdcall Convert_Geodetic_To_MGRS(
double Latitude,
double Longitude,
long Precision,
char* MGRS);
【讨论】:
CoordinateSharp 以 Nuget 包的形式提供,并且可以做到这一点。
Coordinate c = new Coordinate(40.57682, -70.75678);
c.MGRS.ToString(); // Outputs 19T CE 51307 93264
【讨论】:
您可以使用 GDAL 的 C# 包装器将纬度/经度转换为 UTM。然后,您只需为 MGRS 适当地格式化这些值,因为它只是具有不同数字格式的 UTM。
【讨论】:
在js上找到,如果有帮助...
https://github.com/codice/usng.js
用法-
var converter = new usngs.Converter();
alert(converter.LLtoMGRS(33.754032, -98.451233, 9));
【讨论】: