Skip to content

Commit

Permalink
Updated diaryTypes to use GeoJSON Point
Browse files Browse the repository at this point in the history
  • Loading branch information
the-bay-kay committed Jan 25, 2024
1 parent 95d6255 commit 9f73f74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions www/__mocks__/timelineHelperMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand All @@ -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,
};
Expand Down
2 changes: 1 addition & 1 deletion www/js/diary/timelineHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
12 changes: 5 additions & 7 deletions www/js/types/diaryTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand Down Expand Up @@ -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
Expand All @@ -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;
};
Expand All @@ -88,7 +86,7 @@ export type CompositeTrip = {
duration: number;
end_confirmed_place: BEMData<ConfirmedPlace>;
end_fmt_time: string;
end_loc: { type: string; coordinates: number[] };
end_loc: Point;
end_local_dt: LocalDt;
end_place: ObjectId;
end_ts: number;
Expand All @@ -105,7 +103,7 @@ export type CompositeTrip = {
source: string;
start_confirmed_place: BEMData<ConfirmedPlace>;
start_fmt_time: string;
start_loc: { type: string; coordinates: number[] };
start_loc: Point;
start_local_dt: LocalDt;
start_place: ObjectId;
start_ts: number;
Expand Down

0 comments on commit 9f73f74

Please sign in to comment.