mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
feat(coordinates): added DDM format
This commit is contained in:
parent
7155429dc7
commit
d35e6063e7
@ -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);
|
||||
|
||||
@ -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
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else if (referenceSystem === "LatLngDDM") {
|
||||
return (
|
||||
<div
|
||||
className={`
|
||||
${props.className ?? ""}
|
||||
my-auto flex cursor-pointer justify-between gap-2 bg-olympus-400 p-2
|
||||
text-white
|
||||
`}
|
||||
onClick={
|
||||
props.onClick
|
||||
? props.onClick
|
||||
: (ev) => {
|
||||
setReferenceSystem("MGRS");
|
||||
ev.stopPropagation();
|
||||
}
|
||||
}
|
||||
>
|
||||
<div className="flex gap-2">
|
||||
<span
|
||||
className={`
|
||||
w-5 rounded-sm bg-white text-center font-bold text-olympus-700
|
||||
`}
|
||||
>
|
||||
{props.location.lat >= 0 ? "N" : "S"}
|
||||
</span>
|
||||
{DDToDDM(props.location.lat)}
|
||||
</div>
|
||||
<div className="flex w-[50%] gap-2">
|
||||
<span
|
||||
className={`
|
||||
w-5 rounded-sm bg-white text-center font-bold text-olympus-700
|
||||
`}
|
||||
>
|
||||
{props.location.lng >= 0 ? "E" : "W"}
|
||||
</span>
|
||||
{DDToDDM(props.location.lng)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ export function KeybindModal(props: { open: boolean }) {
|
||||
|
||||
return (
|
||||
<Modal open={props.open} size={"sm"}>
|
||||
<div className="flex flex-col gap-4 h-full w-full">
|
||||
<div className="flex h-full w-full flex-col gap-4">
|
||||
<div className={`flex flex-col gap-2`}>
|
||||
<span
|
||||
className={`
|
||||
@ -97,7 +97,7 @@ export function KeybindModal(props: { open: boolean }) {
|
||||
className={`flex flex-wrap gap-2 font-bold text-orange-600`}
|
||||
>
|
||||
{inUseShortcuts.map((shortcut) => (
|
||||
<span>{shortcut.getOptions().label}</span>
|
||||
<span key={shortcut.getId()}>{shortcut.getOptions().label}</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@ -105,7 +105,7 @@ export function KeybindModal(props: { open: boolean }) {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex justify-end mt-auto ">
|
||||
<div className="mt-auto flex justify-end">
|
||||
{shortcut && (
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@ -98,6 +98,7 @@ export function JTACMenu(props: { open: boolean; onClose: () => void; children?:
|
||||
onClick={() => {
|
||||
if (referenceSystem === "MGRS") setReferenceSystem("LatLngDec");
|
||||
else if (referenceSystem === "LatLngDec") setReferenceSystem("LatLngDMS");
|
||||
else if (referenceSystem === "LatLngDMS") setReferenceSystem("LatLngDDM");
|
||||
else setReferenceSystem("MGRS");
|
||||
}}
|
||||
referenceSystem={referenceSystem}
|
||||
@ -133,6 +134,7 @@ export function JTACMenu(props: { open: boolean; onClose: () => void; children?:
|
||||
onClick={() => {
|
||||
if (referenceSystem === "MGRS") setReferenceSystem("LatLngDec");
|
||||
else if (referenceSystem === "LatLngDec") setReferenceSystem("LatLngDMS");
|
||||
else if (referenceSystem === "LatLngDMS") setReferenceSystem("LatLngDDM");
|
||||
else setReferenceSystem("MGRS");
|
||||
}}
|
||||
referenceSystem={referenceSystem}
|
||||
@ -168,6 +170,7 @@ export function JTACMenu(props: { open: boolean; onClose: () => void; children?:
|
||||
onClick={() => {
|
||||
if (referenceSystem === "MGRS") setReferenceSystem("LatLngDec");
|
||||
else if (referenceSystem === "LatLngDec") setReferenceSystem("LatLngDMS");
|
||||
else if (referenceSystem === "LatLngDMS") setReferenceSystem("LatLngDDM");
|
||||
else setReferenceSystem("MGRS");
|
||||
}}
|
||||
referenceSystem={referenceSystem}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user