From d2940f2b22d9084d2f624b789463b688a1f74ab0 Mon Sep 17 00:00:00 2001 From: john payne Date: Fri, 13 Oct 2017 22:17:37 -0800 Subject: [PATCH] Improved parsing of APT.txt to use ICAO codes if they exist, else IATA codes. --- extra/data/airport.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/extra/data/airport.pl b/extra/data/airport.pl index d8972712f..9bd049571 100755 --- a/extra/data/airport.pl +++ b/extra/data/airport.pl @@ -30,7 +30,14 @@ ($) if (m/^APT/) { #sanitize input text for output to csv $_ =~ s/,|"/ /g; - $id = ltrim( rtrim( substr( $_, 27, 4 ) ) ); + $icaoID = ltrim( rtrim( substr( $_, 1210, 4 ) ) ); + $iataID = ltrim( rtrim( substr( $_, 27, 4 ) ) ); + if ( $icaoID eq "" ) { + $id = $iataID; + } + else { + $id = $icaoID; + } $type = ltrim( rtrim( substr( $_, 14, 12 ) ) ); $name = ltrim( rtrim( substr( $_, 133, 50 ) ) ); $state = ltrim( rtrim( substr( $_, 91, 2 ) ) );