GeometryEngine

object GeometryEngine

Performs geometric operations such as spatial relationship tests, reprojections, shape manipulations, topological query and analysis operations on Geometry objects. Capabilities include:

GeometryEngine generally operates in two dimensions; operations do not account for z-values unless documented as such for a specific method (for example GeometryEngine.project(Geometry, SpatialReference) transforms z-values in some cases).

Geodetic methods are better suited to data that have a geographic spatial reference (see SpatialReference.getIsGeographic()), especially for large-area, small-scale use, while planar methods are suitable to data that have a projected coordinate system, especially for local, large-scale areas. Geodetic methods indicate this in the name, for example GeometryEngine.bufferGeodetic(Geometry, double, LinearUnit, double, GeodeticCurveType).

Functions

Link copied to clipboard
fun area(geometry: Geometry): Double

Calculates the area of the given geometry. Planar measurements of distance and area can be extremely inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the geometry's spatial reference. If you need to calculate more accurate results consider using a different spatial reference, or using the geodetic equivalent, GeometryEngine.areaGeodetic(Geometry, AreaUnit, GeodeticCurveType). See [https://developers.arcgis.com/documentation/spatial-references/] for more information about spatial references.

Link copied to clipboard
fun areaGeodetic(    geometry: Geometry,     unit: AreaUnit?,     curveType: GeodeticCurveType): Double

Calculates the geodesic area of the given geometry. Supports true curves, calculating the result by densifying curves.

Link copied to clipboard
fun autoComplete(existingBoundaries: Iterable<Polygon>, newBoundaries: Iterable<Polyline>): List<Polygon>

Fills the closed gaps between polygons using polygon boundaries and polylines as the boundary for the new polygons. The new polygons are created in the closed empty areas bounded by the edges of the existing polygon boundaries and the new boundary polylines. The newly created polygons do not overlap any existing polygons or polylines, and the boundary of a new polygon must contain at least one edge from the polylines. Only polygons that intersect the input polylines participate in the operation, so it makes sense to prefilter the input accordingly.

Link copied to clipboard
fun boundary(geometry: Geometry): Geometry

Calculates the boundary of the given geometry. Supports true curves.

Link copied to clipboard
fun buffer(geometry: Geometry, distance: Double): Polygon

Returns a geometry object that represents a buffer relative to the given geometry. Planar measurements of distance and area can be extremely inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the geometry's spatial reference. If you need to calculate more accurate results consider using a different spatial reference, or using the geodetic equivalent, GeometryEngine.bufferGeodetic(Geometry, Double, LinearUnit, Double, GeodeticCurveType). See [https://developers.arcgis.com/documentation/spatial-references/] for more information about spatial references.

fun buffer(    geometries: Iterable<Geometry>,     distances: Iterable<Double>,     unionResult: Boolean): List<Polygon>

Creates and returns a buffer relative to the given geometries. The geometries must have the same spatial reference. Planar measurements of distance and area can be extremely inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the geometry's spatial reference. If you need to calculate more accurate results consider using a different spatial reference, or using the geodetic equivalent, GeometryEngine.bufferGeodetic(MutableListImpl, MutableListImpl, LinearUnit, Double, GeodeticCurveType, Boolean). See [https://developers.arcgis.com/documentation/spatial-references/] for more information about spatial references. If unionResult is true, the output collection contains a single result. If geometries is empty, an empty array is returned. Returns null on error.

Link copied to clipboard
fun bufferGeodetic(    geometry: Geometry,     distance: Double,     distanceUnit: LinearUnit?,     maxDeviation: Double,     curveType: GeodeticCurveType): Polygon

Calculates the geodesic buffer of a given geometry. Geodesic buffers account for the actual shape of the Earth. Distances are calculated between points on a curved surface (the geoid) as opposed to points on a flat surface (the Cartesian plane).

fun bufferGeodetic(    geometries: Iterable<Geometry>,     distances: Iterable<Double>,     distanceUnit: LinearUnit?,     maxDeviation: Double,     curveType: GeodeticCurveType,     unionResult: Boolean): List<Polygon>

Calculates the geodesic buffer of the geometries in a given collection. Geodesic buffers account for the actual shape of the Earth. Distances are calculated between points on a curved surface (the geoid) as opposed to points on a flat surface (the Cartesian plane).

Link copied to clipboard
fun clip(geometry: Geometry, envelope: Envelope): Geometry

Clips the given geometry with the envelope. Supports true curves.

Link copied to clipboard
fun combineExtents(geometries: Iterable<Geometry>): Envelope

Returns the envelope of geometries in the given collection. The given geometries must have consistent spatial references.

fun combineExtents(geometry1: Geometry, geometry2: Geometry): Envelope

Returns the envelope of the two given geometries. The given geometries must have consistent spatial references.

Link copied to clipboard
fun contains(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if geometry1 contains geometry2. Supports true curves.

Link copied to clipboard
fun convexHull(geometry: Geometry): Geometry

Returns the minimum bounding geometry that completely encloses the given geometry.

fun convexHull(geometries: Iterable<Geometry>, merge: Boolean): List<Geometry>

Returns the convex hull for the geometries in the given collection. The geometries must have consistent spatial references.

Link copied to clipboard
fun createPointAlong(polyline: Polyline, distance: Double): Point

Return the point at the given distance along the line. Supports true curves.

Link copied to clipboard
fun crosses(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if geometry1 crosses geometry2. Supports true curves.

Link copied to clipboard
fun cut(geometry: Geometry, cutter: Polyline): List<Geometry>

Cut the 'geometry' Geometry with the 'cutter' Polyline The cutter and geometry's spatial references must match.

Link copied to clipboard
fun densify(geometry: Geometry, maxSegmentLength: Double): Geometry

Densifies the input geometry by inserting additional vertices along the geometry at an interval defined by maxSegmentLength. Additional vertices are not inserted on segments of the input Envelope, Polygon, or Polyline that are shorter than maxSegmentLength.

Link copied to clipboard
fun densifyGeodetic(    geometry: Geometry,     maxSegmentLength: Double,     lengthUnit: LinearUnit?,     curveType: GeodeticCurveType): Geometry

Densifies the input geometry by creating additional vertices along the geometry, using a geodesic curve.

Link copied to clipboard
fun difference(geometry1: Geometry, geometry2: Geometry): Geometry

Constructs the set-theoretic difference between two geometries. Supports true curves.

Link copied to clipboard
fun disjoint(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if the two geometries are disjoint. Supports true curves.

Link copied to clipboard
fun distance(geometry1: Geometry, geometry2: Geometry): Double

Measures the simple planar distance between two geometries. Planar measurements of distance and area can be extremely inaccurate if using an unsuitable spatial reference. Ensure that you understand the potential for error with the geometry's spatial reference. If you need to calculate more accurate results consider using a different spatial reference, or using the geodetic equivalent, GeometryEngine.distanceGeodetic(Point, Point, LinearUnit, AngularUnit, GeodeticCurveType). See [https://developers.arcgis.com/documentation/spatial-references/] for more information about spatial references.

Link copied to clipboard
fun distanceGeodetic(    point1: Point,     point2: Point,     distanceUnit: LinearUnit?,     azimuthUnit: AngularUnit?,     curveType: GeodeticCurveType): GeodeticDistanceResult

Calculates the geodesic distance between the two points.

Link copied to clipboard
fun ellipseGeodesic(parameters: GeodesicEllipseParameters): Geometry

Constructs a geodesic ellipse centered on a specific point.

Link copied to clipboard
fun equals(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if two geometries are equal The geometries are equal if they have the same spatial reference systems, geometry type and points.

Link copied to clipboard
fun extend(    polyline: Polyline,     extender: Polyline,     extendOptions: Set<GeometryExtendOptions>): Polyline?

Extends a polyline using a polyline as the extender. The output polyline has the first and last segment of each path extended to the extender if the segments can be interpolated to intersect the extender. In the case that the segments can be extended to multiple segments of the extender, the shortest extension is chosen. Only end points for paths that are not shared by the end points of other paths are extended. If the polyline cannot be extended by the input extender, then null is returned.

Link copied to clipboard
fun fractionAlong(    line: Polyline,     point: Point,     tolerance: Double): Double

Finds the location on the line nearest the input point, expressed as the fraction along the line's total geodesic length, if the point is within the specified distance from the closest location on the line. The line and point must have consistent spatial references. Supports true curves.

Link copied to clipboard
fun generalize(    geometry: Geometry,     maxDeviation: Double,     removeDegenerateParts: Boolean): Geometry

Generalizes the given geometry by removing vertices based on the Douglas-Poiker algorithm. Supports true curves as input, producing a densified curve as output where applicable.

Link copied to clipboard
fun intersection(geometry1: Geometry, geometry2: Geometry): Geometry

Calculates the intersection of two geometries. The result has the same dimensionality as the lower dimensionality of the two intersecting geometries. If there is no intersection with this dimensionality, returns an empty geometry. For example, the intersection of two polygons (geometries with area, so they have dimensionality of 2) or, say, a polygon and an envelope (also an area) is a polygon. Similarly, the intersection of a polyline (a line, so dimensionality of 1) and another polyline is always a polyline. Therefore when computing the intersection of polylines, this function does not return points where they cross, but rather lines of overlap. If there are no lines of overlap, an empty polyline is returned even if the input lines cross. To obtain all intersections, irrespective of dimensionality, see GeometryEngine.intersections(Geometry, Geometry). Returns an empty geometry if the two input geometries do not intersect. Returns null on error.

Link copied to clipboard
fun intersections(geometry1: Geometry, geometry2: Geometry): List<Geometry>

Calculates the intersection of two geometries. The returned collection contains one geometry of each dimension for which there are intersections. For example, if both inputs are polylines, the collection contains at most two geometries: the first a multipoint containing the points at which the lines cross, and the second a polyline containing the lines of overlap. If a crossing point lies within a line of overlap, only the line of overlap is present -- the result set is not self-intersecting. If there are no crossing points or there are no lines of overlap, the respective geometry is not be present in the returned collection. If the input geometries do not intersect, the resulting collection is empty. The table below shows, for each combination of pairs of input geometry types, the types of geometry that are contained within the returned collection if there are intersections of that type.

Link copied to clipboard
fun intersects(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if two geometries intersect. Supports true curves.

Link copied to clipboard
fun isSimple(geometry: Geometry): Boolean

Gets a value indicating whether or not the geometry is simple. Point geometry is always simple.

Link copied to clipboard
fun labelPoint(polygon: Polygon): Point

Calculates an interior point for the given polygon. This point can be used by clients to place a label for the polygon. Supports true curves.

Link copied to clipboard
fun length(geometry: Geometry): Double

Calculates the length of the given geometry. Supports true curves.

Link copied to clipboard
fun lengthGeodetic(    geometry: Geometry,     lengthUnit: LinearUnit?,     curveType: GeodeticCurveType): Double

Calculates the geodesic length of the geometry. Supports true curves, calculating the result by densifying curves.

Link copied to clipboard
fun moveGeodetic(    pointCollection: Iterable<Point>,     distance: Double,     distanceUnit: LinearUnit?,     azimuth: Double,     azimuthUnit: AngularUnit?,     curveType: GeodeticCurveType): List<Point>

Moves each point in the point collection by a geodesic distance. There must be the same spatial reference on each point in the input MutableListImpl of points. The returned collection is in the same order as the input, but with new points at their destination locations. Specifying a negative distance moves points in the opposite direction from azimuth.

Link copied to clipboard
fun nearestCoordinate(geometry: Geometry, point: Point): ProximityResult?

Determines the nearest point in the input geometry to the input point using a simple planar measurement. Input geometry of type Envelope is not supported. To find the nearest coordinate on an Envelope, convert it to a Polygon first.

Link copied to clipboard
fun nearestCoordinateGeodetic(    geometry: Geometry,     point: Point,     maxDeviation: Double,     deviationUnit: LinearUnit?): ProximityResult?

Determines the nearest point in the input geometry to the input point, by using a shape preserving geodesic approximation of the input geometry. All geometry types are supported for the geometry parameter. Supports true curves.

Link copied to clipboard
fun nearestVertex(geometry: Geometry, point: Point): ProximityResult?

Returns a ProximityResult that describes the nearest vertex in the input geometry to the input point. Input geometry of type Envelope is not supported. To find the nearest vertex on an Envelope, convert it to a Polygon first.

Link copied to clipboard
fun normalizeCentralMeridian(geometry: Geometry): Geometry?

Folds the geometry into a range of 360 degrees. This may be necessary when wrap around is enabled on the map. Supports true curves.

Link copied to clipboard
fun offset(    geometry: Geometry,     distance: Double,     offsetType: GeometryOffsetType,     bevelRatio: Double,     flattenError: Double): Geometry

Creates an offset version of the input geometry. The offset operation creates a geometry that is a constant distance from the input geometry. If is similar to buffering, but produces a one sided result. If distance 0, then the offset geometry is constructed to the right of the input geometry, otherwise it is constructed to the left.

Link copied to clipboard
fun overlaps(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if two geometries overlap. Supports true curves.

Link copied to clipboard
fun <T : Geometry> project(geometry: T, spatialReference: SpatialReference): T

Projects the given geometry from its current spatial reference system into the given spatial reference system. A default best-choice DatumTransformation is applied to the project operation. To control the specific transformation used, use the GeometryEngine.project(Geometry, SpatialReference, DatumTransformation) overload.

fun <T : Geometry> project(    geometry: T,     outputSpatialReference: SpatialReference,     datumTransformation: DatumTransformation?): T

Projects the given geometry from its current spatial reference system into the given output spatial reference system, applying the datum transformation provided. Use this overload to project a geometry if the difference between the input geometry's SpatialReference and the outputSpatialReference involves a change of datum, and you do not wish to use the default datum transformation used by GeometryEngine.project(Geometry, SpatialReference).

Link copied to clipboard
fun relate(    geometry1: Geometry,     geometry2: Geometry,     relation: String): Boolean

Test if the two geometries are related by the given relation. Supports true curves.

Link copied to clipboard
fun reshape(geometry: Multipart, reshaper: Polyline): Multipart?

Reshape polygons or polylines with a single path polyline. Performs the reshape operation on a polygon or polyline using a single path polyline as the reshaper. The output geometry takes the shape of the Multi_path where it first intersects the reshaper to the last intersection. The first and last intersection points of the reshaper are chosen closest to the end points of the reshaper in the case that multiple intersections are found. For polygons, only individual paths can be reshaped. However, polylines can be reshaped across paths. If the geometry cannot be reshaped by the input reshaper, then null is returned.

Link copied to clipboard
fun sectorGeodesic(parameters: GeodesicSectorParameters): Geometry

Constructs a geodesic sector defined by a geodesic arc and 2 radii.

Link copied to clipboard
fun <T : Geometry> setM(geometry: T, m: Double?): T

Return a copy of a geometry with the supplied m-value. If the given geometry already has m-values, they are replaced within the resulting geometry by the supplied value. The resulting geometry has Geometry.hasM true. If the m-value supplied is null, then the geometry's m-value will be removed, and the resulting geometry has Geometry.hasM false.

Link copied to clipboard
fun <T : Geometry> setZ(geometry: T, z: Double?): T

Return a copy of a geometry with the supplied z-coordinate. If the given geometry already has z-coordinates, they are replaced within the resulting geometry by the supplied value. The resulting geometry has Geometry.hasZ true. If the z-coordinate supplied is null, then the geometry's z-coordinate will be removed, and the resulting geometry has Geometry.hasZ false.

Link copied to clipboard
fun <T : Geometry> setZAndM(    geometry: T,     z: Double?,     m: Double?): T

Return a copy of a geometry with the supplied z-coordinate and m-value. If the given geometry already has z-coordinates or m-values, they are replaced in the resulting geometry by the supplied values. The resulting geometry has both Geometry.getHasZ() and Geometry.getHasM() true. If the z-coordinate supplied is null, then the geometry's z-coordinate will be removed, and the resulting geometry has Geometry.hasZ false. If the m-value supplied is null, then the geometry's m-value will be removed, and the resulting geometry has Geometry.hasM false.

Link copied to clipboard
fun <T : Geometry> simplify(geometry: T): T

Simplifies the given geometry to make it topologically consistent according to its geometry type. Supports true curves.

Link copied to clipboard
fun symmetricDifference(geometry1: Geometry, geometry2: Geometry): Geometry

Calculates the symmetric difference (exclusive or) of the two geometries.

Link copied to clipboard
fun touches(geometry1: Geometry, geometry2: Geometry): Boolean

Test if the two geometries touch on their borders. Supports true curves.

Link copied to clipboard
fun union(geometries: Iterable<Geometry>): Geometry

Calculates the union of a collection of geometries There must be at least one geometry in the given collection. The geometries must have consistent spatial references. If the collection contains geometries of differing dimensionality, returns the union of the subset of geometries with the highest dimensionality. E.g. given a collection of polygons, polylines and points, returns the union of the polygons.

fun union(geometry1: Geometry, geometry2: Geometry): Geometry?

Calculates the union of the two geometries. If the two geometries have different dimensionality, returns a copy of the geometry with the higher dimensionality. E.g. if given a polygon and a point, returns the polygon.

Link copied to clipboard
fun within(geometry1: Geometry, geometry2: Geometry): Boolean

Tests if geometry1 is within geometry2. Supports true curves.