nearestCoordinate static method

ProximityResult? nearestCoordinate(
  1. {required Geometry geometry,
  2. required ArcGISPoint point}
)

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 an Envelope, convert it to a Polygon first using GeometryEngine.boundary.

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 GeometryEngine.nearestVertex 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:

Supports true curves.

Parameters:

  • geometry — A geometry object.
  • point — The point of interest.

Return Value: A ProximityResult containing the results of the operation. This is null if the input geometry is empty. ProximityResult.distance is zero if the point lies inside an input polygon, polyline, or envelope.

Implementation

static ProximityResult? nearestCoordinate(
    {required Geometry geometry, required ArcGISPoint point}) {
  _initializeArcGISEnvironmentIfNeeded();
  final objectHandle = _withThrowingErrorHandler((errorHandler) {
    return runtimecore.RT_GeometryEngine_nearestCoordinate(
        geometry._handle, point._handle, errorHandler);
  });
  return ProximityResult._fromHandle(objectHandle);
}