From 34660b266c93a9d272ef52390c7d743f44c5adf8 Mon Sep 17 00:00:00 2001 From: Paul Bienkowski Date: Wed, 16 Mar 2022 20:16:06 +0100 Subject: [PATCH] Project the whole track to the map, and show both versions --- api/obs/api/process.py | 13 ++++++++++++- api/obs/api/routes/tracks.py | 1 + frontend/src/mapstyles/index.js | 7 +++++++ frontend/src/pages/TrackPage/TrackMap.tsx | 14 ++++++++++---- frontend/src/pages/TrackPage/index.tsx | 9 +++++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/api/obs/api/process.py b/api/obs/api/process.py index fe02492..61e6fd3 100644 --- a/api/obs/api/process.py +++ b/api/obs/api/process.py @@ -151,7 +151,9 @@ async def process_track(session, track, data_source): ) annotator = AnnotateMeasurements( - data_source, cache_dir=app.config.OBS_FACE_CACHE_DIR + data_source, + cache_dir=app.config.OBS_FACE_CACHE_DIR, + fully_annotate_unconfirmed=True, ) input_data = await annotator.annotate(imported_data) @@ -188,10 +190,19 @@ async def process_track(session, track, data_source): }, } + track_raw_json = { + "type": "Feature", + "geometry": { + "type": "LineString", + "coordinates": [[m["longitude_GPS"], m["latitude_GPS"]] for m in track_points], + }, + } + for output_filename, data in [ ("measurements.json", measurements_json), ("overtakingEvents.json", overtaking_events_json), ("track.json", track_json), + ("trackRaw.json", track_raw_json), ]: target = join(output_dir, output_filename) log.debug("Writing file %s", target) diff --git a/api/obs/api/routes/tracks.py b/api/obs/api/routes/tracks.py index 3a3a2e2..d0c4425 100644 --- a/api/obs/api/routes/tracks.py +++ b/api/obs/api/routes/tracks.py @@ -181,6 +181,7 @@ async def get_track_data(req, slug: str): "measurements": "measurements.json", "overtakingEvents": "overtakingEvents.json", "track": "track.json", + "trackRaw": "trackRaw.json", } result = {} diff --git a/frontend/src/mapstyles/index.js b/frontend/src/mapstyles/index.js index acbb9d4..6af0631 100644 --- a/frontend/src/mapstyles/index.js +++ b/frontend/src/mapstyles/index.js @@ -1,4 +1,5 @@ import _ from 'lodash' +import produce from 'immer' import bright from './bright.json' import positron from './positron.json' @@ -70,4 +71,10 @@ export const trackLayer = { }, } +export const trackLayerRaw = produce(trackLayer, draft => { + draft.paint['line-color'] = '#81D4FA' + draft.paint['line-width'][4] = 1 + draft.paint['line-width'][6] = 3 +}) + export const basemap = positron diff --git a/frontend/src/pages/TrackPage/TrackMap.tsx b/frontend/src/pages/TrackPage/TrackMap.tsx index 34207ba..8668a63 100644 --- a/frontend/src/pages/TrackPage/TrackMap.tsx +++ b/frontend/src/pages/TrackPage/TrackMap.tsx @@ -4,7 +4,7 @@ import {Source, Layer} from 'react-map-gl' import type {TrackData} from 'types' import {Map} from 'components' -import {colorByDistance, trackLayer} from '../../mapstyles' +import {colorByDistance, trackLayer, trackLayerRaw} from '../../mapstyles' export default function TrackMap({ trackData, @@ -25,14 +25,20 @@ export default function TrackMap({ return (
+ {showTrack && trackData.trackRaw != null && ( + + + + )} + {showTrack && ( - - + + )} {pointsMode !== 'none' && ( - + setShowTrack(d.checked)} /> Show track +
+ + GPS track +
+
+ + Snapped to road +
Points