decodeCollection<T extends Geometry> static method
GeometryCollection<T>
decodeCollection<T extends Geometry>(
- Uint8List bytes, {
- BinaryFormat<
GeometryContent> format = WKB.geometry, - CoordRefSys? crs,
- Map<
String, dynamic> ? options,
Decodes a geometry collection with elements of T
from bytes
conforming
to format
.
When format
is not given, then the geometry format of WKB 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 binary
input. When data itself have CRS information it overrides this value.
Format or decoder implementation specific options can be set by options
.
See also decodeCollectionHex to decode from bytes represented as a hex string.
Implementation
static GeometryCollection<T> decodeCollection<T extends Geometry>(
Uint8List bytes, {
BinaryFormat<GeometryContent> format = WKB.geometry,
CoordRefSys? crs,
Map<String, dynamic>? options,
}) {
GeometryCollection<T>? result;
// get geometry builder to build a geometry collection containing E
final builder =
GeometryBuilder<GeometryCollection<T>, T>._((geometry, {name}) {
if (result != null) {
throw const FormatException('Already decoded one');
}
result = geometry;
});
// get decoder with the content decoded sent to builder
final decoder = format.decoder(builder, options: options, crs: crs);
// decode and return result if succesful
decoder.decodeBytes(bytes);
if (result != null) {
return result!;
} else {
throw const FormatException('Could not decode bytes');
}
}