AisVessel.parse constructor

AisVessel.parse(
  1. ByteData data_
)

Implementation

factory AisVessel.parse(ByteData data_) {
  if (data_.lengthInBytes < AisVessel.mavlinkEncodedLength) {
    var len = AisVessel.mavlinkEncodedLength - data_.lengthInBytes;
    var d = data_.buffer.asUint8List() + List<int>.filled(len, 0);
    data_ = Uint8List.fromList(d).buffer.asByteData();
  }
  var mmsi = data_.getUint32(0, Endian.little);
  var lat = data_.getInt32(4, Endian.little);
  var lon = data_.getInt32(8, Endian.little);
  var cog = data_.getUint16(12, Endian.little);
  var heading = data_.getUint16(14, Endian.little);
  var velocity = data_.getUint16(16, Endian.little);
  var dimensionBow = data_.getUint16(18, Endian.little);
  var dimensionStern = data_.getUint16(20, Endian.little);
  var tslc = data_.getUint16(22, Endian.little);
  var flags = data_.getUint16(24, Endian.little);
  var turnRate = data_.getInt8(26);
  var navigationalStatus = data_.getUint8(27);
  var type = data_.getUint8(28);
  var dimensionPort = data_.getUint8(29);
  var dimensionStarboard = data_.getUint8(30);
  var callsign = MavlinkMessage.asInt8List(data_, 31, 7);
  var name = MavlinkMessage.asInt8List(data_, 38, 20);

  return AisVessel(
      mmsi: mmsi,
      lat: lat,
      lon: lon,
      cog: cog,
      heading: heading,
      velocity: velocity,
      dimensionBow: dimensionBow,
      dimensionStern: dimensionStern,
      tslc: tslc,
      flags: flags,
      turnRate: turnRate,
      navigationalStatus: navigationalStatus,
      type: type,
      dimensionPort: dimensionPort,
      dimensionStarboard: dimensionStarboard,
      callsign: callsign,
      name: name);
}