From 3092c1bc3a94f8a5f6b7ca1514c1a0732c9ca2e4 Mon Sep 17 00:00:00 2001 From: Tyler Lentz Date: Thu, 30 Nov 2023 19:31:38 -0800 Subject: [PATCH] pull into mission struct complete --- houston/src/pages/Input.tsx | 120 ++++++++++++++++++++++-------------- 1 file changed, 75 insertions(+), 45 deletions(-) diff --git a/houston/src/pages/Input.tsx b/houston/src/pages/Input.tsx index ed1bb822..9786edd3 100644 --- a/houston/src/pages/Input.tsx +++ b/houston/src/pages/Input.tsx @@ -1,11 +1,11 @@ -import { SetStateAction, useState, useEffect, FormEvent } from 'react'; +import { SetStateAction, useState, useEffect, FormEvent, ChangeEvent } from 'react'; import {useMapEvents, Polygon, Polyline} from "react-leaflet" import './Input.css'; import TuasMap from '../components/TuasMap'; import { LatLng } from 'leaflet'; -import { Bottle, BottleDropIndex, ODLCColor, ODLCShape } from '../protos/obc.pb'; +import { Bottle, BottleDropIndex, GPSCoord, Mission, ODLCColor, ODLCShape } from '../protos/obc.pb'; enum MapMode { FlightBound, @@ -69,7 +69,7 @@ function FormTable( ) { // add extra left column for the X button headings = ["---"].concat(headings); - + return ( <> @@ -242,27 +242,28 @@ function BottleInputForm( {bottleAssignments, setBottleAssignments}: {bottleAssignments: Bottle[], setBottleAssignments: React.Dispatch>} ) { - const mapColorsToOptions = (currentColor: ODLCColor) => - (Object.keys(ODLCColor) as unknown as Array) + function mapColorsToOptions() { + return (Object.keys(ODLCColor) as unknown as Array) .filter((color) => { - return (color != ODLCColor.UNRECOGNIZED) + return isNaN(Number(color)); + }) + .map((color) => { + return (<> + + ); + }); + } + function mapShapesToOptions() { + return (Object.keys(ODLCShape) as unknown as Array) + .filter((shape) => { + return isNaN(Number(shape)); }) - .map((color) => - <> - - - ) - - /* - - - - - - - - - */ + .map((shape) => { + return (<> + + ); + }); + } const bottleInput = (bottle: Bottle) => { return ( @@ -271,31 +272,36 @@ function BottleInputForm( Bottle {bottle.Index.toString()} @@ -307,10 +313,10 @@ function BottleInputForm( let bottles = []; for (let i = BottleDropIndex.A; i <= BottleDropIndex.E; i++) { let bottle = { - Alphanumeric: "A", - AlphanumericColor: ODLCColor.Black, - Shape: ODLCShape.Circle, - ShapeColor: ODLCColor.Black, + Alphanumeric: "", + AlphanumericColor: ODLCColor.UnspecifiedColor, + Shape: ODLCShape.UnspecifiedShape, + ShapeColor: ODLCColor.UnspecifiedColor, Index: i, IsMannikin: false } as Bottle; @@ -319,13 +325,9 @@ function BottleInputForm( setBottleAssignments(bottles); }, []); - function submitForm(_e: FormEvent) { - - } - return ( <> -
+
Bottle Input
@@ -432,10 +434,35 @@ function MapIllustrator( * @returns Input page */ function Input() { + // TODO: simplify all of these state variables into one mission state variable + // so instead of number[][] its actually storing them as GPS Coords... const [mapMode, setMapMode] = useState(MapMode.FlightBound); const [mapData, setMapData] = useState>(new Map()); const [bottleAssignments, setBottleAssignments] = useState([]); + function submitMission() { + const mapDataToGpsCoords = (mode: MapMode) => { + let config = getModeConfig(mode); + + return mapData.get(mode)?.map((row) => { + return ({ + Latitude: row[config.headings.indexOf("Latitude")], + Longitude: row[config.headings.indexOf("Longitude")], + Altitude: row[config.headings.indexOf("Altitude")], + } as GPSCoord); + }) || []; + }; + + let mission: Mission = { + BottleAssignments: bottleAssignments, + FlightBoundary: mapDataToGpsCoords(MapMode.FlightBound), + AirdropBoundary: mapDataToGpsCoords(MapMode.SearchBound), + Waypoints: mapDataToGpsCoords(MapMode.Waypoint), + }; + + console.log(mission); + } + return ( <>
@@ -454,6 +481,9 @@ function Input() { bottleAssignments={bottleAssignments} setBottleAssignments={setBottleAssignments} /> + + +