Commit 638f25c679a89cc32f3597b6d40befae512f346d
1 parent
34e0f9db42
Exists in
master
determine vessel date of first appearance
Showing 1 changed file with 9 additions and 1 deletions Side-by-side Diff
src/app/model/vessels.ts
View file @
638f25c
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | |
4 | 4 | export class Vessels { |
5 | 5 | vessels: Map<number, Vessel>; |
6 | + firstAppearance: number; | |
6 | 7 | |
7 | 8 | constructor() { |
8 | 9 | this.vessels = new Map<number, Vessel>(); |
9 | 10 | |
... | ... | @@ -12,8 +13,15 @@ |
12 | 13 | if (!this.vessels.get(Number(message.mmsi))) { |
13 | 14 | this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>())); |
14 | 15 | } |
15 | - | |
16 | + this.determineFirstAppearance(message); | |
16 | 17 | this.vessels.get(Number(message.mmsi)).addMessage(message); |
18 | + } | |
19 | + | |
20 | + determineFirstAppearance(message: Message): void { | |
21 | + const timeInS = Date.parse(message.time) / 1000; | |
22 | + if (this.firstAppearance > timeInS) { | |
23 | + this.firstAppearance = timeInS; | |
24 | + } | |
17 | 25 | } |
18 | 26 | |
19 | 27 | } |