diff --git a/www/js/diary/timelineHelper.ts b/www/js/diary/timelineHelper.ts index 59bc6e964..595fadf48 100644 --- a/www/js/diary/timelineHelper.ts +++ b/www/js/diary/timelineHelper.ts @@ -11,6 +11,7 @@ import { TimelineEntry, GeoJSONData, UnprocessedTrip, + FilteredLocation, } from '../types/diaryTypes'; import { getLabelInputDetails, getLabelInputs } from '../survey/multilabel/confirmHelper'; import { LabelOptions } from '../types/labelTypes'; @@ -338,8 +339,7 @@ const transitionTrip2TripObj = function (trip) { ); const getSensorData = window['cordova'].plugins.BEMUserCache.getSensorDataForInterval; return getUnifiedDataForInterval('background/filtered_location', tq, getSensorData).then( - function (locationList: Array) { - // change 'any' later + function (locationList: Array>) { if (locationList.length == 0) { return undefined; } @@ -527,7 +527,7 @@ export const readUnprocessedTrips = function (startTs, endTs, lastProcessedTrip) logDebug(JSON.stringify(trip, null, 2)); }); var tripFillPromises = tripsList.map(transitionTrip2TripObj); - return Promise.all(tripFillPromises).then(function (raw_trip_gj_list) { + return Promise.all(tripFillPromises).then(function (raw_trip_gj_list: UnprocessedTrip[]) { // Now we need to link up the trips. linking unprocessed trips // to one another is fairly simple, but we need to link the // first unprocessed trip to the last processed trip. @@ -540,7 +540,7 @@ export const readUnprocessedTrips = function (startTs, endTs, lastProcessedTrip) logDebug(`mapped trips to trip_gj_list of size ${raw_trip_gj_list.length}`); /* Filtering: we will keep trips that are 1) defined and 2) have a distance >= 100m or duration >= 5 minutes https://github.com/e-mission/e-mission-docs/issues/966#issuecomment-1709112578 */ - const trip_gj_list: UnprocessedTrip[] = raw_trip_gj_list.filter( + const trip_gj_list = raw_trip_gj_list.filter( (trip) => trip && (trip.distance >= 100 || trip.duration >= 300), ); logDebug( diff --git a/www/js/types/diaryTypes.ts b/www/js/types/diaryTypes.ts index 534f1dfdc..5fa81298d 100644 --- a/www/js/types/diaryTypes.ts +++ b/www/js/types/diaryTypes.ts @@ -191,6 +191,22 @@ export type SectionData = { distance: number; }; +// used in timelineHelper's `transitionTrip2TripObj` +export type FilteredLocation = { + accuracy: number; + altitude: number; + elapsedRealtimeNanos: number; + filter: number; + fmt_time: string; + heading: number; + latitude: number; + loc: Geometry; + local_dt: LocalDt; + longitude: number; + sensed_speed: number; + ts: number; +}; + export type GeoJSONStyledFeature = Feature & { style?: { color: string } }; export type GeoJSONData = {