aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/MapBox/AnimationUtility.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/MapBox/AnimationUtility.ts')
-rw-r--r--src/client/views/nodes/MapBox/AnimationUtility.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/client/views/nodes/MapBox/AnimationUtility.ts b/src/client/views/nodes/MapBox/AnimationUtility.ts
index 3eac50f1f..a3ac68b99 100644
--- a/src/client/views/nodes/MapBox/AnimationUtility.ts
+++ b/src/client/views/nodes/MapBox/AnimationUtility.ts
@@ -1,11 +1,12 @@
import * as turf from '@turf/turf';
-import { Position } from '@turf/turf';
import * as d3 from 'd3';
-import { Feature, GeoJsonProperties, Geometry } from 'geojson';
-import mapboxgl, { MercatorCoordinate } from 'mapbox-gl';
+import { Feature, GeoJsonProperties, Geometry, LineString } from 'geojson';
+import { MercatorCoordinate } from 'mapbox-gl';
import { action, computed, makeObservable, observable, runInAction } from 'mobx';
import { MapRef } from 'react-map-gl';
+export type Position = [number, number];
+
export enum AnimationStatus {
START = 'start',
RESUME = 'resume',
@@ -23,7 +24,7 @@ export class AnimationUtility {
private ROUTE_COORDINATES: Position[] = [];
@observable
- private PATH?: turf.helpers.Feature<turf.helpers.LineString, turf.helpers.Properties> = undefined;
+ private PATH?: Feature<LineString> = undefined; // turf.helpers.Feature<turf.helpers.LineString, turf.helpers.Properties> = undefined;
private PATH_DISTANCE: number = 0;
private FLY_IN_START_PITCH = 40;
@@ -165,7 +166,8 @@ export class AnimationUtility {
}
@action
- public setPath = (path: turf.helpers.Feature<turf.helpers.LineString, turf.helpers.Properties>) => {
+ public setPath = (path: Feature<LineString>) => {
+ // turf.helpers.Feature<turf.helpers.LineString, turf.helpers.Properties>) => {
this.PATH = path;
};
@@ -178,7 +180,7 @@ export class AnimationUtility {
this.ROUTE_COORDINATES = routeCoordinates;
this.PATH = turf.lineString(routeCoordinates);
- this.PATH_DISTANCE = turf.length(this.PATH);
+ this.PATH_DISTANCE = turf.length(this.PATH as Feature<LineString>);
this.terrainDisplayed = terrainDisplayed;
const bearing = this.calculateBearing(
@@ -232,7 +234,7 @@ export class AnimationUtility {
if (!this.PATH) return;
// calculate the distance along the path based on the animationPhase
- const alongPath = turf.along(this.PATH, this.PATH_DISTANCE * animationPhase).geometry.coordinates;
+ const alongPath = turf.along(this.PATH as Feature<LineString>, this.PATH_DISTANCE * animationPhase).geometry.coordinates;
const lngLat = {
lng: alongPath[0],