From d35e6063e7e06eb70dd898180c86fe926237b8a4 Mon Sep 17 00:00:00 2001 From: MarcoJayUsai Date: Sat, 22 Mar 2025 10:21:08 +0100 Subject: [PATCH 1/2] feat(coordinates): added DDM format --- frontend/react/src/other/utils.ts | 7 +++ .../react/src/ui/components/ollocation.tsx | 43 ++++++++++++++++++- frontend/react/src/ui/modals/keybindmodal.tsx | 6 +-- frontend/react/src/ui/panels/jtacmenu.tsx | 3 ++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/frontend/react/src/other/utils.ts b/frontend/react/src/other/utils.ts index df0b6577..d2b01d07 100644 --- a/frontend/react/src/other/utils.ts +++ b/frontend/react/src/other/utils.ts @@ -83,6 +83,13 @@ export function ConvertDDToDMS(D: number, lng: boolean) { else return zeroPad(deg, 2) + "°" + zeroPad(min, 2) + "'" + zeroPad(sec, 2) + "." + zeroPad(dec, 2) + '"'; } +export function DDToDDM(decimalDegrees) { + const degrees = Math.trunc(decimalDegrees); + const minutes = Math.abs((decimalDegrees - degrees) * 60); + + return `${Math.abs(degrees)}° ${minutes.toFixed(4)}'`; +} + export function deg2rad(deg: number) { var pi = Math.PI; return deg * (pi / 180); diff --git a/frontend/react/src/ui/components/ollocation.tsx b/frontend/react/src/ui/components/ollocation.tsx index 34e142f5..f6a76ef2 100644 --- a/frontend/react/src/ui/components/ollocation.tsx +++ b/frontend/react/src/ui/components/ollocation.tsx @@ -1,6 +1,6 @@ import React, { useState } from "react"; import { LatLng } from "leaflet"; -import { ConvertDDToDMS, latLngToMGRS, latLngToUTM, zeroAppend } from "../../other/utils"; +import { ConvertDDToDMS, DDToDDM, latLngToMGRS, latLngToUTM, zeroAppend } from "../../other/utils"; export function OlLocation(props: { location: LatLng; className?: string; referenceSystem?: string; onClick?: () => void }) { const [referenceSystem, setReferenceSystem] = props.referenceSystem ? [props.referenceSystem, () => {}] : useState("LatLngDec"); @@ -82,7 +82,7 @@ export function OlLocation(props: { location: LatLng; className?: string; refere props.onClick ? props.onClick : (ev) => { - setReferenceSystem("MGRS"); + setReferenceSystem("LatLngDDM"); ev.stopPropagation(); } } @@ -109,6 +109,45 @@ export function OlLocation(props: { location: LatLng; className?: string; refere ); + } else if (referenceSystem === "LatLngDDM") { + return ( +
{ + setReferenceSystem("MGRS"); + ev.stopPropagation(); + } + } + > +
+ + {props.location.lat >= 0 ? "N" : "S"} + + {DDToDDM(props.location.lat)} +
+
+ + {props.location.lng >= 0 ? "E" : "W"} + + {DDToDDM(props.location.lng)} +
+
+ ); } else { } } diff --git a/frontend/react/src/ui/modals/keybindmodal.tsx b/frontend/react/src/ui/modals/keybindmodal.tsx index fd98864d..bd4e8a65 100644 --- a/frontend/react/src/ui/modals/keybindmodal.tsx +++ b/frontend/react/src/ui/modals/keybindmodal.tsx @@ -62,7 +62,7 @@ export function KeybindModal(props: { open: boolean }) { return ( -
+
{inUseShortcuts.map((shortcut) => ( - {shortcut.getOptions().label} + {shortcut.getOptions().label} ))}
@@ -105,7 +105,7 @@ export function KeybindModal(props: { open: boolean }) {
)} -
+
{shortcut && (
@@ -959,9 +935,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Full evasion: the unit will try to evade the threat both manoeuvering and using counter-measures
@@ -1016,9 +990,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Radio silence: No radar or ECM will be used @@ -1026,9 +998,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Defensive: The unit will turn radar and ECM on only when threatened @@ -1036,9 +1006,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Attack: The unit will use radar and ECM when engaging other units @@ -1046,9 +1014,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Free: the unit will use the radar and ECM all the time @@ -1269,9 +1235,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
@@ -1451,9 +1415,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {/* ============== Operate as toggle START ============== */} {selectedUnits.every((unit) => unit.getCoalition() === "neutral") && (
void }) { >
Barrel height:{" "}
void }) { }} >
m
Muzzle velocity:{" "}
void }) { }} >
m/s
Aim time:{" "}
void }) { }} >
s
Shots to fire:{" "}
void }) {
Shots base interval:{" "}
void }) { }} >
s
Shots base scatter:{" "}
void }) { }} >
deg
Engagement range:{" "}
void }) { }} >
m
Targeting range:{" "}
void }) { }} >
m
Aim method range:{" "}
void }) { }} >
m
Acquisition range:{" "}
void }) { }} >
m
diff --git a/frontend/react/src/unit/unit.ts b/frontend/react/src/unit/unit.ts index eece5f48..1bb25f9d 100644 --- a/frontend/react/src/unit/unit.ts +++ b/frontend/react/src/unit/unit.ts @@ -60,6 +60,7 @@ import * as turf from "@turf/turf"; import { Carrier } from "../mission/carrier"; import { ContactsUpdatedEvent, + CoordinatesFreezeEvent, HiddenTypesChangedEvent, MapOptionsChangedEvent, UnitContextMenuRequestEvent, @@ -1611,6 +1612,7 @@ export abstract class Unit extends CustomMarker { } #onLeftShortClick(e: any) { + CoordinatesFreezeEvent.dispatch(); DomEvent.stop(e); DomEvent.preventDefault(e); e.originalEvent.stopImmediatePropagation();