center function

Feature<Point> center(
  1. GeoJSONObject geoJSON, {
  2. dynamic id,
  3. BBox? bbox,
  4. Map<String, dynamic>? properties,
})

Takes a Feature or a FeatureCollection and returns the absolute center point of all feature(s).

Implementation

Feature<Point> center(
  GeoJSONObject geoJSON, {
  dynamic id,
  BBox? bbox,
  Map<String, dynamic>? properties,
}) {
  final BBox ext = t.bbox(geoJSON);
  final num x = (ext[0]! + ext[2]!) / 2;
  final num y = (ext[1]! + ext[3]!) / 2;

  return Feature<Point>(
    id: id,
    bbox: bbox,
    properties: properties,
    geometry: Point(coordinates: Position.named(lat: y, lng: x)),
  );
}