Commit ea7eacbe63ae8f1b5e121118d9d4dced300a2f51
1 parent
a6a8df6ff5
Exists in
master
and in
1 other branch
fix NPE
Showing 1 changed file with 60 additions and 29 deletions Inline Diff
src/main/kotlin/application/model/Vessel.kt
View file @
ea7eacb
package application.model | 1 | 1 | package application.model | |
2 | 2 | |||
import java.util.* | 3 | 3 | import java.util.* | |
4 | 4 | |||
class Vessel(val mmsi: String?) { | 5 | 5 | class Vessel(val mmsi: String?) { | |
val messages: SortedMap<Long, Message> = sortedMapOf() | 6 | 6 | val messages: SortedMap<Long, Message> = sortedMapOf() | |
private val messageBeforeSelectedTime: Map<Long, Message> | 7 | 7 | private val messageBeforeSelectedTime: Map<Long, Message> | |
get() { | 8 | 8 | get() { | |
return messages.filter { observableCurrentTime.value > it.key } | 9 | 9 | return messages.filter { observableCurrentTime.value > it.key } | |
} | 10 | 10 | } | |
11 | 11 | |||
var messageToDisplay: Message? = null | 12 | 12 | var messageToDisplay: Message? = null | |
get() { | 13 | 13 | get() { | |
field = | 14 | 14 | field = | |
messages.asSequence().map { it }.firstOrNull { observableCurrentTime.value < it.key }.let { it?.value } | 15 | 15 | messages.asSequence().map { it }.firstOrNull { observableCurrentTime.value < it.key }.let { it?.value } | |
return field | 16 | 16 | return field | |
} | 17 | 17 | } | |
18 | 18 | |||
fun getAllTimeBeforeSelectedTime(): ArrayList<String> { | 19 | 19 | fun getAllTimeBeforeSelectedTime(): ArrayList<String> { | |
val timeList = arrayListOf<String>() | 20 | 20 | val timeList = arrayListOf<String>() | |
messageBeforeSelectedTime.forEach { | 21 | 21 | messageBeforeSelectedTime.forEach { | |
timeList.add(it.value.time.value!!) | 22 | 22 | if (it.value.time.value != null) | |
23 | timeList.add(it.value.time.value!!) | |||
} | 23 | 24 | } | |
24 | 25 | |||
return timeList | 25 | 26 | return timeList | |
} | 26 | 27 | } | |
27 | 28 | |||
fun getAllLatitudeBeforeSelectedTime(): ArrayList<Double> { | 28 | 29 | fun getAllLatitudeBeforeSelectedTime(): ArrayList<Double> { | |
val latitudeList = arrayListOf<Double>() | 29 | 30 | val latitudeList = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 30 | 31 | messageBeforeSelectedTime.forEach { | |
latitudeList.add(it.value.latitude.value!!) | 31 | 32 | if (it.value.latitude.value != null) | |
33 | latitudeList.add(it.value.latitude.value!!) | |||
} | 32 | 34 | } | |
33 | 35 | |||
return latitudeList | 34 | 36 | return latitudeList | |
} | 35 | 37 | } | |
36 | 38 | |||
fun getAllLongitudeBeforeSelectedTime(): ArrayList<Double> { | 37 | 39 | fun getAllLongitudeBeforeSelectedTime(): ArrayList<Double> { | |
val longitudeList = arrayListOf<Double>() | 38 | 40 | val longitudeList = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 39 | 41 | messageBeforeSelectedTime.forEach { | |
longitudeList.add(it.value.longitude.value!!) | 40 | 42 | if (it.value.longitude.value != null) | |
43 | longitudeList.add(it.value.longitude.value!!) | |||
} | 41 | 44 | } | |
42 | 45 | |||
return longitudeList | 43 | 46 | return longitudeList | |
} | 44 | 47 | } | |
45 | 48 | |||
fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList<Double> { | 46 | 49 | fun getAllSpeedOverGroundBeforeSelectedTime(): ArrayList<Double> { | |
val speedOverGroundList = arrayListOf<Double>() | 47 | 50 | val speedOverGroundList = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 48 | 51 | messageBeforeSelectedTime.forEach { | |
speedOverGroundList.add(it.value.speedOverGround.value!!) | 49 | 52 | if (it.value.speedOverGround.value != null) | |
53 | speedOverGroundList.add(it.value.speedOverGround.value!!) | |||
} | 50 | 54 | } | |
51 | 55 | |||
return speedOverGroundList | 52 | 56 | return speedOverGroundList | |
} | 53 | 57 | } | |
54 | 58 | |||
fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList<Double> { | 55 | 59 | fun getAllCourseOverGroundBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 56 | 60 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 57 | 61 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.courseOverGround.value!!) | 58 | 62 | if (it.value.courseOverGround.value != null) | |
63 | res.add(it.value.courseOverGround.value!!) | |||
} | 59 | 64 | } | |
60 | 65 | |||
return res | 61 | 66 | return res | |
} | 62 | 67 | } | |
63 | 68 | |||
fun getAllHeadingBeforeSelectedTime(): ArrayList<Double> { | 64 | 69 | fun getAllHeadingBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 65 | 70 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 66 | 71 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.heading.value!!) | 67 | 72 | if (it.value.heading.value != null) | |
73 | res.add(it.value.heading.value!!) | |||
} | 68 | 74 | } | |
69 | 75 | |||
return res | 70 | 76 | return res | |
} | 71 | 77 | } | |
72 | 78 | |||
fun getAllVesselNameBeforeSelectedTime(): ArrayList<String> { | 73 | 79 | fun getAllVesselNameBeforeSelectedTime(): ArrayList<String> { | |
val res = arrayListOf<String>() | 74 | 80 | val res = arrayListOf<String>() | |
messageBeforeSelectedTime.forEach { | 75 | 81 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.vesselName.value!!) | 76 | 82 | if (it.value.vesselName.value != null) | |
83 | res.add(it.value.vesselName.value!!) | |||
} | 77 | 84 | } | |
return res | 78 | 85 | return res | |
} | 79 | 86 | } | |
80 | 87 | |||
fun getAllIMOBeforeSelectedTime(): ArrayList<String> { | 81 | 88 | fun getAllIMOBeforeSelectedTime(): ArrayList<String> { | |
val res = arrayListOf<String>() | 82 | 89 | val res = arrayListOf<String>() | |
messageBeforeSelectedTime.forEach { | 83 | 90 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.imo.value!!) | 84 | 91 | if (it.value.imo.value != null) | |
92 | res.add(it.value.imo.value!!) | |||
} | 85 | 93 | } | |
return res | 86 | 94 | return res | |
} | 87 | 95 | } | |
88 | 96 | |||
fun getAllCallSignBeforeSelectedTime(): ArrayList<String> { | 89 | 97 | fun getAllCallSignBeforeSelectedTime(): ArrayList<String> { | |
val res = arrayListOf<String>() | 90 | 98 | val res = arrayListOf<String>() | |
messageBeforeSelectedTime.forEach { | 91 | 99 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.callSign.value!!) | 92 | 100 | if (it.value.callSign.value != null) | |
101 | res.add(it.value.callSign.value!!) | |||
} | 93 | 102 | } | |
return res | 94 | 103 | return res | |
} | 95 | 104 | } | |
96 | 105 | |||
fun getAllVesselTypeBeforeSelectedTime(): ArrayList<Double> { | 97 | 106 | fun getAllVesselTypeBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 98 | 107 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 99 | 108 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.vesselType.value!!) | 100 | 109 | if (it.value.vesselType.value != null) | |
110 | res.add(it.value.vesselType.value!!) | |||
} | 101 | 111 | } | |
return res | 102 | 112 | return res | |
} | 103 | 113 | } | |
104 | 114 | |||
fun getAllStatusBeforeSelectedTime(): ArrayList<String> { | 105 | 115 | fun getAllStatusBeforeSelectedTime(): ArrayList<String> { | |
val res = arrayListOf<String>() | 106 | 116 | val res = arrayListOf<String>() | |
messageBeforeSelectedTime.forEach { | 107 | 117 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.status.value!!) | 108 | 118 | if (it.value.status.value != null) | |
119 | res.add(it.value.status.value!!) | |||
} | 109 | 120 | } | |
return res | 110 | 121 | return res | |
} | 111 | 122 | } | |
112 | 123 | |||
fun getAllLengthBeforeSelectedTime(): ArrayList<Double> { | 113 | 124 | fun getAllLengthBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 114 | 125 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 115 | 126 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.length.value!!) | 116 | 127 | if (it.value.length.value != null) | |
128 | res.add(it.value.length.value!!) | |||
} | 117 | 129 | } | |
return res | 118 | 130 | return res | |
} | 119 | 131 | } | |
120 | 132 | |||
fun getAllWidthBeforeSelectedTime(): ArrayList<Double> { | 121 | 133 | fun getAllWidthBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 122 | 134 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 123 | 135 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.width.value!!) | 124 | 136 | if (it.value.width.value != null) | |
137 | res.add(it.value.width.value!!) | |||
} | 125 | 138 | } | |
return res | 126 | 139 | return res | |
} | 127 | 140 | } | |
128 | 141 | |||
fun getAllDraftBeforeSelectedTime(): ArrayList<Double> { | 129 | 142 | fun getAllDraftBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 130 | 143 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 131 | 144 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.draft.value!!) | 132 | 145 | if (it.value.draft.value != null) | |
146 | res.add(it.value.draft.value!!) | |||
} | 133 | 147 | } | |
return res | 134 | 148 | return res | |
} | 135 | 149 | } | |
136 | 150 | |||
fun getAllCargoBeforeSelectedTime(): ArrayList<Double> { | 137 | 151 | fun getAllCargoBeforeSelectedTime(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 138 | 152 | val res = arrayListOf<Double>() | |
messageBeforeSelectedTime.forEach { | 139 | 153 | messageBeforeSelectedTime.forEach { | |
res.add(it.value.cargo.value!!) | 140 | 154 | if (it.value.cargo.value != null) | |
155 | res.add(it.value.cargo.value!!) | |||
} | 141 | 156 | } | |
return res | 142 | 157 | return res | |
} | 143 | 158 | } | |
144 | 159 | |||
fun getAllTime(): ArrayList<String> { | 145 | 160 | fun getAllTime(): ArrayList<String> { | |
val timeList = arrayListOf<String>() | 146 | 161 | val timeList = arrayListOf<String>() | |
messages.forEach { | 147 | 162 | messages.forEach { | |
timeList.add(it.value.time.value!!) | 148 | 163 | if (it.value.time.value != null) | |
164 | timeList.add(it.value.time.value!!) | |||
} | 149 | 165 | } | |
150 | 166 | |||
return timeList | 151 | 167 | return timeList | |
} | 152 | 168 | } | |
153 | 169 | |||
fun getAllLatitude(): ArrayList<Double> { | 154 | 170 | fun getAllLatitude(): ArrayList<Double> { | |
val latitudeList = arrayListOf<Double>() | 155 | 171 | val latitudeList = arrayListOf<Double>() | |
messages.forEach { | 156 | 172 | messages.forEach { | |
latitudeList.add(it.value.latitude.value!!) | 157 | 173 | if (it.value.latitude.value != null) | |
174 | latitudeList.add(it.value.latitude.value!!) | |||
} | 158 | 175 | } | |
159 | 176 | |||
return latitudeList | 160 | 177 | return latitudeList | |
} | 161 | 178 | } | |
162 | 179 | |||
fun getAllLongitude(): ArrayList<Double> { | 163 | 180 | fun getAllLongitude(): ArrayList<Double> { | |
val longitudeList = arrayListOf<Double>() | 164 | 181 | val longitudeList = arrayListOf<Double>() | |
messages.forEach { | 165 | 182 | messages.forEach { | |
longitudeList.add(it.value.longitude.value!!) | 166 | 183 | if (it.value.longitude.value != null) | |
184 | longitudeList.add(it.value.longitude.value!!) | |||
} | 167 | 185 | } | |
168 | 186 | |||
return longitudeList | 169 | 187 | return longitudeList | |
} | 170 | 188 | } | |
171 | 189 | |||
fun getAllSpeedOverGround(): ArrayList<Double> { | 172 | 190 | fun getAllSpeedOverGround(): ArrayList<Double> { | |
val speedOverGroundList = arrayListOf<Double>() | 173 | 191 | val speedOverGroundList = arrayListOf<Double>() | |
messages.forEach { | 174 | 192 | messages.forEach { | |
speedOverGroundList.add(it.value.speedOverGround.value!!) | 175 | 193 | if (it.value.speedOverGround.value != null) | |
194 | speedOverGroundList.add(it.value.speedOverGround.value!!) | |||
} | 176 | 195 | } | |
177 | 196 | |||
return speedOverGroundList | 178 | 197 | return speedOverGroundList | |
} | 179 | 198 | } | |
180 | 199 | |||
fun getAllCourseOverGround(): ArrayList<Double> { | 181 | 200 | fun getAllCourseOverGround(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 182 | 201 | val res = arrayListOf<Double>() | |
messages.forEach { | 183 | 202 | messages.forEach { | |
res.add(it.value.courseOverGround.value!!) | 184 | 203 | if (it.value.courseOverGround.value != null) | |
204 | res.add(it.value.courseOverGround.value!!) | |||
} | 185 | 205 | } | |
186 | 206 | |||
return res | 187 | 207 | return res | |
} | 188 | 208 | } | |
189 | 209 | |||
fun getAllHeading(): ArrayList<Double> { | 190 | 210 | fun getAllHeading(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 191 | 211 | val res = arrayListOf<Double>() | |
messages.forEach { | 192 | 212 | messages.forEach { | |
213 | if (it.value.heading.value != null) | |||
res.add(it.value.heading.value!!) | 193 | 214 | res.add(it.value.heading.value!!) | |
} | 194 | 215 | } | |
195 | 216 | |||
return res | 196 | 217 | return res | |
} | 197 | 218 | } | |
198 | 219 | |||
fun getAllVesselName(): ArrayList<String> { | 199 | 220 | fun getAllVesselName(): ArrayList<String> { | |
val res = arrayListOf<String>() | 200 | 221 | val res = arrayListOf<String>() | |
messages.forEach { | 201 | 222 | messages.forEach { | |
res.add(it.value.vesselName.value!!) | 202 | 223 | if (it.value.vesselName.value != null) | |
224 | res.add(it.value.vesselName.value!!) | |||
} | 203 | 225 | } | |
return res | 204 | 226 | return res | |
} | 205 | 227 | } | |
206 | 228 | |||
fun getAllIMO(): ArrayList<String> { | 207 | 229 | fun getAllIMO(): ArrayList<String> { | |
val res = arrayListOf<String>() | 208 | 230 | val res = arrayListOf<String>() | |
messages.forEach { | 209 | 231 | messages.forEach { | |
res.add(it.value.imo.value!!) | 210 | 232 | if (it.value.imo.value != null) | |
233 | res.add(it.value.imo.value!!) | |||
} | 211 | 234 | } | |
return res | 212 | 235 | return res | |
} | 213 | 236 | } | |
214 | 237 | |||
fun getAllCallSign(): ArrayList<String> { | 215 | 238 | fun getAllCallSign(): ArrayList<String> { | |
val res = arrayListOf<String>() | 216 | 239 | val res = arrayListOf<String>() | |
messages.forEach { | 217 | 240 | messages.forEach { | |
res.add(it.value.callSign.value!!) | 218 | 241 | if (it.value.callSign.value != null) | |
242 | res.add(it.value.callSign.value!!) | |||
} | 219 | 243 | } | |
return res | 220 | 244 | return res | |
} | 221 | 245 | } | |
222 | 246 | |||
fun getAllVesselType(): ArrayList<Double> { | 223 | 247 | fun getAllVesselType(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 224 | 248 | val res = arrayListOf<Double>() | |
messages.forEach { | 225 | 249 | messages.forEach { | |
res.add(it.value.vesselType.value!!) | 226 | 250 | if (it.value.vesselType.value != null) | |
251 | res.add(it.value.vesselType.value!!) | |||
} | 227 | 252 | } | |
return res | 228 | 253 | return res | |
} | 229 | 254 | } | |
230 | 255 | |||
fun getAllStatus(): ArrayList<String> { | 231 | 256 | fun getAllStatus(): ArrayList<String> { | |
val res = arrayListOf<String>() | 232 | 257 | val res = arrayListOf<String>() | |
messages.forEach { | 233 | 258 | messages.forEach { | |
res.add(it.value.status.value!!) | 234 | 259 | if (it.value.status.value != null) | |
260 | res.add(it.value.status.value!!) | |||
} | 235 | 261 | } | |
return res | 236 | 262 | return res | |
} | 237 | 263 | } | |
238 | 264 | |||
fun getAllLength(): ArrayList<Double> { | 239 | 265 | fun getAllLength(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 240 | 266 | val res = arrayListOf<Double>() | |
messages.forEach { | 241 | 267 | messages.forEach { | |
res.add(it.value.length.value!!) | 242 | 268 | if (it.value.length.value != null) | |
269 | res.add(it.value.length.value!!) | |||
} | 243 | 270 | } | |
return res | 244 | 271 | return res | |
} | 245 | 272 | } | |
246 | 273 | |||
fun getAllWidth(): ArrayList<Double> { | 247 | 274 | fun getAllWidth(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 248 | 275 | val res = arrayListOf<Double>() | |
messages.forEach { | 249 | 276 | messages.forEach { | |
res.add(it.value.width.value!!) | 250 | 277 | if (it.value.width.value != null) | |
278 | res.add(it.value.width.value!!) | |||
} | 251 | 279 | } | |
return res | 252 | 280 | return res | |
} | 253 | 281 | } | |
254 | 282 | |||
fun getAllDraft(): ArrayList<Double> { | 255 | 283 | fun getAllDraft(): ArrayList<Double> { | |
val res = arrayListOf<Double>() | 256 | 284 | val res = arrayListOf<Double>() | |
messages.forEach { | 257 | 285 | messages.forEach { | |
res.add(it.value.draft.value!!) | 258 | 286 | if (it.value.draft.value != null) | |
287 | res.add(it.value.draft.value!!) | |||
} | 259 | 288 | } | |
return res | 260 | 289 | return res |