Blame view

src/app/model/vessels.ts 709 Bytes
de59ffef8   lsagona   add model + search
1
2
3
4
5
  import {Vessel} from './vessel';
  import {Message} from './message';
  
  export class Vessels {
    vessels: Map<number, Vessel>;
638f25c67   lsagona   determine vessel ...
6
    firstAppearance: number;
de59ffef8   lsagona   add model + search
7
8
9
10
11
12
13
14
15
  
    constructor() {
      this.vessels = new Map<number, Vessel>();
    }
  
    addMessage(message: Message): void {
      if (!this.vessels.get(Number(message.mmsi))) {
        this.vessels.set(Number(message.mmsi), new Vessel(new Array<Message>()));
      }
638f25c67   lsagona   determine vessel ...
16
      this.determineFirstAppearance(message);
de59ffef8   lsagona   add model + search
17
18
      this.vessels.get(Number(message.mmsi)).addMessage(message);
    }
638f25c67   lsagona   determine vessel ...
19
20
21
22
23
24
    determineFirstAppearance(message: Message): void {
      const timeInS = Date.parse(message.time) / 1000;
      if (this.firstAppearance > timeInS) {
        this.firstAppearance = timeInS;
      }
    }
de59ffef8   lsagona   add model + search
25
  }