emptyGeometry method

  1. @override
void emptyGeometry(
  1. Geom type, {
  2. String? name,
})
override

Writes an empty geometry of type.

Use name to specify a name for a geometry (when applicable).

Note: normally it might be a good idea to avoid "empty geometries" as those are encoded and decoded with different ways in different formats.

An example to write an "empty" point:

  content.emptyGeometry(Geom.point);

Implementation

@override
void emptyGeometry(Geom type, {String? name}) {
  // as there is no a specific "empty-geometry" class, empty geometries are
  // created as "normal" concrete geometry objects with some tricks
  switch (type) {
    case Geom.point:
      // empty point with x and y set to double.nan
      point(Position.view(const [double.nan, double.nan]));
      break;
    case Geom.lineString:
      // empty linestring with empty chain of points
      lineString(PositionSeries.empty());
      break;
    case Geom.polygon:
      // empty polygon with empty list of liner rings
      polygon(const []);
      break;
    case Geom.multiPoint:
      // empty multi point without any points
      multiPoint(const []);
      break;
    case Geom.multiLineString:
      // empty multi linestring without any linestrings
      multiLineString(const []);
      break;
    case Geom.multiPolygon:
      // empty multi polygon without any polygons
      multiPolygon(const []);
      break;
    case Geom.geometryCollection:
      // empty geometry collection without any geometries
      geometryCollection(
        (geom) => {
          // nop
        },
      );
      break;
  }
}