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可分别计算处面积和周长,大家去探索去。我有不想再列举了。


  • 相关阅读:
    J2EE开发环境
    Java核心api
    SCJP (SUN认证Java程序员)
    蓝领”变“金领”
    阿飞正传
    高效项目的七个习惯转载
    写程序的一些感想和教训(转载)
    学习的过程也是迭代的过程
    管理的艺术
    怎样成为优秀的软件模型设计者?[精华]
  • 原文地址:https://www.cnblogs.com/arxive/p/7751954.html
Copyright © 2011-2022 走看看