Commit 638f25c679a89cc32f3597b6d40befae512f346d

Authored by lsagona
1 parent 34e0f9db42
Exists in master

determine vessel date of first appearance

Showing 1 changed file with 9 additions and 1 deletions Inline Diff

src/app/model/vessels.ts View file @ 638f25c
import {Vessel} from './vessel'; 1 1 import {Vessel} from './vessel';
import {Message} from './message'; 2 2 import {Message} from './message';
3 3
export class Vessels { 4 4 export class Vessels {
vessels: Map<number, Vessel>; 5 5 vessels: Map<number, Vessel>;
6 firstAppearance: number;
6 7
constructor() { 7 8 constructor() {
this.vessels = new Map<number, Vessel>(); 8 9 this.vessels = new Map<number, Vessel>();
} 9 10 }
10 11
addMessage(message: Message): void { 11 12 addMessage(message: Message): void {
if (!this.vessels.get(Number(message.mmsi))) { 12 13 if (!this.vessels.get(Number(message.mmsi))) {
this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>())); 13 14 this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>()));
} 14 15 }
15 16 this.determineFirstAppearance(message);
this.vessels.get(Number(message.mmsi)).addMessage(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;