Blame view

src/main/kotlin/application/model/VesselGenerator.kt 751 Bytes
b350f9dfe   lsagona   import vessels an...
1
2
3
  package application.model
  
  import java.io.File
53f01ecc3   lsagona   display message o...
4
5
  import java.util.*
  import kotlin.collections.ArrayList
b350f9dfe   lsagona   import vessels an...
6

53f01ecc3   lsagona   display message o...
7
  fun createVesselCollection(file: File) : SortedMap<Int, Vessel> {
b350f9dfe   lsagona   import vessels an...
8
      val messages : ArrayList<Message> = arrayListOf()
53f01ecc3   lsagona   display message o...
9
      val vessels: SortedMap<Int, Vessel> = sortedMapOf()
b350f9dfe   lsagona   import vessels an...
10
11
12
13
14
15
  
      file.forEachLine {
          val arrayMessage = it.split(",")
          if (arrayMessage[0].toIntOrNull() !== null) {
              val message = Message(arrayMessage)
              messages.add(message)
513c0341c   lsagona   add chart
16
17
              if (!vessels.containsKey(message.mmsi.value)){
                  vessels[message.mmsi.value] = Vessel(message.mmsi.value!!)
b350f9dfe   lsagona   import vessels an...
18
              }
513c0341c   lsagona   add chart
19
              vessels[message.mmsi.value]?.messages?.set(message.time.value, message)
b350f9dfe   lsagona   import vessels an...
20
21
22
23
24
25
          }
  
      }
  
      return vessels
  }