5 Read the apt.dat (or apt.dat.gz) file.
6 Remap airport names to remove ugly abbreviations.
7 Print airport names, one per line.
9 Remapping is done by reference to the atis_remap.hxx file.
12 FG_ROOT=whatever ATIS_ONLY=yes ./list-airports.pl | words_per_line.sh > atis.list
36 my %short_country = ();
39 my $fgroot = $ENV{'FG_ROOT'} || '.';
40 my $atis_only = $ENV{'ATIS_ONLY'} || 0;
43 if ($atis_only && ! $atis) {
48 $str =~ s' *$''; ## remove trailing spaces
50 $str =~ s/[(][^)]*[)]?//g;
60 # Note: in this context, GKI probably stands for Gereja Kristen Indonesia
61 # I guess the church builds lots of airports.
63 my $mapfn = "$fgroot/../fgs/src/ATCDCL/atis_remap.hxx";
64 my $mapch = Symbol::gensym;
65 if (!open($mapch, '<', $mapfn)) {
66 print STDERR "Could not open abbreviation file '$mapfn'\n";
67 print STDERR "Maybe you need to set FG_ROOT\n";
70 while (my $line = <$mapch>) {
72 if ($line =~ s/[ \t]*REMAP[(]//) {
73 $line =~ s/[)][ \t]*$//;
74 my @stuff = split(',', $line, 2);
91 my $incmd = 'zcat /games/sport/fgd/Airports/apt.dat.gz';
92 my $inch = Symbol::gensym;
93 open ($inch, '-|', $incmd)
94 || die "Couldn't open pipe from '$incmd'\n";
99 liner: while (my $line = <$inch>) {
101 my @stuff = split(' ', $line);
102 my $type = shift @stuff || 0;
103 ### print "..$type ... $line ...\n";
106 ## Here if new airport.
108 ## First, print results of previous work, i.e. airport
109 ## stanzas already seen ... since the apt.dat file
110 ## doesn't have a clear way of signaling the end of a stanza.
120 $elev = shift @stuff;
121 $tower = shift @stuff;
122 $bldgs = shift @stuff;
123 $apt_id = shift @stuff;
124 my $name = join $delim, @stuff;
126 for my $from (keys %remap) {
127 my $to = $remap{$from};
128 $name =~ s/\b$from\b/$to/gi;
131 ## option for plain words, not hyphenated phrases
133 $name =~ s/$delim/ /g;
145 $atis = join(' ', @stuff);
148 process_apt(); ## flush out the very last one
149 print STDERR "Total airports: $tot_apts\n";