Readme

Planes Above Me

Inspired by https://louison.substack.com/p/i-built-a-plane-spotter-for-my-son

A little script that grabs that planes above you, just change line 4 to whatever location you want and it'll pull the lat/log for it and query.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
import { round } from "https://esm.town/v/stevekrouse/round";
import { nominatimSearch } from "https://esm.town/v/stevekrouse/nominatimSearch";
export let planesAboveMe = (async () => {
let [{ lat, lon, display_name }] = await nominatimSearch({
q: "atlantic terminal", // <---- change me
});
let epsilon = .1;
let query = new URLSearchParams({
lamax: String(round(lat, 2) + epsilon),
lamin: String(round(lat, 2) - epsilon),
lomax: String(round(lon, 2) + epsilon),
lomin: String(round(lon, 2) - epsilon),
});
console.log({ lat, lon, display_name });
let url = `https://opensky-network.org/api/states/all?${query}`;
let data = await fetchJSON(url);
return data?.states?.map((f) => ({
icao24: f[0],
callsign: f[1],
origin_country: f[2],
time_position: f[3],
last_contact: f[4],
longitude: f[5],
latitude: f[6],
baro_altitude: f[7],
on_ground: f[8],
velocity: f[9],
true_track: f[10],
vertical_rate: f[11],
sensors: f[12],
geo_altitude: f[13],
squawk: f[14],
spi: f[15],
position_source: f[16],
category: f[17],
}));
})();
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.