Message.kt 1.05 KB
package application.model

import java.time.LocalDateTime

class Message(split: List<String>) {
    val mmsi: Int? = split[0].toIntOrNull()
    val time: LocalDateTime = LocalDateTime.parse(split[1])
    val latitude: Double? = split[2].toDoubleOrNull()
    val longitude: Double? = split[3].toDoubleOrNull()
    val speedOverGround: Double? = split[4].toDoubleOrNull()
    val courseOverGround: Double? = split[5].toDoubleOrNull()
    val heading: Int? = split[6].toIntOrNull()
    val vesselName: String? = split[7]
    val imo: String? = split[8]
    val callSign: String? = split[9]
    val vesselType: Int? = split[10].toIntOrNull()
    val status: String? = split[11]
    val length: Double? = split[12].toDoubleOrNull()
    val width: Double? = split[13].toDoubleOrNull()
    val draft: Double? = split[14].toDoubleOrNull()
    val cargo: Int? = split[15].toIntOrNull()

    fun getHexColor(): String{
        var hex = Integer.toHexString(this.mmsi!!)
        if (hex.length > 6){
            hex = hex.substring(hex.length - 6)
        }
        return hex
    }
}