geodesicProximityOperator

AMD: require(["esri/geometry/operators/geodesicProximityOperator"], (geodesicProximityOperator) => { /* code goes here */ });
ESM: import * as geodesicProximityOperator from "@arcgis/core/geometry/operators/geodesicProximityOperator.js";
Object: esri/geometry/operators/geodesicProximityOperator
Since: ArcGIS Maps SDK for JavaScript 4.31
beta

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

Method
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.

Parameters
Specification
geometry Geometry

The input geometry.

point Point

The point used to search for the nearest coordinate in geometry.

options Object
optional

Additional options.

Specification
calculateLeftRightSide Boolean
optional
Default Value: false

When 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 returned ProximityResult object.

maxDeviation Number
optional
Default Value: NaN

The 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 Boolean
optional
Default Value: true

When geometry is a polygon, the function will test if point 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 LengthUnit
optional

The length unit of the max deviation and result distance.

Returns
Type 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

Method
getNearestVertex(geometry, point, options){ProximityResult}

Returns the nearest vertex on the geometry.

Parameters
geometry Geometry

The input geometry.

point Point

The point used to search for the nearest coordinate in the input geometry.

options Object
optional

Additional options.

Specification
unit LengthUnit
optional

The length unit of the result distance.

Returns
Type 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

Method
getNearestVertices(geometry, point, searchRadius, maxVertexCountToReturn, options){ProximityResult[]}

Returns vertices of the geometry that are closer to the given point than the given radius.

Parameters
geometry Geometry

The input geometry.

point Point

The point used to search for the nearest coordinate in geometry.

searchRadius Number

The distance to search from the point to the nearest vertices in the geometry. Unless the unit option is set, the default is meters.

maxVertexCountToReturn Number

The maximum number of vertices that will be returned. Must be a positive number.

options Object
optional

Additional options.

Specification
unit LengthUnit
optional

The length unit of the search radius and result distances.

Returns
Type 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 when geometry 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);

isLoaded

Method
isLoaded(){Boolean}

Indicates if all dependencies of this module have been loaded.

Returns
Type Description
Boolean Returns true if this module's dependencies have been loaded.

load

Method
load(){Promise}

Loads this module's dependencies. This method must be called first if isLoaded returns false.

Returns
Type Description
Promise Resolves when the dependencies have been loaded.
See also

Type Definitions

ProximityResult

Type Definition
ProximityResult

Object returned from the getNearestCoordinate(), getNearestVertex(), and getNearestVertices() methods.

Properties
coordinate Point

The nearest coordinate on the geometry to the given input point.

distance Number

The distance to the input geometry. Unless the unit option is set, the default is meters.

isEmpty Boolean

Indicates if the result is empty.

isRightSide Boolean
optional

Indicates 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 to true when calling getNearestCoordinate().

vertexIndex Number

The index of the vertex on the geometry that is closest to the input point.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.