feature function
Returns the GeoJSON Feature or FeatureCollection for the specified object
in the given topology.
If the object is a GeometryCollection, a FeatureCollection is returned, and
each geometry in the collection is mapped to a Feature. Otherwise, a Feature
is returned. The returned feature is a shallow copy of the source object:
they may share identifiers, bounding boxes, properties and coordinates.
Some examples:
- A point is mapped to a feature with a geometry object of type “Point”.
- Likewise for line strings, polygons, and other simple geometries.
- A null geometry object (of type null in TopoJSON) is mapped to a feature with a null geometry object.
- A geometry collection of points is mapped to a feature collection of features, each with a point geometry.
- A geometry collection of geometry collections is mapped to a feature collection of features, each with a geometry collection.
Implementation
Map<String?, dynamic> feature(
Map<String?, dynamic> topology, Map<String?, dynamic> object) =>
(object["type"] as String?) == "GeometryCollection"
? {
"type": "FeatureCollection",
"features": (object["geometries"] as List<Map<String?, dynamic>>)
.map((o) => _feature(topology, o))
.toList()
}
: _feature(topology, object);