代码之家  ›  专栏  ›  技术社区  ›  SwDevMan81

将lat/lon转换为mgrs

  •  10
  • SwDevMan81  · 技术社区  · 15 年前

    有人知道我在哪里能找到一个代码库,用于将lat/lon位置转换为 Military Grid Reference System (MGRS) ?如果可能的话,我正在寻找一个C实现。

    4 回复  |  直到 7 年前
        1
  •  4
  •   SwDevMan81    14 年前

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

    • 偏振器
    • 转铁器
    • 不间断电源
    • UTM
    • MGRS

    我们使用的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);
    
        2
  •  2
  •   Reed Copsey    15 年前

    你可以使用 GDAL 's c包装纸从lat/lon转换为utm。然后,您只需要为mgrs适当地格式化这些值,因为它只是具有不同数字格式的utm。

        3
  •  0
  •   Zvi Redler    8 年前

    在JS上找到如果有帮助…

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

    用法-

    var converter = new usngs.Converter();
    alert(converter.LLtoMGRS(33.754032, -98.451233, 9));
    
        4
  •  0
  •   Tronald    7 年前

    CoordinateSharp 可作为Nuget软件包提供,并且可以做到这一点。

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