GeomMultiPolygon.fromJson constructor

GeomMultiPolygon.fromJson(
  1. Map<String, dynamic> inputJson, {
  2. bool withInvertedCoords = false,
})

Crée une instance à partir d'un GeoJSON.

Implementation

GeomMultiPolygon.fromJson(Map<String, dynamic> inputJson, {bool withInvertedCoords = false}) {
  final List coordinates = inputJson['coordinates'];
  List<GeomPolygon> polygons = [];

  // Traite chaque ensemble de coordonnées pour les MultiPolygon.
  for (var polygonCoordinates in coordinates) {
    Map<String, dynamic> polygonJson = {
      'type': 'Polygon',
      'coordinates': polygonCoordinates,
    };

    // Utilise la classe GeomPolygon pour créer chaque Polygon.
    final polygon = GeomPolygon.fromJson(polygonJson, withInvertedCoords: withInvertedCoords);
    polygons.add(polygon);
  }

  multiPolygons = polygons;
}