fromData<T extends Geometry> static method
FeatureCollection<Feature<T> >
fromData<T extends Geometry>(
- Map<
String, dynamic> data, { - TextReaderFormat<
FeatureContent> format = GeoJSON.feature, - CoordRefSys? crs,
- Map<
String, dynamic> ? options,
Decodes a feature collection from data
conforming to format
.
Data should be a JSON Object as decoded by the standard json.decode()
.
Feature items on a collection contain a geometry of T
.
When format
is not given, then the feature format of GeoJSON is used
as a default.
Use crs
to give hints (like axis order, and whether x and y must
be swapped when read in) about coordinate reference system in text input.
Format or decoder implementation specific options can be set by options
.
Examples:
// a feature collection with two features
FeatureCollection.fromData(
format: GeoJSON.feature,
{
'type': 'FeatureCollection',
'features': [
// a feature with an id and a point geometry (2D coordinates)
{
'type': 'Feature',
'id': '1',
'geometry': {
'type': 'Point',
'coordinates': [10.0, 20.0]
}
},
// a feature with properties and a line string geometry (3D)
{
'type': 'Feature',
'geometry': {
'type': 'LineString',
'coordinates': [
[10.0, 20.0, 30.0],
[12.5, 22.5, 32.5],
[15.0, 25.0, 35.0]
]
},
'properties': {
'textProp': 'this is property value',
'intProp': 10,
'doubleProp': 29.5,
'arrayProp': ['foo', 'bar']
}
}
]
},
);
Implementation
static FeatureCollection<Feature<T>> fromData<T extends Geometry>(
Map<String, dynamic> data, {
TextReaderFormat<FeatureContent> format = GeoJSON.feature,
CoordRefSys? crs,
Map<String, dynamic>? options,
}) =>
FeatureBuilder.fromData<FeatureCollection<Feature<T>>, T>(
data,
format: format,
crs: crs,
options: options,
);