【问题标题】:Convert Lat/Lon to MGRS将纬度/经度转换为 MGRS
【发布时间】:2010-07-30 18:58:53
【问题描述】:

有谁知道我在哪里可以找到将纬度/经度位置转换为Military Grid Reference System (MGRS) 的代码库?如果可能,我正在寻找 C# 实现。

【问题讨论】:

标签: c# math gis coordinates coordinate-systems


【解决方案1】:

我们最终使用了GeoTrans,并从代码中创建了一个 DLL,并使用 PInvoke 来调用这些函数。 我们从源代码中提取了以下内容,以防有人想知道(最小的解决方案):

  • 极地
  • transmerc
  • 上升
  • utm
  • 经理

我们使用的 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);

【讨论】:

  • 您好,您可以分享您创建的 PInvoke dll 吗?
  • @SwDevMan81 你能分享一下DLL吗?以及如何将它添加到我的 windows phone 项目中
【解决方案2】:

CoordinateSharp 以 Nuget 包的形式提供,并且可以做到这一点。

Coordinate c = new Coordinate(40.57682, -70.75678);
c.MGRS.ToString(); // Outputs 19T CE 51307 93264

【讨论】:

    【解决方案3】:

    您可以使用 GDAL 的 C# 包装器将纬度/经度转换为 UTM。然后,您只需为 MGRS 适当地格式化这些值,因为它只是具有不同数字格式的 UTM。

    【讨论】:

      【解决方案4】:

      在js上找到,如果有帮助...

      https://github.com/codice/usng.js

      用法-

      var converter = new usngs.Converter();
      alert(converter.LLtoMGRS(33.754032, -98.451233, 9));
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-01-14
        • 1970-01-01
        • 1970-01-01
        • 2021-10-20
        • 2016-08-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多