mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Clean up leaflet polygon API surface.
This commit is contained in:
@@ -255,7 +255,7 @@ export type GetFlightByIdApiArg = {
|
||||
withWaypoints?: boolean;
|
||||
};
|
||||
export type GetCommitBoundaryForFlightApiResponse =
|
||||
/** status 200 Successful Response */ number[][];
|
||||
/** status 200 Successful Response */ LatLng[];
|
||||
export type GetCommitBoundaryForFlightApiArg = {
|
||||
flightId: string;
|
||||
};
|
||||
@@ -352,26 +352,26 @@ export type HttpValidationError = {
|
||||
detail?: ValidationError[];
|
||||
};
|
||||
export type HoldZones = {
|
||||
homeBubble: number[][];
|
||||
targetBubble: number[][];
|
||||
joinBubble: number[][];
|
||||
excludedZones: number[][][];
|
||||
permissibleZones: number[][][];
|
||||
preferredLines: number[][][];
|
||||
homeBubble: LatLng[];
|
||||
targetBubble: LatLng[];
|
||||
joinBubble: LatLng[];
|
||||
excludedZones: LatLng[][];
|
||||
permissibleZones: LatLng[][];
|
||||
preferredLines: LatLng[][];
|
||||
};
|
||||
export type IpZones = {
|
||||
homeBubble: number[][];
|
||||
ipBubble: number[][];
|
||||
permissibleZone: number[][];
|
||||
safeZones: number[][][];
|
||||
homeBubble: LatLng[];
|
||||
ipBubble: LatLng[];
|
||||
permissibleZone: LatLng[];
|
||||
safeZones: LatLng[][];
|
||||
};
|
||||
export type JoinZones = {
|
||||
homeBubble: number[][];
|
||||
targetBubble: number[][];
|
||||
ipBubble: number[][];
|
||||
excludedZones: number[][][];
|
||||
permissibleZones: number[][][];
|
||||
preferredLines: number[][][];
|
||||
homeBubble: LatLng[];
|
||||
targetBubble: LatLng[];
|
||||
ipBubble: LatLng[];
|
||||
excludedZones: LatLng[][];
|
||||
permissibleZones: LatLng[][];
|
||||
preferredLines: LatLng[][];
|
||||
};
|
||||
export type Waypoint = {
|
||||
name: string;
|
||||
@@ -415,17 +415,17 @@ export type SupplyRoute = {
|
||||
active_transports: string[];
|
||||
};
|
||||
export type ThreatZones = {
|
||||
full: number[][][];
|
||||
aircraft: number[][][];
|
||||
air_defenses: number[][][];
|
||||
radar_sams: number[][][];
|
||||
full: LatLng[][];
|
||||
aircraft: LatLng[][];
|
||||
air_defenses: LatLng[][];
|
||||
radar_sams: LatLng[][];
|
||||
};
|
||||
export type ThreatZoneContainer = {
|
||||
blue: ThreatZones;
|
||||
red: ThreatZones;
|
||||
};
|
||||
export type NavMeshPoly = {
|
||||
poly: number[][];
|
||||
poly: LatLng[];
|
||||
threatened: boolean;
|
||||
};
|
||||
export type NavMesh = {
|
||||
@@ -446,9 +446,9 @@ export type Game = {
|
||||
map_center: LatLng;
|
||||
};
|
||||
export type MapZones = {
|
||||
inclusion: number[][][];
|
||||
exclusion: number[][][];
|
||||
sea: number[][][];
|
||||
inclusion: LatLng[][];
|
||||
exclusion: LatLng[][];
|
||||
sea: LatLng[][];
|
||||
};
|
||||
export type UnculledZone = {
|
||||
position: LatLng;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Flight } from "../../api/flight";
|
||||
import { useGetCommitBoundaryForFlightQuery } from "../../api/liberationApi";
|
||||
import WaypointMarker from "../waypointmarker";
|
||||
import { LatLng } from "leaflet";
|
||||
import { ReactElement } from "react";
|
||||
import { Polyline } from "react-leaflet";
|
||||
|
||||
@@ -83,15 +82,8 @@ function CommitBoundary(props: CommitBoundaryProps) {
|
||||
);
|
||||
return <></>;
|
||||
}
|
||||
// TODO: Fix the response model and clean up.
|
||||
const positions = data.map(([lat, lng]) => new LatLng(lat, lng));
|
||||
return (
|
||||
<Polyline
|
||||
positions={positions}
|
||||
color="#ffff00"
|
||||
weight={1}
|
||||
interactive={false}
|
||||
/>
|
||||
<Polyline positions={data} color="#ffff00" weight={1} interactive={false} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { selectNavMeshes } from "../../api/navMeshSlice";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
import { LatLng } from "leaflet";
|
||||
import { LayerGroup, Polygon } from "react-leaflet";
|
||||
|
||||
interface NavMeshLayerProps {
|
||||
@@ -13,11 +12,10 @@ export default function NavMeshLayer(props: NavMeshLayerProps) {
|
||||
return (
|
||||
<LayerGroup>
|
||||
{mesh.map((zone, idx) => {
|
||||
const positions = zone.poly.map(([lat, lng]) => new LatLng(lat, lng));
|
||||
return (
|
||||
<Polygon
|
||||
key={idx}
|
||||
positions={positions}
|
||||
positions={zone.poly}
|
||||
color="#000000"
|
||||
weight={1}
|
||||
fill
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import { LatLng } from "leaflet";
|
||||
import { LatLng } from "../../api/liberationApi";
|
||||
import { Polygon } from "react-leaflet";
|
||||
|
||||
interface ThreatZoneProps {
|
||||
poly: number[][];
|
||||
poly: LatLng[];
|
||||
blue: boolean;
|
||||
}
|
||||
|
||||
export default function ThreatZone(props: ThreatZoneProps) {
|
||||
const color = props.blue ? "#0084ff" : "#c85050";
|
||||
// TODO: Fix response model so the type can be used directly.
|
||||
const positions = props.poly.map(([lat, lng]) => new LatLng(lat, lng));
|
||||
return (
|
||||
<Polygon
|
||||
positions={positions}
|
||||
positions={props.poly}
|
||||
color={color}
|
||||
weight={1}
|
||||
fill
|
||||
|
||||
Reference in New Issue
Block a user