src/ol/interaction/Modify.js
function pointDistanceToSegmentDataSquared(pointCoordinates, segmentData) {
  const geometry = segmentData.geometry;

  if (geometry.getType() === GeometryType.CIRCLE) {
    const circleGeometry = /** @type {import("../geom/Circle.js").default} */ (geometry);

    if (segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
      const distanceToCenterSquared =
            squaredCoordinateDistance(circleGeometry.getCenter(), pointCoordinates);
      const distanceToCircumference =
            Math.sqrt(distanceToCenterSquared) - circleGeometry.getRadius();
      return distanceToCircumference * distanceToCircumference;
    }
  }
  return squaredDistanceToSegment(pointCoordinates, segmentData.segment);
}
function pointDistanceToSegmentDataSquared(pointCoordinates, segmentData) {
  const geometry = segmentData.geometry;

  if (geometry.getType() === GeometryType.CIRCLE) {
    const circleGeometry = /** @type {import("../geom/Circle.js").default} */ (geometry);

    if (segmentData.index === CIRCLE_CIRCUMFERENCE_INDEX) {
      const distanceToCenterSquared =
            squaredCoordinateDistance(circleGeometry.getCenter(), pointCoordinates);
      const distanceToCircumference =
            Math.sqrt(distanceToCenterSquared) - circleGeometry.getRadius();
      return distanceToCircumference * distanceToCircumference;
    }
  }
  return squaredDistanceToSegment(pointCoordinates, segmentData.segment);
}
function pointDistanceToSegmentDataSquared ( pointCoordinates , segmentData ) { const geometry = segmentData . geometry ; if ( geometry . getType ( ) === GeometryType . CIRCLE ) { const circleGeometry = /** @type {import("../geom/Circle.js").default} */ ( geometry ) ; if ( segmentData . index === CIRCLE_CIRCUMFERENCE_INDEX ) { const distanceToCenterSquared = squaredCoordinateDistance ( circleGeometry . getCenter ( ) , pointCoordinates ) ; const distanceToCircumference = Math . sqrt ( distanceToCenterSquared ) - circleGeometry . getRadius ( ) ; return distanceToCircumference * distanceToCircumference ; } } return squaredDistanceToSegment ( pointCoordinates , segmentData . segment ) ; }
Returns the distance from a point to a line segment.

@param {import("../coordinate.js").Coordinate} pointCoordinates The coordinates of the point from
which to calculate the distance.
@param {SegmentData} segmentData The object describing the line
segment we are calculating the distance to.
@return {number} The square of the distance between a point and a line segment.
Returns the distance from a point to a line segment .