getGeom function

GeometryObject getGeom(
  1. GeoJSONObject geojson
)

Get Geometry or Geometries from Feature or GeometryCollection Returns List<GeometryType> in case geojson is a GeometryCollection and a GeometryType if geojson is a simple GeometryType. example:

var feature = Feature(
  geometry: Point(
    coordinates: Position.of([110, 40])
  ));
var geom = getGeom(feature)
//= Point(coordinates: Position.of([110, 40]))

Implementation

GeometryObject getGeom(GeoJSONObject geojson) {
  if (geojson is Feature) {
    return geojson.geometry!;
  } else if (geojson is FeatureCollection) {
    throw Exception(
      'Cannot retrieve single Geometry from FeatureCollection in getGeom',
    );
  }
  return geojson as GeometryObject;
}