getCoordinates method

List<GeoCoordinate2D> getCoordinates({
  1. required GeoAngle startAngle,
  2. bool clockwise = false,
  3. required Size size,
  4. BoxFit boxFit = BoxFit.none,
})

Get list of coordinates starting at angle startAngle inside a rectangle defined by size. For regular polygon, make sure size defines a square with equal dimensions. Note: Depending on resolution, a rectangle may be defined to create the visual appearance of a regular polygon. Angle startAngle is defined as start from east direction, and moving counter-clockwise (towards north, west, then south)

Implementation

List<GeoCoordinate2D> getCoordinates(
    {required GeoAngle startAngle,
    bool clockwise = false,
    required Size size,
    BoxFit boxFit = BoxFit.none}) {
  GeoEllipse ellipse = GeoEllipse(size.width / 2, size.height / 2);
  List<GeoCoordinate2D> coords = <GeoCoordinate2D>[];
  double currentAngle = clockwise ? startAngle.radian : -startAngle.radian;

  bool hasBoxFit = (boxFit != BoxFit.none);
  GeoCoordinate2D? center = GeoCoordinate2D(size.width / 2, size.height / 2);
  for (int i = 0; i < sides; i++) {
    coords.add(ellipse.coordinateByRadian(currentAngle, center));
    currentAngle += clockwise ? interiorAngle.radian : -interiorAngle.radian;
  }
  if (hasBoxFit) {
    GeoUtility.scaleToFit(size, boxFit, coords, true, true);
    GeoUtility.recenter(
        GeoCoordinate2D(size.width / 2, size.height / 2), coords, true);
  }
  return coords;
}