Some code rearranging and incremental improvements and bug fixes.
This commit is contained in:
parent
d26a39cfe1
commit
34c905829c
1 changed files with 308 additions and 265 deletions
|
@ -7,96 +7,86 @@
|
|||
use strict;
|
||||
|
||||
my($faa_ils_file) = shift(@ARGV);
|
||||
my($arpt_file) = shift(@ARGV);
|
||||
my($dafift_arpt_file) = shift(@ARGV);
|
||||
my($dafift_ils_file) = shift(@ARGV);
|
||||
my($fgfs_ils_file) = shift(@ARGV);
|
||||
|
||||
die "Usage: $0 " .
|
||||
"<faa_ils_file> <dafift_arpt_file> <dafift_ils_file> <fgfs_ils_file>\n"
|
||||
if !defined($faa_ils_file) || !defined($arpt_file)
|
||||
if !defined($faa_ils_file) || !defined($dafift_arpt_file)
|
||||
|| !defined($dafift_ils_file) || !defined($fgfs_ils_file);
|
||||
|
||||
my( %Airports );
|
||||
my( %ILS );
|
||||
my( $record );
|
||||
|
||||
my( $id, $rwy, $type );
|
||||
my( $has_dme, $has_gs, $has_loc, $has_im, $has_mm, $has_om );
|
||||
my( $dme_lon, $dme_lat, $dme_elev, $dme_bias );
|
||||
my( $gs_lon, $gs_lat, $gs_elev, $gs_angle );
|
||||
my( $loc_type, $loc_lon, $loc_lat, $loc_elev, $loc_freq, $loc_hdg, $loc_width,
|
||||
$loc_id );
|
||||
my( $im_lon, $im_lat, $mm_lon, $mm_lat, $om_lon, $om_lat );
|
||||
|
||||
&load_dafift( $dafift_arpt_file, $dafift_ils_file );
|
||||
&load_faa( $faa_ils_file );
|
||||
&load_fgfs( $faa_ils_file );
|
||||
&write_result();
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
########################################################################
|
||||
# Process FAA data
|
||||
########################################################################
|
||||
|
||||
# Load the DAFIFT ils file
|
||||
sub load_faa() {
|
||||
my( $file ) = shift;
|
||||
|
||||
my( $rec_type, $faa_id, $faa_date, $faa_apt_name, $faa_city, $faa_st,
|
||||
$faa_state, $faa_region, $id, $faa_len, $faa_wid, $faa_cat, $faa_owner,
|
||||
$faa_operator, $faa_bearing, $faa_magvar,
|
||||
$faa_loc_latd, $faa_loc_lats, $faa_loc_lond, $faa_loc_lons,
|
||||
$faa_stop_dist, $faa_app_dist,
|
||||
$faa_gs_type, $faa_gs_freq, $faa_gs_latd, $faa_gs_lats, $faa_gs_lond,
|
||||
$faa_gs_lons, $faa_gs_dist,
|
||||
$faa_im_type, $faa_im_latd, $faa_im_lats, $faa_im_lond, $faa_im_lons,
|
||||
$faa_im_dist,
|
||||
$faa_mm_type, $faa_mm_id, $faa_mm_name, $faa_mm_freq,
|
||||
$faa_mm_latd, $faa_mm_lats, $faa_mm_lond, $faa_mm_lons, $faa_mm_dist,
|
||||
$faa_om_type, $faa_om_id, $faa_om_name, $faa_om_freq,
|
||||
$faa_om_latd, $faa_om_lats, $faa_om_lond, $faa_om_lons, $faa_om_dist,
|
||||
$faa_om_backcourse);
|
||||
open( FAA_ILS, "<$faa_ils_file" ) || die "Cannot open $faa_ils_file\n";
|
||||
open( FAA_ILS, "<$file" ) || die "Cannot open FAA data: $file\n";
|
||||
|
||||
<FAA_ILS>; # skip header line
|
||||
<FAA_ILS>; # skip header line
|
||||
|
||||
while ( <FAA_ILS> ) {
|
||||
while ( <FAA_ILS> ) {
|
||||
chomp;
|
||||
( $rec_type, $faa_id, $rwy, $type, $faa_date, $faa_apt_name, $faa_city,
|
||||
$faa_st, $faa_state, $faa_region, $id, $faa_len, $faa_wid,
|
||||
$faa_cat, $faa_owner, $faa_operator, $faa_bearing, $faa_magvar,
|
||||
$loc_type, $loc_id, $loc_freq, $faa_loc_latd, $faa_loc_lats,
|
||||
$faa_loc_lond, $faa_loc_lons, $loc_width, $faa_stop_dist, $faa_app_dist,
|
||||
$faa_gs_type, $gs_angle, $faa_gs_freq, $faa_gs_latd, $faa_gs_lats,
|
||||
$faa_gs_lond, $faa_gs_lons, $faa_gs_dist, $gs_elev,
|
||||
$faa_im_type, $faa_im_latd, $faa_im_lats, $faa_im_lond, $faa_im_lons,
|
||||
$faa_im_dist,
|
||||
$faa_mm_type, $faa_mm_id, $faa_mm_name, $faa_mm_freq,
|
||||
$faa_mm_latd, $faa_mm_lats, $faa_mm_lond, $faa_mm_lons, $faa_mm_dist,
|
||||
$faa_om_type, $faa_om_id, $faa_om_name, $faa_om_freq,
|
||||
$faa_om_latd, $faa_om_lats, $faa_om_lond, $faa_om_lons,
|
||||
$faa_om_dist, $faa_om_backcourse
|
||||
)
|
||||
= $_ =~ m/^(.{4})(.{11})(.{3})(.{10})(.{10})(.{42})(.{26})(.{2})(.{20})(.{3})(.{4})(.{5})(.{4})(.{9})(.{50})(.{50})(.{3})(.{3})(.{15})(.{5})(.{6})(.{14})(.{11})(.{14})(.{11})(.{5})(.{5})(.{6})(.{15})(.{4})(.{6})(.{14})(.{11})(.{14})(.{11})(.{6})(.{7})(.{15})(.{14})(.{11})(.{14})(.{11})(.{6})(.{15})(.{2})(.{5})(.{3})(.{14})(.{11})(.{14})(.{11})(.{6})(.{15})(.{2})(.{5})(.{3})(.{14})(.{11})(.{14})(.{11})(.{6})(.{9})/;
|
||||
|
||||
$loc_hdg = $faa_bearing + make_dmagvar($faa_magvar);
|
||||
$loc_lat = make_dcoord($faa_loc_lats) / 3600.0;
|
||||
$loc_lon = make_dcoord($faa_loc_lons) / 3600.0;
|
||||
$gs_lat = make_dcoord($faa_gs_lats) / 3600.0;
|
||||
$gs_lon = make_dcoord($faa_gs_lons) / 3600.0;
|
||||
$im_lat = make_dcoord($faa_im_lats) / 3600.0;
|
||||
$im_lon = make_dcoord($faa_im_lons) / 3600.0;
|
||||
$mm_lat = make_dcoord($faa_mm_lats) / 3600.0;
|
||||
$mm_lon = make_dcoord($faa_mm_lons) / 3600.0;
|
||||
$om_lat = make_dcoord($faa_om_lats) / 3600.0;
|
||||
$om_lon = make_dcoord($faa_om_lons) / 3600.0;
|
||||
my ( $rec_type, $faa_id, $rwy, $type, $faa_date,
|
||||
$faa_apt_name, $faa_city, $faa_st, $faa_state,
|
||||
$faa_region, $id, $faa_len, $faa_wid, $faa_cat,
|
||||
$faa_owner, $faa_operator, $faa_bearing, $faa_magvar,
|
||||
$loc_type, $loc_id, $loc_freq, $faa_loc_latd,
|
||||
$faa_loc_lats, $faa_loc_lond, $faa_loc_lons, $loc_width,
|
||||
$faa_stop_dist, $faa_app_dist, $faa_gs_type, $gs_angle,
|
||||
$faa_gs_freq, $faa_gs_latd, $faa_gs_lats, $faa_gs_lond,
|
||||
$faa_gs_lons, $faa_gs_dist, $gs_elev, $faa_im_type,
|
||||
$faa_im_latd, $faa_im_lats, $faa_im_lond, $faa_im_lons,
|
||||
$faa_im_dist, $faa_mm_type, $faa_mm_id, $faa_mm_name,
|
||||
$faa_mm_freq, $faa_mm_latd, $faa_mm_lats, $faa_mm_lond,
|
||||
$faa_mm_lons, $faa_mm_dist, $faa_om_type, $faa_om_id,
|
||||
$faa_om_name, $faa_om_freq, $faa_om_latd, $faa_om_lats,
|
||||
$faa_om_lond, $faa_om_lons, $faa_om_dist,
|
||||
$faa_om_backcourse, $faa_dme_channel, $faa_dme_latd,
|
||||
$faa_dme_lats, $faa_dme_lond, $faa_dme_lons, $faa_dme_app_dist,
|
||||
$faa_dme_stop_dist, $blank)
|
||||
= $_ =~
|
||||
m/^(.{4})(.{11})(.{3})(.{10})(.{10})(.{42})(.{26})(.{2})(.{20})(.{3})(.{4})(.{5})(.{4})(.{9})(.{50})(.{50})(.{3})(.{3})(.{15})(.{5})(.{6})(.{14})(.{11})(.{14})(.{11})(.{5})(.{5})(.{6})(.{15})(.{4})(.{6})(.{14})(.{11})(.{14})(.{11})(.{6})(.{7})(.{15})(.{14})(.{11})(.{14})(.{11})(.{6})(.{15})(.{2})(.{5})(.{3})(.{14})(.{11})(.{14})(.{11})(.{6})(.{15})(.{2})(.{5})(.{3})(.{14})(.{11})(.{14})(.{11})(.{6})(.{9})(.{4})(.{14})(.{11})(.{14})(.{11})(.{6})(.{5})(.{34})/;
|
||||
|
||||
# just hist the start of the next record, dump the current data
|
||||
$record = sprintf( "I ILS %-4s %-3s %06.2f %-4s %06.2f %10.6f %11.6f ",
|
||||
$id, $rwy,
|
||||
$loc_freq, $loc_id, $loc_hdg, $loc_lat, $loc_lon );
|
||||
$record .= sprintf( "%5d %5.2f %10.6f %11.6f ",
|
||||
$gs_elev, $gs_angle, $gs_lat, $gs_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $dme_lat, $dme_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $om_lat, $om_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $mm_lat, $mm_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $im_lat, $im_lon );
|
||||
if ( $rec_type eq "ILS1" && $ILS{$id . $rwy} eq "" ) {
|
||||
print "FAA Adding: $id - $rwy $faa_bearing, $faa_magvar - $loc_hdg \n";
|
||||
$ILS{$id . $rwy} = $record;
|
||||
$loc_id =~ s/-//;
|
||||
my( $loc_hdg ) = $faa_bearing + make_dmagvar($faa_magvar);
|
||||
my( $loc_lat ) = make_dcoord($faa_loc_lats) / 3600.0;
|
||||
my( $loc_lon ) = make_dcoord($faa_loc_lons) / 3600.0;
|
||||
my( $gs_lat ) = make_dcoord($faa_gs_lats) / 3600.0;
|
||||
my( $gs_lon ) = make_dcoord($faa_gs_lons) / 3600.0;
|
||||
my( $im_lat ) = make_dcoord($faa_im_lats) / 3600.0;
|
||||
my( $im_lon ) = make_dcoord($faa_im_lons) / 3600.0;
|
||||
my( $mm_lat ) = make_dcoord($faa_mm_lats) / 3600.0;
|
||||
my( $mm_lon ) = make_dcoord($faa_mm_lons) / 3600.0;
|
||||
my( $om_lat ) = make_dcoord($faa_om_lats) / 3600.0;
|
||||
my( $om_lon ) = make_dcoord($faa_om_lons) / 3600.0;
|
||||
my( $dme_lat ) = make_dcoord($faa_dme_lats) / 3600.0;
|
||||
my( $dme_lon ) = make_dcoord($faa_dme_lons) / 3600.0;
|
||||
|
||||
if ( $rec_type eq "ILS1" ) {
|
||||
if ( $ILS{$id . $rwy} eq "" ) {
|
||||
print "FAA adding: $id - $rwy\n";
|
||||
add_record( $id, $rwy, $loc_freq, $loc_id, $loc_hdg, $loc_lat,
|
||||
$loc_lon, $gs_elev, $gs_angle, $gs_lat, $gs_lon,
|
||||
$dme_lat, $dme_lon, $om_lat, $om_lon, $mm_lat,
|
||||
$mm_lon, $im_lat, $im_lon );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,13 +95,27 @@ while ( <FAA_ILS> ) {
|
|||
# Process DAFIFT data
|
||||
########################################################################
|
||||
|
||||
# Load the DAFIFT airport file
|
||||
sub load_dafift() {
|
||||
my( $arpt_file ) = shift;
|
||||
my( $ils_file ) = shift;
|
||||
|
||||
open( ARPT, "<$arpt_file" ) || die "Cannot open $arpt_file\n";
|
||||
my( $record );
|
||||
|
||||
<ARPT>; # skip header line
|
||||
my( $id, $rwy, $type );
|
||||
my( $has_dme, $has_gs, $has_loc, $has_im, $has_mm, $has_om );
|
||||
my( $dme_lon, $dme_lat, $dme_elev, $dme_bias );
|
||||
my( $gs_lon, $gs_lat, $gs_elev, $gs_angle );
|
||||
my( $loc_type, $loc_lon, $loc_lat, $loc_elev, $loc_freq, $loc_hdg,
|
||||
$loc_width, $loc_id );
|
||||
my( $im_lon, $im_lat, $mm_lon, $mm_lat, $om_lon, $om_lat );
|
||||
|
||||
while ( <ARPT> ) {
|
||||
# load airport file so we can lookup ICAO from internal ID
|
||||
|
||||
open( ARPT, "<$arpt_file" ) || die "Cannot open DAFIFT: $arpt_file\n";
|
||||
|
||||
<ARPT>; # skip header line
|
||||
|
||||
while ( <ARPT> ) {
|
||||
chomp;
|
||||
my(@F) = split(/\t/);
|
||||
my($icao) = $F[3];
|
||||
|
@ -124,58 +128,49 @@ while ( <ARPT> ) {
|
|||
}
|
||||
$Airports{$F[0]} = $icao;
|
||||
# print "$F[0] - $icao\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Load the DAFIFT ils file
|
||||
|
||||
# Load the DAFIFT ils file
|
||||
my( $last_id, $last_rwy ) = ("", "");
|
||||
|
||||
my( $last_id, $last_rwy ) = ("", "");
|
||||
open( DAFIFT_ILS, "<$ils_file" ) || die "Cannot open DAFIFT: $ils_file\n";
|
||||
|
||||
open( DAFIFT_ILS, "<$dafift_ils_file" ) || die "Cannot open $dafift_ils_file\n";
|
||||
<DAFIFT_ILS>; # skip header line
|
||||
|
||||
<DAFIFT_ILS>; # skip header line
|
||||
|
||||
while ( <DAFIFT_ILS> ) {
|
||||
while ( <DAFIFT_ILS> ) {
|
||||
chomp;
|
||||
my @F = split(/\t/);
|
||||
$id = $F[0];
|
||||
$rwy = $F[1];
|
||||
|
||||
if ( $last_id ne "" && ($last_id ne $id || $last_rwy ne $rwy) ) {
|
||||
# just hist the start of the next record, dump the current data
|
||||
$record
|
||||
= sprintf( "I ILS %-4s %-3s %06.2f %-4s %06.2f %10.6f %11.6f ",
|
||||
$Airports{$last_id}, $last_rwy,
|
||||
$loc_freq, $loc_id, $loc_hdg, $loc_lat, $loc_lon );
|
||||
if ( $has_gs ) {
|
||||
$record .= sprintf( "%5d %5.2f %10.6f %11.6f ",
|
||||
$gs_elev, $gs_angle, $gs_lat, $gs_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%5d %5.2f %10.6f %11.6f ", 0, 0, 0, 0 );
|
||||
|
||||
if ( ! $has_gs ) {
|
||||
( $gs_elev, $gs_angle, $gs_lat, $gs_lon ) = ( 0, 0, 0, 0 );
|
||||
}
|
||||
if ( $has_dme ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $dme_lat, $dme_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
if ( ! $has_dme ) {
|
||||
( $dme_lat, $dme_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( $has_om ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $om_lat, $om_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
if ( ! $has_om ) {
|
||||
( $om_lat, $om_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( $has_mm ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $mm_lat, $mm_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
if ( ! $has_mm ) {
|
||||
( $mm_lat, $mm_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( $has_im ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $im_lat, $im_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
if ( ! $has_im ) {
|
||||
( $im_lat, $im_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( $ILS{$Airports{$last_id} . $last_rwy} eq "" ) {
|
||||
print "DAFIFT Adding: $Airports{$last_id} - $last_rwy\n";
|
||||
$ILS{$Airports{$last_id} . $last_rwy} = $record;
|
||||
print "DAFIFT adding: $Airports{$last_id} - $last_rwy\n";
|
||||
add_record( $Airports{$last_id}, $last_rwy, $loc_freq,
|
||||
$loc_id, $loc_hdg, $loc_lat, $loc_lon,
|
||||
$gs_elev, $gs_angle, $gs_lat, $gs_lon,
|
||||
$dme_lat, $dme_lon, $om_lat, $om_lon, $mm_lat,
|
||||
$mm_lon, $im_lat, $im_lon );
|
||||
}
|
||||
|
||||
$has_dme = 0;
|
||||
$has_gs = 0;
|
||||
$has_loc = 0;
|
||||
|
@ -183,6 +178,7 @@ while ( <DAFIFT_ILS> ) {
|
|||
$has_mm = 0;
|
||||
$has_om = 0;
|
||||
}
|
||||
|
||||
$type = $F[2];
|
||||
if ( $type eq "D" ) {
|
||||
# DME entry
|
||||
|
@ -252,41 +248,31 @@ while ( <DAFIFT_ILS> ) {
|
|||
$last_id = $id;
|
||||
$last_rwy = $rwy;
|
||||
# printf("%-5s %10.6f %11.6f\n", $F[0], $F[14], $F[16]);
|
||||
}
|
||||
}
|
||||
|
||||
$record = sprintf( "I ILS %-4s %-3s %06.2f %-4s %06.2f %10.6f %11.6f ",
|
||||
$Airports{$last_id}, $last_rwy,
|
||||
$loc_freq, $loc_id, $loc_hdg, $loc_lat, $loc_lon );
|
||||
if ( $has_gs ) {
|
||||
$record .= sprintf( "%5d %5.2f %10.6f %11.6f ",
|
||||
$gs_elev, $gs_angle, $gs_lat, $gs_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%5d %5.2f %10.6f %11.6f ", 0, 0, 0, 0 );
|
||||
}
|
||||
if ( $has_dme ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $dme_lat, $dme_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
}
|
||||
if ( $has_om ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $om_lat, $om_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
}
|
||||
if ( $has_mm ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $mm_lat, $mm_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
}
|
||||
if ( $has_im ) {
|
||||
$record .= sprintf( "%10.6f %11.6f ", $im_lat, $im_lon );
|
||||
} else {
|
||||
$record .= sprintf( "%10.6f %11.6f ", 0, 0 );
|
||||
}
|
||||
|
||||
if ( $ILS{$Airports{$last_id} . $last_rwy} eq "" ) {
|
||||
print "DAFIFT Adding: $Airports{$last_id} - $last_rwy\n";
|
||||
$ILS{$Airports{$last_id} . $last_rwy} = $record;
|
||||
if ( ! $has_gs ) {
|
||||
( $gs_elev, $gs_angle, $gs_lat, $gs_lon ) = ( 0, 0, 0, 0 );
|
||||
}
|
||||
if ( ! $has_dme ) {
|
||||
( $dme_lat, $dme_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( ! $has_om ) {
|
||||
( $om_lat, $om_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( ! $has_mm ) {
|
||||
( $mm_lat, $mm_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( ! $has_im ) {
|
||||
( $im_lat, $im_lon ) = ( 0, 0 );
|
||||
}
|
||||
if ( $ILS{$Airports{$last_id} . $last_rwy} eq "" ) {
|
||||
print "DAFIFT adding (last): $Airports{$last_id} - $last_rwy\n";
|
||||
add_record( $Airports{$last_id}, $last_rwy, $loc_freq,
|
||||
$loc_id, $loc_hdg, $loc_lat, $loc_lon,
|
||||
$gs_elev, $gs_angle, $gs_lat, $gs_lon,
|
||||
$dme_lat, $dme_lon, $om_lat, $om_lon, $mm_lat,
|
||||
$mm_lon, $im_lat, $im_lon );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -294,37 +280,94 @@ if ( $ILS{$Airports{$last_id} . $last_rwy} eq "" ) {
|
|||
# Process FlightGear ILS data
|
||||
########################################################################
|
||||
|
||||
# Load the FlightGear ils file and fill in any missing ILS approachs
|
||||
sub load_fgfs() {
|
||||
my( $ils_file ) = shift;
|
||||
|
||||
open( FGILS, "zcat $fgfs_ils_file|" ) || die "Cannot open $fgfs_ils_file\n";
|
||||
|
||||
<FGILS>; # skip header line
|
||||
open( FGILS, "zcat $ils_file|" ) || die "Cannot open FGFS: $ils_file\n";
|
||||
|
||||
while ( <FGILS> ) {
|
||||
<FGILS>; # skip header line
|
||||
|
||||
while ( <FGILS> ) {
|
||||
chomp;
|
||||
if ( ! m/\[End\]/ && length($_) > 1 ) {
|
||||
# print "$_\n";
|
||||
my( $type_code, $type_name, $icao, $rwy, $loc_freq, $loc_id, $loc_hdg,
|
||||
$loc_lat, $loc_lon, $gs_elev, $gs_angle, $gs_lat, $gs_lon,
|
||||
$dme_lat, $dme_lon, $om_lat, $om_lon, $mm_lat, $mm_lon,
|
||||
my( $type_code, $type_name, $icao, $rwy, $loc_freq, $loc_id,
|
||||
$loc_hdg, $loc_lat, $loc_lon, $gs_elev, $gs_angle, $gs_lat,
|
||||
$gs_lon, $dme_lat, $dme_lon, $om_lat, $om_lon, $mm_lat, $mm_lon,
|
||||
$im_lat, $im_lon ) = split(/\s+/);
|
||||
if ( $ILS{$icao . $rwy} eq "" ) {
|
||||
print "X-Plane Adding: $icao $rwy\n";
|
||||
print "FGFS adding: $icao $rwy\n";
|
||||
$ILS{$icao . $rwy} = $_;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# dump out the final results
|
||||
print "// FlightGear ILS data, generated from DAFIFT ARPT/ILS.TXT\n";
|
||||
my($key);
|
||||
foreach $key ( sort (keys %ILS) ) {
|
||||
########################################################################
|
||||
# Write out the accumulated combined result
|
||||
########################################################################
|
||||
|
||||
sub write_result() {
|
||||
# dump out the final results
|
||||
print "// FlightGear ILS data, generated from DAFIFT ARPT/ILS.TXT\n";
|
||||
my($key);
|
||||
foreach $key ( sort (keys %ILS) ) {
|
||||
print "$ILS{$key}\n";
|
||||
}
|
||||
print "[End]\n";
|
||||
}
|
||||
print "[End]\n";
|
||||
|
||||
|
||||
########################################################################
|
||||
# Utility functions
|
||||
########################################################################
|
||||
|
||||
|
||||
# add a record to the master list
|
||||
|
||||
sub add_record() {
|
||||
my( $apt_id ) = shift;
|
||||
my( $rwy ) = shift;
|
||||
my( $loc_freq ) = shift;
|
||||
my( $loc_id ) = shift;
|
||||
my( $loc_hdg ) = shift;
|
||||
my( $loc_lat ) = shift;
|
||||
my( $loc_lon ) = shift;
|
||||
my( $gs_elev ) = shift;
|
||||
my( $gs_angle ) = shift;
|
||||
my( $gs_lat ) = shift;
|
||||
my( $gs_lon ) = shift;
|
||||
my( $dme_lat ) = shift;
|
||||
my( $dme_lon ) = shift;
|
||||
my( $om_lat ) = shift;
|
||||
my( $om_lon ) = shift;
|
||||
my( $mm_lat ) = shift;
|
||||
my( $mm_lon ) = shift;
|
||||
my( $im_lat ) = shift;
|
||||
my( $im_lon ) = shift;
|
||||
|
||||
my( $record );
|
||||
$record = sprintf( "I ILS %-4s %-3s %06.2f %-4s %06.2f %10.6f %11.6f ",
|
||||
$apt_id, $rwy,
|
||||
$loc_freq, $loc_id, $loc_hdg, $loc_lat, $loc_lon );
|
||||
$record .= sprintf( "%5d %5.2f %10.6f %11.6f ",
|
||||
$gs_elev, $gs_angle, $gs_lat, $gs_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $dme_lat, $dme_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $om_lat, $om_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $mm_lat, $mm_lon );
|
||||
$record .= sprintf( "%10.6f %11.6f ", $im_lat, $im_lon );
|
||||
|
||||
if ( $ILS{$apt_id . $rwy} eq "" ) {
|
||||
print "Adding (common): $apt_id - $rwy\n";
|
||||
$ILS{$apt_id . $rwy} = $record;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# convert a lon/lat coordinate in various formats to signed decimal
|
||||
|
||||
sub make_dcoord() {
|
||||
my($coord) = shift;
|
||||
my( $dir, $deg, $min, $sec );
|
||||
|
@ -344,12 +387,12 @@ sub make_dcoord() {
|
|||
$value = -$value;
|
||||
}
|
||||
} elsif ( $coord =~ m/[EW]$/ ) {
|
||||
($value, $dir) = m/(\d{6}\.\d{3})(.)/;
|
||||
($value, $dir) = $coord =~ m/(\d{6}\.\d{3})(.)/;
|
||||
if ( $value eq "W" ) {
|
||||
$value = -$value;
|
||||
}
|
||||
} elsif ( $coord =~ m/[NS]$/ ) {
|
||||
($value, $dir) = m/(\d{6}\.\d{3})(.)/;
|
||||
($value, $dir) = $coord =~ m/(\d{6}\.\d{3})(.)/;
|
||||
if ( $value eq "S" ) {
|
||||
$value = -$value;
|
||||
}
|
||||
|
@ -358,6 +401,8 @@ sub make_dcoord() {
|
|||
return $value;
|
||||
}
|
||||
|
||||
# convert a magnetic variation in various formats to signed decimal
|
||||
|
||||
sub make_dmagvar() {
|
||||
my( $coord ) = shift;
|
||||
my( $value );
|
||||
|
@ -380,5 +425,3 @@ sub make_dmagvar() {
|
|||
|
||||
return $value;
|
||||
}
|
||||
|
||||
# end of dafif2fix.pl
|
||||
|
|
Loading…
Add table
Reference in a new issue