diff --git a/.gitignore b/.gitignore index aa56df6..f598250 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,9 @@ META.yml MYMETA.yml nytprof.out pm_to_blib +/local +/tilers_tools +/mbutil +/parallelGdal2tiles DDTPP*.zip + diff --git a/georeference_airport_diagrams_via_db.pl b/georeference_airport_diagrams_via_db.pl index d9f88f2..054aa7d 100755 --- a/georeference_airport_diagrams_via_db.pl +++ b/georeference_airport_diagrams_via_db.pl @@ -79,8 +79,10 @@ use vars qw/ %opt /; -# Define the valid command line options -my $opt_string = 'nspva:c:i:'; + +#Define the valid command line options +my $opt_string = 'cspva:c:i:d:'; + my $arg_num = scalar @ARGV; # We need at least one argument (the name of the PDF to process) @@ -148,8 +150,17 @@ 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=nasr.sqlite", "", "", { RaiseError => 1 } ) + or croak $DBI::errstr; our ( @@ -2530,6 +2541,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"; diff --git a/load_dtpp_metadata.pl b/load_dtpp_metadata.pl index c7a1cc9..663f4a6 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,17 @@ 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!"; +} + +our $downloadAll = $opt{d}; + + my $BASE_DIR = shift @ARGV; my $cycle = shift @ARGV; @@ -87,11 +98,13 @@ # 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 ( $count, $downloadedCount, $deletedCount, $changedCount, $addedCount ); +my ( $count, $downloadedCount, $deletedCount, $changedCount, $addedCount ) = (0) x 5; my %countHash; @@ -99,18 +112,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"; } @@ -339,6 +349,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 @@ -393,19 +408,27 @@ 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 ) @@ -596,5 +619,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"; }