recenter static method

List<GeoCoordinate2D> recenter(
  1. GeoCoordinate2D center,
  2. List<GeoCoordinate2D> coords, [
  3. bool bInPlace = false
])

Center the coordinates defined in coords based on new center (or origin). If bInPlace is true, the coords array values will be updated, otherwise a new coordinate array will be returned.

Implementation

static List<GeoCoordinate2D> recenter(
    GeoCoordinate2D center, List<GeoCoordinate2D> coords,
    [bool bInPlace = false]) {
  if (bInPlace) {
    for (GeoCoordinate2D coord in coords) {
      coord.x = center.x + coord.x;
      coord.y = center.y + coord.y;
    }
    return coords;
  } else {
    List<GeoCoordinate2D> newcoords = <GeoCoordinate2D>[];
    for (GeoCoordinate2D coord in coords) {
      newcoords.add(GeoCoordinate2D(center.x + coord.x, center.y + coord.y));
    }
    return newcoords;
  }
}