Skip to content
import { isLoaded, load, getNearestCoordinate, getNearestVertex, getNearestVertices } from "@arcgis/core/geometry/operators/geodesicProximityOperator.js";
Since
ArcGIS Maps SDK for JavaScript 4.31

Finds closest vertices of a 2D geometry using geodesic distance.

Notes

Verify that isLoaded() returns true before using this module. Use load() to load this module's dependencies.

Geodesic proximity operator

Type definitions

Options

Type definition

unit

Property
Type
LengthUnit | undefined

The length unit of the result distance.

Default value
"meters"

GetNearestCoordinateOptions

Type definition
Supertypes
Options

calculateLeftRightSide

Property
Type
boolean | undefined

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 isRightSide property of the returned ProximityResult object.

Default value
false

maxDeviation

Property
Type
number | undefined

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.

Default value
NaN

testPolygonInterior

Property
Type
boolean | undefined

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.

Default value
true

Functions

isLoaded

Function

Indicates if all dependencies of this module have been loaded.

Signature
isLoaded (): boolean
Returns
boolean

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

load

Function

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

See also
Signature
load (): Promise<void>
Returns
Promise<void>

Resolves when the dependencies have been loaded.

getNearestCoordinate

Function

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.

Signature
getNearestCoordinate (geometry: GeometryUnion, point: Point, options?: GetNearestCoordinateOptions): ProximityResult
Parameters
ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

options

Additional options.

Returns
ProximityResult

Returns the result of proximity operation.

Example
if (!geodesicProximityOperator.isLoaded()) {
await geodesicProximityOperator.load();
}
// Calculate the nearest coordinate on a polyline to the given point
const result = geodesicProximityOperator.getNearestCoordinate(polyline, point);

getNearestVertex

Function

Returns the nearest vertex on the geometry.

Signature
getNearestVertex (geometry: GeometryUnion, point: Point, options?: Options): ProximityResult
Parameters
ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

options

Additional options.

Returns
ProximityResult

Returns the result of proximity operation.

Example
if (!geodesicProximityOperator.isLoaded()) {
await geodesicProximityOperator.load();
}
// Calculate the nearest vertex on a polyline to the given point
const result = geodesicProximityOperator.getNearestVertex(polyline, point);

getNearestVertices

Function

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

Signature
getNearestVertices (geometry: GeometryUnion, point: Point, searchRadius: number, maxVertexCountToReturn: number, options?: Options): ProximityResult[]
Parameters
ParameterTypeDescriptionRequired
geometry

The input geometry.

point

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

searchRadius

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

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

options

Additional options.

Returns
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
if (!geodesicProximityOperator.isLoaded()) {
await geodesicProximityOperator.load();
}
// Calculate the nearest vertices on a polyline to the given point
const result = geodesicProximityOperator.getNearestVertices(polyline, point, 100, 5);

Variables

supportsCurves

Variable

Indicates if the operator supports input geometries that contain curves. The value is null or undefined until the operator is loaded, then it will always be true.

Type
boolean | null | undefined