ArcGIS for Android 100.3.0(15):GeometryEngine类的常用方法介绍

GeometryEngine

定义用于对几何执行各种操作的静态方法。例如坐标转化,计算距离,面积等。

API

https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/geometry/GeometryEngine.html

坐标转化相关方法

//把给定几何体从其当前空间空间坐标转化到指定空间坐标
public static Geometry project (Geometry geometry, SpatialReference spatialReference)

public static Geometry project (Geometry geometry, SpatialReference spatialReference,
 DatumTransformation datumTransformation)

案例:

把当前坐标系转化为84坐标

 android.graphics.Point clickedLocation = new android.graphics.Point(Math.round(motionEvent.getX()),
                        Math.round(motionEvent.getY()));
Point originalPoint = mMapView.screenToLocation(clickedLocation);
inputPointGraphic.setGeometry(originalPoint);
// project the web mercator point to WGS84 (WKID 4326)
Point projectedPoint = (Point) GeometryEngine.project(originalPoint, SpatialReference.create(4236));
// Create a geometry located in London, UK, with British National Grid spatial reference
Point britishNationalGridPt = new Point(538985.355, 177329.516, SpatialReference.create(27700));

// Create a GeographicTransformation with a single step using WKID for OSGB_1936_To_WGS_1984_NGA_7PAR transformation
GeographicTransformation transform = GeographicTransformation.create(GeographicTransformationStep.create(108336));

// Project the point to WGS84, using the transformation
Point wgs84Pt = (Point) GeometryEngine.project(britishNationalGridPt, SpatialReferences.getWgs84(), transform);

计算长度

方法1:计算给定折线的长度。

public static double length (Polyline polyline)

方法2:计算几何的大地长度。

LinearUnit:返回值的计量单位。如果为null,则默认为Id的线性单位 METERS

public static double lengthGeodetic (Geometry geometry, LinearUnit lengthUnit, 
GeodeticCurveType curveType)

计算面积

public static double area (Polygon polygon)

public static double area (Envelope envelope)

public static double areaGeodetic (Geometry geometry, AreaUnit areaUnit, GeodeticCurveType curveType)

计算给定几何的边界

public static Geometry boundary (Geometry geometry)

合并两个给定几何的范围

public static Envelope combineExtents (Geometry geometry1,Geometry geometry2)

合并几何集合的范围

public static Envelope combineExtents (Iterable < Geometry > geometry )

测试geometry1是否包含geometry2

public static boolean contains (Geometry container,Geometry within)

densify

public static Geometry densify (Geometry geometry, double maxSegmentLength)

public static Geometry densifyGeodetic (Geometry geometry, double maxSegmentLength,
 LinearUnit lengthUnit, GeodeticCurveType curveType)

案例:

Polyline polyline = new Polyline(points);

// 将路径压缩为测地线曲线,并用路径图表示
Geometry pathGeometry = GeometryEngine.densifyGeodetic(
              polyline, 1, mUnitOfMeasurement, GeodeticCurveType.GEODESIC);
path.setGeometry(pathGeometry);

// 计算路径的距离
double distance = GeometryEngine.lengthGeodetic(pathGeometry, mUnitOfMeasurement, GeodeticCurveType.GEODESIC);

构造两个几何之间的集合理论差异。这将返回一个几何体,该几何体由geometry1中不在geometry2中的部分组成。

public static Geometry difference (Geometry geometry1,Geometry geometry2)

测试两个几何是否不相交

public static boolean disjoint (Geometry geometry1,Geometry geometry2)

测量两个几何之间的简单平面距离

public static double distanceBetween (Geometry geometry1,Geometry geometry2)

计算两个点之间的距离,以给定的线性测量单位返回结果。通过使用给定的大地曲线类型考虑地球表面的曲率来计算距离。

public static GeodeticDistanceResult distanceGeodetic (Point point1,Point point2,
LinearUnit distanceUnit,AngularUnit azimuthUnit,GeodeticCurveType curveType)

测试两个几何是否相等

public static boolean equals (Geometry geometry1,Geometry geometry2)

计算两个几何的交集

public static Geometry intersection (Geometry geometry1,Geometry geometry2)

计算两个几何的交点

public static List<Geometry> intersections (Geometry geometry1, Geometry geometry2)

测试两个几何是否相交

public static boolean intersects (Geometry geometry1,Geometry geometry2)

测试两个几何是否重叠

public static boolean overlap (Geometry geometry1,Geometry geometry2)

计算两个几何的并集

public static Geometry union (Geometry geometry1,Geometry geometry2)

计算几何集合的并集

public static Geometry union (Iterable<Geometry> geometries)

测试是否within在内container

public static boolean within (Geometry within, Geometry container)

猜你喜欢

转载自blog.csdn.net/qq_36699930/article/details/82586371