...
|
...
|
@@ -29,6 +29,7 @@ import { |
29
|
29
|
getRatio,
|
30
|
30
|
interpolateOnLineSegment,
|
31
|
31
|
parseArray,
|
|
32
|
+ parseFunction,
|
32
|
33
|
parseWithTranslation,
|
33
|
34
|
safeExecute
|
34
|
35
|
} from '../lib/maps/maps-utils';
|
...
|
...
|
@@ -65,7 +66,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
65
|
66
|
minTimeFormat: string;
|
66
|
67
|
maxTime: number;
|
67
|
68
|
maxTimeFormat: string;
|
68
|
|
- anchors = [];
|
|
69
|
+ anchors: number[] = [];
|
69
|
70
|
useAnchors: boolean;
|
70
|
71
|
|
71
|
72
|
static getSettingsSchema(): JsonSettingsSchema {
|
...
|
...
|
@@ -94,6 +95,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
94
|
95
|
}
|
95
|
96
|
this.settings = { ...settings, ...this.ctx.settings };
|
96
|
97
|
this.useAnchors = this.settings.showPoints && this.settings.usePointAsAnchor;
|
|
98
|
+ this.settings.pointAsAnchorFunction = parseFunction(this.settings.pointAsAnchorFunction, ['data', 'dsData', 'dsIndex']);
|
97
|
99
|
this.settings.fitMapBounds = true;
|
98
|
100
|
this.normalizationStep = this.settings.normalizationStep;
|
99
|
101
|
const subscription = this.ctx.subscriptions[Object.keys(this.ctx.subscriptions)[0]];
|
...
|
...
|
@@ -141,11 +143,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
141
|
143
|
this.mapWidget.map.updatePolygons(this.interpolatedTimeData);
|
142
|
144
|
}
|
143
|
145
|
if (this.settings.showPoints) {
|
144
|
|
- this.mapWidget.map.updatePoints(this.interpolatedTimeData, this.calcTooltip);
|
145
|
|
- // this.anchors = this.interpolatedTimeData
|
146
|
|
- // .filter(data =>
|
147
|
|
- // this.settings.usePointAsAnchor ||
|
148
|
|
- // safeExecute(this.settings.pointAsAnchorFunction, [this.interpolatedTimeData, data, data.dsIndex])).map(data => data.time);
|
|
146
|
+ this.mapWidget.map.updatePoints(_.values(_.union(this.interpolatedTimeData)[0]), this.calcTooltip);
|
149
|
147
|
}
|
150
|
148
|
this.mapWidget.map.updateMarkers(currentPosition);
|
151
|
149
|
}
|
...
|
...
|
@@ -162,7 +160,12 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
162
|
160
|
this.maxTimeFormat = this.maxTime !== -Infinity ? moment(this.maxTime).format('YYYY-MM-DD HH:mm:ss') : '';
|
163
|
161
|
this.interpolatedTimeData[index] = this.interpolateArray(dataSource);
|
164
|
162
|
});
|
165
|
|
-
|
|
163
|
+ if (this.useAnchors) {
|
|
164
|
+ const anchorDate = Object.entries(_.union(this.interpolatedTimeData)[0]);
|
|
165
|
+ this.anchors = anchorDate
|
|
166
|
+ .filter((data: [string, FormattedData]) => safeExecute(this.settings.pointAsAnchorFunction, [data[1], anchorDate, data[1].dsIndex]))
|
|
167
|
+ .map(data => parseInt(data[0], 10));
|
|
168
|
+ }
|
166
|
169
|
}
|
167
|
170
|
|
168
|
171
|
calcTooltip = (point?: FormattedData, setTooltip = true) => {
|
...
|
...
|
@@ -200,20 +203,17 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { |
200
|
203
|
const result = {};
|
201
|
204
|
const latKeyName = this.settings.latKeyName;
|
202
|
205
|
const lngKeyName = this.settings.lngKeyName;
|
203
|
|
- for (let i = 0; i < originData.length; i++) {
|
204
|
|
- const currentTime = originData[i].time;
|
|
206
|
+ for (const data of originData) {
|
|
207
|
+ const currentTime = data.time;
|
205
|
208
|
const normalizeTime = this.minTime + Math.ceil((currentTime - this.minTime) / this.normalizationStep) * this.normalizationStep;
|
206
|
|
- if (i !== originData.length - 1) {
|
207
|
|
- result[normalizeTime] = {
|
208
|
|
- ...originData[i],
|
209
|
|
- rotationAngle: this.settings.rotationAngle + findAngle(originData[i], originData[i + 1], latKeyName, lngKeyName)
|
210
|
|
- };
|
211
|
|
- } else {
|
212
|
|
- result[normalizeTime] = {
|
213
|
|
- ...originData[i],
|
214
|
|
- rotationAngle: this.settings.rotationAngle + findAngle(originData[i - 1], originData[i], latKeyName, lngKeyName)
|
215
|
|
- };
|
216
|
|
- }
|
|
209
|
+ result[normalizeTime] = {
|
|
210
|
+ ...data,
|
|
211
|
+ rotationAngle: this.settings.rotationAngle
|
|
212
|
+ };
|
|
213
|
+ }
|
|
214
|
+ const timeStamp = Object.keys(result);
|
|
215
|
+ for(let i = 0; i < timeStamp.length - 1; i++){
|
|
216
|
+ result[timeStamp[i]].rotationAngle += findAngle(result[timeStamp[i]], result[timeStamp[i + 1]], latKeyName, lngKeyName)
|
217
|
217
|
}
|
218
|
218
|
return result;
|
219
|
219
|
}
|
...
|
...
|
|