Message.kt
1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 getHexColorStroke(): String{
var hex = Integer.toHexString(this.mmsi!!)
if (hex.length > 6){
hex = hex.substring(hex.length - 6)
}
return hex
}
fun getHexColorFill(): String{
var hex = Integer.toHexString(this.mmsi!! - 50)
if (hex.length > 6){
hex = hex.substring(hex.length - 6)
}
return hex
}
}