Commit 29e50d28c6f4464dba34fec4e9c3d53460a5183c
1 parent
783fd26bfe
Exists in
master
put date of first appearance in the right class
Showing 2 changed files with 12 additions and 9 deletions Side-by-side Diff
src/app/model/vessel.ts
View file @
29e50d2
... | ... | @@ -2,13 +2,16 @@ |
2 | 2 | |
3 | 3 | export class Vessel { |
4 | 4 | messages: Array<Message>; |
5 | + firstAppearance: number; | |
5 | 6 | |
6 | 7 | constructor(messages: Array<Message>) { |
7 | 8 | this.messages = messages; |
8 | 9 | } |
9 | 10 | |
10 | 11 | addMessage(message: Message): void { |
11 | - this.messages.push(message); | |
12 | + this.messages.push(message); | |
13 | + this.determineFirstAppearance(message); | |
14 | + | |
12 | 15 | } |
13 | 16 | |
14 | 17 | getMMSI(): string { |
... | ... | @@ -24,6 +27,13 @@ |
24 | 27 | |
25 | 28 | public getColor(): string { |
26 | 29 | return '#' + (+this.getMMSI()).toString(16).substr(0, 6); |
30 | + } | |
31 | + | |
32 | + determineFirstAppearance(message: Message): void { | |
33 | + const timeInS = Date.parse(message.time) / 1000; | |
34 | + if (this.firstAppearance > timeInS) { | |
35 | + this.firstAppearance = timeInS; | |
36 | + } | |
27 | 37 | } |
28 | 38 | |
29 | 39 | } |
src/app/model/vessels.ts
View file @
29e50d2
... | ... | @@ -3,7 +3,6 @@ |
3 | 3 | |
4 | 4 | export class Vessels { |
5 | 5 | vessels: Map<number, Vessel>; |
6 | - firstAppearance: number; | |
7 | 6 | |
8 | 7 | constructor() { |
9 | 8 | this.vessels = new Map<number, Vessel>(); |
10 | 9 | |
... | ... | @@ -13,15 +12,9 @@ |
13 | 12 | if (!this.vessels.get(Number(message.mmsi))) { |
14 | 13 | this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>())); |
15 | 14 | } |
16 | - this.determineFirstAppearance(message); | |
17 | 15 | this.vessels.get(Number(message.mmsi)).addMessage(message); |
18 | 16 | } |
19 | 17 | |
20 | - determineFirstAppearance(message: Message): void { | |
21 | - const timeInS = Date.parse(message.time) / 1000; | |
22 | - if (this.firstAppearance > timeInS) { | |
23 | - this.firstAppearance = timeInS; | |
24 | - } | |
25 | - } | |
18 | + | |
26 | 19 | } |