Introduction
Introduction Statistics Contact Development Disclaimer Help
metar - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
metar (1518B)
---
1 #!/bin/sh
2
3 iata2icao() {
4 awk -v IATA="$1" --csv 'BEGIN { IATA = toupper(IATA) } $10 == IATA {…
5 }
6
7 printart() {
8 awk 'BEGIN { RS = ""; srand() } { if (rand() < 1 / ++n) out = $0 } E…
9 }
10
11 dromeinfo() {
12 awk -v aerodrome="$1" --csv '
13 BEGIN { aerodrome = toupper(aerodrome) }
14 NR == 1 { split($0, header) }
15 $1 == aerodrome || $10 == aerodrome {
16 for (i = 1; i <= NF; i++)
17 if ($i)
18 {
19 gsub(/_/, " ", header[i])
20 gsub(/_/, " ", $i)
21 s = s sprintf(" %s %s\n", header[i]":", $i)
22 }
23 }
24 END { if (!s) exit; print s }' "$csv"
25 }
26
27 if ! id=$(printf '%s\n' "$1" | grep '^[A-Za-z0-9]\{3,4\}$'); then
28 printf '%s\n' "invalid IATA/ICAO code."
29 exit 1
30 fi
31
32 fmt=decoded
33 uri="https://aviationweather.gov/api/data/{stationinfo,metar}/"
34 txt="$HOME/bin/modules/metar/ascii-planes.txt"
35 csv="$HOME/bin/modules/airport-codes/data/airport-codes.csv"
36
37 [ "${#id}" = 3 ] && id=$(iata2icao "$id")
38
39 if [ -z "$id" ]; then
40 printf '%s\n' "invalid IATA code."
41 exit 1
42 fi
43
44 metar=$(curl -Ssfm 5 --data-urlencode format="$fmt" --data-urlencode ids…
45
46 if [ -z "$metar" ]; then
47 printf '%s\n' "error retrieving METAR for $id."
48 exit 1
49 fi
50
51 raw=$(printf '%s\n' "$metar" | sed -n '/Text:/ s/.*: //p')
52 art=$(printart | sed 's/^#//')
53 decode=$(printf '%s\n\n' "$metar" "$art" | /br/bin/bitreich-paste)
54 printf '%s\n' "$raw ; decode: $decode"
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.