Blame view

src/main/kotlin/application/model/VesselGenerator.kt 657 Bytes
b350f9dfe   lsagona   import vessels an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  package application.model
  
  import java.io.File
  
  fun createVesselCollection(file: File) : MutableMap<Int?, Vessel> {
      val messages : ArrayList<Message> = arrayListOf()
      val vessels: MutableMap<Int?, Vessel> = mutableMapOf()
  
      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
  }