TerrainReport.parse constructor

TerrainReport.parse(
  1. ByteData data_
)

Implementation

factory TerrainReport.parse(ByteData data_) {
  if (data_.lengthInBytes < TerrainReport.mavlinkEncodedLength) {
    var len = TerrainReport.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var lat = data_.getInt32(0, Endian.little);
  var lon = data_.getInt32(4, Endian.little);
  var terrainHeight = data_.getFloat32(8, Endian.little);
  var currentHeight = data_.getFloat32(12, Endian.little);
  var spacing = data_.getUint16(16, Endian.little);
  var pending = data_.getUint16(18, Endian.little);
  var loaded = data_.getUint16(20, Endian.little);

  return TerrainReport(
      lat: lat,
      lon: lon,
      terrainHeight: terrainHeight,
      currentHeight: currentHeight,
      spacing: spacing,
      pending: pending,
      loaded: loaded);
}