From df68a9fdcc44bce10a158df2905bf566f2245627 Mon Sep 17 00:00:00 2001 From: lsagona Date: Tue, 1 Sep 2020 13:11:18 +0200 Subject: [PATCH] refactor graph minor optimization --- .../application/controller/DataPanelController.kt | 196 +++++++++++--------- src/main/kotlin/application/model/Message.kt | 4 +- src/main/kotlin/application/model/MessageData.kt | 12 +- src/main/kotlin/application/model/Vessel.kt | 180 +++++++++--------- .../kotlin/application/model/VesselGenerator.kt | 2 +- 5 files changed, 211 insertions(+), 183 deletions(-) diff --git a/src/main/kotlin/application/controller/DataPanelController.kt b/src/main/kotlin/application/controller/DataPanelController.kt index f0c6fa3..1ee21d4 100644 --- a/src/main/kotlin/application/controller/DataPanelController.kt +++ b/src/main/kotlin/application/controller/DataPanelController.kt @@ -20,35 +20,34 @@ import java.util.* class DataPanelController : Initializable, SelectedVesselListener { - private var dataList: ObservableList>> = FXCollections.observableArrayList() - private lateinit var timeData: ArrayList - - private val latitude: ArrayList = arrayListOf() - private val longitude: ArrayList = arrayListOf() - private val speedOverGround: ArrayList = arrayListOf() - private val courseOverGround: ArrayList = arrayListOf() - private val heading: ArrayList = arrayListOf() - private val vesselName: ArrayList = arrayListOf() - private val imo: ArrayList = arrayListOf() - private val callSign: ArrayList = arrayListOf() - private val vesselType: ArrayList = arrayListOf() - private val status: ArrayList = arrayListOf() - private val length: ArrayList = arrayListOf() - private val width: ArrayList = arrayListOf() - private val draft: ArrayList = arrayListOf() - private val cargo: ArrayList = arrayListOf() - - private var selectedItem: Pair>? = null + private var dataList: ObservableList = FXCollections.observableArrayList() + private lateinit var timeData: ArrayList + + private val latitude: ArrayList = arrayListOf() + private val longitude: ArrayList = arrayListOf() + private val speedOverGround: ArrayList = arrayListOf() + private val courseOverGround: ArrayList = arrayListOf() + private val heading: ArrayList = arrayListOf() + private val vesselName: ArrayList = arrayListOf() + private val imo: ArrayList = arrayListOf() + private val callSign: ArrayList = arrayListOf() + private val vesselType: ArrayList = arrayListOf() + private val status: ArrayList = arrayListOf() + private val length: ArrayList = arrayListOf() + private val width: ArrayList = arrayListOf() + private val draft: ArrayList = arrayListOf() + private val cargo: ArrayList = arrayListOf() + + private var selectedItem: String? = null @FXML - var dataListView = ListView>>() + var dataListView = ListView() @FXML var dataViewer = JavaFxDataViewer() private val plotData = PlotData() private val config = DataViewerConfiguration() - override fun initialize(location: URL?, resources: ResourceBundle?) { setObservableSelectedVesselListener() dataListView.items = dataList @@ -61,13 +60,13 @@ class DataPanelController : Initializable, SelectedVesselListener { setObservableCurrentTimeListener() dataListView.setCellFactory { - object : ListCell>?>() { - override fun updateItem(item: Pair>?, empty: Boolean) { + object : ListCell() { + override fun updateItem(item: String?, empty: Boolean) { super.updateItem(item, empty) text = if (empty) { null } else { - item?.first + item } } } @@ -98,7 +97,9 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun plot(data: Pair>?) { + + + private fun plot(data: String?) { if (data == null) { plotData.allTraces.clear() config.setxAxisTitle("") @@ -108,39 +109,62 @@ class DataPanelController : Initializable, SelectedVesselListener { dataViewer.resetPlot() return - }else if (data.second.size < timeData.size) return - - val getValueVisitorX = GetValueVisitor() - val getValueVisitorY = GetValueVisitor() - - val arrayListStringX = arrayListOf() -// val arrayListDoubleX = arrayListOf() - val arrayListStringY = arrayListOf() - val arrayListDoubleY = arrayListOf() - - for (x in 0 until timeData.size) { - timeData[x]?.accept(getValueVisitorX) - data.second[x]?.accept(getValueVisitorY) - - if (getValueVisitorY.value.toDoubleOrNull() == null) { - arrayListStringX.add(getValueVisitorX.value) - arrayListStringY.add(getValueVisitorY.value) - } else { - arrayListStringX.add(getValueVisitorX.value) - arrayListDoubleY.add(getValueVisitorY.value.toDouble()) - } } val scatterTrace = ScatterTrace() scatterTrace.traceColour = TraceColour.RED scatterTrace.traceVisibility = TraceVisibility.TRUE - val serieStringX: Array = arrayListStringX.toTypedArray() + val serieStringX: Array = timeData.toTypedArray() // val serieDoubleX: Array = arrayListDoubleX.toTypedArray() - val serieStringY: Array = arrayListStringY.toTypedArray() - val serieDoubleY: Array = arrayListDoubleY.toTypedArray() + var serieStringY: Array = arrayOf() + var serieDoubleY: Array = arrayOf() + when (data) { + "Latitude" -> { + serieDoubleY = latitude.toTypedArray() + } + "Longitude" -> { + serieDoubleY = longitude.toTypedArray() + } + "Speed Over Ground" -> { + serieDoubleY = speedOverGround.toTypedArray() + } + "Course Over Ground" -> { + serieDoubleY = courseOverGround.toTypedArray() + } + "Heading" -> { + serieDoubleY = heading.toTypedArray() + } + "Vessel Name" -> { + serieStringY = vesselName.toTypedArray() + } + "IMO" -> { + serieStringY = imo.toTypedArray() + } + "Call Sign" -> { + serieStringY = callSign.toTypedArray() + } + "Vessel Type" -> { + serieDoubleY = vesselType.toTypedArray() + } + "Status" -> { + serieStringY = status.toTypedArray() + } + "Length" -> { + serieDoubleY = length.toTypedArray() + } + "Width" -> { + serieDoubleY = width.toTypedArray() + } + "Draft" -> { + serieDoubleY = draft.toTypedArray() + } + "Cargo" -> { + serieDoubleY = cargo.toTypedArray() + } + } - if (getValueVisitorY.value.toDoubleOrNull() == null) { + if (serieStringY.isNotEmpty()) { scatterTrace.setxArray(serieStringX) scatterTrace.setyArray(serieStringY) } else { @@ -150,7 +174,7 @@ class DataPanelController : Initializable, SelectedVesselListener { config.plotTitle = "" config.setxAxisTitle("Time (s)") - config.setyAxisTitle(data.first) + config.setyAxisTitle(data) dataViewer.resetPlot() plotData.allTraces.clear() plotData.addTrace(scatterTrace) @@ -159,12 +183,11 @@ class DataPanelController : Initializable, SelectedVesselListener { } - private fun setObservableSelectedVesselListener() { observableSelectedVessel.listeners.add(this) } - private fun populateTime(vessel: Vessel): ArrayList { + private fun populateTime(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllTimeBeforeSelectedTime() } else { @@ -172,8 +195,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - - private fun populateLatitude(vessel: Vessel): ArrayList { + private fun populateLatitude(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllLatitudeBeforeSelectedTime() } else { @@ -181,7 +203,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateLongitude(vessel: Vessel): ArrayList { + private fun populateLongitude(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllLongitudeBeforeSelectedTime() } else { @@ -189,7 +211,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateSpeedOverGround(vessel: Vessel): ArrayList { + private fun populateSpeedOverGround(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllSpeedOverGroundBeforeSelectedTime() } else { @@ -197,7 +219,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateCourseOverGround(vessel: Vessel): ArrayList { + private fun populateCourseOverGround(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllCourseOverGroundBeforeSelectedTime() } else { @@ -205,7 +227,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateHeading(vessel: Vessel): ArrayList { + private fun populateHeading(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllHeadingBeforeSelectedTime() } else { @@ -213,7 +235,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateVesselName(vessel: Vessel): ArrayList { + private fun populateVesselName(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllVesselNameBeforeSelectedTime() } else { @@ -221,7 +243,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateIMO(vessel: Vessel): ArrayList { + private fun populateIMO(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllIMOBeforeSelectedTime() } else { @@ -229,7 +251,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateCallSign(vessel: Vessel): ArrayList { + private fun populateCallSign(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllCallSignBeforeSelectedTime() } else { @@ -237,7 +259,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateVesselType(vessel: Vessel): ArrayList { + private fun populateVesselType(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllVesselTypeBeforeSelectedTime() } else { @@ -245,7 +267,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateStatus(vessel: Vessel): ArrayList { + private fun populateStatus(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllStatusBeforeSelectedTime() } else { @@ -253,7 +275,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateLength(vessel: Vessel): ArrayList { + private fun populateLength(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllLengthBeforeSelectedTime() } else { @@ -261,7 +283,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateWidth(vessel: Vessel): ArrayList { + private fun populateWidth(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllWidthBeforeSelectedTime() } else { @@ -269,7 +291,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateDraft(vessel: Vessel): ArrayList { + private fun populateDraft(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllDraftBeforeSelectedTime() } else { @@ -277,7 +299,7 @@ class DataPanelController : Initializable, SelectedVesselListener { } } - private fun populateCargo(vessel: Vessel): ArrayList { + private fun populateCargo(vessel: Vessel): ArrayList { return if (observableIsReplayState.value) { vessel.getAllCargoBeforeSelectedTime() } else { @@ -286,22 +308,22 @@ class DataPanelController : Initializable, SelectedVesselListener { } private fun initDataList() { - val data = arrayListOf>>() - - data.add(Pair("Latitude", latitude)) - data.add(Pair("Longitude", longitude)) - data.add(Pair("Speed Over Ground", speedOverGround)) - data.add(Pair("Course Over Ground", courseOverGround)) - data.add(Pair("Heading", heading)) - data.add(Pair("Vessel Name", vesselName)) - data.add(Pair("IMO", imo)) - data.add(Pair("Call Sign", callSign)) - data.add(Pair("Vessel Type", vesselType)) - data.add(Pair("Status", status)) - data.add(Pair("Length", length)) - data.add(Pair("Width", width)) - data.add(Pair("Draft", draft)) - data.add(Pair("Cargo", cargo)) + val data = arrayListOf() + + data.add("Latitude") + data.add("Longitude") + data.add("Speed Over Ground") + data.add("Course Over Ground") + data.add("Heading") + data.add("Vessel Name") + data.add("IMO") + data.add("Call Sign") + data.add("Vessel Type") + data.add("Status") + data.add("Length") + data.add("Width") + data.add("Draft") + data.add("Cargo") dataList.addAll(data) } @@ -309,9 +331,9 @@ class DataPanelController : Initializable, SelectedVesselListener { private fun updateDataList(vessel: Vessel) { timeData = populateTime(vessel) - if(dataListView.selectionModel.selectedItem == null) return - - when (dataListView.selectionModel.selectedItem.first) { + if (dataListView.selectionModel.selectedItem == null) return +//NOTE: Ajouter les nouvelles donnée à la fin + when (dataListView.selectionModel.selectedItem) { "Latitude" -> { latitude.clear() latitude.addAll(populateLatitude(vessel)) diff --git a/src/main/kotlin/application/model/Message.kt b/src/main/kotlin/application/model/Message.kt index 68d7726..404c211 100644 --- a/src/main/kotlin/application/model/Message.kt +++ b/src/main/kotlin/application/model/Message.kt @@ -13,12 +13,12 @@ class Message(split: List) { val vesselName = VesselName(if (split[7] == "") null else split[7]) val imo = IMO(if (split[8] == "") null else split[8]) val callSign = CallSign(if (split[9] == "") null else split[9]) - val vesselType = VesselType(split[10].toIntOrNull()) + val vesselType = VesselType(split[10].toDoubleOrNull()) val status = Status(if (split[11] == "") null else split[11]) val length = Length(split[12].toDoubleOrNull()) val width = Width(split[13].toDoubleOrNull()) val draft = Draft(split[14].toDoubleOrNull()) - val cargo = Cargo(split[15].toIntOrNull()) + val cargo = Cargo(split[15].toDoubleOrNull()) fun getHexColorStroke(): String { var hex = Integer.toHexString(this.mmsi.value?.toInt()!!) diff --git a/src/main/kotlin/application/model/MessageData.kt b/src/main/kotlin/application/model/MessageData.kt index 2596b99..258898e 100644 --- a/src/main/kotlin/application/model/MessageData.kt +++ b/src/main/kotlin/application/model/MessageData.kt @@ -31,7 +31,13 @@ data class MMSI(val value: String?) : MessageData { override fun accept(visitor: MessageDataVisitor) = visitor.visit(messageData = this) } -data class Time(val value: LocalDateTime) : MessageData { +data class Time(val date: LocalDateTime) : MessageData { + val value: String? + + init { + value = date.toString() + } + override fun accept(visitor: MessageDataVisitor) = visitor.visit(messageData = this) } @@ -67,7 +73,7 @@ data class CallSign(val value: String?) : MessageData { override fun accept(visitor: MessageDataVisitor) = visitor.visit(messageData = this) } -data class VesselType(val value: Int?) : MessageData { +data class VesselType(val value: Double?) : MessageData { override fun accept(visitor: MessageDataVisitor) = visitor.visit(messageData = this) } @@ -87,7 +93,7 @@ data class Draft(val value: Double?) : MessageData { override fun accept(visitor: MessageDataVisitor) = visitor.visit(messageData = this) } -data class Cargo(val value: Int?) : MessageData { +data class Cargo(val value: Double?) : MessageData { override fun accept(visitor: MessageDataVisitor) = visitor.visit(messageData = this) } diff --git a/src/main/kotlin/application/model/Vessel.kt b/src/main/kotlin/application/model/Vessel.kt index 4709919..8d3d5a3 100644 --- a/src/main/kotlin/application/model/Vessel.kt +++ b/src/main/kotlin/application/model/Vessel.kt @@ -16,254 +16,254 @@ class Vessel(val mmsi: String?) { return field } - fun getAllTimeBeforeSelectedTime(): ArrayList { - val timeList = arrayListOf() + fun getAllTimeBeforeSelectedTime(): ArrayList { + val timeList = arrayListOf() messageBeforeSelectedTime.forEach { - timeList.add(it.value.time) + timeList.add(it.value.time.value!!) } return timeList } - fun getAllLatitudeBeforeSelectedTime(): ArrayList { - val latitudeList = arrayListOf() + fun getAllLatitudeBeforeSelectedTime(): ArrayList { + val latitudeList = arrayListOf() messageBeforeSelectedTime.forEach { - latitudeList.add(it.value.latitude) + latitudeList.add(it.value.latitude.value!!) } return latitudeList } - fun getAllLongitudeBeforeSelectedTime(): ArrayList { - val longitudeList = arrayListOf() + fun getAllLongitudeBeforeSelectedTime(): ArrayList { + val longitudeList = arrayListOf() messageBeforeSelectedTime.forEach { - longitudeList.add(it.value.longitude) + longitudeList.add(it.value.longitude.value!!) } return longitudeList } - fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList { - val speedOverGroundList = arrayListOf() + fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList { + val speedOverGroundList = arrayListOf() messageBeforeSelectedTime.forEach { - speedOverGroundList.add(it.value.speedOverGround) + speedOverGroundList.add(it.value.speedOverGround.value!!) } return speedOverGroundList } - fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.courseOverGround) + res.add(it.value.courseOverGround.value!!) } return res } - fun getAllHeadingBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllHeadingBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.heading) + res.add(it.value.heading.value!!) } return res } - fun getAllVesselNameBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllVesselNameBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.vesselName) + res.add(it.value.vesselName.value!!) } return res } - fun getAllIMOBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllIMOBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.imo) + res.add(it.value.imo.value!!) } return res } - fun getAllCallSignBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllCallSignBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.callSign) + res.add(it.value.callSign.value!!) } return res } - fun getAllVesselTypeBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllVesselTypeBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.vesselType) + res.add(it.value.vesselType.value!!) } return res } - fun getAllStatusBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllStatusBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.status) + res.add(it.value.status.value!!) } return res } - fun getAllLengthBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllLengthBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.length) + res.add(it.value.length.value!!) } return res } - fun getAllWidthBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllWidthBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.width) + res.add(it.value.width.value!!) } return res } - fun getAllDraftBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllDraftBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.draft) + res.add(it.value.draft.value!!) } return res } - fun getAllCargoBeforeSelectedTime(): ArrayList { - val res = arrayListOf() + fun getAllCargoBeforeSelectedTime(): ArrayList { + val res = arrayListOf() messageBeforeSelectedTime.forEach { - res.add(it.value.cargo) + res.add(it.value.cargo.value!!) } return res } - fun getAllTime(): ArrayList { - val timeList = arrayListOf() + fun getAllTime(): ArrayList { + val timeList = arrayListOf() messages.forEach { - timeList.add(it.value.time) + timeList.add(it.value.time.value!!) } return timeList } - fun getAllLatitude(): ArrayList { - val latitudeList = arrayListOf() + fun getAllLatitude(): ArrayList { + val latitudeList = arrayListOf() messages.forEach { - latitudeList.add(it.value.latitude) + latitudeList.add(it.value.latitude.value!!) } return latitudeList } - fun getAllLongitude(): ArrayList { - val longitudeList = arrayListOf() + fun getAllLongitude(): ArrayList { + val longitudeList = arrayListOf() messages.forEach { - longitudeList.add(it.value.longitude) + longitudeList.add(it.value.longitude.value!!) } return longitudeList } - fun getAllSpeedOverGround(): ArrayList { - val speedOverGroundList = arrayListOf() + fun getAllSpeedOverGround(): ArrayList { + val speedOverGroundList = arrayListOf() messages.forEach { - speedOverGroundList.add(it.value.speedOverGround) + speedOverGroundList.add(it.value.speedOverGround.value!!) } return speedOverGroundList } - fun getAllCourseOverGround(): ArrayList { - val res = arrayListOf() + fun getAllCourseOverGround(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.courseOverGround) + res.add(it.value.courseOverGround.value!!) } return res } - fun getAllHeading(): ArrayList { - val res = arrayListOf() + fun getAllHeading(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.heading) + res.add(it.value.heading.value!!) } return res } - fun getAllVesselName(): ArrayList { - val res = arrayListOf() + fun getAllVesselName(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.vesselName) + res.add(it.value.vesselName.value!!) } return res } - fun getAllIMO(): ArrayList { - val res = arrayListOf() + fun getAllIMO(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.imo) + res.add(it.value.imo.value!!) } return res } - fun getAllCallSign(): ArrayList { - val res = arrayListOf() + fun getAllCallSign(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.callSign) + res.add(it.value.callSign.value!!) } return res } - fun getAllVesselType(): ArrayList { - val res = arrayListOf() + fun getAllVesselType(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.vesselType) + res.add(it.value.vesselType.value!!) } return res } - fun getAllStatus(): ArrayList { - val res = arrayListOf() + fun getAllStatus(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.status) + res.add(it.value.status.value!!) } return res } - fun getAllLength(): ArrayList { - val res = arrayListOf() + fun getAllLength(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.length) + res.add(it.value.length.value!!) } return res } - fun getAllWidth(): ArrayList { - val res = arrayListOf() + fun getAllWidth(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.width) + res.add(it.value.width.value!!) } return res } - fun getAllDraft(): ArrayList { - val res = arrayListOf() + fun getAllDraft(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.draft) + res.add(it.value.draft.value!!) } return res } - fun getAllCargo(): ArrayList { - val res = arrayListOf() + fun getAllCargo(): ArrayList { + val res = arrayListOf() messages.forEach { - res.add(it.value.cargo) + res.add(it.value.cargo.value!!) } return res } diff --git a/src/main/kotlin/application/model/VesselGenerator.kt b/src/main/kotlin/application/model/VesselGenerator.kt index 522fa3a..9d7ba50 100644 --- a/src/main/kotlin/application/model/VesselGenerator.kt +++ b/src/main/kotlin/application/model/VesselGenerator.kt @@ -18,7 +18,7 @@ fun createVesselCollection(file: File): SortedMap { if (!vessels.containsKey(message.mmsi.value)) { vessels[message.mmsi.value] = Vessel(message.mmsi.value!!) } - val time = message.time.value.toEpochSecond(ZoneOffset.UTC) + val time = message.time.date.toEpochSecond(ZoneOffset.UTC) vessels[message.mmsi.value]?.messages?.set(time, message) if (time > maxTime) { maxTime = time -- 1.7.10.4