Commit 07a328c4 authored by Janet Barrett's avatar Janet Barrett
Browse files

Modified ddd2isis so that it prints out label information to assist the user...

Modified ddd2isis so that it prints out label information to assist the user in importing non-standard ddd files. Fixes #1713.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5738 41f8697f-d340-4b68-9986-7bafba869bb8
parent a695d8fb
Loading
Loading
Loading
Loading
+34 −18
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
#include "UserInterface.h"
#include "SpecialPixel.h"
#include "FileName.h"
#include "Pvl.h"

using namespace std;
using namespace Isis;
@@ -12,7 +13,7 @@ void IsisMain() {
  ProcessImport p;
  IString from = ui.GetFileName("FROM");
  EndianSwapper swp("MSB");
  int nsamples = 0, nlines = 0, nbands = 1, noffset = 0;
  int nsamples = 0, nlines = 0, nbands = 1, noffset = 0, bittype = 0, nbytes = 0;

  union {
    char readChars[4];
@@ -57,7 +58,7 @@ void IsisMain() {

  fin.read(readBytes.readChars, 4);
  readBytes.readFloat = swp.Float(readBytes.readChars);
  nsamples = (int)readBytes.readLong;
  nbytes = (int)readBytes.readLong;

  fin.read(readBytes.readChars, 4);
  readBytes.readFloat = swp.Float(readBytes.readChars);
@@ -67,22 +68,7 @@ void IsisMain() {
    throw IException(IException::Io, msg, _FILEINFO_);
  }

  switch(readBytes.readLong) {
    case 8:
      p.SetPixelType(Isis::UnsignedByte);
      break;
    case 16:
      p.SetPixelType(Isis::UnsignedWord);
      break;
    case 32:
      p.SetPixelType(Isis::Real);
      break;
    default:
      IString msg = "Unsupported bit per pixel count [" + IString((int)readBytes.readLong) + "]";
      throw IException(IException::Io, msg, _FILEINFO_);
  }

  nsamples /= (readBytes.readLong / 8);
  bittype = readBytes.readLong;

  fin.read(readBytes.readChars, 4);
  readBytes.readFloat = swp.Float(readBytes.readChars);
@@ -94,8 +80,37 @@ void IsisMain() {
    noffset = 1024;
  }

  PvlGroup results("FileInfo");
  results += PvlKeyword("NumberOfLines", toString(nlines));
  results += PvlKeyword("NumberOfBytesPerLine", toString(nbytes));
  results += PvlKeyword("BitType", toString(bittype));
  nsamples = nbytes / (bittype / 8);
  results += PvlKeyword("NumberOfSamples", toString(nsamples));
  nbands = nbytes / nsamples;
  results += PvlKeyword("NumberOfBands", toString(nbands));
  results += PvlKeyword("LabelBytes", toString(noffset));
  Application::Log(results);

  fin.close();

  if (ui.WasEntered("TO")) {
    switch(bittype) {
      case 8:
        p.SetPixelType(Isis::UnsignedByte);
        break;
      case 16:
        p.SetPixelType(Isis::UnsignedWord);
        break;
      case 32:
        p.SetPixelType(Isis::Real);
        break;
      default:
        IString msg = "Unsupported bit per pixel count [" + IString(bittype) + "]. ";
        msg += "(Use the raw2isis and crop programs to import the file in case it is ";
        msg += "line or sample interleaved.)";
        throw IException(IException::Io, msg, _FILEINFO_);
    }

    p.SetDimensions(nsamples, nlines, nbands);
    p.SetFileHeaderBytes(noffset);
    p.SetByteOrder(Isis::Msb);
@@ -104,6 +119,7 @@ void IsisMain() {

    p.StartProcess();
    p.EndProcess();
  }

  return;
}
+10 −1
Original line number Diff line number Diff line
@@ -20,7 +20,15 @@
      to read in the image offset from the file header. This image offset is a
      4 byte integer that starts at byte 20 in the file header. If the offset is
      set to 0, then this means the label is 1024 bytes long. The offset must be
      a multiple of 1024.
      a multiple of 1024. Fixes #1594.
    </change>
    <change name="Janet Barrett" date="2013-07-11">
      Modified code to write out number of lines, number of samples, number of
      bands, bit type, and label bytes to assist in determining how the file
      should be read in. If the input file is a standard ddd file, then this
      program will be able to import it. If the data is interleaved, then it
      will need to be read in using a combination of the raw2isis and crop
      programs. Fixes #1713.
    </change>
  </history>

@@ -47,6 +55,7 @@
      <parameter name="TO">
         <type>cube</type>
         <fileMode>output</fileMode>
         <internalDefault>None</internalDefault>
         <brief>
           Output Isis cube
         </brief>