diff --git a/isis/src/base/apps/topds4/topds4.cpp b/isis/src/base/apps/topds4/topds4.cpp index 25917a740b..1ce2ec412c 100644 --- a/isis/src/base/apps/topds4/topds4.cpp +++ b/isis/src/base/apps/topds4/topds4.cpp @@ -38,10 +38,9 @@ namespace Isis { Process p; p.SetInputCube(icube); + // Setup the output file so that we can use it in callbacks QString outputFile = ui.GetFileName("TO"); - // NEED TO WRITE AND CLOSE THE OUTPUT FILE BEFORE RENDERING SO THE FILE SIZE CALLBACK CAN GET THE FINAL FILE SIZE - // Name for output image FileName outputFileName(outputFile); QString path(outputFileName.originalPath()); @@ -157,27 +156,26 @@ namespace Isis { }); /** - * Renders to the filename of the output img + * Renders to the filename of the output image file */ - env.add_callback("imageFileName", 0, [icube](Arguments& args) { - QString cubeFilename = icube->fileName().split("/").back(); - return (cubeFilename.split(".")[0] + ".img").toStdString(); + env.add_callback("imageFileName", 0, [outputCubePath](Arguments& args) { + return outputCubePath.split("/").back().toStdString(); }); /** - * Renders to the final file size in bytes of the output cube or img + * Renders to the final file size in bytes of the output image file */ env.add_callback("outputFileSize", 0, [outputFile](Arguments& args) { FileName cubeFilename = outputFile; - return QFile(outputFile).size(); + return QFile(outputFile).size(); }); /** - * Renders to the MD5 hash for the input cube + * Renders to the MD5 hash for the output image file */ - env.add_callback("md5Hash", 0, [icube](Arguments& args) { + env.add_callback("md5Hash", 0, [outputCubePath](Arguments& args) { md5wrapper md5; - return md5.getHashFromFile(icube->fileName()).toStdString(); + return md5.getHashFromFile(outputCubePath).toStdString(); }); std::string inputTemplate = ui.GetFileName("TEMPLATE").toStdString(); @@ -192,9 +190,5 @@ namespace Isis { jsonDataFile << dataSource.dump(4); jsonDataFile.close(); } - - std::cout << "============Result===============" << std::endl; - std::cout << result << std::endl; - std::cout << "=================================" << std::endl; } } diff --git a/isis/src/base/apps/topds4/topds4.xml b/isis/src/base/apps/topds4/topds4.xml index 02ba22ea82..adc58ea721 100644 --- a/isis/src/base/apps/topds4/topds4.xml +++ b/isis/src/base/apps/topds4/topds4.xml @@ -12,8 +12,17 @@

The image file is generated from the input ISIS cube specified by the FROM parameter. - The format of the output image file can be either an ISIS cube or a raw binary file containing - only the image DNs (i.e., no header or trailing data). + The output image file will a copy of the input ISIS cube with the image data stored in + Band Sequential format. +

+

+ This application uses the Inja templating engine + to render the template file. The input data from the cube and extra data sources + is converted to JSON and then it is accessed via the Inja templating syntax. + See the Inja documentation for the full template + syntax. The data from the label of the input cube is accessible under "MainLabel", + the data from the original label of the input cube is accessible under "OriginalLabel", + and the extra data is accessible under "ExtraPvl", "ExtraXml", and "ExtraJson".

@@ -65,7 +74,7 @@ The output file name of the PDS4 label. The output image name will be derived from this - parameter by removing the last extension and adding .cub + parameter by removing the last extension and adding .cub. diff --git a/isis/tests/FunctionalTestsTopds4.cpp b/isis/tests/FunctionalTestsTopds4.cpp index 742302b929..e49be73c16 100644 --- a/isis/tests/FunctionalTestsTopds4.cpp +++ b/isis/tests/FunctionalTestsTopds4.cpp @@ -355,12 +355,13 @@ TEST_F(SmallCube, FunctionalTestTopds4ImageFileName) { renderedStream.open(renderedFile.toStdString()); std::string line; std::getline(renderedStream, line); - EXPECT_EQ("small.img", line); + EXPECT_EQ("current_time.cub", line); } TEST_F(SmallCube, FunctionalTestTopds4MD5Hash) { QString templateFile = tempDir.path()+"/current_time.tpl"; QString renderedFile = tempDir.path()+"/current_time.txt"; + QString renderedCube = tempDir.path()+"/current_time.cub"; std::ofstream of; of.open(templateFile.toStdString()); of << "{{md5Hash()}}"; @@ -375,5 +376,5 @@ TEST_F(SmallCube, FunctionalTestTopds4MD5Hash) { std::string line; std::getline(renderedStream, line); md5wrapper md5; - EXPECT_EQ(md5.getHashFromFile(testCube->fileName()).toStdString(), line); + EXPECT_EQ(md5.getHashFromFile(renderedCube).toStdString(), line); }