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