Closed armantorkzaban closed 2 years ago
how should this function behave with GeometryObject
, which can be a GeometryCollection
or a concrete geometry type?
Suggestion:
/// Get Geometry or Geometries from [Feature] or [GeometryType]
/// Returns [List<GeometryType>] in case geojson is a [GeometryCollection] and a
/// [GeometryType] if geojson is a simple [GeometryType].
/// example:
/// ```dart
/// var feature = Feature(
/// geometry: Point(
/// coordinates: Position.of([110, 40])
/// ));
/// var geom = getGeom(feature)
/// //= Point(coordinates: Position.of([110, 40]))
getGeom(GeoJSONObject geojson) {
if (geojson is Feature) {
return (geojson).geometry;
} else if (geojson is GeometryCollection) {
return geojson.geometries;
}
return geojson;
}
This is incomplete. No return type specified, cases like FeatureCollection are not handled. Otherwise okay.
decided against implementation.
The point is to get the GeometryType out of a GeoJSONObject which can be either Feature or GeometryType. This happens in various boolean functions.