zoukankan      html  css  js  c++  java
  • Android GIS开发系列-- 入门季(7) 利用GeometryEngine坐标转换、计算距离与面积等

    GeometryEngine是Arcgis的重要工具类,利用此工具类,可以计算地图上的距离、面积,将点、线、面转化为Json数据,将Json转化为点线面,坐标转换作用非常强大。

    一、坐标转化

    将用到方法 GeometryEngine.project(Geometry geometry, SpatialReference inputSR, SpatialReference outputSR),第二个为Geometry的坐标,第三个参数为要转换的坐标。如果将84坐标转换为墨卡托坐标代码如下:

    Point point1 = new Point(113,23);
        Point point2 =(Point)GeometryEngine.project(point1,SpatialReference.create(SpatialReference.WKID_WGS84), SpatialReference.create(SpatialReference.WKID_WGS84_WEB_MERCATOR));

    二、GeometryEngine计算两点的距离

    用到 GeometryEngine.geodesicDistance(Geometry geometry1, Geometry geometry2, SpatialReference spatialReference, LinearUnit distanceUnit)方法。注意最好不要用GeometryEngine.distance方法,此方法是计算2D长度的,计算不准确。代码如下:

    Point point1 = new Point(113,23);
    Point point2 = new Point(113,24);
      double distance = GeometryEngine.geodesicDistance(point3,point4, SpatialReference.create(SpatialReference.WKID_WGS84), new LinearUnit(LinearUnit.Code.KILOMETER));
    Log.i("TAG","distance ==="+distance );



    此外, 通过GeometryEngine.geodesicArea, GeometryEngine.geodesicLength可分别计算处面积和周长,大家去探索去。我有不想再列举了。


  • 相关阅读:
    linux basename 和 dirname 获取当前路径
    灵活的装饰器
    ubuntu 20version install wechat
    git pull 总提示让输入merge 信息
    Linux脚本中$#、$0、$1、$@、$*、$$、$?
    ansible
    MMD讲解
    再生希尔伯特空间与核函数讲解
    流形学习
    聚类
  • 原文地址:https://www.cnblogs.com/arxive/p/7751954.html
Copyright © 2011-2022 走看看