diff --git a/packages/client/src/components/molecules/MapMolecules/Map.tsx b/packages/client/src/components/molecules/MapMolecules/Map.tsx index 47917684..1375d1bd 100644 --- a/packages/client/src/components/molecules/MapMolecules/Map.tsx +++ b/packages/client/src/components/molecules/MapMolecules/Map.tsx @@ -27,12 +27,7 @@ import { } from "@shared/helios-types"; import MapControls from "./MapControls"; -import { - Hydrated_Grand_Full_course, - TRACK_LIST, - mapCameraControls, -} from "./MapSetup"; -import PacketMarker from "./PacketMarker"; +import { TRACK_LIST, mapCameraControls } from "./MapSetup"; const { distance, fitBounds, isOutsideBounds, lerp } = mapCameraControls; // @ts-expect-error:next-line @@ -94,13 +89,11 @@ export default function Map({ const [mapStates, setMapStates] = useState({ centered: true, currentCarLocation: carLocation, + isFullscreen: false, satelliteMode: false, }); const [popupOpen, setPopupOpen] = useState(false); const [viewTracks, setViewTracks] = useState(TRACK_LIST.map(() => true)); - const [dataPoints, setDataPoints] = useState( - Hydrated_Grand_Full_course, - ); const [mapControlsAdded, setMapControlsAdded] = useState(false); const mapRef = useRef(undefined); @@ -167,15 +160,22 @@ export default function Map({ map.getCenter().lng, ); const speedFactor = 80; + + const maxSpeed = 5; + const minSpeed = 1.5; + const rawSpeed = speedFactor * dist; + const speed = Math.min(Math.max(rawSpeed, minSpeed), maxSpeed); map.flyTo({ + bearing: map.getBearing(), center: [carLocation.long, carLocation.lat], curve: 1, // Adjust the curve of the animation easing: (t) => t, // Easing function for the animation - speed: speedFactor * dist, - zoom: 16, + pitch: map.getPitch(), + speed, + zoom: mapStates.isFullscreen ? 20 : 14, }); } - }, [carLocation, lapLocation, mapStates.centered]); + }, [carLocation, lapLocation, mapStates.centered, mapStates.isFullscreen]); const toggleMapStyle = useCallback(() => { setMapStates((prev) => ({ ...prev, satelliteMode: !prev.satelliteMode })); @@ -184,29 +184,45 @@ export default function Map({ const toggleCentred = useCallback(() => { setMapStates((prev) => ({ ...prev, centered: !prev.centered })); }, [setMapStates]); - const onMouseEnterDataPoint = useCallback( - (index: number) => { - setDataPoints((prevDataPoints) => - prevDataPoints.map((point, i) => - i === index ? { ...point, open: true } : point, - ), - ); - }, - [setDataPoints], - ); - const onMouseLeaveDataPoint = useCallback( - (index: number) => { - setDataPoints((prevDataPoints) => - prevDataPoints.map((point, i) => - i === index ? { ...point, open: false } : point, - ), - ); + + const geojson: FeatureCollection = { + features: [ + { + geometry: { + coordinates: [lapLocation.long, lapLocation.lat], + type: "Point", + }, + properties: { title: "Finish Line" }, + type: "Feature", + }, + ], + type: "FeatureCollection", + }; + + const layerStyle: LayerProps = { + id: "finish-line", + paint: { + "circle-color": "#B94A6C", + "circle-opacity": 0.8, + "circle-radius": [ + "interpolate", + ["linear"], + ["zoom"], + 10, + 10, + 15, + 10, + 20, + 150, + ], + "circle-stroke-color": "#9C0534", + "circle-stroke-width": 2, }, - [setDataPoints], - ); + type: "circle", + }; return ( -
+
setViewState(evt.viewState)} + onMove={(evt) => { + setViewState(evt.viewState); + }} ref={(instance) => { if (instance) { mapRef.current = instance; @@ -260,39 +278,37 @@ export default function Map({ > map-pin setPopupOpen(true)} onMouseLeave={() => setPopupOpen(false)} src={HeliosModel} style={{ transform: `rotate(${calculateBearing(mapStates.currentCarLocation, carLocation)}deg)`, }} - width={20} + width={mapStates.isFullscreen ? 60 : 20} /> - - - {dataPoints.map((packetMarker, index) => ( - - ))} + + {mapStates.isFullscreen && ( + + + + )} + {TRACK_LIST.map(({ layerProps, sourceProps }, index) => { if (!viewTracks[index]) return null; return ( diff --git a/packages/client/src/components/molecules/MapMolecules/MapSetup.ts b/packages/client/src/components/molecules/MapMolecules/MapSetup.ts index f9cd2c0d..25877a43 100644 --- a/packages/client/src/components/molecules/MapMolecules/MapSetup.ts +++ b/packages/client/src/components/molecules/MapMolecules/MapSetup.ts @@ -680,470 +680,149 @@ const GRAND_MAX_STRAIGHT_GEO_JSON = { id: "root", type: "FeatureCollection", }; +const GRAND_FULL_COURSE_ORIGINAL = [ + [-86.363608991, 37.003595476], + [-86.363525842, 37.004265921], + [-86.36270777, 37.004837829], + [-86.362694359, 37.005386171], + [-86.362514652, 37.005653915], + [-86.36207477, 37.00575887], + [-86.361728765, 37.005591798], + [-86.361498095, 37.005178401], + [-86.361648299, 37.004884951], + [-86.361849464, 37.00446084], + [-86.361669756, 37.004139542], + [-86.361197687, 37.0040303], + [-86.360677338, 37.004278771], + [-86.360570052, 37.004632199], + [-86.360500311, 37.004912795], + [-86.360390341, 37.005356181], + [-86.360344743, 37.005645345], + [-86.36043862, 37.005945216], + [-86.360819493, 37.006125139], + [-86.361404215, 37.006365035], + [-86.362300073, 37.006446429], + [-86.362911616, 37.006262223], + [-86.363415872, 37.00589381], + [-86.363786017, 37.005251225], + [-86.364220534, 37.00460435], + [-86.364719425, 37.004171671], + [-86.365277324, 37.003691863], + [-86.365845952, 37.003130656], + [-86.366473589, 37.002629422], + [-86.368034635, 37.001926832], + [-86.368689093, 37.001665502], + [-86.369606408, 37.001691207], + [-86.370078477, 37.001695491], + [-86.370443257, 37.001348477], + [-86.370743665, 37.001091428], + [-86.371446404, 37.000778684], + [-86.371945295, 37.000555907], + [-86.372192058, 37.000598749], + [-86.372256431, 37.000855799], + [-86.372127685, 37.001151406], + [-86.371811184, 37.001545547], + [-86.371280107, 37.001832583], + [-86.370362791, 37.00211105], + [-86.369971189, 37.002380947], + [-86.369702968, 37.002903603], + [-86.369381103, 37.003353427], + [-86.368785652, 37.00345196], + [-86.368383321, 37.003254895], + [-86.367879066, 37.002916455], + [-86.367546472, 37.002903603], + [-86.366940292, 37.00316493], + [-86.36650041, 37.00366616], + [-86.366505775, 37.003974608], + [-86.367691311, 37.004313043], + [-86.368447694, 37.004467266], + [-86.369000229, 37.004394438], + [-86.369456204, 37.004175956], + [-86.369922909, 37.003691865], + [-86.370829495, 37.002663696], + [-86.372068676, 37.001948254], + [-86.372841153, 37.001271363], + [-86.374214444, 36.999823309], + [-86.37438074, 36.999564113], + [-86.374321731, 36.999242794], + [-86.374192985, 36.999009302], + [-86.373747739, 36.998990023], + [-86.37298063, 36.999154968], + [-86.372288617, 36.999343474], + [-86.371164771, 36.999844729], + [-86.36983976, 37.000433808], + [-86.367600115, 37.001491996], + [-86.364697966, 37.002854337], + [-86.363914762, 37.003231334], + [-86.363608991, 37.003595476], // loop back to start +]; + +function interpolatePoints(a: number[], b: number[], steps: number) { + const points = []; + for (let i = 1; i < steps; i++) { + const t = i / steps; + if ( + a && + b && + a[0] !== undefined && + a[1] !== undefined && + b[0] !== undefined && + b[1] !== undefined + ) { + points.push([a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t]); + } + } + return points; +} + +const GRAND_FULL_COURSE_DENSE: unknown[] = []; +let idCounter = 0; +for (let i = 0; i < GRAND_FULL_COURSE_ORIGINAL.length - 1; i++) { + const a = GRAND_FULL_COURSE_ORIGINAL[i]; + const b = GRAND_FULL_COURSE_ORIGINAL[i + 1]; + GRAND_FULL_COURSE_DENSE.push({ + geometry: { coordinates: a, type: "Point" }, + id: `dense${idCounter++}`, + properties: {}, + type: "Feature", + }); + // Add 4 interpolated points between each pair + if (a && b) { + interpolatePoints(a, b, 5).forEach((coords) => { + GRAND_FULL_COURSE_DENSE.push({ + geometry: { coordinates: coords, type: "Point" }, + id: `dense${idCounter++}`, + properties: {}, + type: "Feature", + }); + }); + } +} + +// Add the last point +GRAND_FULL_COURSE_DENSE.push({ + geometry: { coordinates: GRAND_FULL_COURSE_ORIGINAL.at(-1)!, type: "Point" }, + id: `dense${idCounter++}`, + properties: {}, + type: "Feature", +}); + const GRAND_FULL_COURSE_GEO_JSON = { - features: [ - { - geometry: { coordinates: [-86.363608991, 37.003595476], type: "Point" }, - id: "sma85350e6", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.363525842, 37.004265921], type: "Point" }, - id: "sm7270301a", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.363013541, 37.004657904], type: "Point" }, - id: "sm0ccceba4", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.36270777, 37.004837829], type: "Point" }, - id: "sm0c2176b8", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.362694359, 37.005386171], type: "Point" }, - id: "sme0fd315c", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.362514652, 37.005653915], type: "Point" }, - id: "sm02710934", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.36207477, 37.00575887], type: "Point" }, - id: "sm3d2e60bd", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361728765, 37.005591798], type: "Point" }, - id: "sm8ca40e45", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361498095, 37.005178401], type: "Point" }, - id: "sm7eabddd0", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361648299, 37.004884951], type: "Point" }, - id: "sm20b9ada9", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361849464, 37.00446084], type: "Point" }, - id: "sm8dc776ea", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361669756, 37.004139542], type: "Point" }, - id: "smf243ba54", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361197687, 37.0040303], type: "Point" }, - id: "sm8ec26ec5", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.360677338, 37.004278771], type: "Point" }, - id: "sm271a0c2e", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.360570052, 37.004632199], type: "Point" }, - id: "sm51becaf8", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.360500311, 37.004912795], type: "Point" }, - id: "sm45a8ac64", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.360390341, 37.005356181], type: "Point" }, - id: "sm04eb3d03", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.360344743, 37.005645345], type: "Point" }, - id: "sm465d5bbd", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.36043862, 37.005945216], type: "Point" }, - id: "sm42d287ef", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.360819493, 37.006125139], type: "Point" }, - id: "sma0ecb2c4", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.361404215, 37.006365035], type: "Point" }, - id: "sm74d18684", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.362300073, 37.006446429], type: "Point" }, - id: "sm52a30982", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.362911616, 37.006262223], type: "Point" }, - id: "smb17c50e8", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.363415872, 37.00589381], type: "Point" }, - id: "smf0bb72ef", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.363786017, 37.005251225], type: "Point" }, - id: "sm9ac9ffed", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.364220534, 37.00460435], type: "Point" }, - id: "smc9c2ad47", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.364719425, 37.004171671], type: "Point" }, - id: "sm94cca9a9", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.365277324, 37.003691863], type: "Point" }, - id: "sm641fc855", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.365845952, 37.003130656], type: "Point" }, - id: "sm046db624", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.366473589, 37.002629422], type: "Point" }, - id: "sm7a3043c1", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.368034635, 37.001926832], type: "Point" }, - id: "sm54c39eea", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.368689093, 37.001665502], type: "Point" }, - id: "sm6991b5aa", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369606408, 37.001691207], type: "Point" }, - id: "sm7ad11996", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.370078477, 37.001695491], type: "Point" }, - id: "smedf14920", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.370443257, 37.001348477], type: "Point" }, - id: "sm67431388", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.370743665, 37.001091428], type: "Point" }, - id: "smaf2eee8b", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.371446404, 37.000778684], type: "Point" }, - id: "sm9a5158f7", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.371945295, 37.000555907], type: "Point" }, - id: "smb584eea4", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.372192058, 37.000598749], type: "Point" }, - id: "sm427af187", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.372256431, 37.000855799], type: "Point" }, - id: "smcd26cfbd", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.372127685, 37.001151406], type: "Point" }, - id: "sma7945d34", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.371811184, 37.001545547], type: "Point" }, - id: "sm1c38f1d4", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.371280107, 37.001832583], type: "Point" }, - id: "sm4ea18f36", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.370362791, 37.00211105], type: "Point" }, - id: "smdb30d270", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369971189, 37.002380947], type: "Point" }, - id: "sm9c482eac", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369702968, 37.002903603], type: "Point" }, - id: "sm2d668b8e", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369381103, 37.003353427], type: "Point" }, - id: "sm43ee265f", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.368785652, 37.00345196], type: "Point" }, - id: "sm7eeb1071", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.368383321, 37.003254895], type: "Point" }, - id: "sm0fe86ac3", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.367879066, 37.002916455], type: "Point" }, - id: "sme40c2b8d", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.367546472, 37.002903603], type: "Point" }, - id: "sm873274a6", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.366940292, 37.00316493], type: "Point" }, - id: "sme62aa6c3", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.36650041, 37.00366616], type: "Point" }, - id: "sm8ec06207", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.366505775, 37.003974608], type: "Point" }, - id: "smaf8b045c", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.367691311, 37.004313043], type: "Point" }, - id: "smb5843186", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.368447694, 37.004467266], type: "Point" }, - id: "sma2e94d94", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369000229, 37.004394438], type: "Point" }, - id: "smb91bcaf6", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369456204, 37.004175956], type: "Point" }, - id: "sm7f70cc04", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.369922909, 37.003691865], type: "Point" }, - id: "smfc42c285", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.370829495, 37.002663696], type: "Point" }, - id: "sma6c5c962", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.372068676, 37.001948254], type: "Point" }, - id: "sm2f1dfe11", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.372841153, 37.001271363], type: "Point" }, - id: "smfd15f9d6", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.374214444, 36.999823309], type: "Point" }, - id: "smb46027b1", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.37438074, 36.999564113], type: "Point" }, - id: "sm0e9e66c5", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.374321731, 36.999242794], type: "Point" }, - id: "sm83364f72", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.374192985, 36.999009302], type: "Point" }, - id: "sm09cb4e0c", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.373747739, 36.998990023], type: "Point" }, - id: "sme1d98c0c", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.37298063, 36.999154968], type: "Point" }, - id: "sm496a41a7", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.372288617, 36.999343474], type: "Point" }, - id: "sm197bb154", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.371164771, 36.999844729], type: "Point" }, - id: "smbdcde48f", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.36983976, 37.000433808], type: "Point" }, - id: "sm6ef753fb", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.367600115, 37.001491996], type: "Point" }, - id: "sm20de3f1b", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.364697966, 37.002854337], type: "Point" }, - id: "smbbe4046c", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.363914762, 37.003231334], type: "Point" }, - id: "sm93f01508", - properties: {}, - type: "Feature", - }, - { - geometry: { coordinates: [-86.363608991, 37.003595476], type: "Point" }, - id: "sma85350e6", - properties: {}, - type: "Feature", - }, - ], + features: GRAND_FULL_COURSE_DENSE, id: "root", type: "FeatureCollection", }; const CORVETTE_RACE_LOOP = CORVETTE_RACE_LOOP_GEO_JSON.features.map( - (feature) => feature.geometry.coordinates, + (feature) => + (feature as { geometry: { coordinates: number[] } }).geometry.coordinates, ); const GRAND_MAX_STRAIGHT = GRAND_MAX_STRAIGHT_GEO_JSON.features.map( - (feature) => feature.geometry.coordinates, + (feature) => + (feature as { geometry: { coordinates: number[] } }).geometry.coordinates, ); const GRAND_FULL_COURSE = GRAND_FULL_COURSE_GEO_JSON.features.map( - (feature) => feature.geometry.coordinates, + (feature) => + (feature as { geometry: { coordinates: number[] } }).geometry.coordinates, ); const raceTrackGeoJSON = { features: [ diff --git a/packages/client/src/components/molecules/MapMolecules/PacketMarker.tsx b/packages/client/src/components/molecules/MapMolecules/PacketMarker.tsx deleted file mode 100644 index 68475533..00000000 --- a/packages/client/src/components/molecules/MapMolecules/PacketMarker.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { JSX } from "react"; -import { Marker, Popup } from "react-map-gl"; - -import SportsScoreIcon from "@mui/icons-material/SportsScore"; - -import type { PacketMarkerData } from "./Map"; - -export default function PacketMarker(props: { - packetMarker: PacketMarkerData; - index: number; - setDataPoints: React.Dispatch>; - onMouseEnterDataPoint: (index: number) => void; - onMouseLeaveDataPoint: (index: number) => void; -}): JSX.Element { - const { index, onMouseEnterDataPoint, onMouseLeaveDataPoint, packetMarker } = - props; - const { data, markerCoords, open } = packetMarker; - return ( - <> - {open && {data.TimeStamp}} - - onMouseEnterDataPoint(index)} - onMouseLeave={() => onMouseLeaveDataPoint(index)} - /> - - - ); -} diff --git a/packages/client/src/contexts/AppStateContext.tsx b/packages/client/src/contexts/AppStateContext.tsx index 9d9095e4..2184a04f 100644 --- a/packages/client/src/contexts/AppStateContext.tsx +++ b/packages/client/src/contexts/AppStateContext.tsx @@ -71,7 +71,7 @@ export function AppStateContextProvider({ children }: Props) { displayLoading: true, error: false, favourites: [], - lapCoords: { lat: 37.001949324, long: -86.366554059 }, + lapCoords: { lat: 51.081021, long: -114.136084 }, loading: true, playbackSwitch: false, radioConnected: false, diff --git a/packages/server/src/controllers/BackendController/BackendController.ts b/packages/server/src/controllers/BackendController/BackendController.ts index abf834e5..cf366f4c 100644 --- a/packages/server/src/controllers/BackendController/BackendController.ts +++ b/packages/server/src/controllers/BackendController/BackendController.ts @@ -9,7 +9,7 @@ import { SolarMQTTClient } from "@/datasources/SolarMQTTClient/SolarMQTTClient"; import { options } from "@/datasources/SolarMQTTClient/SolarMQTTClient.types"; import { logger } from "@/index"; -import { ILapData, type ITelemetryData } from "@shared/helios-types"; +import { type ITelemetryData, devFlag } from "@shared/helios-types"; //getDriverInfo export class BackendController implements BackendControllerTypes { @@ -45,7 +45,11 @@ export class BackendController implements BackendControllerTypes { public async handlePacketReceive(message: ITelemetryData) { // Insert the packet into the database - this.dynamoDB.insertPacketData(message); + console.log(process.env.NODE_ENV); + if (!devFlag) { + this.dynamoDB.insertPacketData(message); + logger.info("Inserting packet data into DynamoDB"); + } // Broadcast the packet to the frontend this.socketIO.broadcastPacket(message); diff --git a/packages/server/src/controllers/LapController/LapController.ts b/packages/server/src/controllers/LapController/LapController.ts index 92b26139..7dbcb853 100644 --- a/packages/server/src/controllers/LapController/LapController.ts +++ b/packages/server/src/controllers/LapController/LapController.ts @@ -37,8 +37,8 @@ export class LapController implements LapControllerType { public previouslyInFinishLineProximity: boolean = false; public lapNumber: number = 0; public finishLineLocation: Coords = { - lat: 37.001949324, - long: -86.366554059, + lat: 51.081021, + long: -114.136084, }; backendController: BackendController; @@ -76,7 +76,7 @@ export class LapController implements LapControllerType { public async handleLapData(lapData: ILapData) { await this.backendController.socketIO.broadcastLapData(lapData); - await this.backendController.dynamoDB.insertLapData(lapData); + if (!devFlag) await this.backendController.dynamoDB.insertLapData(lapData); } public async handlePacket(packet: ITelemetryData) { diff --git a/packages/shared/src/prodFlag.ts b/packages/shared/src/prodFlag.ts index 0ca6433c..c05b3980 100644 --- a/packages/shared/src/prodFlag.ts +++ b/packages/shared/src/prodFlag.ts @@ -7,3 +7,5 @@ export const prodURL = process.env.NODE_ENV === "production" ? "https://aedes.calgarysolarcar.ca:3001" : "http://localhost:3001"; + +export const devFlag = process.env.NODE_ENV === "development" ? true : false;