function squaredDistanceToSegment(coordinate, segment) {
  return squaredDistance(coordinate, closestOnSegment(coordinate, segment));
}
Calculate the squared distance from a coordinate to a line segment.

@param {Coordinate} coordinate Coordinate of the point.
@param {Array<Coordinate>} segment Line segment (2
coordinates).
@return {number} Squared distance from the point to the line segment.