From 9f73f74acdeea4a2ad478d6e9e94ef525cb3d890 Mon Sep 17 00:00:00 2001 From: Katie Rischpater <98350084+the-bay-kay@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:48:37 -0800 Subject: [PATCH] Updated diaryTypes to use GeoJSON `Point` --- www/__mocks__/timelineHelperMocks.ts | 4 ++-- www/js/diary/timelineHelper.ts | 2 +- www/js/types/diaryTypes.ts | 12 +++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/www/__mocks__/timelineHelperMocks.ts b/www/__mocks__/timelineHelperMocks.ts index b18c2854a..014e892cb 100644 --- a/www/__mocks__/timelineHelperMocks.ts +++ b/www/__mocks__/timelineHelperMocks.ts @@ -60,7 +60,7 @@ export const mockUnprocessedTrip: UnprocessedTrip = { distance: 1.0, duration: 3.0, end_fmt_time: '', - end_loc: { type: '', coordinates: [] }, + end_loc: { type: 'Point', coordinates: [] }, end_local_dt: null, expectation: null, inferred_labels: [], @@ -70,7 +70,7 @@ export const mockUnprocessedTrip: UnprocessedTrip = { source: '', start_local_dt: null, start_ts: 0.1, - start_loc: { type: '', coordinates: [] }, + start_loc: { type: 'Point', coordinates: [] }, starting_trip: null, user_input: null, }; diff --git a/www/js/diary/timelineHelper.ts b/www/js/diary/timelineHelper.ts index 1d583cd73..1db03cd2d 100644 --- a/www/js/diary/timelineHelper.ts +++ b/www/js/diary/timelineHelper.ts @@ -198,7 +198,7 @@ function keysForNotesInputs(appConfig: AppConfig) { * @returns a GeoJSON feature with type "Point", the given location's coordinates and the given feature type */ const location2GeojsonPoint = ( - locationPoint: { type: string; coordinates: number[] }, + locationPoint: Point, featureType: string, ): Feature => ({ type: 'Feature', diff --git a/www/js/types/diaryTypes.ts b/www/js/types/diaryTypes.ts index bfaee2a14..64cd87e3b 100644 --- a/www/js/types/diaryTypes.ts +++ b/www/js/types/diaryTypes.ts @@ -4,7 +4,7 @@ import { BaseModeKey, MotionTypeKey } from '../diary/diaryHelper'; import { BEMData, LocalDt } from './serverData'; -import { FeatureCollection, Feature, Geometry } from 'geojson'; +import { FeatureCollection, Feature, Geometry, Point } from 'geojson'; type ObjectId = { $oid: string }; @@ -58,9 +58,7 @@ export type UnprocessedTrip = { distance: number; duration: number; end_fmt_time: string; - /* While the end_loc & start_loc objects are similar to GeoJSON's `Point` object, - they lack the additional GeoJSONObject methods, so `Point` cannot be used here. */ - end_loc: { type: string; coordinates: number[] }; + end_loc: Point; end_local_dt: LocalDt; expectation: any; // TODO "{to_label: boolean}" inferred_labels: any[]; // TODO @@ -70,7 +68,7 @@ export type UnprocessedTrip = { source: string; start_local_dt: LocalDt; start_ts: number; - start_loc: { type: string; coordinates: number[] }; + start_loc: Point; starting_trip?: any; user_input: UserInput; }; @@ -88,7 +86,7 @@ export type CompositeTrip = { duration: number; end_confirmed_place: BEMData; end_fmt_time: string; - end_loc: { type: string; coordinates: number[] }; + end_loc: Point; end_local_dt: LocalDt; end_place: ObjectId; end_ts: number; @@ -105,7 +103,7 @@ export type CompositeTrip = { source: string; start_confirmed_place: BEMData; start_fmt_time: string; - start_loc: { type: string; coordinates: number[] }; + start_loc: Point; start_local_dt: LocalDt; start_place: ObjectId; start_ts: number;