Unverified Commit f6815ed2 authored by acpaquette's avatar acpaquette Committed by GitHub
Browse files

isis2ascii spacing fix (#3910)

* Increased the width of ascii DN output from 13 spaces to 14 spaces

* Removed old ISIS test make files

* Addresses PR feedback

* Added a test for a custom delimiter

* Added new delimiter to header
parent a8de5e67
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ namespace Isis {
   *
   * @internal
   *   @history 2016-06-15 Adam Paquette - Original Version
   *   @history 2020-06-10 Adam Paquette - Added delimiter variable to use in
   *                                       output file and removed static spacing
   *
   */

@@ -27,12 +29,12 @@ namespace Isis {
                                   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;
@@ -43,6 +45,9 @@ namespace Isis {
            else {
              fout << in[i];
            }
            if (i != in.size() - 1) {
              fout << delimiter;
            }
          }
          fout << endl;
      }
@@ -52,6 +57,7 @@ namespace Isis {
      QString his;
      QString lrs;
      QString lis;
      QString delimiter;
  };

  void isis2ascii(UserInterface &ui) {
@@ -78,12 +84,17 @@ namespace Isis {
    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;
      fout << "Samples " << icube->sampleCount() << endl;
      fout << "Lines " << icube->lineCount() << endl;
      fout << "Bands " << icube->bandCount() << endl;
      fout << "Input_Cube" << delimiter << icube->fileName() << endl;
      fout << "Samples" << delimiter << icube->sampleCount() << endl;
      fout << "Lines" << delimiter << icube->lineCount() << endl;
      fout << "Bands" << delimiter << icube->bandCount() << endl;
    }

    //Determine special pixel values
@@ -102,7 +113,7 @@ namespace Isis {
      lis = "LIS";
    }

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

    fout << std::setprecision(7);

+54 −35
Original line number Diff line number Diff line
@@ -71,6 +71,14 @@
    <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-08">
      Changed the formatting of the header to be easier to parse using
      a space delimited CSV reader.
    </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>


@@ -108,6 +116,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">
+0 −9
Original line number Diff line number Diff line
APPNAME  = isis2ascii

include $(ISISROOT)/make/isismake.tsts

isis2asciiTruth.txt.SKIPLINES = 1

commands:
	$(APPNAME) from=$(INPUT)/isisTruth.cub \
	  to=$(OUTPUT)/isis2asciiTruth.txt > /dev/null;
+0 −9
Original line number Diff line number Diff line
APPNAME = isis2ascii

include $(ISISROOT)/make/isismake.tsts
vesta64ascii.txt.SKIPLINES = 1


commands:
	$(APPNAME) from = $(INPUT)/vesta64_dtm_top.cub \
	  to = $(OUTPUT)/vesta64ascii.txt > /dev/null;
+0 −9
Original line number Diff line number Diff line
APPNAME = isis2ascii

include $(ISISROOT)/make/isismake.tsts
vikcalascii.txt.SKIPLINES = 1


commands:
	$(APPNAME) from = $(INPUT)/vikcalTruth.cub \
	  to = $(OUTPUT)/vikcalascii.txt > /dev/null;
Loading