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 Original line Diff line number Diff line
@@ -4,6 +4,7 @@
#include "SpecialPixel.h"
#include "SpecialPixel.h"
#include "FileName.h"
#include "FileName.h"
#include "Pvl.h"
#include "Pvl.h"
#include <QMap>


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


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


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


    // Read bytes 20-23 to get offset
    // Read bytes 20-23 to get offset
    // New header format may have different offsets
    fin.read(readBytes.readChars, 4);
    fin.read(readBytes.readChars, 4);
    readBytes.readFloat = swp.Float(readBytes.readChars);
    readBytes.readFloat = swp.Float(readBytes.readChars);
  int nOffset = (int) readBytes.readLong;
    nOffset = (int) readBytes.readLong;
    if (nOffset < 1024) {
    if (nOffset < 1024) {
      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();
  fin.close();