Commit 783fd26bfe069e204fea1d4b19f76516c2f772e2
1 parent
638f25c679
Exists in
master
determine vessel date of first appearance
Showing 1 changed file with 0 additions and 1 deletions Inline Diff
src/app/model/vessels.ts
View file @
783fd26
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>; | |
firstAppearance: number; | 6 | 6 | firstAppearance: number; | |
7 | 7 | |||
constructor() { | 8 | 8 | constructor() { | |
this.vessels = new Map<number, Vessel>(); | 9 | 9 | this.vessels = new Map<number, Vessel>(); | |
} | 10 | 10 | } | |
11 | 11 | |||
addMessage(message: Message): void { | 12 | 12 | addMessage(message: Message): void { | |
if (!this.vessels.get(Number(message.mmsi))) { | 13 | 13 | if (!this.vessels.get(Number(message.mmsi))) { | |
this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>())); | 14 | 14 | this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>())); | |
} | 15 | 15 | } | |
this.determineFirstAppearance(message); | 16 | 16 | this.determineFirstAppearance(message); | |
this.vessels.get(Number(message.mmsi)).addMessage(message); | 17 | 17 | this.vessels.get(Number(message.mmsi)).addMessage(message); | |
} | 18 | 18 | } | |
19 | 19 | |||
determineFirstAppearance(message: Message): void { | 20 | 20 | determineFirstAppearance(message: Message): void { | |
const timeInS = Date.parse(message.time) / 1000; | 21 | 21 | const timeInS = Date.parse(message.time) / 1000; | |
if (this.firstAppearance > timeInS) { | 22 | 22 | if (this.firstAppearance > timeInS) { |