diff --git a/isis/src/base/apps/topds4/20190612T090019S776_map_L0pan.xml.full b/isis/src/base/apps/topds4/20190612T090019S776_map_L0pan.xml.full index c9eea369c0..9c742be987 100644 --- a/isis/src/base/apps/topds4/20190612T090019S776_map_L0pan.xml.full +++ b/isis/src/base/apps/topds4/20190612T090019S776_map_L0pan.xml.full @@ -389,63 +389,63 @@ - 20190612T090019S776_map_L0pan.fits - 2020-01-17T19:16:18.256Z - 4443840 + {{imageFileName()}} + {{currentTime()}} + {{outputFileSize()}}
0 - 17280 - FITS 3.0 + {{ int(MainLabel.IsisCube.Core.StartByte.Value) - 2}} + ISIS3
Active Area - 17280 + {{ int(MainLabel.IsisCube.Core.Pixels.Multiplier.Value) - 1}} 2 Last Index Fastest OCAMS image 1024 by 1024 pixel active array. UnsignedMSB2 DN - 1 - 32768 + {{MainLabel.IsisCube.Core.Pixels.Multiplier.Value}} + {{MainLabel.IsisCube.Core.Pixels.Base.Value}} Line - 1024 + {{MainLabel.IsisCube.Core.Dimensions.Lines.Value}} 1 Sample - 1024 + {{MainLabel.IsisCube.Core.Dimensions.Samples.Value}} 2
- 2116800 - 2880 - FITS 3.0 + 0 + TBD + ISIS3
Active Array and Extended Pixel Regions - 2119680 + TBD 2 Last Index Fastest OCAMS 1044 sample by 1112 line extended pixel array. The extended pixel array contains the detector overscan and dark pixels. UnsignedMSB2 DN - 1 - 32768 + TBD + TBD Line - {{MainLabel.IsisCube.Core.Dimensions.Lines.Value}} + TBD 1 Sample - 1112{{MainLabel.IsisCube.Core.Dimensions.Samples.Value}} + TBD 2 diff --git a/isis/src/base/apps/topds4/topds4.cpp b/isis/src/base/apps/topds4/topds4.cpp index 84b8abf217..51b39d4d45 100644 --- a/isis/src/base/apps/topds4/topds4.cpp +++ b/isis/src/base/apps/topds4/topds4.cpp @@ -5,6 +5,7 @@ #include #include "md5wrapper.h" +#include "QFile.h" #include "topds4.h" @@ -30,6 +31,9 @@ namespace Isis { Process p; p.SetInputCube(icube); + // NEED TO WRITE AND CLOSE THE OUTPUT FILE BEFORE RENDERING SO THE FILE SIZE CALLBACK CAN GET THE FINAL FILE SIZE + QString outputFile = ui.GetFileName("TO"); + json dataSource; Pvl &cubeLabel = *icube->label(); @@ -50,13 +54,8 @@ namespace Isis { // get the xml label and add it to the template data } - std::cout << "=============Data================" << std::endl; - std::cout << dataSource.dump(4) << std::endl; - std::cout << "=================================" << std::endl; - - Environment env; - // Call back functions + // Template engine call back functions /** * Renders to the current UTC time formatted as YYYY-MM-DDTHH:MM:SS */ @@ -76,6 +75,14 @@ namespace Isis { return (cubeFilename.split(".")[0] + ".img").toStdString(); }); + /** + * Renders to the final file size in bytes of the output cube or img + */ + env.add_callback("outputFileSize", 0, [outputFile](Arguments& args) { + FileName cubeFilename = outputFile; + return QFile(outputFile).size(); + }); + /** * Renders to the MD5 hash for the input cube */ @@ -85,13 +92,18 @@ namespace Isis { }); std::string inputTemplate = ui.GetFileName("TEMPLATE").toStdString(); - std::string result = env.render_file(inputTemplate, dataSource); std::ofstream outFile(ui.GetFileName("TO").toStdString()); outFile << result; outFile.close(); + if (ui.WasEntered("DATA")) { + std::ofstream jsonDataFile(FileName(ui.GetFileName("DATA")).expanded().toStdString()); + 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 c29862bc69..9f9ef6d0dd 100644 --- a/isis/src/base/apps/topds4/topds4.xml +++ b/isis/src/base/apps/topds4/topds4.xml @@ -2,20 +2,28 @@ - dummy + Convert from ISIS3 cube to PDS 4 format using template XML files - dummy +

+ Writes a PDS4 compatible label file and image file. The contents of the label file are + generated useing the template file specified by the TEMPLATE parameter. +

+

+ 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). +

- Trim and Mask + Import and Export - - Removed unreachable code. + + Original version @@ -28,7 +36,7 @@ Input cube - This is the input cube that will be cropped. + This is the input cube that will be converted to PDS4 format. *.cub @@ -42,7 +50,10 @@ Input template - Input template + The file name of the input template. This file contains "inja" compatible + template syntax inside of a PDS4 XML label. The data used to replace the + template elements comes from the ISIS cube label, the original label + (PDS3, FITS, PDS4), and other input PVL, XML, or JSON files. @@ -53,9 +64,26 @@ Output PDS4 label - The. + 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 + + + + + filename + None + output + + Output JSON data + + + The output file name to store the template data source. This is a dump of the JSON data used + by the template engine to fill in the template elements. It is a combination of the ISIS + main cube lable, the original lable, and any other data sources supplied. The purpose of this + parameter is for debugging the templates. +