Skip to content

Commit

Permalink
Port #3910 to 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jessemapel committed Jun 15, 2020
1 parent 0ff503c commit 1321aeb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
33 changes: 24 additions & 9 deletions isis/src/base/apps/isis2ascii/isis2ascii.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<description>
This program converts sn ISIS cube to ASCII file format. Special pixels such as
<def>NULL</def>, <def>LIS</def>, <def>LRS</def>, <def>HIS</def> and <def>HRS</def>
have predetermined pixel values. You may opt to assign a range of pixel values to
the individual <def>Special Pixels</def> using the SETPIXELVALUES parameter. Bands in the cube
<def>NULL</def>, <def>LIS</def>, <def>LRS</def>, <def>HIS</def> and <def>HRS</def>
have predetermined pixel values. You may opt to assign a range of pixel values to
the individual <def>Special Pixels</def> using the SETPIXELVALUES parameter. Bands in the cube
will be output in band sequential format.
<br />
<br />
Expand Down Expand Up @@ -63,14 +63,18 @@
Documentation fixes
</change>
<change name="Steven Lambright" date="2008-05-12">
Removed references to CubeInfo
Removed references to CubeInfo
</change>
<change name="Makayla Shepherd" date="2015-01-30">
Increased precision of the DNs in the output text file from 6 to 7
</change>
<change name="Adam Paquette" date="2016-06-15">
Added the ability for a user to specify the special pixel values
</change>
<change name="Adam Paquette" date="2020-06-09">
Changed output formatting to use a delimiter that is placed after each
entry, rather than depending on a set width.
</change>
</history>


Expand Down Expand Up @@ -108,6 +112,17 @@
<item>YES</item>
</default>
</parameter>
<parameter name="DELIMITER">
<type>string</type>
<brief>Output Delimiter</brief>
<description>
Sets the value to place between entries in the output file. This will
default to a space if nothing is entered.
</description>
<default>
<item></item>
</default>
</parameter>
</group>

<group name="Special Pixels">
Expand All @@ -118,7 +133,7 @@
</default>
<brief>User defined output for special pixels</brief>
<description>
Determine whether the user would like a
Determine whether the user would like a
specific output for the special pixels in the image.
</description>
<inclusions>
Expand All @@ -129,7 +144,7 @@
<item>HRSVALUE</item>
</inclusions>
</parameter>

<parameter name="NULLVALUE">
<type>string</type>
<default>
Expand Down Expand Up @@ -215,12 +230,12 @@

<example>
<brief> Header default </brief>
<description>
<description>
Demonstrate the isis2ascii application with header
</description>
<terminalInterface>
<commandLine> f=../IN/f332s28.cub t=OUT/isis2ascii.txt </commandLine>
<description>
<description>
Convert Viking ISIS image to ascii file. Let header default to yes.
</description>
</terminalInterface>
Expand All @@ -237,7 +252,7 @@
<outputImages>
<image src="assets/image/isis2asciiTxt.jpg" width="500" height="523">
<brief> Example output ascii text from isis2ascii run</brief>
<description>
<description>
This is the output ascii text file isis2ascii.txt with the header.
</description>
<thumbnail caption="Output image showing results of the isis2ascii application." src="assets/thumb/isis2asciiTxt.jpg" width="200" height="209"/>
Expand Down
21 changes: 15 additions & 6 deletions isis/src/base/apps/isis2ascii/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class SpecialPixelFunctor{
QString hrs,
QString his,
QString lrs,
QString lis) :
null(null), hrs(hrs), his(his), lrs(lrs), lis(lis) {}
QString lis,
QString delimiter) :
null(null), hrs(hrs), his(his), lrs(lrs), lis(lis), delimiter(delimiter) {}

void operator() (Buffer &in) const {
for(int i = 0; i < in.size(); i++) {
fout.width(13); // Width must be set everytime
if(IsSpecial(in[i])) {
if(IsNullPixel(in[i])) fout << null;
if(IsHrsPixel(in[i])) fout << hrs;
Expand All @@ -49,6 +49,9 @@ class SpecialPixelFunctor{
else {
fout << in[i];
}
if (i != in.size() - 1) {
fout << delimiter;
}
}
fout << endl;
}
Expand All @@ -58,6 +61,7 @@ class SpecialPixelFunctor{
QString his;
QString lrs;
QString lis;
QString delimiter;
};

void IsisMain() {
Expand All @@ -78,6 +82,11 @@ void IsisMain() {
QString to = ui.GetFileName("TO", "txt");
fout.open(to.toLatin1().data());

QString delimiter = ui.GetString("DELIMITER");
if (delimiter.isEmpty()) {
delimiter = " ";
}

// Print header if needed
if(ui.GetBoolean("HEADER")) {
fout << "Input Cube: " << icube->fileName() << endl;
Expand All @@ -101,10 +110,10 @@ void IsisMain() {
lis = "LIS";
}

SpecialPixelFunctor isis2ascii(null, hrs, his, lrs, lis);
SpecialPixelFunctor isis2ascii(null, hrs, his, lrs, lis, delimiter);

fout << std::setprecision(7);

// List the cube
p.ProcessCubeInPlace(isis2ascii, false);
p.EndProcess();
Expand Down

0 comments on commit 1321aeb

Please sign in to comment.