Compare View
Commits (5)
Diff
Showing 3 changed files Side-by-side Diff
src/app/component/graph/graph.component.ts
View file @
1af45d9
... | ... | @@ -62,7 +62,7 @@ export class GraphComponent implements OnInit { |
62 | 62 | break; |
63 | 63 | case 'time': |
64 | 64 | this.selectedVessel.messages.forEach(value => { |
65 | - this.trace.x.push(Date.parse(value.time) / 1000); | |
65 | + this.trace.x.push(Date.parse(value.time) / 1000 - this.selectedVessel.firstAppearance); | |
66 | 66 | }); |
67 | 67 | break; |
68 | 68 | case 'latitude': |
... | ... | @@ -152,7 +152,7 @@ export class GraphComponent implements OnInit { |
152 | 152 | break; |
153 | 153 | case 'time': |
154 | 154 | this.selectedVessel.messages.forEach(value => { |
155 | - this.trace.y.push(Date.parse(value.time) / 1000); | |
155 | + this.trace.y.push(Date.parse(value.time) / 1000 - this.selectedVessel.firstAppearance); | |
156 | 156 | }); |
157 | 157 | break; |
158 | 158 | case 'latitude': |
src/app/model/vessel.ts
View file @
1af45d9
... | ... | @@ -2,13 +2,15 @@ import {Message} from './message'; |
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); | |
12 | 14 | } |
13 | 15 | |
14 | 16 | getMMSI(): string { |
... | ... | @@ -26,4 +28,11 @@ export class Vessel { |
26 | 28 | return '#' + (+this.getMMSI()).toString(16).substr(0, 6); |
27 | 29 | } |
28 | 30 | |
31 | + determineFirstAppearance(message: Message): void { | |
32 | + const timeInS = Date.parse(message.time) / 1000; | |
33 | + if (this.firstAppearance === undefined || this.firstAppearance > timeInS) { | |
34 | + this.firstAppearance = timeInS; | |
35 | + } | |
36 | + } | |
37 | + | |
29 | 38 | } |
src/app/model/vessels.ts
View file @
1af45d9