https://github.com/Esri/samples-geometry-api-java
-
Topological operations
Boolean operations on Polygons, Polylines, Points and MultiPoints.
-
Validation
- Simplify - validates and fixes the geometry to be correct for storage in geodatabase
- IsSimple - validates the geometry to be correct for storage in geodatabase
- Simplify with OGC restrictions - validates and fixes the geometry to be correct according to OGC rules
- IsSimple with OGC restrictions - checks if the geometry is correct according to OGC rules
-
Relational operations
-
Import/Export operations
-
Boundary - creates a geometry that is the boundary of a given geometry
-
Buffer - creates buffer polygon around the given geometry
-
Clip - clips geometries with a 2-dimensional envelope
-
Convex Hull - creates the convex hull of a given geometry
-
Densify - densifies geometries by plotting points between existing vertices
-
Distance - calculates the distance between two geometries
-
Generalize - simplifies geometries using the Douglas-Peucker algorithm
-
Offset - creates geometries that are offset from the input geometries by a given distance
-
Proximity - finds the closest point on a geometry to a given point
-
Quadtree structure - can be used for spatial indexing
-
Geodesic Distance (see geodesicDistanceOnWGS84 in GeometryEngine) - calculates the shortest distance between two points on the WGS84 spheroid
OperatorDistance
double execute = OperatorDistance.local().execute(point, point2, null);
OperatorCut
Polygon poly = new Polygon();
poly.startPath(0, 0);
poly.lineTo(0, 1);
poly.lineTo(1, 1);
poly.lineTo(1, 0);
Polyline polyline = new Polyline();
polyline.startPath(-1, -1);
polyline.lineTo(2, 2);
String execute = OperatorExportToWkt.local().execute(WktExportFlags.wktExportDefaults, poly, null);
System.out.println(execute);
GeometryCursor cursor = OperatorCut.local().execute(false, poly, polyline, SpatialReference.create(4326), null);
while (true) {
Polygon polygon = (Polygon) cursor.next();
if (polygon == null) {
break;
}
System.out.println(OperatorExportToWkt.local().execute(WktExportFlags.wktExportDefaults, polygon, null));
}
OperatorExportToWkt
String geoJsonString = "{\"type\":\"Polygon\",\"coordinates\":[[[58.71093750000001,51.39920565355378],[137.4609375,55.3791104480105],[136.7578125,17.308687886770034],[78.046875,28.92163128242129],[58.71093750000001,51.39920565355378]]]}";
Polygon polygon = (Polygon) OperatorImportFromGeoJson.local().execute(GeoJsonImportFlags.geoJsonImportDefaults, Geometry.Type.Polygon, geoJsonString, null).getGeometry();
Geometry geometry = OperatorBoundary.local().execute(polygon, null);
// 面
System.out.println(geoJsonString);
// 线段
System.out.println(OperatorExportToGeoJson.local().execute(geometry));
String execute = OperatorExportToWkt.local().execute(WktExportFlags.wktExportPolygon, polygon, null);
System.out.println(execute);