Commit 69f41be5768098ea0ba035cd0e4327dba94569e3

Authored by Artem Halushko
1 parent aac5b0e7

interpolation fix

@@ -389,6 +389,9 @@ export default abstract class LeafletMap { @@ -389,6 +389,9 @@ export default abstract class LeafletMap {
389 const poly = this.polylines.get(name); 389 const poly = this.polylines.get(name);
390 if (poly) { 390 if (poly) {
391 this.map.removeLayer(poly.leafletPoly); 391 this.map.removeLayer(poly.leafletPoly);
  392 + if (poly.polylineDecorator) {
  393 + this.map.removeLayer(poly.polylineDecorator);
  394 + }
392 this.polylines.delete(name); 395 this.polylines.delete(name);
393 } 396 }
394 } 397 }
@@ -56,7 +56,6 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { @@ -56,7 +56,6 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
56 historicalData: FormattedData[][]; 56 historicalData: FormattedData[][];
57 normalizationStep: number; 57 normalizationStep: number;
58 interpolatedTimeData = []; 58 interpolatedTimeData = [];
59 - intervals = [];  
60 widgetConfig: WidgetConfig; 59 widgetConfig: WidgetConfig;
61 settings; 60 settings;
62 mainTooltip = ''; 61 mainTooltip = '';
@@ -104,9 +103,10 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { @@ -104,9 +103,10 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
104 if (subscription) subscription.callbacks.onDataUpdated = () => { 103 if (subscription) subscription.callbacks.onDataUpdated = () => {
105 this.historicalData = parseArray(this.ctx.data).filter(arr => arr.length); 104 this.historicalData = parseArray(this.ctx.data).filter(arr => arr.length);
106 if (this.historicalData.length) { 105 if (this.historicalData.length) {
107 - this.activeTrip = this.historicalData[0][0]; 106 + if (!this.activeTrip)
  107 + this.activeTrip = this.historicalData[0][0];
108 this.calculateIntervals(); 108 this.calculateIntervals();
109 - this.timeUpdated(this.minTime); 109 + this.timeUpdated(this.currentTime ? this.currentTime : this.minTime);
110 } 110 }
111 this.mapWidget.map.map?.invalidateSize(); 111 this.mapWidget.map.map?.invalidateSize();
112 this.cd.detectChanges(); 112 this.cd.detectChanges();
@@ -122,12 +122,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { @@ -122,12 +122,7 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
122 this.currentTime = time; 122 this.currentTime = time;
123 const currentPosition = this.interpolatedTimeData 123 const currentPosition = this.interpolatedTimeData
124 .map(dataSource => dataSource[time]) 124 .map(dataSource => dataSource[time])
125 - .filter(ds => ds)  
126 - .map(ds => {  
127 - ds.minTime = this.minTimeFormat;  
128 - ds.maxTime = this.maxTimeFormat;  
129 - return ds;  
130 - }); 125 + .filter(ds => ds);
131 if (isUndefined(currentPosition[0])) { 126 if (isUndefined(currentPosition[0])) {
132 const timePoints = Object.keys(this.interpolatedTimeData[0]).map(item => parseInt(item, 10)); 127 const timePoints = Object.keys(this.interpolatedTimeData[0]).map(item => parseInt(item, 10));
133 for (let i = 1; i < timePoints.length; i++) { 128 for (let i = 1; i < timePoints.length; i++) {
@@ -138,6 +133,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { @@ -138,6 +133,8 @@ export class TripAnimationComponent implements OnInit, AfterViewInit {
138 currentPosition[0] = { 133 currentPosition[0] = {
139 ...beforePosition, 134 ...beforePosition,
140 time, 135 time,
  136 + minTime: this.minTimeFormat,
  137 + maxTime: this.maxTimeFormat,
141 ...interpolateOnLineSegment(beforePosition, afterPosition, this.settings.latKeyName, this.settings.lngKeyName, ratio) 138 ...interpolateOnLineSegment(beforePosition, afterPosition, this.settings.latKeyName, this.settings.lngKeyName, ratio)
142 } 139 }
143 break; 140 break;