cellCentroid method

Point? cellCentroid(
  1. int i
)

Returns the centroid of cell i.

Implementation

Point? cellCentroid(int i) {
  final polygon = cellPolygon(i);
  if (polygon == null || polygon.isEmpty) return null;

  double cx = 0, cy = 0;
  for (final p in polygon) {
    cx += p.x;
    cy += p.y;
  }
  return Point(cx / polygon.length, cy / polygon.length);
}