Commit 2a85c3be authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Updated from trunk.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@6293 41f8697f-d340-4b68-9986-7bafba869bb8
parents 393168a0 4024af4b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -121,9 +121,9 @@ quickclean: localclean
clean:  localclean
	$(RM) $(OBJS) $(BINS) $(PROTOSGEN) $(MOCGEN) `basename $(CURDIR)`.html \
	  $(UIHEADERS) $(QTRESOURCEFILES) *.csexe *.csmes;                     \
	$(RM) -r scopecoverage scopecoverage.html                              \
	         linecoverage linecoverage.html                                \
	         functioncoverage functioncoverage.html;                       \
	$(RM) -r scopecoverage scopecoverage.html scopecoverage_html           \
	         linecoverage linecoverage.html linecoverage_html              \
	         functioncoverage functioncoverage.html functioncoverage_html; \
	if [ -d "tsts" ];                                                      \
	then                                                                   \
	  if [ -f "tsts/Makefile" ];                                           \
+3 −3
Original line number Diff line number Diff line
@@ -231,9 +231,9 @@ clean: localclean
	  $(UIHEADERS) $(ARCHIVELIB) $(SHAREDLIB) libisis$(ISISLIBVERSION).a  \
	  libisis$(ISISLIBVERSION).so libisis$(ISISLIBVERSION).dylib          \
	  unitTest.output;                                                    \
	$(RM) -rf html scopecoverage scopecoverage.html                       \
	  linecoverage linecoverage.html functioncoverage                     \
	  functioncoverage.html .objs *.csexe *.csmes
	$(RM) -rf html scopecoverage scopecoverage.html scopecoverage_html    \
	  linecoverage linecoverage.html linecoverage_html functioncoverage   \
	  functioncoverage.html functioncoverage_html .objs *.csexe *.csmes

localclean:
	if [ "$(findstring cleanlocal,$(shell $(GREP) cleanlocal Makefile))" = "cleanlocal" ]; \
+25 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ double TestSpecial(const double pixel);
void ascii2isis(Buffer &out);
ifstream fin;
QString order;
QString from;
//Initialize values to make special pixels invalid
double null_min = DBL_MAX;
double null_max = DBL_MIN;
@@ -24,10 +25,15 @@ double lrs_min = DBL_MAX;
double lrs_max = DBL_MIN;

void IsisMain() {
  //initialize fin
  if (fin.is_open()) {
    fin.close();
  }

  //  Open input text file
  UserInterface &ui = Application::GetUserInterface();
  QString from = ui.GetFileName("FROM");
  from = ui.GetFileName("FROM");
  
  // Get storage order of data
  order = ui.GetString("ORDER");

@@ -45,6 +51,7 @@ void IsisMain() {
    null_min = ui.GetDouble("NULLMIN");
    null_max = ui.GetDouble("NULLMAX");
  }
  
  if (ui.GetBoolean("SETHRSRANGE")) {
    hrs_min = ui.GetDouble("HRSMIN");
    hrs_max = ui.GetDouble("HRSMAX");
@@ -54,19 +61,23 @@ void IsisMain() {
    lrs_max = ui.GetDouble("LRSMAX");
  }

  
  fin.open(from.toAscii().data(), std::ios::in);
  if (!fin.is_open()) {
    QString msg = "Cannot open input file [" + from + "]";
    throw IException(IException::Io, msg, _FILEINFO_);
  }

  
  //  Skip header information if it exists
  fin.seekg(skip, std::ios::beg);

  
  //  Set up process depending on order
  if (order == "BSQ") {
    ProcessByLine p;

    
    p.SetOutputCube(ui.GetFileName("TO"), att, ns, nl, nb);
    p.StartProcess(ascii2isis);
    p.EndProcess();
@@ -74,6 +85,7 @@ void IsisMain() {
  if (order == "BIL") {
    ProcessBySpectra p(Isis::ProcessBySpectra::ByLine);

    
    // Set Special Pixel ranges
    p.SetOutputCube(ui.GetFileName("TO"), att, ns, nl, nb);
    p.StartProcess(ascii2isis);
@@ -82,6 +94,7 @@ void IsisMain() {
  if (order == "BIP") {
    ProcessBySpectra p(Isis::ProcessBySpectra::PerPixel);

    
    p.SetOutputCube(ui.GetFileName("TO"), att, ns, nl, nb);
    p.StartProcess(ascii2isis);
    p.EndProcess();
@@ -93,13 +106,22 @@ void IsisMain() {
void ascii2isis(Buffer &out) {
  //Define all legal characters for the beginning of a number
  const string legal = ".0123456789+-";

    
  for (int i = 0; i < out.size(); i++) {
    fin >> out[i];
    out[i] = TestSpecial(out[i]);
    
    //Discard all nonlegal characters
    while ((legal.find(fin.peek()) == string::npos) && !fin.eof()) {
      fin.ignore();
    }  
    
    fin >> out[i];
    if (!fin && fin.eof()) {
      QString msg = "End of file reached. There is not enough data in [" + from;
      msg += "] to fill the output cube.";
      throw IException(IException::User, msg, _FILEINFO_);
    }
    out[i] = TestSpecial(out[i]);
  }
}

+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@
    <change name="Steven Koechle" date="2008-08-30">
        Added ability to change special pixel ranges. Added example.
    </change>
    <change name="Makayla Shepherd" data="2015-07-15">
        Fixed a problem with non-numeric cahracters in the file which resulted ascii2isis
        hanging. Fixes #2066.
    </change>
  </history>


+18 −0
Original line number Diff line number Diff line
APPNAME = ascii2isis

include $(ISISROOT)/make/isismake.tsts

commands:
	# Test an input file with not enough data
	if [ `$(APPNAME) \
	  from=$(INPUT)/ascii2isis_input.txt \
	  to=$(OUTPUT)/temp.cub >& $(OUTPUT)/temp.txt \
	  order=bsq \
	  lines=100 \
	  samples=100 \
	  bands=100 \
	  skip=0` ]; then \
	  true; \
	fi;
	$(SED) 's/\[.*\/\(ascii2isis_input.txt\)\]/[\1]/' < $(OUTPUT)/temp.txt > $(OUTPUT)/not_enough_data.txt;
	$(RM) $(OUTPUT)/temp.txt $(OUTPUT)/temp.cub > /dev/null;
Loading