Commit c24b46996ae5faee8b70af824d453cac60892975
1 parent
096b2944
Fix not correct use coordinate key
Showing
2 changed files
with
20 additions
and
18 deletions
@@ -56,10 +56,10 @@ export function getRatio(firsMoment: number, secondMoment: number, intermediateM | @@ -56,10 +56,10 @@ export function getRatio(firsMoment: number, secondMoment: number, intermediateM | ||
56 | return (intermediateMoment - firsMoment) / (secondMoment - firsMoment); | 56 | return (intermediateMoment - firsMoment) / (secondMoment - firsMoment); |
57 | } | 57 | } |
58 | 58 | ||
59 | -export function findAngle(startPoint, endPoint) { | ||
60 | - let angle = -Math.atan2(endPoint.latitude - startPoint.latitude, endPoint.longitude - startPoint.longitude); | ||
61 | - angle = angle * 180 / Math.PI; | ||
62 | - return parseInt(angle.toFixed(2), 10); | 59 | +export function findAngle(startPoint: FormattedData, endPoint: FormattedData, latKeyName: string, lngKeyName: string): number { |
60 | + let angle = -Math.atan2(endPoint[latKeyName] - startPoint[latKeyName], endPoint[lngKeyName] - startPoint[lngKeyName]); | ||
61 | + angle = angle * 180 / Math.PI; | ||
62 | + return parseInt(angle.toFixed(2), 10); | ||
63 | } | 63 | } |
64 | 64 | ||
65 | 65 |
@@ -21,9 +21,9 @@ import { interpolateOnPointSegment } from 'leaflet-geometryutil'; | @@ -21,9 +21,9 @@ import { interpolateOnPointSegment } from 'leaflet-geometryutil'; | ||
21 | 21 | ||
22 | import { AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, SecurityContext, ViewChild } from '@angular/core'; | 22 | import { AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, SecurityContext, ViewChild } from '@angular/core'; |
23 | import { MapWidgetController, TbMapWidgetV2 } from '../lib/maps/map-widget2'; | 23 | import { MapWidgetController, TbMapWidgetV2 } from '../lib/maps/map-widget2'; |
24 | -import { MapProviders, FormattedData } from '../lib/maps/map-models'; | ||
25 | -import { initSchema, addToSchema, addGroupInfo, addCondition } from '@app/core/schema-utils'; | ||
26 | -import { tripAnimationSchema, mapPolygonSchema, pathSchema, pointSchema } from '../lib/maps/schemes'; | 24 | +import { FormattedData, MapProviders } from '../lib/maps/map-models'; |
25 | +import { addCondition, addGroupInfo, addToSchema, initSchema } from '@app/core/schema-utils'; | ||
26 | +import { mapPolygonSchema, pathSchema, pointSchema, tripAnimationSchema } from '../lib/maps/schemes'; | ||
27 | import { DomSanitizer } from '@angular/platform-browser'; | 27 | import { DomSanitizer } from '@angular/platform-browser'; |
28 | import { WidgetContext } from '@app/modules/home/models/widget-component.models'; | 28 | import { WidgetContext } from '@app/modules/home/models/widget-component.models'; |
29 | import { findAngle, getRatio, parseArray, parseWithTranslation, safeExecute } from '../lib/maps/maps-utils'; | 29 | import { findAngle, getRatio, parseArray, parseWithTranslation, safeExecute } from '../lib/maps/maps-utils'; |
@@ -86,17 +86,19 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { | @@ -86,17 +86,19 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { | ||
86 | rotationAngle: 0 | 86 | rotationAngle: 0 |
87 | } | 87 | } |
88 | this.settings = { ...settings, ...this.ctx.settings }; | 88 | this.settings = { ...settings, ...this.ctx.settings }; |
89 | - this.useAnchors = this.settings.usePointAsAnchor && this.settings.showPoints; | 89 | + this.useAnchors = this.settings.showPoints && this.settings.usePointAsAnchor; |
90 | this.settings.fitMapBounds = true; | 90 | this.settings.fitMapBounds = true; |
91 | this.normalizationStep = this.settings.normalizationStep; | 91 | this.normalizationStep = this.settings.normalizationStep; |
92 | const subscription = this.ctx.subscriptions[Object.keys(this.ctx.subscriptions)[0]]; | 92 | const subscription = this.ctx.subscriptions[Object.keys(this.ctx.subscriptions)[0]]; |
93 | - if (subscription) subscription.callbacks.onDataUpdated = () => { | ||
94 | - this.historicalData = parseArray(this.ctx.data); | ||
95 | - this.activeTrip = this.historicalData[0][0]; | ||
96 | - this.calculateIntervals(); | ||
97 | - this.timeUpdated(this.intervals[0]); | ||
98 | - this.mapWidget.map.map?.invalidateSize(); | ||
99 | - this.cd.detectChanges(); | 93 | + if (subscription) { |
94 | + subscription.callbacks.onDataUpdated = () => { | ||
95 | + this.historicalData = parseArray(this.ctx.data); | ||
96 | + this.activeTrip = this.historicalData[0][0]; | ||
97 | + this.calculateIntervals(); | ||
98 | + this.timeUpdated(this.intervals[0]); | ||
99 | + this.mapWidget.map.map?.invalidateSize(); | ||
100 | + this.cd.detectChanges(); | ||
101 | + } | ||
100 | } | 102 | } |
101 | } | 103 | } |
102 | 104 | ||
@@ -174,12 +176,12 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { | @@ -174,12 +176,12 @@ export class TripAnimationComponent implements OnInit, AfterViewInit { | ||
174 | const before = originData[i - 1]; | 176 | const before = originData[i - 1]; |
175 | const after = originData[i]; | 177 | const after = originData[i]; |
176 | const interpolation = interpolateOnPointSegment( | 178 | const interpolation = interpolateOnPointSegment( |
177 | - new L.Point(before.latitude, before.longitude), | ||
178 | - new L.Point(after.latitude, after.longitude), | 179 | + new L.Point(before[this.settings.latKeyName], before[this.settings.lngKeyName]), |
180 | + new L.Point(after[this.settings.latKeyName], after[this.settings.lngKeyName]), | ||
179 | getRatio(before.time, after.time, currentTime)); | 181 | getRatio(before.time, after.time, currentTime)); |
180 | result[currentTime] = ({ | 182 | result[currentTime] = ({ |
181 | ...originData[i], | 183 | ...originData[i], |
182 | - rotationAngle: findAngle(before, after) + this.settings.rotationAngle, | 184 | + rotationAngle: findAngle(before, after, this.settings.latKeyName, this.settings.lngKeyName) + this.settings.rotationAngle, |
183 | latitude: interpolation.x, | 185 | latitude: interpolation.x, |
184 | longitude: interpolation.y | 186 | longitude: interpolation.y |
185 | }); | 187 | }); |