ArcGIS for Android 10.2.9(8):计算距离,周长,面积
GeometryEngine是Arcgis的重要工具类,利用此工具类,可以计算地图上的距离、面积,将点、线、面转化为Json数据,将Json转化为点线面,坐标转换作用非常强大。
1.计算距离:
//计算两点距离:
Point point1 = new Point(113, 23);
Point point2 = new Point(113, 24);
double distance = GeometryEngine.geodesicDistance(point1, point2,
SpatialReference.create(SpatialReference.WKID_WGS84),
new LinearUnit(LinearUnit.Code.KILOMETER)); //单位
Log.e("xyh", "distance ==" + distance);
2.计算周长:
//计算周长
Polyline polyline = new Polyline();
polyline.startPath(new Point(110, 13));
polyline.lineTo(new Point(115, 13));
polyline.lineTo(new Point(115, 23));
double length = GeometryEngine.geodesicLength(polyline,
SpatialReference.create(SpatialReference.WKID_WGS84),
new LinearUnit(LinearUnit.Code.METER));
Log.e("xyh", "length==" + length);
//还可以用这种方法计算线段长度
double v = polyline.calculateLength2D();
3.计算面积:
//计算面积
Polygon polygon = new Polygon();
polygon.startPath(new Point(110, 13));
polygon.lineTo(new Point(115, 13));
polygon.lineTo(new Point(115, 23));
double area = GeometryEngine.geodesicArea(polygon,
SpatialReference.create(SpatialReference.WKID_WGS84),
new AreaUnit(AreaUnit.Code.SQUARE_METER));//单位为平方米
Log.e("xyh", "area==" + area);
// 还可以用这种方法计算面积
double area2D = polygon.calculateArea2D();
转载自:https://blog.csdn.net/qq_36699930/article/details/80005950