From 29e50d28c6f4464dba34fec4e9c3d53460a5183c Mon Sep 17 00:00:00 2001 From: lsagona Date: Wed, 18 Nov 2020 09:50:28 +0100 Subject: [PATCH] put date of first appearance in the right class --- src/app/model/vessel.ts | 12 +++++++++++- src/app/model/vessels.ts | 9 +-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app/model/vessel.ts b/src/app/model/vessel.ts index 070f33e..5d56693 100644 --- a/src/app/model/vessel.ts +++ b/src/app/model/vessel.ts @@ -2,13 +2,16 @@ import {Message} from './message'; export class Vessel { messages: Array; + firstAppearance: number; constructor(messages: Array) { this.messages = messages; } addMessage(message: Message): void { - this.messages.push(message); + this.messages.push(message); + this.determineFirstAppearance(message); + } getMMSI(): string { @@ -26,4 +29,11 @@ export class Vessel { return '#' + (+this.getMMSI()).toString(16).substr(0, 6); } + determineFirstAppearance(message: Message): void { + const timeInS = Date.parse(message.time) / 1000; + if (this.firstAppearance > timeInS) { + this.firstAppearance = timeInS; + } + } + } diff --git a/src/app/model/vessels.ts b/src/app/model/vessels.ts index fea6cef..3a6572a 100644 --- a/src/app/model/vessels.ts +++ b/src/app/model/vessels.ts @@ -3,7 +3,6 @@ import {Message} from './message'; export class Vessels { vessels: Map; - firstAppearance: number; constructor() { this.vessels = new Map(); @@ -13,14 +12,8 @@ export class Vessels { if (!this.vessels.get(Number(message.mmsi))) { this.vessels.set(Number(message.mmsi), new Vessel(new Array())); } - this.determineFirstAppearance(message); this.vessels.get(Number(message.mmsi)).addMessage(message); } - determineFirstAppearance(message: Message): void { - const timeInS = Date.parse(message.time) / 1000; - if (this.firstAppearance > timeInS) { - this.firstAppearance = timeInS; - } - } + } -- 1.7.10.4