8#include "CubeBsqHandler.h"
14#include "IException.h"
16#include "PvlKeyword.h"
18#include "RawCubeChunk.h"
35 const QList<int> *virtualBandList,
const Pvl &labels,
bool alreadyOnDisk)
36 :
CubeIoHandler(dataFile, virtualBandList, labels, alreadyOnDisk) {
38 int numLinesInChunk = 1;
42 int sizeLimit = 1024 * 1024 * 1024;
43 int maxNumLines = (sizeLimit) / (SizeOf(
pixelType()) * numSamplesInChunk);
69 PvlObject &core = label.findObject(
"IsisCube").findObject(
"Core");
70 core.addKeyword(PvlKeyword(
"Format",
"BandSequential"),
71 PvlContainer::Replace);
81 if(dataFile->seek(startByte)) {
82 QByteArray binaryData = dataFile->read(chunkToFill.
getByteCount());
91 IString msg =
"Reading from the file [" + dataFile->fileName() +
"] "
92 "failed with reading [" +
94 "] bytes at position [" + QString::number(startByte) +
"]";
95 throw IException(IException::Io, msg, _FILEINFO_);
103 bool success =
false;
106 if(dataFile->seek(startByte)) {
107 BigInt dataWritten = dataFile->write(chunkToWrite.
getRawData());
115 IString msg =
"Writing to the file [" + dataFile->fileName() +
"] "
116 "failed with writing [" +
118 "] bytes at position [" + QString::number(startByte) +
"]";
119 throw IException(IException::Io, msg, _FILEINFO_);
134 int chunkDimensionSize;
136 if (dimensionSize <= maxSize) {
137 chunkDimensionSize = dimensionSize;
141 int greatestDivisor = maxSize;
142 while (dimensionSize % greatestDivisor > 0) {
145 chunkDimensionSize = greatestDivisor;
147 return chunkDimensionSize;
CubeBsqHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Construct a BSQ IO handler.
virtual void readRaw(RawCubeChunk &chunkToFill)
This needs to populate the chunkToFill with unswapped raw bytes from the disk.
virtual void writeRaw(const RawCubeChunk &chunkToWrite)
This needs to write the chunkToWrite directly to disk with no modifications to the data itself.
int findGoodSize(int maxSize, int dimensionSize) const
This method attempts to compute a good chunk line size.
BigInt getChunkStartByte(const RawCubeChunk &chunk) const
This is a helper method that goes from chunk to file position.
void updateLabels(Pvl &labels)
Function to update the labels with a Pvl object.
~CubeBsqHandler()
The destructor writes all cached data to disk.
virtual void clearCache(bool blockForWriteCache=true) const
Free all cube chunks (cached cube data) from memory and write them to disk.
PixelType pixelType() const
void setChunkSizes(int numSamples, int numLines, int numBands)
This should be called once from the child constructor.
CubeIoHandler(QFile *dataFile, const QList< int > *virtualBandList, const Pvl &label, bool alreadyOnDisk)
Creates a new CubeIoHandler using a RegionalCachingAlgorithm.
BigInt getBytesPerChunk() const
BigInt getDataStartByte() const
int getChunkIndex(const RawCubeChunk &) const
Given a chunk, what's its index in the file.
A section of raw data on the disk.
QByteArray & getRawData() const
void setRawData(QByteArray rawData)
Sets the chunk's raw data.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.