fromData<R extends FeatureObject, E extends Geometry> static method
R
fromData<R extends FeatureObject, E extends Geometry>(
- Map<
String, dynamic> data, { - TextReaderFormat<
FeatureContent> format = GeoJSON.feature, - CoordRefSys? crs,
- Map<
String, dynamic> ? options,
Decode a feature object of R
from data
conforming to format
.
Data should be a JSON Object as decoded by the standard json.decode()
.
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
.
Implementation
static R fromData<R extends FeatureObject, E extends Geometry>(
Map<String, dynamic> data, {
TextReaderFormat<FeatureContent> format = GeoJSON.feature,
CoordRefSys? crs,
Map<String, dynamic>? options,
}) {
R? result;
// get feature builder to build a feature object of R
final builder = FeatureBuilder<R, E>._((object, {name}) {
if (result != null) {
throw const FormatException('Already decoded one');
}
result = object;
});
// get decoder with the content decoded sent to builder
final decoder = format.decoder(
builder,
crs: crs,
options: options,
);
// decode and return result if succesful
decoder.decodeData(data);
if (result != null) {
return result!;
} else {
throw const FormatException('Could not decode text');
}
}