diff --git a/README.md b/README.md index 36fecf2..ea73beb 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/package.json b/package.json index e911a67..2319bde 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 63cb211..97b2f6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -80,9 +80,6 @@ importers: eslint-plugin-react-compiler: specifier: ^19.1.0-rc.2 version: 19.1.0-rc.2(eslint@9.38.0) - fast-xml-parser: - specifier: ^5.3.0 - version: 5.3.0 geolib: specifier: ^3.3.4 version: 3.3.4 @@ -2389,10 +2386,6 @@ packages: fast-uri@3.1.0: resolution: {integrity: sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==} - fast-xml-parser@5.3.0: - resolution: {integrity: sha512-gkWGshjYcQCF+6qtlrqBqELqNqnt4CxruY6UVAWWnqb3DQ6qaNFEIKqzYep1XzHLM/QtrHVCxyPOtTk4LTQ7Aw==} - hasBin: true - fastq@1.19.1: resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} @@ -3689,9 +3682,6 @@ packages: strip-literal@3.1.0: resolution: {integrity: sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==} - strnum@2.1.1: - resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==} - stylis@4.2.0: resolution: {integrity: sha512-Orov6g6BB1sDfYgzWfTHDOxamtX1bE/zo104Dh9e6fqJ3PooipYyfJ0pUmrZO2wAvO8YbEyeFrkV91XTsGMSrw==} @@ -6651,10 +6641,6 @@ snapshots: fast-uri@3.1.0: {} - fast-xml-parser@5.3.0: - dependencies: - strnum: 2.1.1 - fastq@1.19.1: dependencies: reusify: 1.1.0 @@ -8037,8 +8023,6 @@ snapshots: dependencies: js-tokens: 9.0.1 - strnum@2.1.1: {} - stylis@4.2.0: {} suncalc@1.9.0: {} diff --git a/src/services/aviationWeather.ts b/src/services/aviationWeather.ts index fc7c11e..339ea3e 100644 --- a/src/services/aviationWeather.ts +++ b/src/services/aviationWeather.ts @@ -1,9 +1,6 @@ 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; @@ -11,7 +8,7 @@ export interface TAFReport { 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, @@ -19,26 +16,25 @@ export async function getTAF({ lat: number; lon: number; }): Promise { + // 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, }; }