getCoordinates method

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

Get list of coordinates rotated by angle rotate inside a rectangle defined by size. The coordinate are scaled to fit if boxFit is defined. 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 rotate,
    bool clockwise = false,
    required Size size,
    BoxFit boxFit = BoxFit.none}) {
  GeoCoordinate2D center = GeoCoordinate2D(size.width / 2, size.height / 2);
  List<GeoCoordinate2D> coords = <GeoCoordinate2D>[];
  for (int i = 0; i < points.length; i++) {
    coords.add(points[i].rotate(clockwise ? rotate : -rotate, center));
  }

  bool hasBoxFit = (boxFit != BoxFit.none);
  if (hasBoxFit) {
    GeoUtility.scaleToFit(size, boxFit, coords, true, true);
    GeoUtility.recenter(
        GeoCoordinate2D(size.width / 2, size.height / 2), coords, true);
  }
  return coords;
}