Skip to content

Commit 56d6469

Browse files
comments
1 parent c2be92b commit 56d6469

File tree

10 files changed

+59
-0
lines changed

10 files changed

+59
-0
lines changed

examples/playground/src/components/map/avwx.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@ export const weatherColors: Record<AVWXSource, string> = {
1818
SIGMET: "rgb(27, 136, 136)",
1919
}
2020

21+
/**
22+
* Handles the rendering of Aviation Weather reports to the map
23+
*/
2124
const Avwx = memo(() => {
2225
const weatherApi = getWeatherApi()
2326

2427
const sources = useRecoilValue(avwxState)
2528

29+
// Queries reports for all of the selected AVWX layers
2630
const layers = useQueries({
2731
queries: sources.map(source => ({
2832
queryKey: ["avwx", source],
2933
queryFn: async () => [source, await weatherApi.getAvwxReports([source])] as const,
3034
})),
3135
})
3236

37+
// Store refs to the map layers so they can be updated based on selections
3338
const layersRef = useRef<Partial<Record<AVWXSource, LeafletGeoJSON>>>({})
3439

3540
return layers.map(({ data }) => {

examples/playground/src/components/map/weatherRoute.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { Marker, Polyline, useMap } from "react-leaflet"
44
import { useRecoilState } from "recoil"
55
import { weatherRouteEditState, weatherRouteState } from "../../state/weather"
66

7+
/**
8+
* Handles the creation and rendering of routes for weather queries along routes
9+
*/
710
export default function WeatherRouteManager() {
811
const map = useMap()
912

@@ -15,17 +18,20 @@ export default function WeatherRouteManager() {
1518

1619
useEffect(() => {
1720
const clickCallback = (e: LeafletMouseEvent) => {
21+
// If the edit process is active, append the location of any clicks to the route array
1822
if (editActive) {
1923
setRoute([...route, e.latlng])
2024
}
2125
}
2226

2327
const mouseMoveCallback = (e: LeafletMouseEvent) => {
28+
// If the edit process is active, set the nextPosition state to the lat/lng position of the mouse for an indication of where the next line will be
2429
if (editActive) {
2530
setNextPosition(e.latlng)
2631
}
2732
}
2833

34+
// If the edit process is not active, the nextPosition should not be rendered
2935
if (!editActive) {
3036
setNextPosition(null)
3137
}
@@ -41,6 +47,7 @@ export default function WeatherRouteManager() {
4147

4248
useEffect(() => {
4349
const callback = (e: KeyboardEvent) => {
50+
// Whenever editing is active, pressing enter should stop it
4451
if (e.key === "Enter" && editActive) {
4552
setEditActive(false)
4653
}

packages/weather/src/api/avwx/getAvwxReports.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ import { FeatureCollection, Geometry } from "geojson"
44
import { getAvwxApiRoot } from "../../constants"
55
import { AVWXSource, AVWXSourceProperties } from "../types"
66

7+
/**
8+
* Queries GeoJSON data for all AVWX reports currently available from the selected sources
9+
* @param sources - List of sources to from which to load AVWX reports from
10+
* @returns A GEOJson feature collection containing the reports
11+
*/
712
export default async function getAvwxReports<S extends AVWXSource>(sources: S[]) {
813
const result = await navigraphRequest
914
.get<FeatureCollection<Geometry, AVWXSourceProperties[S]>>(`${getAvwxApiRoot()}/combined`, {

packages/weather/src/api/getReportsAlongRoute.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { Position } from "geojson"
44
import { getRouteApiRoot } from "../constants"
55
import { Metar, Taf } from "./types"
66

7+
/**
8+
* Queries all TAFs or METARs within a certain range of a geographic route issued within approximately the last 10 hours
9+
* @param path - List of coordinates making up the query route
10+
* @param type - The type of report to query, either `'metar'` or `'taf'`
11+
* @returns - An array of TAF or METAR objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
12+
*/
713
export default async function getReportsAlongRoute<T extends "metar" | "taf">(
814
path: Position[],
915
type: T,

packages/weather/src/api/metar/getMetarAtAirport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getMetarApiRoot } from "../../constants"
44
import { Metar } from "../types"
55

6+
/**
7+
* Queries the most recently issued METAR for a given airport
8+
* @param icao - The ICAO code of the airport from which to load the METAR
9+
* @returns - A METAR object parsed from the raw report using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
10+
*/
611
export default async function getMetarAtAirport(icao: string) {
712
const result = await navigraphRequest
813
.get<Metar>(`${getMetarApiRoot()}/${icao}`)

packages/weather/src/api/metar/getMetarsAroundPoint.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getMetarApiRoot } from "../../constants"
44
import { Metar } from "../types"
55

6+
/**
7+
* Queries all METARs within a distance of a point issued within approximately the last 10 hours, ordered by distance from the center point
8+
* @param latitude - Latitude of the center point
9+
* @param longitude - longitude of the center point
10+
* @param radius - Radius in **nautical miles** around the center point to search for METARs within
11+
* @param limit - Maximum number of METARs to return
12+
* @returns - An array of METAR objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
13+
*/
614
export default async function getMetarsAroundPoint(
715
latitude: number,
816
longitude: number,

packages/weather/src/api/metar/getMetarsAtAirport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getMetarApiRoot } from "../../constants"
44
import { Metar } from "../types"
55

6+
/**
7+
* Queries all METARs for an airport issued within approximately the last 10 hours
8+
* @param icao - The ICAO code of the airport from which to load the METARs
9+
* @returns - An array of METAR objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
10+
*/
611
export default async function getMetarsAtAirport(icao: string) {
712
const result = await navigraphRequest
813
.get<Metar[]>(`${getMetarApiRoot()}/multi/${icao}`)

packages/weather/src/api/taf/getTafAtAirport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getTafApiRoot } from "../../constants"
44
import { Taf } from "../types"
55

6+
/**
7+
* Queries the most recently issued TAF for a given airport
8+
* @param icao - The ICAO code of the airport from which to load the TAF
9+
* @returns - A TAF object parsed from the raw report using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
10+
*/
611
export default async function getTafAtAirport(icao: string) {
712
const result = await navigraphRequest
813
.get<Taf>(`${getTafApiRoot()}/${icao}`)

packages/weather/src/api/taf/getTafsAroundPoint.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getTafApiRoot } from "../../constants"
44
import { Taf } from "../types"
55

6+
/**
7+
* Queries all TAFs within a distance of a point issued within approximately the last 10 hours, ordered by distance from the center point
8+
* @param latitude - Latitude of the center point
9+
* @param longitude - longitude of the center point
10+
* @param radius - Radius in **nautical miles** around the center point to search for TAFs within
11+
* @param limit - Maximum number of TAFs to return
12+
* @returns - An array of TAF objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
13+
*/
614
export default async function getTafsAroundPoint(latitude: number, longitude: number, radius?: number, limit?: number) {
715
const result = await navigraphRequest
816
.get<Taf[]>(`${getTafApiRoot()}/around/${latitude}/${longitude}`, {

packages/weather/src/api/taf/getTafsAtAirport.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { isAxiosError, navigraphRequest } from "@navigraph/auth"
33
import { getTafApiRoot } from "../../constants"
44
import { Taf } from "../types"
55

6+
/**
7+
* Queries all TAFs for an airport issued within approximately the last 10 hours
8+
* @param icao - The ICAO code of the airport from which to load the TAFs
9+
* @returns - An array of TAF objects parsed from the raw reports using {@link https://www.npmjs.com/package/metar-taf-parser metar-taf-parser}
10+
*/
611
export default async function getTafsAtAirport(icao: string) {
712
const result = await navigraphRequest
813
.get<Taf[]>(`${getTafApiRoot()}/multi/${icao}`)

0 commit comments

Comments
 (0)