Skip to content

Commit

Permalink
Map: add aerodromes
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Sep 5, 2023
1 parent f9e89d4 commit 260d77d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 29 deletions.
33 changes: 8 additions & 25 deletions atciss-frontend/src/app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ type EBG = {
uir: string
sectors: string[]
majorAerodromes: string[]
minorAerodromes: string[]
aerodromes: string[]
relevantAerodromes: string[]
}
export const EBG_SETTINGS: { [name: string]: EBG } = {
EDMM_W: {
Expand All @@ -24,36 +26,17 @@ export const EBG_SETTINGS: { [name: string]: EBG } = {
"ZUG",
],
majorAerodromes: ["EDDM"],
aerodromes: [
"EDJA",
"EDMA",
// "EDME",
"EDMO",
// "EDMS",
// "EDMX",
// "EDPR",
// "ETHL",
"ETSI",
"ETSL",
"ETSN",
],
// "EDDS", "EDDF"
aerodromes: ["EDJA", "EDMA", "EDMO", "ETSI", "ETSL", "ETSN"],
minorAerodromes: ["EDME", "EDMS", "EDMX", "EDPR", "ETHL"],
relevantAerodromes: ["EDDS", "EDDF"],
},
EDMM_E: {
fir: "EDMM",
uir: "EDUU",
sectors: ["BBG", "FRK", "GER", "HAL", "HOF", "MEI", "SAS", "TRN", "TRS"],
majorAerodromes: ["EDDN", "EDDP"],
aerodromes: [
"EDDC",
"EDDE",
"EDQM",
// "EDAB",
// "EDQD",
// "EDQC",
// "EDQA",
// "ETEB",
// "ETIC",
],
aerodromes: ["EDDC", "EDDE", "EDQM"],
minorAerodromes: ["EDAB", "EDQD", "EDQC", "EDQA", "ETEB", "ETIC"],
relevantAerodromes: [],
},
}
5 changes: 4 additions & 1 deletion atciss-frontend/src/components/ADInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { usePollAtisByIcaoCodes } from "../services/atisApi"

export const ADinfo = ({ sx }: { sx?: ThemeUIStyleObject }) => {
const activeEbg = useAppSelector(selectActiveEbg)
const aerodromes: string[] = EBG_SETTINGS[activeEbg]?.aerodromes ?? []
const aerodromes: string[] = [
...EBG_SETTINGS[activeEbg].aerodromes,
...EBG_SETTINGS[activeEbg].relevantAerodromes,
]
const { data: metars } = usePollMetarByIcaoCodes(aerodromes)
const { data: atis } = usePollAtisByIcaoCodes(aerodromes)

Expand Down
2 changes: 1 addition & 1 deletion atciss-frontend/src/components/Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const Nav = ({ sx }: { sx?: ThemeUIStyleObject }) => {
onChange={(e) => dispatch(setActiveEbg(e.target.value))}
>
{Object.keys(EBG_SETTINGS).map((ebg) => (
<option>{ebg}</option>
<option key={ebg}>{ebg}</option>
))}
</select>
</Flex>
Expand Down
43 changes: 41 additions & 2 deletions atciss-frontend/src/views/Map.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { Flex, Grid, Input, Label, Slider, ThemeUIStyleObject } from "theme-ui"
import { MapContainer, TileLayer } from "react-leaflet"
import {
Flex,
Grid,
Input,
Label,
Slider,
Text,
ThemeUIStyleObject,
} from "theme-ui"
import { MapContainer, Marker, TileLayer, Tooltip } from "react-leaflet"
import { LatLngTuple } from "leaflet"
import "leaflet/dist/leaflet.css"
import { Sector, sectorApi } from "../services/airspaceApi"
Expand All @@ -8,6 +16,9 @@ import { SectorChoice } from "../components/map/SectorChoice"
import { useAppSelector } from "../app/hooks"
import { selectActivePositions } from "../services/activePositionSlice"
import { SectorPolygon } from "../components/map/SectorPolygon"
import { adApi } from "../services/adApi"
import { selectActiveEbg } from "../services/configSlice"
import { EBG_SETTINGS } from "../app/config"

const position = [49.2646, 11.4134] as LatLngTuple

Expand All @@ -17,7 +28,19 @@ const Map = ({ sx }: { sx?: ThemeUIStyleObject }) => {

const activePositions = useAppSelector(selectActivePositions)

const activeEbg = useAppSelector(selectActiveEbg)

const levelSliderId = useId()
const { data: aerodromes } = adApi.useGetByIcaoCodesQuery([
...new Set(
[
...EBG_SETTINGS[activeEbg].majorAerodromes,
...EBG_SETTINGS[activeEbg].aerodromes,
...EBG_SETTINGS[activeEbg].minorAerodromes,
...Object.keys(data?.airports ?? {}),
].filter((ad) => ad.startsWith("ED")),
),
])

const levelFilter = (s: Sector) =>
(s.min ?? 0) <= parseInt(level) && parseInt(level) < (s.max ?? 999)
Expand Down Expand Up @@ -67,6 +90,22 @@ const Map = ({ sx }: { sx?: ThemeUIStyleObject }) => {
))
: []
})}
{Object.values(aerodromes ?? {}).map((ad) => {
const station = data?.airports?.[
ad.locationIndicatorICAO
]?.topdown?.find((pos) => activePositions[pos])
return (
<Marker
position={[ad.latitude, ad.longitude]}
key={ad.locationIndicatorICAO}
>
<Tooltip>
<Text variant="label">{ad.locationIndicatorICAO}</Text>
{station ? ` by ${station}` : ""}
</Tooltip>
</Marker>
)
})}
</MapContainer>
<Flex sx={{ flexDirection: "column", gap: 3, overflow: "hidden" }}>
<Grid
Expand Down
2 changes: 2 additions & 0 deletions atciss-frontend/src/views/Notam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const Notam = ({ sx }: { sx?: ThemeUIStyleObject }) => {
EBG_SETTINGS[activeEbg].fir,
EBG_SETTINGS[activeEbg].uir,
...EBG_SETTINGS[activeEbg].aerodromes,
...EBG_SETTINGS[activeEbg].minorAerodromes,
...EBG_SETTINGS[activeEbg].relevantAerodromes,
])

// TODO:
Expand Down

0 comments on commit 260d77d

Please sign in to comment.