require(["esri/geometry/operators/proximityOperator"], (proximityOperator) => { /* code goes here */ });
import * as proximityOperator from "@arcgis/core/geometry/operators/proximityOperator.js";
esri/geometry/operators/proximityOperator
Find the closest vertices of the 2D geometry.
Method Overview
Name | Return Type | Summary | Object |
---|---|---|---|
Returns the nearest coordinate on the geometry to the given input point. | proximityOperator | ||
Returns the nearest vertex on the geometry. | proximityOperator | ||
Returns vertices of the geometry that are closer to the given point than the given radius. | proximityOperator |
Method Details
-
getNearestCoordinate
getNearestCoordinate(geometry, point, options){ProximityResult}
-
Returns the nearest coordinate on the geometry to the given input point.
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.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 to false, 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 result distance. An error will be thrown if this is set for Geographic Coordinate Systems.
ReturnsType Description ProximityResult Returns the proximity result which contains the nearest coordinate on the input geometry
to the giveninputPoint
.Example// Return the nearest result on a polygon to the given point const proximityResult = proximityOperator.getNearestCoordinate(polygon, 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. An error will be thrown if this is set for Geographic Coordinate Systems.
ReturnsType Description ProximityResult Returns the proximity result which contains the nearest vertex on the geometry
to the giveninputPoint
.Example// Return the nearest vertex on a polygon to the given point const proximityResult = proximityOperator.getNearestVertex(polygon, 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 planar distance from the
inputPoint
to search for vertices. Unless theunit
option is set, the default is the geometry's spatial reference unit.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. An error will be thrown if this is set for Geographic Coordinate Systems.
ReturnsType Description ProximityResult[] Returns an array of proximity results which contain the nearest vertices on geometry
to the giveninputPoint
that are less than or equal to the planar distance of search radius. The array is sorted by distance to theinputPoint
with the closest point first. When there are more than themaxVertexCountToReturn
vertices to return, it returns the closest vertices. The array will be empty whengeometry
is empty.Example// Return the nearest vertices on a polygon to the given point const proximityResultsArray = proximityOperator.getNearestVertices(polygon, point, 100, 5);
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 planar distance between the input point and the nearest coordinate on the geometry. Unless the
unit
option is set, the default is the spatial reference unit of the input geometries.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.