esriToGeo method

Map<String, Object?> esriToGeo(
  1. Map<String, Object?> esrijson
)

This script will convert an EsriJSON dictionary to a GeoJSON dictionary

send a GeoJSON feature: feature = json.loads(esri_input) result = esri_to_geo(feature) optional: response = json.dumps(result)

Still in the works:

  • parse all geometry types

Implementation

Map<String, Object?> esriToGeo(Map<String, Object?> esrijson) {
  Map<String, Object?> geojson = <String, Object?>{};
  List<Map<String, Object?>> features =
      esrijson["features"] as List<Map<String, Object?>>;
  String esriGeomType = '${esrijson["geometryType"]}';
  geojson["type"] = "FeatureCollection";

  List<Map<String, Object?>> feats = <Map<String, Object?>>[];
  for (Map<String, Object?> feat in features) {
    feats.add(_extract(feat, esriGeomType));
  }

  geojson["features"] = feats;

  return geojson;
}