From 6aeab0cc0d3c858b4de38fb04c336aef34b416ad Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 18:41:32 +0100 Subject: [PATCH 1/8] git ignore local perl installation --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c15b52a..c5e2206 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ META.yml MYMETA.yml nytprof.out pm_to_blib +/local From 359299511e018157bbdf296903e63f0cb7e0ff66 Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 18:44:45 +0100 Subject: [PATCH 2/8] ignore git dependencies --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index c5e2206..b839664 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ MYMETA.yml nytprof.out pm_to_blib /local +/tilers_tools +/mbutil +/parallelGdal2tiles From bc244f2ab6450564d22faadbcedf3f4bdb77c351 Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 20:30:08 +0100 Subject: [PATCH 3/8] get lat/lon from nasr db --- georeferenceAirportDiagramsViaDb.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/georeferenceAirportDiagramsViaDb.pl b/georeferenceAirportDiagramsViaDb.pl index d187969..097c2e2 100755 --- a/georeferenceAirportDiagramsViaDb.pl +++ b/georeferenceAirportDiagramsViaDb.pl @@ -134,7 +134,8 @@ our $dbh; my $sth; -$dbh = DBI->connect( "dbi:SQLite:dbname=locationinfo.db", +# The nasr database created by processFaaData +$dbh = DBI->connect( "dbi:SQLite:dbname=../processFaaData/nasr.sqlite", "", "", { RaiseError => 1 } ) or croak $DBI::errstr; @@ -555,7 +556,7 @@ sub findAirportLatitudeAndLongitude { # Query the database for airport my $sth = $dbh->prepare( - "SELECT FaaID, Latitude, Longitude, Name FROM airports WHERE FaaID = '$airportId'" + "SELECT location_identifier, apt_latitude, apt_longitude, official_facility_name FROM APT_APT WHERE location_identifier = '$airportId'" ); $sth->execute(); From 7050e9ac10f6980b353d2fc3ee3eb9ff743aa0d1 Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 20:35:36 +0100 Subject: [PATCH 4/8] download the dtpp catalog --- load_dtpp_metadata.pl | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/load_dtpp_metadata.pl b/load_dtpp_metadata.pl index 984bf92..8658c5d 100755 --- a/load_dtpp_metadata.pl +++ b/load_dtpp_metadata.pl @@ -86,9 +86,8 @@ die "$dtppDownloadDir doesn't exist" if ( !-e $dtppDownloadDir ); #URL of the DTPP catalog -# my $dtpp_url = -# "http://aeronav.faa.gov/d-tpp/$cycle/xml_data/d-TPP_Metafile.xml"; -my $dtpp_url = "https://nfdc.faa.gov/webContent/dtpp/current.xml"; +my $dtpp_url = "http://aeronav.faa.gov/d-tpp/$cycle/xml_data/d-TPP_Metafile.xml"; +# my $dtpp_url = "https://nfdc.faa.gov/webContent/dtpp/current.xml"; my ( $count, $downloadedCount, $deletedCount, $changedCount, $addedCount ); @@ -98,18 +97,15 @@ say "Using existing local metafile: $TPP_METADATA_FILE"; } else { - die - "Unable to load dTPP metadata catalog: $TPP_METADATA_FILE does not exist locally"; + print "Downloading the d-TPP metafile: " . $dtpp_url . "..."; + + # my $ret = 200; + my $ret = getstore( $dtpp_url, $TPP_METADATA_FILE ); - # print "Downloading the d-TPP metafile: " . $dtpp_url . "..."; - # - # # my $ret = 200; - # my $ret = getstore( $dtpp_url, $TPP_METADATA_FILE ); - # - # if ( $ret != 200 ) { - # die "Unable to download d-TPP metadata."; - # } - # print "done\n"; + if ( $ret != 200 ) { + die "Unable to download d-TPP metadata."; + } + print "done\n"; } From 1b3f535b71673ae26bf4790162e7d84ee93e0a67 Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 21:11:04 +0100 Subject: [PATCH 5/8] option for nasr db --- georeferenceAirportDiagramsViaDb.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/georeferenceAirportDiagramsViaDb.pl b/georeferenceAirportDiagramsViaDb.pl index 097c2e2..7eb5606 100755 --- a/georeferenceAirportDiagramsViaDb.pl +++ b/georeferenceAirportDiagramsViaDb.pl @@ -77,7 +77,7 @@ use vars qw/ %opt /; #Define the valid command line options -my $opt_string = 'cspva:i:'; +my $opt_string = 'cspva:i:d:'; my $arg_num = scalar @ARGV; #We need at least one argument (the name of the PDF to process) @@ -134,8 +134,15 @@ our $dbh; my $sth; +my $dbhPath = "../processFaaData/nasr.sqlite"; +if ( $opt{d} ) { + #If something provided on the command line use it instead + $dbhPath = $opt{d}; + say "Supplied airport lat/long db: $dbhPath"; +} + # The nasr database created by processFaaData -$dbh = DBI->connect( "dbi:SQLite:dbname=../processFaaData/nasr.sqlite", +$dbh = DBI->connect( "dbi:SQLite:dbname=$dbhPath", "", "", { RaiseError => 1 } ) or croak $DBI::errstr; @@ -2517,6 +2524,7 @@ sub touchFile { sub usage { say "Usage: $0 "; say "-v debug"; + say "-d The path of the nasr db generated by processFaaData."; say "-a To specify an airport ID"; say "-i<2 Letter state ID> To specify a specific state"; say "-p Output a marked up version of PDF"; From 1a9d682422b135682680b4a08ea2e406db1523d7 Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 21:26:39 +0100 Subject: [PATCH 6/8] assign default values to counter --- load_dtpp_metadata.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/load_dtpp_metadata.pl b/load_dtpp_metadata.pl index 8658c5d..15510b1 100755 --- a/load_dtpp_metadata.pl +++ b/load_dtpp_metadata.pl @@ -89,7 +89,7 @@ my $dtpp_url = "http://aeronav.faa.gov/d-tpp/$cycle/xml_data/d-TPP_Metafile.xml"; # my $dtpp_url = "https://nfdc.faa.gov/webContent/dtpp/current.xml"; -my ( $count, $downloadedCount, $deletedCount, $changedCount, $addedCount ); +my ( $count, $downloadedCount, $deletedCount, $changedCount, $addedCount ) = (0) x 5; my %countHash; From 0fc639c9cf5b1eee4c1f21b7c6990179ceb8f72e Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 21:35:09 +0100 Subject: [PATCH 7/8] added airport filter option --- load_dtpp_metadata.pl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/load_dtpp_metadata.pl b/load_dtpp_metadata.pl index 15510b1..7118a05 100755 --- a/load_dtpp_metadata.pl +++ b/load_dtpp_metadata.pl @@ -53,7 +53,7 @@ my $arg_num = scalar @ARGV; #Define the valid command line options -my $opt_string = 'dr'; +my $opt_string = 'dra:'; #This will fail if we receive an invalid option unless ( getopts( "$opt_string", \%opt ) ) { @@ -67,6 +67,16 @@ exit(1); } +#Default to all airports for the SQL query +our $airportId = ""; +if ( $opt{a} ) { + #If something provided on the command line use it instead + $airportId = $opt{a}; + say "Supplied airport ID: Only $airportId will be processed!"; +} + + + my $BASE_DIR = shift @ARGV; my $cycle = shift @ARGV; @@ -334,6 +344,11 @@ sub record { ++$count; + if ( !( $airportId eq "" ) && $airportId ne $faa_code) { + #say "Skipping airport $faa_code"; + return; + } + say "\rLoading # $count : $pdf_name: $chart_name"; #TPP_VOLUME @@ -588,5 +603,6 @@ sub usage { say "eg: $0 . 1502"; say "-d Download ALL plates (default is only added/new)"; say "-r Rasterize ALL plates (default is only added/new)"; + say "-a To specify an airport ID"; } From 1e1201b15ae60c03d6a638b1a6f518175a15bfc5 Mon Sep 17 00:00:00 2001 From: Jan Chaloupecky Date: Sun, 21 Jan 2018 21:47:02 +0100 Subject: [PATCH 8/8] -d option to force chart download --- load_dtpp_metadata.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/load_dtpp_metadata.pl b/load_dtpp_metadata.pl index 7118a05..bfad6ca 100755 --- a/load_dtpp_metadata.pl +++ b/load_dtpp_metadata.pl @@ -75,6 +75,7 @@ say "Supplied airport ID: Only $airportId will be processed!"; } +our $downloadAll = $opt{d}; my $BASE_DIR = shift @ARGV; @@ -402,17 +403,22 @@ sub record { deleteStaleFiles($pdf_name); ++$deletedCount; } + + my $doDownload = 0; if ( $user_action =~ /A/i ) { say "Added " . "$dtppDownloadDir" . "$pdf_name"; - downloadPlate($pdf_name); ++$addedCount; + $doDownload = 1 } if ( $user_action =~ /C/i ) { - downloadPlate($pdf_name); ++$changedCount; + $doDownload = 1; } + if ($doDownload || $downloadAll) { + downloadPlate($pdf_name); + } #If the pdf doesn't exist locally fetch it #but don't bother trying to download DELETED charts if ( !( $pdf_name =~ /DELETED/i )