Blame view

src/main/kotlin/application/model/VesselGenerator.kt 721 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
16
  
      file.forEachLine {
          val arrayMessage = it.split(",")
          if (arrayMessage[0].toIntOrNull() !== null) {
              val message = Message(arrayMessage)
              messages.add(message)
              if (!vessels.containsKey(message.mmsi)){
2bbe36a1b   lsagona   addd the possibil...
17
                  vessels[message.mmsi] = Vessel(message.mmsi!!)
b350f9dfe   lsagona   import vessels an...
18
19
20
21
22
23
24
25
              }
              vessels[message.mmsi]?.messages?.set(message.time, message)
          }
  
      }
  
      return vessels
  }