read method

  1. @override
dynamic read(
  1. LByteBuffer buffer,
  2. ShapeType type,
  3. bool flatGeometry
)
override

Read a geometry from the ByteBuffer. The buffer's position, byteOrder, and limit are set to that which is needed. The record has been read as well as the shape type integer. The handler need not worry about reading unused information as the ShapefileReader will correctly adjust the buffer position after this call.

@param buffer The ByteBuffer to read from. @return A geometry object.

Implementation

@override
dynamic read(LByteBuffer buffer, ShapeType type, bool flatGeometry) {
  if (type == ShapeType.NULL) {
    return createNull();
  }

  Coordinate c;
  if (shapeType == ShapeType.POINTZ) {
    c = CoordinateXYZM.empty();
  } else if (shapeType == ShapeType.POINTM) {
    c = CoordinateXYM.empty();
  } else {
    c = CoordinateXY();
  }
  c.setX(buffer.getDouble64());
  c.setY(buffer.getDouble64());

  if (shapeType == ShapeType.POINTM) {
    c.setM(buffer.getDouble64());
  }

  if (shapeType == ShapeType.POINTZ) {
    c.setZ(buffer.getDouble64());
    c.setM(buffer.getDouble64());
  }

  return geometryFactory.createPoint(c);
}