Navigation Menu

Skip to content

Commit

Permalink
Added config option for EMWIN handler to disable output of TXT files
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbates12 committed May 6, 2020
1 parent 543ece3 commit 2f54169
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/goesproc/config.cc
Expand Up @@ -174,6 +174,11 @@ bool loadHandlers(const toml::Value& v, Config& out) {
h.json = json->as<bool>();
}

auto exclude_txt = th->find("exclude_txt");
if (exclude_txt) {
h.exclude_txt = exclude_txt->as<bool>();
}

auto crop = th->find("crop");
if (crop) {
auto vs = crop->as<std::vector<int>>();
Expand Down
3 changes: 3 additions & 0 deletions src/goesproc/config.h
Expand Up @@ -51,6 +51,9 @@ struct Config {
// Write LRIT header contents as JSON file.
bool json = false;

// Exclude TXT files from EMWIN.
bool exclude_txt = false;

// Crop (applied before scaling)
Area crop;

Expand Down
13 changes: 13 additions & 0 deletions src/goesproc/handler_emwin.cc
Expand Up @@ -52,6 +52,13 @@ void EMWINHandler::handle(std::shared_ptr<const lrit::File> f) {
auto zip = Zip(f->getData());
fb.filename = zip.fileName();

// Don't write file if EMWIN TXT is disabled in config
if (config_.exclude_txt) {
if (fb.filename.substr(fb.filename.length() - 3) == "TXT") {
return;
}
}

// Use filename and extension straight from ZIP file
const auto path = fb.build("{filename}");
fileWriter_->write(path, zip.read());
Expand All @@ -66,6 +73,12 @@ void EMWINHandler::handle(std::shared_ptr<const lrit::File> f) {

// Write with TXT extension if this is not a compressed file
if (nlh.noaaSpecificCompression == 0) {

// Don't write file if EMWIN TXT is disabled in config
if (config_.exclude_txt) {
return;
}

fb.filename = removeSuffix(text);

// Compressed TXT files also use the uppercase TXT extension
Expand Down

0 comments on commit 2f54169

Please sign in to comment.