Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Using a reverse proxy such as Nginx, configure the following:
- GET `/api/openmeteo/{proxy+}` ➡ `https://api.open-meteo.com/v1/{proxy}` Get worldwide winds aloft and forecast information
- OPTIONAL endpoints (to further enhance basic global support):
- GET `/api/rap` ➡ `https://rucsoundings.noaa.gov/get_soundings.cgi`
- GET `/api/aviationweather` ➡ `https://www.aviationweather.gov/adds/dataserver_current/httpparam`
- GET `/api/aviationweather` ➡ `https://www.aviationweather.gov/api/data/taf`
- GET `/api/weather/{proxy+}` ➡ `https://api.weather.gov/{proxy}` Greedy path capturing, forwards to api.weather.gov.
- GET `/api/pqs` ➡ `https://epqs.nationalmap.gov/v1/json` Get United States altitude information for a given geolocation.
- GET `/api/googleelevation` ➡ `https://maps.googleapis.com/maps/api/elevation/json` Get global altitude information for a given geolocation (backup API).
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"detect-browser": "^5.3.0",
"emotion": "^11.0.0",
"eslint-plugin-react-compiler": "^19.1.0-rc.2",
"fast-xml-parser": "^5.3.0",
"geolib": "^3.3.4",
"gsl-parser": "^3.0.1",
"i18next": "^25.6.0",
Expand Down
16 changes: 0 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 13 additions & 17 deletions src/services/aviationWeather.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
import axios from "axios";
import { XMLParser } from "fast-xml-parser";
import type { GeometryObject } from "geojson";

const parser = new XMLParser();

export interface TAFReport {
raw: string;
issued: string;
lat: number;
lon: number;
}

// Proxy to https://www.aviationweather.gov/adds/dataserver_current/httpparam
// Proxy to https://www.aviationweather.gov/api/data/taf
export async function getTAF({
lat,
lon,
}: {
lat: number;
lon: number;
}): Promise<TAFReport | undefined> {
// Create a bounding box around the point (approximately 35nm radius)
// 1 degree ≈ 60nm, so 35nm ≈ 0.58 degrees
const buffer = 0.58;
const bbox = `${lat - buffer},${lon - buffer},${lat + buffer},${lon + buffer}`;

const response = await axios.get("/api/aviationweather", {
params: {
dataSource: "tafs",
requestType: "retrieve",
format: "xml",
radialDistance: `35;${lon},${lat}`,
hoursBeforeNow: 3,
mostRecent: true,
fields: ["raw_text", "issue_time", "latitude", "longitude"].join(","),
bbox,
format: "json",
},
});
const parsed = parser.parse(response.data);

if (!parsed.response.data?.TAF) return;
const tafData = response.data[0];

return {
raw: parsed.response.data.TAF.raw_text,
issued: parsed.response.data.TAF.issue_time,
lat: +parsed.response.data.TAF.latitude,
lon: +parsed.response.data.TAF.longitude,
raw: tafData.rawTAF,
issued: tafData.issueTime,
lat: tafData.lat,
lon: tafData.lon,
};
}

Expand Down