toBytes method

Uint8List toBytes({
  1. BinaryFormat<GeometryContent> format = WKB.geometry,
  2. Endian? endian,
  3. CoordRefSys? crs,
  4. Map<String, dynamic>? options,
})

The binary representation of this geometry object, with format applied.

When format is not given, then the geometry format of WKB is used as a default.

An optional endian specifies endianness for byte sequences written. Some encoders might ignore this, and some has a default value for it.

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 output. When data itself have CRS information it overrides this value.

Other format or encoder implementation specific options can be set by options.

See also toBytesHex to get the binary representation as a hex string.

Implementation

Uint8List toBytes({
  BinaryFormat<GeometryContent> format = WKB.geometry,
  Endian? endian,
  CoordRefSys? crs,
  Map<String, dynamic>? options,
}) {
  final encoder = format.encoder(endian: endian, crs: crs, options: options);
  writeTo(encoder.writer);
  return encoder.toBytes();
}