require(["esri/geometry/operators/geodesicProximityOperator"], (geodesicProximityOperator) => { /* code goes here */ });
import * as geodesicProximityOperator from "@arcgis/core/geometry/operators/geodesicProximityOperator.js";
esri/geometry/operators/geodesicProximityOperator
Finds closest vertices of a 2D geometry using geodesic distance.
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Returns the nearest coordinate on the geometry to the given input point. | geodesicProximityOperator | ||
Returns the nearest vertex on the geometry. | geodesicProximityOperator | ||
Returns vertices of the geometry that are closer to the given point than the given radius. | geodesicProximityOperator | ||
Indicates if all dependencies of this module have been loaded. | geodesicProximityOperator | ||
Promise | Loads this module's dependencies. | geodesicProximityOperator |
Method Details
-
getNearestCoordinate
getNearestCoordinate(geometry, point, options){ProximityResult}
-
Returns the nearest coordinate on the geometry to the given input point. The operator interprets all segments in the shape preserving manner, that is it treats segments as if they are densified with a small step in the input spatial reference and then the calculation is performed geodesicly.
ParametersSpecificationgeometry GeometryThe input geometry.
point PointThe point used to search for the nearest coordinate in
geometry
.options ObjectoptionalAdditional options.
SpecificationcalculateLeftRightSide BooleanoptionalDefault Value: falseWhen the parameter is set to true, this function will calculate the left/right side of a polyline or polygon. Look for the result in the
rightSide
property of the returnedProximityResult
object.maxDeviation NumberoptionalDefault Value: NaNThe value controls the error of calculation. The method uses shape preserving densification to approximate the input segments with great piecewise elliptical arcs. When the value is zero or NaN, internally the operator uses 0.01 meters. For other values, unless the
unit
option is set, the default is meters.testPolygonInterior BooleanoptionalDefault Value: trueWhen
geometry
is a polygon, the function will test ifpoint
is inside of the polygon. Points that are inside of the polygon have zero distance to the polygon. When set tofalse
, the function will not check if the point is inside of the polygon, but will only determine proximity to the boundary.unit LengthUnitoptionalThe length unit of the max deviation and result distance.
ReturnsType Description ProximityResult Returns the result of proximity operation. Example// Calculate the nearest coordinate on a polyline to the given point if (geodesicProximityOperator.isLoaded()) { const result = geodesicProximityOperator.getNearestCoordinate(polyline, point); }
-
getNearestVertex
getNearestVertex(geometry, point, options){ProximityResult}
-
Returns the nearest vertex on the geometry.
Parametersgeometry GeometryThe input geometry.
point PointThe point used to search for the nearest coordinate in the input
geometry
.options ObjectoptionalAdditional options.
Specificationunit LengthUnitoptionalThe length unit of the result distance.
ReturnsType Description ProximityResult Returns the result of proximity operation. Example// Calculate the nearest vertex on a polyline to the given point if (geodesicProximityOperator.isLoaded()) { const result = geodesicProximityOperator.getNearestVertex(polyline, point);
-
getNearestVertices
getNearestVertices(geometry, point, searchRadius, maxVertexCountToReturn, options){ProximityResult[]}
-
Returns vertices of the geometry that are closer to the given point than the given radius.
Parametersgeometry GeometryThe input geometry.
point PointThe point used to search for the nearest coordinate in
geometry
.searchRadius NumberThe distance to search from the
point
to the nearest vertices in thegeometry
. Unless theunit
option is set, the default is meters.maxVertexCountToReturn NumberThe maximum number of vertices that will be returned. Must be a positive number.
options ObjectoptionalAdditional options.
Specificationunit LengthUnitoptionalThe length unit of the search radius and result distances.
ReturnsType Description ProximityResult[] The array of vertices that are in the given search radius to the point. The array is sorted by distance to the queryPoint with the closest point first. When there are more than the maxVertexCountToReturn
vertices to return, it returns the closest vertices. The array will be empty whengeometry
is empty.Example// Calculate the nearest vertices on a polyline to the given point if (geodesicProximityOperator.isLoaded()) { const result = geodesicProximityOperator.getNearestVertices(polyline, point, 100, 5);
-
Loads this module's dependencies. This method must be called first if
isLoaded
returnsfalse
.ReturnsType Description Promise Resolves when the dependencies have been loaded. - See also
Type Definitions
-
Object returned from the getNearestCoordinate(), getNearestVertex(), and getNearestVertices() methods.
- Properties
-
coordinate Point
The nearest coordinate on the geometry to the given input point.
distance NumberThe distance to the input geometry. Unless the
unit
option is set, the default is meters.isEmpty BooleanIndicates if the result is empty.
isRightSide BooleanIndicates if the nearest coordinate is on the right side or left side of the input point. This property will only be present when
calculateLeftRightSide
is set totrue
when callinggetNearestCoordinate()
.vertexIndex NumberThe index of the vertex on the geometry that is closest to the input point.