Blame view
src/main/kotlin/application/model/VesselGenerator.kt
707 Bytes
b350f9dfe import vessels an... |
1 2 3 |
package application.model import java.io.File |
53f01ecc3 display message o... |
4 5 |
import java.util.* import kotlin.collections.ArrayList |
b350f9dfe import vessels an... |
6 |
|
53f01ecc3 display message o... |
7 |
fun createVesselCollection(file: File) : SortedMap<Int, Vessel> { |
b350f9dfe import vessels an... |
8 |
val messages : ArrayList<Message> = arrayListOf() |
53f01ecc3 display message o... |
9 |
val vessels: SortedMap<Int, Vessel> = sortedMapOf() |
b350f9dfe import vessels an... |
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
file.forEachLine { val arrayMessage = it.split(",") if (arrayMessage[0].toIntOrNull() !== null) { val message = Message(arrayMessage) messages.add(message) if (!vessels.containsKey(message.mmsi)){ vessels[message.mmsi] = Vessel() } vessels[message.mmsi]?.messages?.set(message.time, message) } } return vessels } |