bigworld

compute diameter of flights graph
git clone https://a3nm.net/git/bigworld/
Log | Files | Refs

antipodes.sh (1368B)


      1 #!/bin/bash
      2 
      3 if [ ! -f airports.dat ]
      4 then
      5   wget -O airports.dat 'https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat'
      6 fi
      7 
      8 # rev is to avoid problems with ',' occurring in earlier fields
      9 cat airports.dat |
     10   grep -vE "`cat bad_antipodes | sed 's/#.*//' | tr '\n' '|' | sed 's/|$//'`" |
     11   rev | cut -d, -f4,5,6,7,8 | rev |
     12   tr -d '"' | tr ',' ' ' | sed 's/ /-/' > airports
     13 
     14 g++ -o antipodes -O2 -Wall -Wextra antipodes.cpp
     15 ./antipodes < airports
     16 sort -k3,3n euclidean | sponge euclidean
     17 sort -k3,3n haversine | sponge haversine
     18 sort -k3,3n ellipsoid_in | sponge ellipsoid_in
     19 
     20 # GeodSolve from geographiclib-tools
     21 paste -d ' ' ellipsoid_in \
     22   <(cut -d' ' -f4,5,7,8 ellipsoid_in | GeodSolve -i | cut -d ' ' -f3) |
     23   sort -k10,10n > ellipsoid_full
     24 cut -d' ' -f1,2,10 ellipsoid_full | sort -k3,3n > ellipsoid
     25 cat ellipsoid_full | awk '{
     26   printf "%s %s %lf\n",
     27   $1, $2, $10 + 0.3048 * (($6 > 0 ? $6 : -$6)+ ($9 > 0 ? $9 : -$9))}' |
     28   sort -k3,3n > altitude
     29 cat ellipsoid_full | cut -d' ' -f4-6 | CartConvert > geocentric_1
     30 cat ellipsoid_full | cut -d' ' -f7-9 | CartConvert > geocentric_2
     31 paste -d' ' geocentric_1 geocentric_2 | awk '{
     32   dx = $1 - $4;
     33   dy = $2 - $5;
     34   dz = $3 - $6;
     35   printf "%lf\n", sqrt(dx*dx + dy*dy + dz*dz);}' > geocentric_dists
     36 paste -d' ' ellipsoid_full geocentric_dists | cut -f1,2,11 |
     37   sort -k3,3n > geocentric
     38