Milradar to GeoJSON Converter

A simple HTTP endpoint that fetches military aircraft data from milradar.com API and converts it to GeoJSON format.

Usage

Make a GET request to the /planes.geojson endpoint:

curl https://your-val-town-url/planes.geojson

Data Format

Input (Milradar API)

[ { "id": 8409, "plane_type_id": 1409, "lat": 47.611162, "lon": -68.5568, "gspeed": 433, "type": "C17", "callsign": "BRK81 ", "track": 199, "is_flying": true } ]

Output (GeoJSON)

{ "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 } } ] }

Key Transformations

  1. Coordinate System: Converts from lat, lon to GeoJSON [longitude, latitude] format
  2. Data Cleaning: Trims whitespace from callsigns
  3. Structure: Wraps individual points in GeoJSON Feature format
  4. Collection: Groups all features into a FeatureCollection

Response Headers

  • Content-Type: application/geo+json
  • Cache-Control: public, max-age=60 (1 minute cache)
  • Access-Control-Allow-Origin: * (CORS enabled)

Error Handling

Returns appropriate HTTP status codes:

  • 200 OK: Successful conversion
  • 500 Internal Server Error: Conversion failure (with error details in JSON response)