militaryplanes
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v4View latest version
This project provides an ETL (Extract, Transform, Load) pipeline that fetches military aircraft data from the milradar.com API and converts it to GeoJSON format for use in mapping applications.
- Extract: Fetches real-time aircraft data from milradar.com API
- Transform: Converts the data to standard GeoJSON format
- Load: Provides optional filtering capabilities
- HTTP API: Accessible via web endpoint with query parameters
- Error Handling: Robust error handling with detailed logging
- Caching: 1-minute cache headers for performance
The ETL pipeline is available as an HTTP endpoint at /etl-pipeline.ts.
GET /etl-pipeline.ts
Returns all aircraft as GeoJSON FeatureCollection.
only_flying=true- Filter to only include aircraft that are currently flyingmin_speed=<number>- Filter to only include aircraft with ground speed >= specified valueaircraft_types=<comma-separated-list>- Filter to only include specific aircraft types
# Get all aircraft curl "https://your-val-town-url/etl-pipeline.ts" # Get only flying aircraft with speed >= 300 knots curl "https://your-val-town-url/etl-pipeline.ts?only_flying=true&min_speed=300" # Get only B737 and A332 aircraft with speed >= 300 knots curl "https://your-val-town-url/etl-pipeline.ts?min_speed=300&aircraft_types=B737,A332"
[ { "id": 8409, "plane_type_id": 1409, "lat": 47.611162, "lon": -68.5568, "gspeed": 433, "type": "C17", "callsign": "BRK81 ", "track": 199, "is_flying": true } ]
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-68.5568, 47.611162] }, "properties": { "id": 8409, "plane_type_id": 1409, "gspeed": 433, "type": "C17", "callsign": "BRK81", "track": 199, "is_flying": true } } ] }
- Coordinate System: Converts from
lat, lonto GeoJSON[longitude, latitude]format - Data Cleaning: Trims whitespace from callsigns
- Structure: Wraps individual points in GeoJSON Feature format
- Collection: Groups all features into a FeatureCollection
// Fetch all aircraft data
const response = await fetch('/etl-pipeline.ts');
const geoJSON = await response.json();
// Use with mapping libraries like Leaflet, Mapbox, etc.
L.geoJSON(geoJSON).addTo(map);
import requests # Fetch filtered data response = requests.get('/etl-pipeline.ts?only_flying=true&min_speed=200') geojson_data = response.json() # Use with mapping libraries like Folium import folium m = folium.Map() folium.GeoJson(geojson_data).add_to(m)
The API returns appropriate HTTP status codes:
200 OK: Successful data retrieval and transformation500 Internal Server Error: Pipeline failure (with error details in JSON response)
Error responses include:
{ "error": "ETL Pipeline failed", "message": "Detailed error message", "timestamp": "2024-01-01T12:00:00.000Z" }
- Caching: Responses are cached for 1 minute to reduce API load
- CORS: Enabled for cross-origin requests
- Content-Type: Proper
application/geo+jsoncontent type
The API includes various military aircraft types:
B737: Boeing 737C17: Boeing C-17 Globemaster IIIA332: Airbus A330-200H60: Sikorsky UH-60 Black HawkTEX2: Beechcraft T-6 Texan IIC30J: Lockheed Martin C-130J Super Hercules- And many more...
The pipeline is implemented as a single TypeScript file with:
- Type definitions for both input and output formats
- Modular functions for each ETL stage
- Comprehensive error handling and logging
- Query parameter parsing for filtering options