Commit 01cffb75 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Made some changes to clarify exactly what happens if the ddd file has an old header format.

parent bf12d998
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
#include "SpecialPixel.h"
#include "FileName.h"
#include "Pvl.h"
#include <QMap>

using namespace std;
using namespace Isis;
@@ -89,7 +90,7 @@ void IsisMain() {

  // Maps the bit type of the file to the number of bytes of that type
  // Taken directly from a given python program that reads in ddd data
  map<int, int> dataTypes = {
  QMap<int, int> dataTypes = {
    {1450901768, 1},
    {1450902032, 2},
    {1450902288, 2},
@@ -109,21 +110,26 @@ void IsisMain() {
  int bitType = (int) readBytes.readLong;

  int dataTypeBytes;
  //Old header format has no bit type
  if (bitType == 0) {
    dataTypeBytes = dataTypes.find(totalBandBits) -> second;
  }
  else {
    dataTypeBytes = dataTypes.find(bitType) -> second;
  }
  int nOffset;
  // Check for new header format. Taken from the python program.
  if ( (bitType & 0xfffff000) == 0x567b0000 ) {
    dataTypeBytes = dataTypes.value(bitType);

    // Read bytes 20-23 to get offset
    // New header format may have different offsets
    fin.read(readBytes.readChars, 4);
    readBytes.readFloat = swp.Float(readBytes.readChars);
  int nOffset = (int) readBytes.readLong;
    nOffset = (int) readBytes.readLong;
    if (nOffset < 1024) {
      nOffset = 1024;
    }
  }
  else {
    // Old header format does not have a bit type
    // Old header format's offset is always 1024.
     dataTypeBytes = dataTypes.value(totalBandBits);
     nOffset = 1024;
  }

  fin.close();