centerPoint property

  1. @override
Coordinates get centerPoint
override

Gets the representative center point of this geographic area.

Calculates a coordinate that represents the geographic center of the area. The exact computation method depends on the area type: rectangles use the midpoint of corners, circles return their center coordinate, and polygons compute the centroid of their vertices.

Returns

  • A Coordinates object representing the center point of the area.

Implementation

@override
Coordinates get centerPoint {
  final bool isAltitudeNull =
      topLeft.altitude == null || bottomRight.altitude == null;

  return Coordinates(
    latitude: (topLeft.latitude + bottomRight.latitude) * 0.5,
    longitude: (topLeft.longitude + bottomRight.longitude) * 0.5,
    altitude: isAltitudeNull
        ? null
        : (topLeft.altitude! + bottomRight.altitude!) * 0.5,
  );
}