write method

  1. @override
void write(
  1. LByteBuffer buffer,
  2. Object geometry
)
override

Write the geometry into the ByteBuffer. The position, byteOrder, and limit are all set. The handler is not responsible for writing the record or shape type integer.

@param buffer The ByteBuffer to write to. @param geometry The geometry to write.

Implementation

@override
void write(LByteBuffer buffer, Object geometry) {
  Point point = geometry as Point;
  Coordinate c = point.getCoordinate();

  buffer.putDouble64(c.x);
  buffer.putDouble64(c.y);

  if (shapeType == ShapeType.POINTZ) {
    if (c.getZ().isNaN) {
      // nan means not defined
      buffer.putDouble64(0.0);
    } else {
      buffer.putDouble64(c.getZ());
    }
  }

  if ((shapeType == ShapeType.POINTZ) || (shapeType == ShapeType.POINTM)) {
    double m = point.getCoordinateSequence().getM(0);
    buffer.putDouble64(m.isNaN ? 0.0 : m); // M
  }
}