17#include <nlohmann/json.hpp>
21#include "PvlKeyword.h"
31 class CubeAttributeOutput;
32 class CubeCachingAlgorithm;
44 class OriginalXmlLabel;
247 void attachSpiceFromIsd(nlohmann::json Isd);
249 void close(
bool remove =
false);
251 void create(
const QString &cfile);
253 void open(
const QString &cfile, QString access =
"r");
254 void reopen(QString access =
"r");
257 const std::vector<PvlKeyword> keywords = std::vector<PvlKeyword>())
const;
261 const std::vector<PvlKeyword> keywords = std::vector<PvlKeyword>())
const;
266 void write(
Blob &blob,
bool overwrite=
true);
271 void write(
History &history,
const QString &name =
"IsisCube");
298 QString msg =
"Gathering histogram");
300 const double &validMax,
301 QString msg =
"Gathering histogram");
303 int labelSize(
bool actual =
false)
const;
311 QString msg =
"Gathering statistics");
313 const double &validMax,
314 QString msg =
"Gathering statistics");
319 bool deleteBlob(QString BlobName, QString BlobType);
324 bool hasBlob(
const QString &name,
const QString &type);
326 void latLonRange(
double &minLatitude,
double &maxLatitude,
double &minLongitude,
327 double &maxLongitude);
Buffer for reading and writing cube data.
Manipulate and parse attributes of output cube filenames.
This is the parent of the caching algorithms.
IO Handler for Isis Cubes.
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
void clearIoCache()
This will clear excess RAM used for quicker IO in the cube.
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
QFile * m_dataFile
This is only sometimes allocated.
Pvl realDataFileLabel() const
Function to read data from a cube label and return it as a PVL object.
ImagePolygon readFootprint() const
Read the footprint polygon for the Cube.
Cube()
Constructs a Cube object.
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude, double &maxLongitude)
Returns the latitude and longitude range for the Cube.
void deleteGroup(const QString &group)
Deletes a group from the cube labels.
void reformatOldIsisLabel(const QString &oldCube)
This is a helper, used by open(...), that handles opening Isis 2 cubes as if they were Isis cubes.
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band,...
bool deleteBlob(QString BlobName, QString BlobType)
This method will delete a blob label object from the cube as specified by the Blob type and name.
int m_bands
The band count of the open cube or the cube that will be created.
void initialize()
This sets Cube to its default state: Native byte order Format = Tile PixelType = Real (4 bytes per pi...
PixelType m_pixelType
This is the pixel type on disk.
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
void construct()
Initialize members from their initial undefined states.
int m_labelBytes
The maximum allowed size of the label; the allocated space.
virtual Histogram * histogram(const int &band=1, QString msg="Gathering histogram")
This method returns a pointer to a Histogram object which allows the program to obtain and use variou...
void initLabelFromFile(FileName labelFileName, bool readWrite)
This function initializes the Cube label from a file passed as a parameter.
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
CubeIoHandler * m_ioHandler
This does the heavy lifting for cube DN IO and is always allocated when isOpen() is true.
FileName realDataFileName() const
This gets the file name of the file which actually contains the DN data.
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files.
CubeStretch readCubeStretch(QString name="CubeStretch", const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
Read a Stretch from a cube.
Statistics * statistics(const int &band=1, QString msg="Gathering statistics")
This method returns a pointer to a Statistics object which allows the program to obtain and use vario...
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Camera * camera()
Return a camera associated with the cube.
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
double m_base
The base of the open cube or the cube that will be created; does not apply if m_pixelType is Real.
bool m_attached
True if labels are attached.
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
bool m_storesDnData
True (most common case) when the cube DN data is inside the file we're writing to.
bool isOpen() const
Test if a cube file has been opened/created.
void setBaseMultiplier(double base, double mult)
Used prior to the Create method, this will specify the base and multiplier for converting 8-bit/16-bi...
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true.
int m_lines
The line count of the open cube or the cube that will be created.
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access)
Initialize Cube data from a PVL label and JSON ISD.
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
QFile * dataFile() const
This returns the QFile with cube DN data in it.
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
void create(const QString &cfile)
This method will create an isis cube for writing.
FileName * m_tempCube
If open was called with an Isis 2 cube, then this will be the name of the imported ISIS cube.
bool hasBlob(const QString &name, const QString &type)
Check to see if the cube contains a BLOB.
void cleanUp(bool remove)
This clears all of the allocated memory associated with an open cube.
ByteOrder byteOrder() const
Returns the byte order/endian-ness of the cube file.
ByteOrder m_byteOrder
The byte order of the opened cube; if there is no open cube then this is the byte order that will be ...
QFile * m_labelFile
This is the file that contains the labels always; if labels are attached then this contains the file ...
bool labelsAttached() const
Test if labels are attached.
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
PixelType pixelType() const
bool storesDnData() const
This method returns a boolean value.
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
FileName * m_formatTemplateFile
Label pvl format template file (describes how to format labels)
Pvl * m_label
The label if IsOpen(), otherwise NULL.
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
bool isProjected() const
Returns true if the labels of the cube appear to have a valid mapping group.
OriginalLabel readOriginalLabel(const QString &name="IsisCube") const
Read the original PDS3 label from a cube.
Format
These are the possible storage formats of ISIS cubes.
@ Tile
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
@ Bsq
Cubes are stored in band-sequential format, that is the order of the pixels in the file (on disk) is:
virtual int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Table readTable(const QString &name)
Read a Table from the cube.
Camera * m_camera
Camera allocated from the camera() method.
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
OriginalXmlLabel readOriginalXmlLabel() const
Read the original PDS4 label from a cube.
virtual QString fileName() const
Returns the opened cube's filename.
void fromLabel(const FileName &fileName, Pvl &label, QString access)
Initialize Cube data from a PVL label.
virtual ~Cube()
Destroys the Cube object.
QList< int > * m_virtualBandList
If allocated, converts from physical on-disk band # to virtual band #.
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
FileName * m_labelFileName
The full filename of the label file (.lbl or .cub)
void setExternalDnData(FileName cubeFileWithDnData)
Used to set external dn data to cube.
void close(bool remove=false)
Closes the cube and updates the labels.
History readHistory(const QString &name="IsisCube") const
Read the History from the Cube.
void writeLabels()
Write the Pvl labels to the cube's label file.
QMutex * m_mutex
Basic thread-safety mutex; this class is not optimized for threads.
void initCoreFromLabel(const Pvl &label)
This function initializes the Cube core from a Pvl Label passed as a parameter.
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
int m_samples
The sample count of the open cube or the cube that will be created.
void openCheck()
Throw an exception if the cube is not open.
Projection * projection()
double m_multiplier
The multiplier of the open cube or the cube that will be created; does not apply if m_pixelType is Re...
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
Projection * m_projection
Projection allocated from the projection() method.
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
FileName * m_dataFileName
The full filename of the data file (.cub)
void applyVirtualBandsToLabel()
Applies virtual bands to label.
Format m_format
If isOpen() then this is the IO format that the cube uses.
Handles converting buffers to and from disk.
Stores stretch information for a cube.
File name manipulation and expansion.
Container of a cube histogram.
Create cube polygons, read/write polygons to blobs.
Read and store original labels.
Read and store original Xml labels.
Base class for Map Projections.
Contains multiple PvlContainers.
Container for cube-like labels.
This class is used to accumulate statistics on double arrays.
Class for storing Table blobs information.
ByteOrder
Tests the current architecture for byte order.
This is free and unencumbered software released into the public domain.
PixelType
Enumerations for Isis Pixel Types.