Vessel.kt 7.22 KB
package application.model

import java.util.*

class Vessel(val mmsi: String?) {
    val messages: SortedMap<Long, Message> = sortedMapOf()
    private val messageBeforeSelectedTime: Map<Long, Message>
        get() {
            return messages.filter { observableCurrentTime.value > it.key }
        }

    var messageToDisplay: Message? = null
        get() {
            field =
                messages.asSequence().map { it }.firstOrNull { observableCurrentTime.value < it.key }.let { it?.value }
            return field
        }

    fun getAllTimeBeforeSelectedTime(): ArrayList<MessageData?> {
        val timeList = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            timeList.add(it.value.time)
        }

        return timeList
    }

    fun getAllLatitudeBeforeSelectedTime(): ArrayList<MessageData?> {
        val latitudeList = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            latitudeList.add(it.value.latitude)
        }

        return latitudeList
    }

    fun getAllLongitudeBeforeSelectedTime(): ArrayList<MessageData?> {
        val longitudeList = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            longitudeList.add(it.value.longitude)
        }

        return longitudeList
    }

    fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList<MessageData?> {
        val speedOverGroundList = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            speedOverGroundList.add(it.value.speedOverGround)
        }

        return speedOverGroundList
    }

    fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.courseOverGround)
        }

        return res
    }

    fun getAllHeadingBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.heading)
        }

        return res
    }

    fun getAllVesselNameBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.vesselName)
        }
        return res
    }

    fun getAllIMOBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.imo)
        }
        return res
    }

    fun getAllCallSignBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.callSign)
        }
        return res
    }

    fun getAllVesselTypeBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.vesselType)
        }
        return res
    }

    fun getAllStatusBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.status)
        }
        return res
    }

    fun getAllLengthBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.length)
        }
        return res
    }

    fun getAllWidthBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.width)
        }
        return res
    }

    fun getAllDraftBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.draft)
        }
        return res
    }

    fun getAllCargoBeforeSelectedTime(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messageBeforeSelectedTime.forEach {
            res.add(it.value.cargo)
        }
        return res
    }

    fun getAllTime(): ArrayList<MessageData?> {
        val timeList = arrayListOf<MessageData?>()
        messages.forEach {
            timeList.add(it.value.time)
        }

        return timeList
    }

    fun getAllLatitude(): ArrayList<MessageData?> {
        val latitudeList = arrayListOf<MessageData?>()
        messages.forEach {
            latitudeList.add(it.value.latitude)
        }

        return latitudeList
    }

    fun getAllLongitude(): ArrayList<MessageData?> {
        val longitudeList = arrayListOf<MessageData?>()
        messages.forEach {
            longitudeList.add(it.value.longitude)
        }

        return longitudeList
    }

    fun getAllSpeedOverGround(): ArrayList<MessageData?> {
        val speedOverGroundList = arrayListOf<MessageData?>()
        messages.forEach {
            speedOverGroundList.add(it.value.speedOverGround)
        }

        return speedOverGroundList
    }

    fun getAllCourseOverGround(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.courseOverGround)
        }

        return res
    }

    fun getAllHeading(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.heading)
        }

        return res
    }

    fun getAllVesselName(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.vesselName)
        }
        return res
    }

    fun getAllIMO(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.imo)
        }
        return res
    }

    fun getAllCallSign(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.callSign)
        }
        return res
    }

    fun getAllVesselType(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.vesselType)
        }
        return res
    }

    fun getAllStatus(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.status)
        }
        return res
    }

    fun getAllLength(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.length)
        }
        return res
    }

    fun getAllWidth(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.width)
        }
        return res
    }

    fun getAllDraft(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.draft)
        }
        return res
    }

    fun getAllCargo(): ArrayList<MessageData?> {
        val res = arrayListOf<MessageData?>()
        messages.forEach {
            res.add(it.value.cargo)
        }
        return res
    }

    companion object {
        var maxTime: Long = 0
        var minTime: Long = 0
    }

}