Skip to content

Commit

Permalink
Expanded diaryTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
the-bay-kay committed Nov 22, 2023
1 parent fe3d417 commit 667fec8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions www/js/diary/timelineHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
TimelineEntry,
GeoJSONData,
UnprocessedTrip,
FilteredLocation,
} from '../types/diaryTypes';
import { getLabelInputDetails, getLabelInputs } from '../survey/multilabel/confirmHelper';
import { LabelOptions } from '../types/labelTypes';
Expand Down Expand Up @@ -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<any>) {
// change 'any' later
function (locationList: Array<ServerData<FilteredLocation>>) {
if (locationList.length == 0) {
return undefined;
}
Expand Down Expand Up @@ -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.
Expand All @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions www/js/types/diaryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit 667fec8

Please sign in to comment.