Geometry
objects. Spatial relationship tests are based on the Dimensionally Extended 9 Intersection Model (DE-9IM)
developed by Clementini et al.
Capabilities include:
- Create new geometries from others with
buffer(Geometry, double)
,clip(Geometry, Envelope)
, andunion(Geometry, Geometry)
. - Test spatial relationships between geometries such as
intersects(Geometry, Geometry)
, andcontains(Geometry, Geometry)
. - Find the
nearestCoordinate(Geometry, Point)
ornearestVertex(Geometry, Point)
between geometries. - Reproject a geometry to another
SpatialReference
usingproject(Geometry, SpatialReference)
. - Calculate area and length using
area(Polygon)
andlength(Polyline)
, or the geodetic equivalents (bufferGeodetic(Geometry, double, LinearUnit, double, GeodeticCurveType)
andlengthGeodetic(Geometry, LinearUnit, GeodeticCurveType)
) that account for the curvature of the earth.
GeometryEngine
generally operates in two dimensions; operations do not account for z-values unless
documented as such for a specific method (for example project(Geometry, SpatialReference)
will transform z-values in some cases).
GeometryEngine
provides both planar (Euclidean) and geodetic versions of many operations. Be aware
that methods named with only the operation are the planar versions (buffer(Geometry, double)
, for example),
while the geodetic equivalent has "Geodetic" appended to the name (for example
bufferGeodetic(Geometry, double, LinearUnit, double, GeodeticCurveType)
).
Planar methods are suitable for data with a projected coordinate system, especially for local, large-scale
areas. Geodetic methods are better suited to data with a geographic spatial reference (see
SpatialReference.isGeographic()
), especially for large-area, small-scale use.
Most GeometryEngine methods require inputs to have equivalent spatial references. The methods which have more
than one geometry parameter, or have a separate spatial reference parameter which could conflict with that of the
geometry, will throw if the spatial references are not equivalent. Exceptions to this rule
(for example rotate(Geometry, double, Point)
) are highlighted in the method documentation.
- Since:
- 100.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
Calculates the area of the given Envelope.static double
Calculates the area of the given Polygon.static double
areaGeodetic
(Geometry geometry, AreaUnit areaUnit, GeodeticCurveType curveType) Calculates the geodetic area of the given geometry using a geodetic curve.autoComplete
(Iterable<Polygon> existingBoundaries, Iterable<Polyline> newBoundaries) Fills the closed gaps between polygons using polygon boundaries and polylines as the boundary for the new polygons.static Geometry
Calculates the boundary of the given geometry.static Polygon
Creates a buffer polygon at the specified distance around the given geometry.Creates a buffer or buffers relative to the given collection of geometries.static Polygon
bufferGeodetic
(Geometry geometry, double distance, LinearUnit distanceUnit, double maxDeviation, GeodeticCurveType curveType) Creates a buffer polygon at the specified distance around the given geometry, calculated using a geodetic curve.bufferGeodetic
(Iterable<Geometry> geometries, Iterable<Double> distances, LinearUnit distanceUnit, double maxDeviation, GeodeticCurveType curveType, boolean unionResult) Creates and returns a geodetic buffer or buffers relative to the given collection of geometries.static Geometry
Constructs the portion of a geometry that intersects an envelope.static Envelope
combineExtents
(Geometry geometry1, Geometry geometry2) Returns anEnvelope
representing the minimum extent that encloses both geometry1 and geometry2.static Envelope
combineExtents
(Iterable<Geometry> geometries) Returns anEnvelope
representing the minimum extent that encloses all geometries in the given collection.static boolean
Tests if geometry1 contains geometry2.static Geometry
convexHull
(Geometry geometry) Calculates the minimum bounding geometry (convex hull) that completely encloses the given geometry.convexHull
(Iterable<Geometry> geometries, boolean unionResult) Calculates the minimum bounding geometry (convex hull) for the geometries in the given collection.static Point
createPointAlong
(Polyline polyline, double distance) Calculates the point at the given distance along the line.static boolean
Tests if geometry1 crosses geometry2.Cuts the 'geometry' into parts with the 'cutter'Polyline
.static Geometry
Densifies the input geometry by inserting additional vertices along the geometry at an interval defined bymaxSegmentLength
.static Geometry
densifyGeodetic
(Geometry geometry, double maxSegmentLength, LinearUnit lengthUnit, GeodeticCurveType curveType) Densifies the input geometry by creating additional vertices along the geometry, using a geodetic curve.static Geometry
difference
(Geometry geometry1, Geometry geometry2) Constructs the set-theoretic difference between two geometries.static boolean
Tests if the two geometries are disjoint.static double
distanceBetween
(Geometry geometry1, Geometry geometry2) Calculates the simple planar (Euclidean) distance between two geometries.static GeodeticDistanceResult
distanceGeodetic
(Point point1, Point point2, LinearUnit distanceUnit, AngularUnit azimuthUnit, GeodeticCurveType curveType) Calculates the geodetic distance between two given points and calculates the azimuth at both points for the geodetic curve that connects the points.static Geometry
ellipseGeodesic
(GeodesicEllipseParameters parameters) Constructs a geodesic ellipse centered on a specific point.static boolean
Tests if two geometries are equal.static Polyline
extend
(Polyline polyline, Polyline extender, ExtendOptions... extendOptions) Extends a polyline using a polyline as the extender.static double
fractionAlong
(Polyline line, Point point, double tolerance) Finds the location on the line nearest the 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.static Geometry
generalize
(Geometry geometry, double maxDeviation, boolean removeDegenerateParts) Generalizes the given geometry by removing vertices based on the Douglas-Poiker algorithm.static Geometry
intersection
(Geometry geometry1, Geometry geometry2) Calculates the intersection of two geometries.intersections
(Geometry geometry1, Geometry geometry2) Calculates the intersections of two geometries.static boolean
intersects
(Geometry geometry1, Geometry geometry2) Tests if two geometries intersect each other.static boolean
Indicates if this Geometry is topologically simple (in other words, is topologically correct).static Point
labelPoint
(Polygon polygon) Calculates an interior point for the given polygon.static double
Calculates the length of the given polyline.static double
lengthGeodetic
(Geometry geometry, LinearUnit lengthUnit, GeodeticCurveType curveType) Calculates the geodetic length of the geometry.static Geometry
Moves the provided geometry by the specified distances along the x-axis and y-axis.static Point
moveGeodetic
(Point point, double distance, LinearUnit distanceUnit, double azimuth, AngularUnit azimuthUnit, GeodeticCurveType curveType) Moves a given Point in a specified direction by a geodesic distance.moveGeodetic
(List<Point> points, double distance, LinearUnit distanceUnit, double azimuth, AngularUnit azimuthUnit, GeodeticCurveType curveType) Moves each point in the point collection in a specified direction by a geodetic distance.static ProximityResult
nearestCoordinate
(Geometry geometry, Point point) Determines the nearest point in the input geometry to the input point using a simple planar measurement.static ProximityResult
nearestCoordinateGeodetic
(Geometry geometry, Point point, double maxDeviation, LinearUnit deviationUnit) Determines the nearest point in the input geometry to the input point, by using a shape preserving geodetic approximation of the input geometry.static ProximityResult
nearestVertex
(Geometry geometry, Point point) Returns aProximityResult
that describes the nearest vertex in the input geometry to the input point.static Geometry
normalizeCentralMeridian
(Geometry geometry) Normalizes the input geometry so that it does not intersect the antimeridian.static Geometry
offset
(Geometry geometry, double distance, GeometryOffsetType offsetType, double bevelRatio, double flattenError) Creates an offset version of the input geometry.static boolean
Tests if two geometries overlap.static Geometry
project
(Geometry geometry, SpatialReference spatialReference) Projects the given geometry from its current spatial reference system into the given spatial reference system, using the default geographic transformation.static Geometry
project
(Geometry geometry, SpatialReference spatialReference, DatumTransformation datumTransformation) Projects the given geometry from its current spatial reference system into the given output spatial reference system, applying the datum transformation provided.static boolean
Tests if the two geometries are related using a custom relation.static Geometry
Creates a copy of a geometry with its m values removed.static Geometry
Creates a copy of a geometry with its z values removed.static Geometry
removeZAndM
(Geometry geometry) Creates a copy of the given geometry with its z-coordinates and m-values removed.static Multipart
Reshapes a polygon or polyline using a single path polyline as thereshaper
.static Geometry
Rotates the geometry by the specified angle of rotation around the provided origin point.static Geometry
Scales the given geometry by the specified factors from the specified origin point.static Geometry
sectorGeodesic
(GeodesicSectorParameters parameters) Constructs a geodesic sector defined by a geodesic arc and 2 radii.static Geometry
Creates a copy of a geometry with its m values set to the given value.static Geometry
Creates a copy of a geometry with its z values set to the given value.static Geometry
Creates a copy of a geometry with the supplied z-coordinate and m-value.static Geometry
Simplifies the given geometry to make it topologically consistent according to its geometry type.static Geometry
symmetricDifference
(Geometry geometry1, Geometry geometry2) Calculates the symmetric difference (exclusive or) of the two geometries.static boolean
Tests if the two geometries have at least one boundary point in common, but no interior points.static Geometry
Calculates the union of the two geometries.static Geometry
Calculates the union of a collection of geometries.static boolean
Tests if geometry1 is within geometry2.
-
Method Details
-
area
Calculates the area of the given Envelope.This planar measurement uses 2D Cartesian mathematics to compute the area. It is based upon the
SpatialReference
of the input geometry. If the input geometry does not use an 'area preserving' spatial reference, the result can be inaccurate. You have two options available to calculate a more accurate result:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
areaGeodetic(Geometry, AreaUnit, GeodeticCurveType)
.
- Parameters:
envelope
- envelope whose area is to be calculated- Returns:
- area in units matching the envelope's spatial reference
- Throws:
NullPointerException
- if envelope is null- Since:
- 100.0.0
- Use a different spatial reference. Use the
-
area
Calculates the area of the given Polygon.This planar measurement uses 2D Cartesian mathematics to compute the area. It is based upon the
SpatialReference
of the input geometry. If the input geometry does not use an 'area preserving' spatial reference, the result can be inaccurate. You have two options available to calculate a more accurate result:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
areaGeodetic(Geometry, AreaUnit, GeodeticCurveType)
.
Geometry must be topologically correct to accurately calculate area. Polygons that are self-intersecting or that have inconsistent ring orientations may produce inaccurate area values. In some cases, area values for polygons with incorrect topology may be negative. Geometries returned by ArcGIS Server services are always topologically correct. To ensure that polygons constructed or modified programmatically are topologically consistent, however, it's best to simplify the input geometry using
simplify(Geometry)
before you call this method.Supports true curves.
- Parameters:
polygon
- polygon whose area is to be calculated- Returns:
- area of the given polygon, in the same units as the polygon's spatial reference
- Throws:
NullPointerException
- if polygon is null- Since:
- 100.0.0
- Use a different spatial reference. Use the
-
areaGeodetic
public static double areaGeodetic(Geometry geometry, AreaUnit areaUnit, GeodeticCurveType curveType) Calculates the geodetic area of the given geometry using a geodetic curve.Calculating area using a geodetic measurement accounts for the curvature of the earth's surface. Using geodetic algorithms to calculate areas and distances provides a highly accurate way to obtain measurements of geographic features, typically superior to that returned by the
area(Envelope)
method, which provides a planar measurement that can introduce distortion depending on theSpatialReference
the geometry is in.Geometry must be topologically correct to accurately calculate area. Polygons that are self-intersecting or that have inconsistent ring orientations may produce inaccurate area values. In some cases, area values for polygons with incorrect topology may be negative. Geometries returned by ArcGIS Server services are always topologically correct. To ensure that polygons constructed or modified programmatically are topologically consistent, however, it's best to simplify the input geometry using
simplify(Geometry)
before you call this method.Supports true curves, calculating the result by densifying curves.
- Parameters:
geometry
- geometry whose area is to be calculatedareaUnit
- the unit of measure for the return value. If null, the default unit is meters squared.curveType
- the type of curve to calculate the geodetic area- Returns:
- the calculated geodetic area in the requested unit
- Throws:
IllegalArgumentException
- if geometry or curveType is null- Since:
- 100.0.0
-
autoComplete
public static List<Polygon> autoComplete(Iterable<Polygon> existingBoundaries, Iterable<Polyline> newBoundaries) 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 will participate in the operation, so it makes sense to filter the input accordingly.
All geometries in the existingBoundaries collection must have an area. They must be polygons or envelopes.
All geometries in the newBoundaries collection must be polylines.
- Parameters:
existingBoundaries
- the polygonsnewBoundaries
- the polylines- Returns:
- an unmodifiable list of the new polygons that were created; empty if either existingBoundaries or newBoundaries is empty
- Throws:
IllegalArgumentException
- if existingBoundaries or newBoundaries is nullArcGISRuntimeException
- if the geometries in existingBoundaries and newBoundaries have inconsistent spatial references- Since:
- 100.1.0
-
boundary
Calculates the boundary of the given geometry.- For
Point
- returns an empty geometry. Points have no boundary. - For
Multipoint
- returns an empty geometry. Points have no boundary. - For
Polyline
- returns a multipoint containing the end points of the polyline's parts. - For
Polygon
- returns a polyline describing its outer and inner rings.
Supports true curves.
- Parameters:
geometry
- geometry whose boundary is to be calculated- Returns:
- the boundary of the given geometry
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.0.0
- For
-
buffer
Creates a buffer polygon at the specified distance around the given geometry. This is a planar buffer operation. UsebufferGeodetic(Geometry, double, LinearUnit, double, GeodeticCurveType)
to produce geodetic buffers.This planar measurement uses 2D Cartesian mathematics to compute the buffer area. It is based upon the
SpatialReference
of the input geometry. If the input geometry does not use an 'area preserving' spatial reference, the result can be inaccurate. You have two options available to calculate a more accurate result:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
bufferGeodetic(Geometry, double, LinearUnit, double, GeodeticCurveType)
.
Supports true curves as input, producing a densified curve as output where applicable.
- Parameters:
geometry
- geometry to bufferdistance
- the distance to buffer the geometry. It must be in the same units as the geometry's spatial reference.- Returns:
- a polygon that represents a buffer at the desired distance around the given geometry
- Throws:
NullPointerException
- if geometry is null- Since:
- 100.0.0
- Use a different spatial reference. Use the
-
buffer
public static List<Polygon> buffer(Iterable<Geometry> geometries, Iterable<Double> distances, boolean unionResult) Creates a buffer or buffers relative to the given collection of geometries. This is a planar buffer operation. UsebufferGeodetic(Geometry, double, LinearUnit, double, GeodeticCurveType)
to produce geodetic buffers.This planar measurement uses 2D Cartesian mathematics to compute the buffer areas. It is based upon the
SpatialReference
of the input geometries. If the input geometries do not use an 'area preserving' spatial reference, the results can be inaccurate. You have two options available to calculate a more accurate results:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
bufferGeodetic(Iterable, Iterable, LinearUnit, double, GeodeticCurveType, boolean)
.
If unionResult is true, the output collection contains a single result. If geometries is empty, an empty array is returned.
Supports true curves as input, producing a densified curve as output where applicable.
This method allows you to create different-sized buffers for each input in a geometry collection using corresponding values in a distance collection. Typically, there's a one-to-one correspondence of input geometries to the input buffer distances. However, you may have fewer input buffer distances than input geometries. In that case, the last distance value in the buffer distances collection is applied to the remaining geometries. If needed, you could also specify a single buffer value in the input buffer distances collection to apply to all items in the input geometries collection.
- Parameters:
geometries
- the geometries to bufferdistances
- the buffer distances for the geometries, in the same units as the geometry's spatial reference. If the number of distances is fewer than the number of geometries, the last distance value is used for the rest of the geometries.unionResult
- true to return a single geometry that buffers all the input geometries; false to return a separate buffer for each of the input geometries.- Returns:
- an unmodifiable list containing either a single polygon or one polygon per input geometry, depending on the value of unionResult
- Throws:
IllegalArgumentException
- if geometries is null, or if distances is null or emptyArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent- Since:
- 100.1.0
- Use a different spatial reference. Use the
-
bufferGeodetic
public static Polygon bufferGeodetic(Geometry geometry, double distance, LinearUnit distanceUnit, double maxDeviation, GeodeticCurveType curveType) Creates a buffer polygon at the specified distance around the given geometry, calculated using a geodetic curve.Geodetic 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).
Negative distance can be used to create a buffer inside a
Polygon
or anEnvelope
. Using a negative buffer distance will shrink geometry's boundary by the distance specified. Note that if the negative buffer distance is large enough, the geometry may collapse to an empty polygon.- Parameters:
geometry
- the geometry to bufferdistance
- the buffer distance for the geometrydistanceUnit
- the unit of measurement for distancemaxDeviation
- the maximum deviation between points. If NaN then a maximum deviation of up to 0.2% of the buffer distance, with a maximum of 0.01 meters, aiming to give an output geometry with a smooth boundary.curveType
- the type of geodetic curve to use- Returns:
- the geodetic buffer
- Throws:
IllegalArgumentException
- if geometry, distanceUnit or curveType is nullArcGISRuntimeException
- if the spatial reference of geometry is null- Since:
- 100.1.0
-
bufferGeodetic
public static List<Polygon> bufferGeodetic(Iterable<Geometry> geometries, Iterable<Double> distances, LinearUnit distanceUnit, double maxDeviation, GeodeticCurveType curveType, boolean unionResult) Creates and returns a geodetic buffer or buffers relative to the given collection of geometries. The geometries must have consistent, non-null spatial references.Geodetic 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).
Negative distance can be used to create buffers inside polygons. Using a negative buffer distance will shrink polygons' boundaries by the distance specified. Note that if the negative buffer distance is large enough, polygons may collapse to empty geometries.
- Parameters:
geometries
- the geometries to bufferdistances
- the buffer distances for the geometries. If the number of distances is fewer than the number of geometries, the last distance value is used for the rest of the geometries.distanceUnit
- the unit of measurement for distancesmaxDeviation
- the maximum deviation between points. If NaN then a maximum deviation of up to 0.2% of the buffer distance, with a maximum of 0.01 meters, aiming to give an output geometry with a smooth boundary.curveType
- the type of geodetic curve to useunionResult
- true to return a single geometry that buffers all the input geometries; false to return a separate buffer for each of the input geometries- Returns:
- a collection of polygon geometries that represent a geodetic buffer
- Throws:
IllegalArgumentException
- if geometries, distanceUnit or curveType is null, or if distances is null or emptyArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent- Since:
- 100.1.0
-
combineExtents
Returns anEnvelope
representing the minimum extent that encloses both geometry1 and geometry2.Supports true curves.
- Parameters:
geometry1
- a geometrygeometry2
- another geometry- Returns:
- the maximum extent of the two given geometries
- Throws:
IllegalArgumentException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.1.0
-
combineExtents
Returns anEnvelope
representing the minimum extent that encloses all geometries in the given collection.Supports true curves.
- Parameters:
geometries
- the input geometries- Returns:
- the maximum extent of the geometries in the collection
- Throws:
IllegalArgumentException
- if geometries is null or emptyArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent- Since:
- 100.1.0
-
contains
Tests if geometry1 contains geometry2.This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
container
- geometry that is tested for the "contains" relationship towithin
within
- geometry that is tested for the "within" relationship tocontainer
- Returns:
- true if
container
containswithin
, false otherwise - Throws:
NullPointerException
- if container or within is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
convexHull
Calculates the minimum bounding geometry (convex hull) that completely encloses the given geometry.The convex hull is the minimal bounding geometry that encloses the input geometry, such that all outer angles are convex. If you imagine a rubber band stretched around the input geometry, the rubber band takes the shape of the convex hull.
- Parameters:
geometry
- the input geometry- Returns:
- the convex hull of the given geometry
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.0.0
-
convexHull
Calculates the minimum bounding geometry (convex hull) for the geometries in the given collection.If merge is true, returns a single convex hull that encloses all the geometries in the collection as a single geometry in an array. If merge is false, returns the minimum bounding geometry that completely encloses each of the geometries in the given collection as an array of geometries. If geometries is empty, returns an empty array.
- Parameters:
geometries
- the input geometriesunionResult
- true indicates that a single convex hull geometry is calculated that encloses all the geometries in the collection. False indicates that one convex hull geometry is calculated for each geometry in the collection.- Returns:
- an unmodifiable list containing either a single geometry or one geometry per input geometry, depending on the value of unionResult
- Throws:
IllegalArgumentException
- if geometries is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent- Since:
- 100.1.0
-
crosses
Tests if geometry1 crosses geometry2.Two polylines cross if their intersection contains only points, and at least one of the points of intersection is internal to both polylines. A polyline and polygon cross if a connected part of the polyline is partly inside and partly outside the polygon. A polyline and polygon cross if they share a polyline in common on the interior of the polygon, which is not equal to the entire polyline. The target and join features must be either polylines or polygons.
This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
geometry1
- one of the two geometriesgeometry2
- the other geometry- Returns:
- true if
geometry1
crossesgeometry2
, false otherwise - Throws:
IllegalArgumentException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
cut
Cuts the 'geometry' into parts with the 'cutter'Polyline
.When a
Polyline
orPolygon
is cut, it is split where it intersects the cutterPolyline
. The cut parts are output as a collection of geometries. All left cuts are grouped together in the firstGeometry
, all right cuts are grouped in the secondGeometry
, any uncut parts are output as separate geometries.If the input polyline is not simple, then the operation will be performed on a simplified copy of the polyline. There is no need for you to call any simplify method. If there were no cuts then an empty
List
is returned.- Parameters:
geometry
- geometry to cutcutter
- polyline that cuts the geometry- Returns:
- collection of geometries after cut
- Throws:
IllegalArgumentException
- if geometry or cutter is null- Since:
- 100.0.0
-
densify
Densifies the input geometry by inserting additional vertices along the geometry at an interval defined bymaxSegmentLength
. Additional vertices are not inserted on segments of the inputPolyline
orPolygon
that are shorter thanmaxSegmentLength
.Supports true curves as input, producing a densified curve as output where applicable.
- Parameters:
geometry
- aPolyline
orPolygon
to densifymaxSegmentLength
- The maximum distance between vertices when the input geometry is densified. The linear unit is assumed to be that of the input geometry's spatial reference (decimal degrees for a geometry with a geographic spatial reference, meters for geometry with a Mercator spatial reference, and so on). UseSpatialReference.getUnit()
to determine the unit used by the spatial reference.- Returns:
- the densified geometry
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.0.0
-
densifyGeodetic
public static Geometry densifyGeodetic(Geometry geometry, double maxSegmentLength, LinearUnit lengthUnit, GeodeticCurveType curveType) Densifies the input geometry by creating additional vertices along the geometry, using a geodetic curve.- Parameters:
geometry
- geometry to densifymaxSegmentLength
- the maximum distance between vertices when the input geometry is densified. Must be a positive value.lengthUnit
- unit of measure formaxSegmentLength
. If null, defaults to linear unit of IdLinearUnitId.METERS
.curveType
- type of geodetic curve to calculate- Returns:
- the geodetic densified geometry
- Throws:
IllegalArgumentException
- if geometry or curveType is nullArcGISRuntimeException
- if the spatial reference of geometry is null- Since:
- 100.0.0
-
difference
Constructs the set-theoretic difference between two geometries.This method returns a geometry consisting of the parts of geometry1 that are not in geometry2. It performs a spatial subtraction from the two input geometries. The order of the two input geometry arguments produces different results if they are switched. Think of the difference equation as:
A (Difference) B != B (Difference) A
Use
symmetricDifference(Geometry, Geometry)
to get the parts that are in either geometry, but not in both.Supports true curves.
- Parameters:
geometry1
- first geometrygeometry2
- second geometry- Returns:
- new geometry object that represents the difference of the two given input geometries
- Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
disjoint
Tests if the two geometries are disjoint.Geometries are disjoint if their boundaries or interiors do not intersect.
This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
geometry1
- one of the two geometriesgeometry2
- the other geometry- Returns:
- true if
geometry1
andgeometry2
do not intersect/overlap, false otherwise - Throws:
IllegalArgumentException
- if geometry1 or geometry2 are nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
distanceBetween
Calculates the simple planar (Euclidean) distance between two geometries.This planar measurement uses 2D Cartesian mathematics to compute the distance. It is based upon the
SpatialReference
of the input geometries. If the input geometries do not use an 'distance preserving' spatial reference, the result can be inaccurate. You have two options available to calculate a more accurate result:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
distanceGeodetic(Point, Point, LinearUnit, AngularUnit, GeodeticCurveType)
.
- Parameters:
geometry1
- first geometrygeometry2
- second geometry- Returns:
- the distance between the two geometries in the same units as the geometry's spatial reference
- Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
- See Also:
- Use a different spatial reference. Use the
-
distanceGeodetic
public static GeodeticDistanceResult distanceGeodetic(Point point1, Point point2, LinearUnit distanceUnit, AngularUnit azimuthUnit, GeodeticCurveType curveType) Calculates the geodetic distance between two given points and calculates the azimuth at both points for the geodetic curve that connects the points.- Parameters:
point1
- the Point to calculate distance frompoint2
- the Point to calculate distance todistanceUnit
- the linear unit of measurement for the returned resultazimuthUnit
- the angular unit of measurement for the returned resultcurveType
- the type of geodetic curve between the two points to use to calculate distance- Returns:
- a structure containing the distance and the azimuth at both points for the geodetic curve that connects
- Throws:
IllegalArgumentException
- if any of the arguments is nullArcGISRuntimeException
- if point1 and point2 have different spatial references- Since:
- 100.0.0
-
moveGeodetic
public static List<Point> moveGeodetic(List<Point> points, double distance, LinearUnit distanceUnit, double azimuth, AngularUnit azimuthUnit, GeodeticCurveType curveType) Moves each point in the point collection in a specified direction by a geodetic distance.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.
- Parameters:
points
- the points to use as the starting locations for the returned pointsdistance
- the distance to move the pointsdistanceUnit
- the unit of measure of distance. If null,LinearUnitId.METERS
will be used.azimuth
- the azimuth angle of the direction for the pointsazimuthUnit
- the angular unit of measure of azimuth. If null,AngularUnitId.DEGREES
will be used.curveType
- the type of geodetic curve to move the points along- Returns:
- an unmodifiable List of new Points, moved by the given distance from the input points
- Throws:
IllegalArgumentException
- if points or curveType is nullArcGISRuntimeException
- if the spatial references of the input points are inconsistent or null- Since:
- 100.0.0
-
moveGeodetic
public static Point moveGeodetic(Point point, double distance, LinearUnit distanceUnit, double azimuth, AngularUnit azimuthUnit, GeodeticCurveType curveType) Moves a given Point in a specified direction by a geodesic distance.Specifying a negative distance moves the point in the opposite direction from azimuth.
- Parameters:
point
- the point to use as starting location for the returned pointdistance
- the distance to move the pointsdistanceUnit
- the unit of measure of distance. If null,LinearUnitId.METERS
will be used.azimuth
- the azimuth (angle) of the direction of movementazimuthUnit
- the angular unit of measure of azimuth. If null,AngularUnitId.DEGREES
will be used.curveType
- the type of geodetic curve to move the point along- Returns:
- a new Point moved by the given distance from the input point
- Throws:
IllegalArgumentException
- if point or curveType is nullArcGISRuntimeException
- if point spatial reference is null- Since:
- 100.0.0
-
ellipseGeodesic
Constructs a geodesic ellipse centered on a specific point.It returns a piecewise approximation of a geodesic ellipse (or geodesic circle, if
GeodesicEllipseParameters.getSemiAxis1Length()
=GeodesicEllipseParameters.getSemiAxis2Length()
) consisting ofLineSegment
objects.If this method is used to generate a polygon or a polyline, the result may have more than one path, depending on the size of the ellipse and its position relative to the horizon of the coordinate system. When the method generates a polyline or a multipoint, the result vertices lie on the boundary of the ellipse. When a polygon is generated, the interior of the polygon is the interior of the ellipse, however the boundary of the polygon may contain segments from the spatial reference horizon, or from the geographic coordinate system extent.
If the smaller axis is zero, the ellipse will degenerate to a line segment, a point, or an empty geometry (depending on the larger axis and output type). Otherwise, if
GeodesicEllipseParameters.getMaxPointCount()
< 10, the number of vertices will default to 10. Supported output geometry types arePolygon
,Polyline
, addMultipoint
.- Parameters:
parameters
- various options needed to construct the ellipse- Returns:
- a geodesic ellipse centered on a specific point
- Throws:
IllegalArgumentException
- if parameters is nullIllegalArgumentException
- if theGeodesicEllipseParameters.getGeometryType()
is not one ofGeometryType.MULTIPOINT
,GeometryType.POLYLINE
,GeometryType.POLYGON
ArcGISRuntimeException
- if parameters is not valid- Since:
- 100.0.0
-
equals
Tests if two geometries are equal.The geometries are equal if they have the same spatial reference systems, geometry type, points and occupy the same space. For a more strict comparison of the two geometries (which take into account coordinate order) use:
Point.equals(Geometry, double)
Geometry.equals(Geometry, double)
Object.equals(Object)
Geometry.equals(Geometry, double)
Geometry.equals(Geometry, double)
Geometry.equals(Geometry, double)
Supports true curves.
- Parameters:
geometry1
- does this geometry equal geometry2?geometry2
- does this geometry equal geometry1?- Returns:
- true if the two geometries are equal, false otherwise
- Throws:
NullPointerException
- if geometry1 or geometry2 is null- Since:
- 100.0.0
-
extend
Extends a polyline using a polyline as the extender.The output polyline will have 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 will be extended.
- Parameters:
polyline
- the polyline to be extendedextender
- the polyline to extend toextendOptions
- an array or sequence of one or more ExtendOptions, indicating the type of extend operation to perform- Returns:
- the extended polyline, or null if polyline cannot be extended by extender
- Throws:
IllegalArgumentException
- if polyline, extender or extendOptions is null, or extendOptions is emptyIllegalArgumentException
- if multiple extendOptions are passed and they contain values that are incompatible with each other- Since:
- 100.1.0
-
fractionAlong
Finds the location on the line nearest the 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.This method supports true curves.
- Parameters:
line
- the line to locate the point's distance along its lengthpoint
- the point to locatetolerance
- maximum distance that a point is allowed to be from the line, in the units of theSpatialReference
. If the tolerance is -1, the fraction of the closest location on the line is always returned as long as the point lies between the two ends of the polyline. If the distance from the point to the closest location on the line is greater than the tolerance, or the tolerance is -1 and the point does not lie between the two ends of the polyline, NaN is returned.- Returns:
- the length along the line nearest the input point, expressed as the fraction of the line's length between 0.0 and 1.0, or NAN if the point is outside the tolerance
- Throws:
IllegalArgumentException
- if the line or point parameters are null- Since:
- 100.6.0
-
generalize
public static Geometry generalize(Geometry geometry, double maxDeviation, boolean removeDegenerateParts) Generalizes the given geometry by removing vertices based on the Douglas-Poiker algorithm.Point
andMultipoint
geometries are left unchanged.Envelope
is converted to aPolygon
and then generalized.Supports true curves as input, producing a densified curve as output where applicable.
- Parameters:
geometry
- geometry to generalizemaxDeviation
- the maximum distance that the generalized geometry can deviate from the original, in the same units as the geometry's spatial reference systemremoveDegenerateParts
- true if degenerate parts of the resulting geometry that are undesired for drawing are removed, false otherwise- Returns:
- geometry that represents the generalization of the input geometry
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.0.0
-
intersection
Calculates the intersection of two geometries.The result has the same dimensionality as the lower dimensionality of the two intersecting geometries. Returns an empty geometry if there is no intersection with this dimensionality. 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
intersections(Geometry, Geometry)
.Returns an empty geometry if the two input geometries do not intersect.
Supports true curves.
- Parameters:
geometry1
- first geometrygeometry2
- second geometry- Returns:
- geometry object that represents the intersection of the given geometries
- Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
intersections
Calculates the intersections of two geometries.The returned list contains one geometry of each dimension for which there are intersections. For example, if both inputs are polylines, the list will contain 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 will not be present in the list. If the input geometries do not intersect, the list will be empty. The table below shows, for each combination of pairs of input geometry types, the types of geometry that will be contained within the list if there are intersections of that type.
Set of potential output geometry types for pairs of input geometry types: Input type Point/Multipoint Polyline Polygon/Envelope Point/Multipoint Multipoint Multipoint Multipoint Polyline Multipoint Multipoint, Polyline Multipoint, Polyline Polygon/Envelope Multipoint Multipoint, Polyline Multipoint, Polyline, Polygon The geometries in the returned list are sorted by ascending dimensionality, for example multipoint (dimension 0) then polyline (dimension 1) then polygon (dimension 2) for the intersection of two geometries with area that have intersections of those types.
Supports true curves.
- Parameters:
geometry1
- first geometrygeometry2
- second geometry- Returns:
- an unmodifiable list containing geometry objects that represent the intersection of the given geometries
- Throws:
IllegalArgumentException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.1.0
-
intersects
Tests if two geometries intersect each other.A geometry intersects another geometry if it shares any portion of its geometry with the other geometry feature. If either geometry contain, is within, crosses, touches, or overlaps the other geometry, they intersect.
This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
geometry1
- first geometrygeometry2
- second geometry- Returns:
- true if the two geometries intersect, false otherwise
- Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
labelPoint
Calculates an interior point for the given polygon. This point can be used by clients to place a label for the polygon.This method supports true curves.
- Parameters:
polygon
- polygon to calculate the interior point of- Returns:
- a point that represents the interior point for the given polygon
- Throws:
IllegalArgumentException
- if polygon is null- Since:
- 100.0.0
-
length
Calculates the length of the given polyline.This planar measurement uses 2D Cartesian mathematics to compute the length. It is based upon the
SpatialReference
of the input geometry. If the input geometry is not using a 'distance preserving' spatial reference, the result can be inaccurate. You have two options available to calculate a more accurate result:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
lengthGeodetic(Geometry, LinearUnit, GeodeticCurveType)
.
Supports true curves.
- Parameters:
polyline
- polyline to calculate the length of- Returns:
- the length of the given geometry in the same units as the polyline's spatial reference
- Throws:
NullPointerException
- if polyline is null- Since:
- 100.0.0
- Use a different spatial reference. Use the
-
lengthGeodetic
public static double lengthGeodetic(Geometry geometry, LinearUnit lengthUnit, GeodeticCurveType curveType) Calculates the geodetic length of the geometry.Supports true curves, calculating the result by densifying curves.
- Parameters:
geometry
- geometry to calculate the geodetic length oflengthUnit
- unit of measure for the return value. If null, defaults to linear unit of IdLinearUnitId.METERS
.curveType
- geodetic curve type to calculate the length- Returns:
- the geodetic length of the given geometry
- Throws:
IllegalArgumentException
- if geometry or curveType is nullArcGISRuntimeException
- if the spatial reference of geometry is null- Since:
- 100.0.0
-
move
Moves the provided geometry by the specified distances along the x-axis and y-axis.Planar measurements of distance 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. For input geometries with a geographic spatial reference, consider projecting to an appropriate projected coordinate system before attempting to move them, as the distance represented by angular units of measure will differ depending on the geometry's location on the earth. See Spatial references for more information.
Supports true curves.
- Parameters:
geometry
- the geometry to movedeltaX
- the distance to move the geometry along the x-axis, in the units of the given geometry's spatial referencedeltaY
- the distance to move the geometry along the y-axis, in the units of the given geometry's spatial reference- Returns:
- a new geometry based on moving the given geometry by the given delta values
- Throws:
NullPointerException
- if geometry is null- Since:
- 200.2.0
- See Also:
-
nearestCoordinate
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 anEnvelope
, convert it to aPolygon
first usingboundary(Geometry)
.If the specified geometry is a polyline or polygon the nearest coordinate is the closest point in a segment that comprises geometry; it may not necessarily be the closest vertex of a segment. If you want to obtain the closest vertex in the polyline or polygon use the
nearestVertex(Geometry, Point)
method instead.This calculation uses 2D Cartesian mathematics to compute the nearest coordinate. It is based upon the
SpatialReference
of the input geometries. If the input geometries do not use an 'distance preserving' spatial reference, the result can be inaccurate. You have two options available to calculate a more accurate result:- Use a different spatial reference. Use the
project(Geometry, SpatialReference)
method to project the geometry to a projected coordinate system that is better suited for area calculations. See Spatial references and Supported map projections for more information. - Use the geodetic equivalent,
nearestCoordinateGeodetic(Geometry, Point, double, LinearUnit)
.
Supports true curves.
- Parameters:
geometry
- geometry on which to find the nearest coordinate.Envelope
is not supportedpoint
- point to calculate the nearest coordinate from- Returns:
- a
ProximityResult
containing the results of the operation. This is null if the input geometry is empty.ProximityResult.getDistance()
is zero if the point lies inside an input polygon or polyline. - Throws:
IllegalArgumentException
- if geometry or point is nullIllegalArgumentException
- if geometry is of typeEnvelope
ArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
- Use a different spatial reference. Use the
-
nearestCoordinateGeodetic
public static ProximityResult nearestCoordinateGeodetic(Geometry geometry, Point point, double maxDeviation, LinearUnit deviationUnit) Determines the nearest point in the input geometry to the input point, by using a shape preserving geodetic approximation of the input geometry.Supports true curves.
- Parameters:
geometry
- a geometry object on which to calculate the nearest coordinate to thepoint
parameterpoint
- the point from which to calculate the nearest coordinate on thegeometry
parametermaxDeviation
- the maximum distance that the geodetic geometry can deviate from the original, in the units of thedeviationUnit
parameter. This value controls the error of calculation. If <= zero, or if NAN, deviation defaults to 0.01 meters.deviationUnit
- the unit of measure for themaxDeviation
parameter. If null, the units ofmaxDeviation
are assumed to be meters.- Returns:
- a
ProximityResult
containing the results of the operation, where theProximityResult.getDistance()
is returned in meters. Returns null if the input geometry is empty.ProximityResult.getDistance()
is zero if the point lies inside an input polygon, polyline, or envelope. - Throws:
IllegalArgumentException
- if geometry is nullIllegalArgumentException
- if point is null- Since:
- 100.14.0
- See Also:
-
nearestVertex
Returns aProximityResult
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 anEnvelope
, convert it to aPolygon
first.If the specified geometry is a polyline or polygon, the nearest vertex is the closest end point of the line segment that comprises the geometry; it may not necessarily be the closest point along the line segment. If you want to obtain the closest point in the polyline or polygon use the
nearestCoordinate(Geometry, Point)
method instead.Input geometries with true curves (where
Geometry.hasCurves()
is true) are supported, although curve segments do not affect the return value.- Parameters:
geometry
- geometry on which to find the nearest vertex.Envelope
is not supportedpoint
- point to calculate the nearest vertex from- Returns:
- result containing the nearest vertex
- Throws:
IllegalArgumentException
- if geometry or point is nullIllegalArgumentException
- if geometry is of typeEnvelope
ArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
normalizeCentralMeridian
Normalizes the input geometry so that it does not intersect the antimeridian. This may be necessary when wrap around is enabled on the map.Normalization is used when a geometry intersects the minimum or maximum meridian of the spatial reference, or when the geometry is completely outside of the meridian range. You may wish to use this method to normalize geometries before passing them to methods that require coordinates within the spatial reference domain, for example geodatabase editing methods or geocoding services.
Use this method when editing geometries on a map that has wraparound enabled. For example, if you pan west across the dateline several times and then add new features to a map, the coordinates of the newly added features would correspond to the frame of the map and be incorrectly outside of the spatial reference's maximum extent. Use this method to normalize the geometry coordinates into the correct range.
The geometry's spatial reference must be a pannable projected coordinate system (PCS) or a geographic coordinate system (GCS). A pannable PCS is a rectangular PCS where the x-coordinate range corresponds to a 360-degree range on the defining GCS. A GCS is always pannable.
If geometry or its spatial reference are empty, an empty geometry is returned. If the geometry's spatial reference is not pannable, the input geometry is returned. If the geometry is a non-empty envelope, this method returns a polygon.
Supports true curves.
- Parameters:
geometry
- the geometry to be normalized- Returns:
- the normalized geometry
- Throws:
NullPointerException
- if geometry is null- Since:
- 100.0.0
-
offset
public static Geometry offset(Geometry geometry, double distance, GeometryOffsetType offsetType, double bevelRatio, double flattenError) Creates an offset version of the input geometry.The offset operation creates a geometry that is a constant distance from the input geometry. It is similar to buffering, but produces a one sided result. If offset distance is greater than 0, then the offset geometry is constructed to the right of the oriented input geometry, otherwise it is constructed to the left. For a simple polygon, the orientation of outer rings is clockwise and for inner rings it is counterclockwise. So the "right side" of a simple polygon is always its inside. The bevelRatio is multiplied by the offset distance and the result determines how far a mitered offset intersection can be from the input curve before it is beveled.
- Parameters:
geometry
- geometry to create the offset fromdistance
- offset distance for the geometry result. If distance is greater than 0, then the offset geometry is constructed to the right of the input geometry, otherwise it is constructed to the leftoffsetType
- offset type of the geometry resultbevelRatio
- the ratio used to produce a bevel join instead of a miter join (used only when the offset type isGeometryOffsetType.MITERED
)flattenError
- the maximum distance of the resulting segments compared to the true circular arc (used only when the offset type isGeometryOffsetType.ROUNDED
). The algorithm never produces more than around 180 vertices for each round join.- Returns:
- an offset version of the input geometry
- Throws:
IllegalArgumentException
- if geometry or offsetType is null- Since:
- 100.0.0
-
overlaps
Tests if two geometries overlap.Two geometries overlap when they have the same dimension and when their intersection result is a geometry of the same dimension. If the intersection result is a geometry with a lesser dimension than the input geometries, the method returns false. For example, two input polygons must return a polygon to overlap. If two polygons intersect each other at exactly one point, then no overlap has occurred because the intersection result is a point, whose dimension is zero.
This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
geometry1
- one of the two geometriesgeometry2
- the other geometry- Returns:
- true if the two geometries overlap, false otherwise
- Throws:
IllegalArgumentException
- ifgeometry1
orgeometry2
is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
project
Projects the given geometry from its current spatial reference system into the given spatial reference system, using the default geographic transformation.A default best-choice
DatumTransformation
is applied to the project operation. You can use theTransformationCatalog.getTransformation(SpatialReference, SpatialReference)
method to find out which transformation is used by default for the given spatial references. To control the specific transformation used, use theproject(Geometry, SpatialReference, DatumTransformation)
overload.If the geometry parameter has z values, those z values will also be transformed, provided that both the
SpatialReference
of that geometry and thespatialReference
parameter have a vertical coordinate system.Supports true curves. Projecting curves located at poles and coordinate system horizons using the API may give results that differ slightly from other ArcGIS software because this API uses a different geometry projection function.
- Parameters:
geometry
- input geometry to projectspatialReference
- the output spatial reference into which the geometry will be projected- Returns:
- the geometry projected into the output spatial reference. If the input
geometry
has a nullSpatialReference
, no projection occurs; instead, this method returns an identical geometry that has the spatial reference specified by thespatialReference
parameter. - Throws:
NullPointerException
- if geometry or spatialReference is null- Since:
- 100.0.0
-
project
public static Geometry project(Geometry geometry, SpatialReference spatialReference, DatumTransformation datumTransformation) 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 byproject(Geometry, SpatialReference)
.// 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);
Supports true curves. Projecting curves located at poles and coordinate system horizons using the API may give results that differ slightly from other ArcGIS software because this API uses a different geometry projection function.
- Parameters:
geometry
- the input geometry to projectspatialReference
- the output spatial reference into which the geometry will be projecteddatumTransformation
- the datum transformation that describes how coordinates are converted from one coordinate system to another; if null, then the default transformation is used. Using aHorizontalVerticalTransformation
here will also transform the z-values of the geometry, if (1) thegeometry
has z-values and (2) both thespatialReference
parameter and theSpatialReference
of thegeometry
parameter have a vertical coordinate system set.- Returns:
- the geometry projected into the output spatial reference. If the input
geometry
has a nullSpatialReference
no projection occurs; instead, this method returns an identical geometry that has the spatial reference specified by thespatialReference
parameter. - Throws:
IllegalArgumentException
- if geometry or spatialReference is nullArcGISRuntimeException
- if the datumTransformation'sDatumTransformation.isMissingProjectionEngineFiles()
method returns true- Since:
- 100.2.0
-
relate
Tests if the two geometries are related using a custom relation.You can test for a custom spatial relationship by defining your own relation. For example, you can create a relation that tests if two geometries intersect and touch.
The Dimensionally Extended 9 Intersection Model (DE-9IM) matrix relation (encoded as a string) is a custom spatial relationship type used to test the relationship of two geometries. See Custom spatial relationships for more information about the DE-9IM model and how the relationship string patterns are constructed.
For example, each of the following DE-9IM string codes are valid for testing whether a polygon geometry completely contains a line geometry: "TTTFFTFFT" (Boolean), "T*****FF*" (ignore irrelevant intersections), or "102FF*FF*" (dimension form). Each returns the same result.
Supports true curves.
- Parameters:
geometry1
- one of the two geometriesgeometry2
- the other geometryrelation
- the DE-9IM string to be evaluated. This must be nine characters long and only contain the characters TF*012.- Returns:
- true if the two geometries are related by the given relation, false otherwise
- Throws:
IllegalArgumentException
- if geometry1 or geometry2 is nullIllegalArgumentException
- if relation is null or emptyArcGISRuntimeException
- if relation is not valid- Since:
- 100.0.0
-
removeM
Creates a copy of a geometry with its m values removed. If the given geometry has no m values, the given geometry itself is returned. The resulting geometry will haveGeometry.hasM()
false.Supports true curves.
- Parameters:
geometry
- the input geometry- Returns:
- a copy of the input geometry with its m values removed, or the input geometry itself if it already has no m values
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.1.0
-
removeZ
Creates a copy of a geometry with its z values removed. If the given geometry has no z values, the given geometry itself is returned. The resulting geometry will haveGeometry.hasZ()
false.Supports true curves.
- Parameters:
geometry
- the input geometry- Returns:
- a copy of the input geometry with its z values removed, or the input geometry itself if it already has no z values
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.1.0
-
removeZAndM
Creates a copy of the given geometry with its z-coordinates and m-values removed.If the given geometry has no z-coordinates and no m-values, the given geometry is returned. The resulting geometry will have
Geometry.hasZ()
andGeometry.hasM()
false.Supports true curves.
- Parameters:
geometry
- the input geometry- Returns:
- a copy of the input geometry with its z- and m values removed, or the input geometry itself if it already has no z- or m values
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.1.0
-
reshape
Reshapes a polygon or polyline using a single path polyline as thereshaper
. The output geometry takes the shape of the input geometry where it first intersects thereshaper
to the last intersection. The first and last intersection points of thereshaper
are chosen closest to the end points of thereshaper
in the case that multiple intersections are found. For polygons, only individual paths can be reshaped. However, polylines can be reshaped across paths.- Parameters:
geometry
- the polygon or polyline to be reshapedreshaper
- the single path polyline reshaper- Returns:
- the reshaped polygon or polyline, or null if the input geometry cannot be reshaped by the reshaper
- Throws:
IllegalArgumentException
- if geometry or reshaper is null- Since:
- 100.1.0
-
rotate
Rotates the geometry by the specified angle of rotation around the provided origin point.The angle of rotation is used in the form of the modulo of 360 degrees; for example rotating by 540 degrees is equivalent to rotating the geometry by 180 degrees. A positive value corresponds to a counterclockwise rotation.
The
GeometryType
of the returned geometry is the same as the input geometry, except for an inputEnvelope
which returns aPolygon
result.If the origin
Point
has a differentSpatialReference
to that of the geometry parameter, the point will be reprojected before the geometry is rotated, using the default transformation.Rotating a
Point
using the same location for the origin parameter returns aPoint
with the same values as the input.Supports true curves.
- Parameters:
geometry
- the geometry to rotateangle
- the angle by which to rotate the geometry, counterclockwise, in degreesorigin
- the center of rotation. If null, orGeometry.isEmpty()
is true, the center of the extent of the given geometry is used.- Returns:
- a new geometry constructed by rotating the input geometry by the specified angle of rotation around the provided origin point
- Throws:
NullPointerException
- if geometry is null- Since:
- 200.2.0
- See Also:
-
scale
Scales the given geometry by the specified factors from the specified origin point.If the origin
Point
has a differentSpatialReference
than that of the geometry parameter, the point will be reprojected before the geometry is scaled, using the default transformation.Scaling a
Point
using the same location for the origin parameter returns aPoint
with the same values as the input.Positive scale factors greater than 1 increase the size of the
GeometryEditor.geometryProperty()
, and positive factors between 0 and 1 reduce the size of the geometry. 0 or negative scale factors produce a geometry reflected across the axes of the origin point. Negative factors less than -1 both reflect and increase the size of the geometry, and negative factors between -1 and 0 both reflect and reduce the size of the geometry. Scale factors of -1 reflect the geometry across the axes of the origin point without changing the size.Supports true curves.
- Parameters:
geometry
- the geometry to scalescaleX
- the scale factor along the x-axis. It can be positive or negative. It cannot be a non-numeric value.scaleY
- the scale factor along the y-axis. It can be positive or negative. It cannot be a non-numeric value.origin
- the point around which the geometry will be scaled. If null, orGeometry.isEmpty()
is true, the center of the extent of the geometry parameter is used.- Returns:
- a new geometry constructed by scaling the input geometry by the specified factors from the specified origin point
- Throws:
NullPointerException
- if geometry is null- Since:
- 200.2.0
- See Also:
-
sectorGeodesic
Constructs a geodesic sector defined by a geodesic arc and 2 radii.Creates a sector as a polygon, polyline, or multipoint geometry. A geodesic sector is defined by a geodesic elliptical arc and two radii extending from the center point of the arc to the points where they each intersect the arc. The arc is a portion of an ellipse. The ellipse is defined by a center point, the lengths of its semi-major and semi-minor axes, and the direction of its semi-major axis. The first radius of the sector is defined by the start direction angle relative to the direction of the semi-major axis. The second radius is the sum of the start direction and the sector angle.
The new geometry consists of a series of
LineSegment
objects.- Parameters:
parameters
- options for constructing the sector- Returns:
- a geometry representing the geodesic sector
- Throws:
IllegalArgumentException
- if parameters is nullIllegalArgumentException
- if theGeodesicEllipseParameters.getGeometryType()
is not one ofGeometryType.MULTIPOINT
,GeometryType.POLYLINE
,GeometryType.POLYGON
ArcGISRuntimeException
- if parameters is not valid- Since:
- 100.0.0
-
setM
Creates a copy of a geometry with its m values set to the given value. If the given geometry already has m values, they will be replaced within the resulting geometry by the given m value. The resulting geometry has aGeometry.hasM()
value of true.Supports true curves.
- Parameters:
geometry
- the input geometrym
- the m value to set- Returns:
- a copy of the input geometry with its m values set to the given value
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.1.0
-
setZ
Creates a copy of a geometry with its z values set to the given value. If the given geometry already has z values, they will be replaced within the resulting geometry by the given z value. The resulting geometry has aGeometry.hasZ()
value of true.Supports true curves.
- Parameters:
geometry
- the input geometryz
- the z value to set- Returns:
- a copy of the input geometry with its z values set to the given value
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.1.0
-
setZAndM
Creates 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.hasZ()
andGeometry.hasM()
values of true.Supports true curves.
- Parameters:
geometry
- the input geometryz
- the z value to setm
- the m value to set- Returns:
- a copy of the input geometry with its z- and m values set to the given values
- Throws:
IllegalArgumentException
- if geometry is null- Since:
- 100.1.0
-
simplify
Simplifies the given geometry to make it topologically consistent according to its geometry type.This method rectifies polygons that may be self-intersecting or contain incorrect ring orientations.
Geometries must be topologically correct to perform topological operations. Polygons that are self-intersecting or that have inconsistent ring orientations may produce inaccurate results. To ensure that polygons constructed or modified programmatically are topologically consistent it's best to simplify their geometry using this method. Geometries returned by ArcGIS Server services are always topologically correct.
Supports true curves.
- Parameters:
geometry
- geometry to simplify- Returns:
- simplified geometry
- Throws:
NullPointerException
- if geometry is null- Since:
- 100.0.0
-
symmetricDifference
Calculates the symmetric difference (exclusive or) of the two geometries.Symmetric difference obtains those parts of the two input geometries that do not overlap. If you want to perform a more atomic-level difference operation where the spatial subtraction of two input geometries might look different if the order of the geometries were switched, consider using
difference(Geometry, Geometry)
.Supports true curves.
- Parameters:
geometry1
- one of the two geometriesgeometry2
- the other geometry- Returns:
- the symmetric difference of the two geometries
- Throws:
IllegalArgumentException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
touches
Tests if the two geometries have at least one boundary point in common, but no interior points.This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
geometry1
- does this geometry touch geometry2?geometry2
- does this geometry touch geometry1?- Returns:
- true if the two geometries have at least one boundary point in common, but no interior points. False otherwise.
- Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
union
Calculates the union of the two geometries.The union combines those parts of the two geometries which overlap into a single geometry.
Returns all parts of the two input geometries combined into a single geometry. The order of the input parameters is irrelevant. If the two geometries have different dimensionality, the geometry with the higher dimensionality is returned. For example, a polygon is returned if the given geometries are
Polygon
andPoint
.Supports true curves.
- Parameters:
geometry1
- first geometrygeometry2
- second geometry- Returns:
- the union of the two geometries
- Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
union
Calculates the union of a collection of geometries.The union combines those parts of the input geometries which overlap into a single geometry.
If the collection contains geometries of differing dimensionality, the geometry with the higher dimensionality is returned. For example, a polygon is returned if the given a collection contains polygons, polylines, and points.
Supports true curves.
- Parameters:
geometries
- the input geometries- Returns:
- the union of the input geometries
- Throws:
IllegalArgumentException
- if geometries is null or emptyArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent- Since:
- 100.1.0
-
within
Tests if geometry1 is within geometry2.Returns true if geometry1 lies in the interior of geometry2. The boundary and interior of the geometry1 is not allowed to intersect the exterior of the geometry2 and the geometry1 may not equal the geometry2.
This spatial relationship test is based on the Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., and is discussed further in the web pages: DE-9IM and Spatial relationships.
Supports true curves.
- Parameters:
geometry1
- geometry that is tested for the "within" relationship togeometry2
geometry2
- geometry that is tested for the "contains" relationship togeometry1
- Returns:
- true if
geometry1
lies in the interior ofgeometry2
, false otherwise. The boundary and interior ofgeometry1
is not allowed to intersect the exterior ofgeometry2
andgeometry1
may not equalgeometry2
. - Throws:
NullPointerException
- if geometry1 or geometry2 is nullArcGISRuntimeException
- if the spatial references of the input geometries are inconsistent or null- Since:
- 100.0.0
-
clip
Constructs the portion of a geometry that intersects an envelope.If the
Geometry
intersects theEnvelope
, the portion of theGeometry
contained within theEnvelope
is returned. If no part of theGeometry
lies within theEnvelope
, an emptyGeometry
is returned. If theGeometry
lies completely within theEnvelope
, the entireGeometry
is returned.Supports true curves.
- Parameters:
geometry
- the geometry to be clipped by the given envelopeenvelope
- the extent at which to clip the given geometry- Returns:
- a geometry object that represents the portion of a geometry that intersects an envelope
- Throws:
IllegalArgumentException
- if geometry or envelope is nullArcGISRuntimeException
- if geometry and envelope arguments have different spatial references- Since:
- 100.0.0
- See Also:
-
isSimple
Indicates if this Geometry is topologically simple (in other words, is topologically correct).Point
geometry is always simple.Multipoint
geometries cannot have any points with exactly equal x and y.Polyline
geometries cannot have degenerate segments. When the polyline has no z, the degenerate segments are those that have a length in the xy plane less than or equal to the tolerance. When the polyline has z, the degenerate segments are those that are shorter than the tolerance in the xy plane, and the change in the z-value along the segment is less than or equal to the z-tolerance.Polygon
geometries are considered simple if the following is true:- Exterior rings are clockwise, and interior rings (holes) are counterclockwise.
- Rings can touch other rings in a finite number of points.
- Rings can be self-tangent in a finite number of points.
- No segment length is zero.
- Each path contains at least three non-equal vertices.
- No empty paths allowed.
- Order of rings does not matter.
Supports true curves.
- Parameters:
geometry
- the geometry to be tested if it is simple- Returns:
- true if the provided geometry is simple, false otherwise
- Throws:
IllegalArgumentException
- if the geometry is null- Since:
- 100.0.0
-
createPointAlong
Calculates the point at the given distance along the line.If
distance
is less than or equal to zero, the point returned is coincident with the start of the line. If thedistance
is greater than or equal to the line's length, the point returned is coincident with the end of the line. If the line has multiple parts (notes: the gap does not count as part of line, it is ignored), and the distance falls exactly on a boundary between two parts, the returned point will be coincident with either the end of one part or the start of the next – which is undetermined.This method supports true curves.
As an example to illustrate the returned point you expect to obtain, suppose that you have a polyline with two parts, one is from [0, 0] to [10, 0], the other from [30, 0] to [50, 0], here is the table for the returned point at a given distance:
Distance Point returned Comments 0 [0, 0] Start of part 0 5 [5, 0] Midpoint of part 0 10 [10, 0] End of part 0 10 [30, 0] OR start of part 1 20 [40, 0] Midpoint of part 1 30 [50, 0] end of part 1 - Parameters:
polyline
- the polyline from which the point is createddistance
- the distance along the polyline where the point is created, using the units of the polyline- Returns:
- the point at the given distance along the line
- Throws:
IllegalArgumentException
- if polyline is null- Since:
- 100.3.0
-