Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis Developer Reference
Cube.h
Go to the documentation of this file.
1#ifndef Cube_h
2#define Cube_h
7
8/* SPDX-License-Identifier: CC0-1.0 */
9
10#include <vector>
11
12// This is needed for the QVariant macro
13#include <QMetaType>
14#include <QList>
15#include <QMap>
16
17#include <nlohmann/json.hpp>
18
19#include "Blob.h"
20#include "IEndian.h"
21#include "PixelType.h"
22#include "PvlKeyword.h"
23
24class QFile;
25class QMutex;
26class QString;
27
28namespace Isis {
29 class Buffer;
30 class Camera;
33 class CubeStretch;
34 class FileName;
35 class ImageIoHandler;
36 class Projection;
37 class Pvl;
38 class PvlGroup;
39 class Statistics;
40 class Table;
41 class Histogram;
42 class History;
43 class OriginalLabel;
44 class OriginalXmlLabel;
45 class ImagePolygon;
46
47
168 class Cube {
169 public:
170 Cube();
171 Cube(const FileName &fileName, QString access = "r");
172
173 virtual ~Cube();
174
236
257
258 void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access);
259 void fromIsd(const FileName &fileName, FileName &labelFile, FileName &isdFile, QString access);
260
261 void fromLabel(const FileName &fileName, Pvl &label, QString access);
262
263 bool isOpen() const;
264 bool isProjected() const;
265 bool isReadOnly() const;
266 bool isReadWrite() const;
267 LabelAttachment labelsAttached() const;
268
269 void attachSpiceFromIsd(nlohmann::json Isd);
270 void attachLineScanTableFromIsd(nlohmann::json isd);
271
272 void close(bool remove = false);
273 Cube *copy(FileName newFile, const CubeAttributeOutput &newFileAttributes);
274 void create(const QString &cfile);
275 void create(const QString &cfile, const CubeAttributeOutput &att);
276 void createGdal(QString &dataFileName, QString &, char **papszOptions);
277 void checkAccess(QString access);
278 void open(const QString &cfile, QString access = "r");
279 void openCube(const QString &cubeFileName, QString access);
280 void openGdal(const QString &cubeFileName, QString access);
281 void reopen(QString access = "r");
282
283 void read(Blob &blob,
284 const std::vector<PvlKeyword> keywords = std::vector<PvlKeyword>()) const;
285 void read(Buffer &rbuf) const;
286 OriginalLabel readOriginalLabel(const QString &name="IsisCube") const;
287 CubeStretch readCubeStretch(QString name="CubeStretch",
288 const std::vector<PvlKeyword> keywords = std::vector<PvlKeyword>()) const;
290 History readHistory(const QString &name = "IsisCube") const;
292 Table readTable(const QString &name);
293 void write(Blob &blob, bool overwrite=true);
294 void write(const Table &table);
295 void write(const CubeStretch &cubeStretch);
296 void write(OriginalLabel &lab);
297 void write(const OriginalXmlLabel &lab);
298 void write(History &history, const QString &name = "IsisCube");
299 void write(const ImagePolygon &polygon);
300 void write(Buffer &wbuf);
301
302 void setBaseMultiplier(double base, double mult);
303 void setMinMax(double min, double max);
304 void setByteOrder(ByteOrder byteOrder);
305 void setDimensions(int ns, int nl, int nb);
306 void setExternalDnData(FileName cubeFileWithDnData);
307 void setFormat(Format format);
308 void setLabelsAttached(LabelAttachment attached);
309 // void setLabelsExternal(bool external);
310 void setLabelSize(int labelBytes);
311 void setPixelType(PixelType pixelType);
312 void setVirtualBands(const QList<QString> &vbands);
313 void setVirtualBands(const std::vector<QString> &vbands);
314
315 void relocateDnData(FileName dnDataFile);
316// static void relocateDnData(FileName externalLabelFile, FileName dnDataFile);
317
318 virtual int bandCount() const;
319 double base() const;
320 ByteOrder byteOrder() const;
321 Camera *camera();
322 void setCamera(Camera *camera);
323 FileName externalCubeFileName() const;
324 virtual QString fileName() const;
325 Format format() const;
326 virtual Histogram *histogram(const int &band = 1,
327 QString msg = "Gathering histogram");
328 virtual Histogram *histogram(const int &band, const double &validMin,
329 const double &validMax,
330 QString msg = "Gathering histogram");
331 Pvl *label() const;
332 int labelSize(bool actual = false) const;
333 int lineCount() const;
334 double multiplier() const;
335 PixelType pixelType() const;
336 virtual int physicalBand(const int &virtualBand) const;
338 int sampleCount() const;
339 Statistics *statistics(const int &band = 1,
340 QString msg = "Gathering statistics");
341 Statistics *statistics(const int &band, const double &validMin,
342 const double &validMax,
343 QString msg = "Gathering statistics");
344
346 void clearIoCache();
347 bool deleteBlob(QString BlobName, QString BlobType);
348 void deleteGroup(const QString &group);
349 PvlGroup &group(const QString &group) const;
350 bool hasGroup(const QString &group) const;
351 bool hasTable(const QString &name);
352 bool hasBlob(const QString &name, const QString &type);
353 void putGroup(const PvlGroup &group);
354 void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude,
355 double &maxLongitude);
356 FileName realDataFileName() const;
357
358 private:
359 void applyVirtualBandsToLabel();
360 void cleanUp(bool remove);
361
362 void construct();
363 QFile *dataFile() const;
364 GDALDataset *gdalDataset() const;
365
366 void initialize();
367 void initCoreFromLabel(const Pvl &label);
368 void initCoreFromGdal(const QString &labelFile);
369 void initLabelState(const Pvl &label);
370 void initLabelFromFile(FileName labelFileName, bool readWrite);
371 void openCheck();
372 Pvl realDataFileLabel() const;
373 void reformatOldIsisLabel(const QString &oldCube);
374 void writeLabels();
375
376 private:
385 QFile *m_labelFile;
386
392 QFile *m_dataFile;
393
397 GDALDataset *m_geodataSet = nullptr;
398
403 ImageIoHandler *m_ioHandler;
404
410 ByteOrder m_byteOrder;
411
417 Format m_format;
418
424 PixelType m_pixelType;
425
427 QMutex *m_mutex;
428
430 Camera *m_camera;
431
433 Projection *m_projection;
434
436 FileName *m_labelFileName;
437
439 FileName *m_dataFileName;
440
446 FileName *m_tempCube;
447
449 FileName *m_formatTemplateFile;
450
452 LabelAttachment m_attached;
453
455 Pvl *m_label;
456
458 QMap<QString, Blob> m_blobMap;
459 QList<QString> m_blobQueue;
460
462 int m_labelBytes;
463
465 int m_samples;
466
468 int m_lines;
469
471 int m_bands;
472
477 double m_base;
478
483 double m_multiplier;
484
486 QList<int> *m_virtualBandList;
487 };
488}
489
492
493#endif
Q_DECLARE_METATYPE(Isis::Cube *)
This allows Cube *'s to be stored in a QVariant.
Buffer for reading and writing cube data.
Definition Buffer.h:53
Definition Camera.h:236
Manipulate and parse attributes of output cube filenames.
Definition CubeAttribute.h:452
This is the parent of the caching algorithms.
Definition CubeCachingAlgorithm.h:31
IO Handler for Isis Cubes.
Definition Cube.h:168
void checkAccess(QString access)
Definition Cube.cpp:772
void addCachingAlgorithm(CubeCachingAlgorithm *)
This will add the given caching algorithm to the list of attempted caching algorithms.
Definition Cube.cpp:2198
void clearIoCache()
This will clear excess RAM used for quicker IO in the cube.
Definition Cube.cpp:2214
bool hasTable(const QString &name)
Check to see if the cube contains a pvl table by the provided name.
Definition Cube.cpp:2343
ImagePolygon readFootprint() const
Read the footprint polygon for the Cube.
Definition Cube.cpp:1114
Cube()
Constructs a Cube object.
Definition Cube.cpp:50
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
Definition Cube.cpp:1540
void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude, double &maxLongitude)
Returns the latitude and longitude range for the Cube.
Definition Cube.cpp:2855
void deleteGroup(const QString &group)
Deletes a group from the cube labels.
Definition Cube.cpp:2275
void attachLineScanTableFromIsd(nlohmann::json isd)
Definition Cube.cpp:1795
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band,...
Definition Cube.cpp:1502
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.
Definition Cube.cpp:2231
Format format() const
Definition Cube.cpp:1861
void relocateDnData(FileName dnDataFile)
Relocates the DN data for a cube to an external cube label file.
Definition Cube.cpp:1602
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...
Definition Cube.cpp:1885
int lineCount() const
Definition Cube.cpp:2020
double multiplier() const
Returns the multiplier value for converting 8-bit/16-bit pixels to 32-bit.
Definition Cube.cpp:2034
FileName realDataFileName() const
This gets the file name of the file which actually contains the DN data.
Definition Cube.cpp:2509
CubeStretch readCubeStretch(QString name="CubeStretch", const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
Read a Stretch from a cube.
Definition Cube.cpp:1160
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...
Definition Cube.cpp:2116
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
Definition Cube.cpp:1450
Camera * camera()
Return a camera associated with the cube.
Definition Cube.cpp:1687
FileName externalCubeFileName() const
If this is an external cube label file, this will give you the cube dn file that this label reference...
Definition Cube.cpp:1822
LabelAttachment
Input cube label type tracker.
Definition Cube.h:245
@ ExternalLabel
The label is pointing to an external DN file - the label is also external to the data.
Definition Cube.h:254
@ GdalLabel
Definition Cube.h:255
@ AttachedLabel
The input label is embedded in the image file.
Definition Cube.h:246
@ DetachedLabel
The input label is in a separate data file from the image.
Definition Cube.h:247
PvlGroup & group(const QString &group) const
Read a group from the cube into a Label.
Definition Cube.cpp:2289
int sampleCount() const
Definition Cube.cpp:2093
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
Definition Cube.cpp:2356
bool isOpen() const
Test if a cube file has been opened/created.
Definition Cube.cpp:189
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...
Definition Cube.cpp:1384
bool isReadOnly() const
Test if the opened cube is read-only, that is write operations will fail if this is true.
Definition Cube.cpp:215
double base() const
Returns the base value for converting 8-bit/16-bit pixels to 32-bit.
Definition Cube.cpp:1663
void fromIsd(const FileName &fileName, Pvl &label, nlohmann::json &isd, QString access)
Initialize Cube data from a PVL label and JSON ISD.
Definition Cube.cpp:99
void openGdal(const QString &cubeFileName, QString access)
This method will open an existing geotiff for reading or reading/writing.
Definition Cube.cpp:974
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
Definition Cube.cpp:1401
void attachSpiceFromIsd(nlohmann::json Isd)
Definition Cube.cpp:1707
Cube * copy(FileName newFile, const CubeAttributeOutput &newFileAttributes)
Copies the cube to the new fileName.
Definition Cube.cpp:288
void create(const QString &cfile)
This method will create an isis cube for writing.
Definition Cube.cpp:426
bool hasBlob(const QString &name, const QString &type)
Check to see if the cube contains a BLOB.
Definition Cube.cpp:2317
void openCube(const QString &cubeFileName, QString access)
This method will open an existing isis cube for reading or reading/writing.
Definition Cube.cpp:850
ByteOrder byteOrder() const
Returns the byte order/endian-ness of the cube file.
Definition Cube.cpp:1675
void open(const QString &cfile, QString access="r")
This method will try to open a file as either a cube or geotiff in either read or read/write.
Definition Cube.cpp:792
PixelType pixelType() const
Definition Cube.cpp:2044
void setCamera(Camera *camera)
Set the camera for this cube.
Definition Cube.cpp:1701
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
Definition Cube.cpp:1557
LabelAttachment labelsAttached() const
Test if labels are attached.
Definition Cube.cpp:260
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
Definition Cube.cpp:1043
bool isProjected() const
Returns true if the labels of the cube appear to have a valid mapping group.
Definition Cube.cpp:204
OriginalLabel readOriginalLabel(const QString &name="IsisCube") const
Read the original PDS3 label from a cube.
Definition Cube.cpp:1137
Format
These are the possible storage formats of ISIS cubes.
Definition Cube.h:179
@ GTiff
Definition Cube.h:234
@ Tile
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
Definition Cube.h:233
@ Bsq
Cubes are stored in band-sequential format, that is the order of the pixels in the file (on disk) is:
Definition Cube.h:200
virtual int physicalBand(const int &virtualBand) const
This method will return the physical band number given a virtual band number.
Definition Cube.cpp:2059
Table readTable(const QString &name)
Read a Table from the cube.
Definition Cube.cpp:1200
bool hasGroup(const QString &group) const
Return if the cube has a specified group in the labels.
Definition Cube.cpp:2302
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
Definition Cube.cpp:1527
OriginalXmlLabel readOriginalXmlLabel() const
Read the original PDS4 label from a cube.
Definition Cube.cpp:1179
virtual QString fileName() const
Returns the opened cube's filename.
Definition Cube.cpp:1849
void fromLabel(const FileName &fileName, Pvl &label, QString access)
Initialize Cube data from a PVL label.
Definition Cube.cpp:76
virtual ~Cube()
Destroys the Cube object.
Definition Cube.cpp:166
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
Definition Cube.cpp:1219
bool isReadWrite() const
Test if the opened cube is read-write, that is read and write operations should succeed if this is tr...
Definition Cube.cpp:247
void setExternalDnData(FileName cubeFileWithDnData)
Used to set external dn data to cube.
Definition Cube.cpp:1467
void close(bool remove=false)
Closes the cube and updates the labels.
Definition Cube.cpp:272
History readHistory(const QString &name="IsisCube") const
Read the History from the Cube.
Definition Cube.cpp:1095
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
Definition Cube.cpp:1999
Projection * projection()
Definition Cube.cpp:2080
void setLabelsAttached(LabelAttachment attached)
Use prior to calling create, this sets whether or not to use separate label and data files.
Definition Cube.cpp:1514
virtual int bandCount() const
Returns the number of virtual bands for the cube.
Definition Cube.cpp:1646
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1987
void reopen(QString access="r")
This method will reopen an isis sube for reading or reading/writing.
Definition Cube.cpp:1010
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
Definition Cube.cpp:1435
void createGdal(QString &dataFileName, QString &, char **papszOptions)
Definition Cube.cpp:682
Stores stretch information for a cube.
Definition CubeStretch.h:27
Container of a cube histogram.
Definition Histogram.h:74
Definition History.h:38
Handles converting buffers to and from disk.
Definition ImageIoHandler.h:99
Create cube polygons, read/write polygons to blobs.
Definition ImagePolygon.h:153
Read and store original labels.
Definition OriginalLabel.h:35
Read and store original Xml labels.
Definition OriginalXmlLabel.h:32
Base class for Map Projections.
Definition Projection.h:154
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:93
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
This is free and unencumbered software released into the public domain.
Definition CubeIoHandler.h:23
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16