18#include "Application.h"
21#include "CameraFactory.h"
22#include "CubeAttribute.h"
23#include "CubeBsqHandler.h"
24#include "CubeTileHandler.h"
25#include "CubeStretch.h"
28#include "GdalIoHandler.h"
30#include "ImageHistogram.h"
31#include "ImagePolygon.h"
32#include "IException.h"
33#include "LineManager.h"
35#include "OriginalLabel.h"
36#include "OriginalXmlLabel.h"
37#include "Preference.h"
38#include "ProgramLauncher.h"
39#include "Projection.h"
40#include "SpecialPixel.h"
41#include "Statistics.h"
43#include "TProjection.h"
80 PvlObject cubeLabel =
label.findObject(
"IsisCube");
81 for (
auto grpIt = cubeLabel.beginGroup(); grpIt!= cubeLabel.endGroup(); grpIt++) {
102 PvlGroup &instGrp =
label.findGroup(
"Instrument", Pvl::Traverse);
103 if (isd.contains(
"line_scan_rate") && (QString)instGrp[
"InstrumentId"] ==
"HRSC") {
104 attachLineScanTableFromIsd(isd);
107 attachSpiceFromIsd(isd);
124 std::ifstream isdStream(isdFile.expanded().toStdString());
125 std::ifstream labelStream(labelFile.expanded().toStdString());
127 if (isdStream.fail()) {
128 QString msg = QString(
"failed to open isd stream: %1").arg(isdFile.expanded());
129 throw IException(IException::Io, msg,
130 isdFile.baseName().toStdString().c_str(), 153);
133 if (labelStream.fail()) {
134 QString msg =
"failed to open file stream";
135 throw IException(IException::Io, msg,
136 fileName.baseName().toStdString().c_str(), 153);
143 labelStream >>
label;
145 catch (std::exception &ex) {
146 QString msg = QString(
"Failed to open label file, %1, %2").arg(labelFile.expanded()).arg(ex.what());
147 throw IException(IException::Io, msg,
148 fileName.baseName().toStdString().c_str(), 153);
155 catch (std::exception &ex) {
156 QString msg = QString(
"Failed to open ISD file, %1, %2").arg(isdFile.expanded()).arg(ex.what());
157 throw IException(IException::Io, msg,
158 fileName.baseName().toStdString().c_str(), 145);
205 return label()->findObject(
"IsisCube").hasGroup(
"Mapping");
216 bool readOnly =
false;
219 QString msg =
"No cube opened";
220 throw IException(IException::Programmer, msg, _FILEINFO_);
224 if ((
m_labelFile->openMode() & QIODevice::ReadWrite) != QIODevice::ReadWrite)
232 QString msg =
"No source files open";
233 throw IException(IException::Programmer, msg, _FILEINFO_);
290 throw IException(IException::Unknown,
291 QObject::tr(
"Cube::copy requires the originating cube to be open"),
323 QObject::tr(
"Cannot reduce the output PixelType for [%1] from [%2] without output "
324 "pixel range").arg(newFile.original()).arg(
fileName());
325 throw IException(IException::User, msg, _FILEINFO_);
345 result->
create(newFile.expanded());
347 PvlObject &isisCube =
label()->findObject(
"IsisCube");
348 PvlObject &outIsisCube = result->
label()->findObject(
"IsisCube");
349 for(
int i = 0; i < isisCube.groups(); i++) {
350 outIsisCube.addGroup(isisCube.group(i));
353 if (
label()->hasObject(
"NaifKeywords")) {
354 result->
label()->addObject(
355 label()->findObject(
"NaifKeywords"));
358 for (
int i = 0; i <
m_label->objects(); i++) {
359 PvlObject &obj =
m_label->object(i);
360 if (obj.isNamed(
"Table") || obj.isNamed(
"Polygon") || obj.isNamed(
"OriginalLabel") ||
361 obj.isNamed(
"History")) {
362 Isis::Blob t((QString)obj[
"Name"], obj.name());
379 while (!input.
end()) {
381 output.
Copy(input,
false);
383 result->
write(output);
429 string msg =
"You already have a cube opened";
430 throw IException(IException::Programmer, msg, _FILEINFO_);
436 "] cannot be less than 1";
437 throw IException(IException::Programmer, msg, _FILEINFO_);
441 throw IException(IException::Unknown,
442 QString(
"Cannot create the cube [%1] with a pixel type set to None")
456 int maxSizePreference = 0;
459 Preference::Preferences().findGroup(
"CubeCustomization")[
"MaximumSize"];
461 if (size > maxSizePreference) {
463 msg +=
"The cube you are attempting to create [" + imageFileName +
"] is ["
464 +
toString(size) +
"GB]. This is larger than the current allowed "
465 "size of [" +
toString(maxSizePreference) +
"GB]. The cube "
469 "wish to create this cube, the maximum value can be changed in your personal "
470 "preference file located in [~/.Isis/IsisPreferences] within the group "
471 "CubeCustomization, keyword MaximumSize. If you do not have an ISISPreference file, "
472 "please refer to the documentation 'Environment and Preference Setup'. Error ";
473 throw IException(IException::User, msg, _FILEINFO_);
478 FileName imageFile(imageFileName);
479 PvlObject isiscube(
"IsisCube");
480 PvlObject core(
"Core");
483 PvlGroup dims(
"Dimensions");
489 PvlGroup ptype(
"Pixels");
490 ptype += PvlKeyword(
"Type", PixelTypeName(
m_pixelType));
493 ptype += PvlKeyword(
"ByteOrder", ByteOrderName(
m_byteOrder));
498 if (
format() != Format::GTiff) {
499 imageFile = imageFile.addExtension(
"cub");
501 else if (
format() == Format::GTiff) {
502 if (imageFile.extension() !=
"tif" &&
503 imageFile.extension() !=
"tiff") {
504 imageFile = imageFile.addExtension(
"tif");
509 throw IException(IException::Programmer, msg, _FILEINFO_);
522 core += PvlKeyword(
"StartByte",
toString(1));
523 core += PvlKeyword(
"^Core", imageFile.name());
526 FileName labelFileName(imageFile);
527 labelFileName = labelFileName.setExtension(
"lbl");
533 throw IException(IException::Programmer, msg, _FILEINFO_);
536 core.addGroup(ptype);
539 imageFile = imageFile.addExtension(
"ecub");
542 imageFile = imageFile.setExtension(
"cub");
545 PvlObject isiscube(
"IsisCube");
546 PvlObject dnCore(core);
547 PvlKeyword fileFormat(
"Format", CubeAttributeOutput::toString(
format()));
549 dnCore.addKeyword(fileFormat);
550 dnCore.addGroup(dims);
551 dnCore.addGroup(ptype);
553 isiscube.addObject(dnCore);
554 dnLabel.addObject(isiscube);
557 dnCube.
fromLabel(imageFile, dnLabel,
"rw");
560 else if (
format() == Format::GTiff) {
561 imageFile = imageFile.setExtension(
"tif");
565 imageFile = imageFile.setExtension(
"ecub");
566 FileName labelFileName(imageFile);
579 throw IException(IException::Programmer, msg, _FILEINFO_);
582 isiscube.addObject(core);
588 PvlObject lbl(
"Label");
592 const PvlGroup &pref =
593 Preference::Preferences().findGroup(
"CubeCustomization");
594 bool overwrite = pref[
"Overwrite"][0].toUpper() ==
"ALLOW";
596 QString msg =
"Cube file [" +
m_labelFileName->original() +
"] exists, " +
597 "user preference does not allow overwrite";
598 throw IException(IException::User, msg, _FILEINFO_);
601 if (!
m_labelFile->open(QIODevice::Truncate | QIODevice::ReadWrite)) {
602 QString msg =
"Failed to create [" +
m_labelFile->fileName() +
"]. ";
603 msg +=
"Verify the output path exists and you have permission to write to the path.";
605 throw IException(IException::Io, msg, _FILEINFO_);
610 QString msg =
"Failed to create [" +
m_dataFile->fileName() +
"]. ";
611 msg +=
"Verify the output path exists and you have permission to write to the path.";
613 throw IException(IException::Io, msg, _FILEINFO_);
616 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] for reading. ";
617 msg +=
"Verify the output path exists and you have permission to read from the path.";
619 throw IException(IException::Io, msg, _FILEINFO_);
635 if (!dataAlreadyOnDisk) {
639 else if(
format() == Format::GTiff) {
640 char **papszOptions = NULL;
649 papszOptions = CSLSetNameValue(papszOptions,
"PREDICTOR",
"2");
650 papszOptions = CSLSetNameValue(papszOptions,
"NUM_THREADS",
"4");
652 papszOptions = CSLSetNameValue(papszOptions,
"COMPRESS",
"DEFLATE");
655 papszOptions = CSLSetNameValue(papszOptions,
"COMPRESS",
"LZW");
656 papszOptions = CSLSetNameValue(papszOptions,
"BIGTIFF",
"YES");
661 createGdal(datafile,
format, papszOptions);
663 m_geodataSet = GDALDataset::FromHandle(GDALOpen(datafile.toStdString().c_str(), GA_Update));
665 QString msg =
"Failed opening GDALDataset from [" +
m_dataFileName->name() +
"]";
667 throw IException(IException::Programmer, msg, _FILEINFO_);
674 QString msg =
"Format [" +
toString(
format()) +
"] not supported";
675 throw IException(IException::Programmer, msg, _FILEINFO_);
682 void Cube::createGdal(QString &dataFileName, QString &driverName,
char **papszOptions) {
683 GDALDriver* driver = GetGDALDriverManager()->GetDriverByName(driverName.toStdString().c_str());
688 noDataValue = (double) NULL1;
691 noDataValue = (double) NULLS1;
694 noDataValue = (double) NULLU2;
697 noDataValue = (double) NULL2;
699 case UnsignedInteger:
700 noDataValue = (double) NULLUI4;
703 noDataValue = (double) NULLI4;
706 noDataValue = (double) NULL4;
715 QString msg =
"Could not create file [" + dataFileName +
"] from [" + driverName +
"] Driver.";
716 throw IException(IException::Io, msg, _FILEINFO_);
719 GDALRasterBand *band = dataset->GetRasterBand(i);
721 band->SetOffset(
base());
722 band->SetNoDataValue(noDataValue);
723 band->Fill(noDataValue);
724 band->CreateMaskBand(GMF_ALPHA);
725 band->GetMaskBand()->Fill(255);
728 CSLDestroy( papszOptions );
731 QString msg =
"No Driver found for name [" + driverName +
"]";
732 throw IException(IException::Io, msg, _FILEINFO_);
772 void Cube::checkAccess(QString access) {
773 if (!(access ==
"r" || access ==
"rw")) {
774 QString msg =
"Unknown value for access [" + access +
"]. Expected 'r' "
777 throw IException(IException::Programmer, msg, _FILEINFO_);
792 void Cube::open(
const QString &cubeFileName, QString access) {
796 string msg =
"You already have a cube opened";
797 throw IException(IException::Programmer, msg, _FILEINFO_);
804 if(att.
bands().size() != 0) {
805 vector<QString> bands = att.
bands();
808 }
catch(IException& e) {
813 QString msg =
"Failed to open [" + cubeFileName +
"]";
814 IException exceptions(IException::Io, msg, _FILEINFO_);
816 GDALDriverH hDriver = GDALIdentifyDriver(FileName(cubeFileName).expanded().toStdString().c_str(),
nullptr);
817 bool openWithGdal =
false;
818 if (hDriver !=
nullptr) {
819 GDALDriver* poDriver = (GDALDriver*)hDriver;
820 QString driverDescription = poDriver->GetDescription();
821 openWithGdal = (!driverDescription.contains(
"ISIS"));
832 catch(IException &e) {
834 exceptions.append(e);
857 PvlObject &core =
m_label->findObject(
"IsisCube").findObject(
"Core");
859 if (core.hasKeyword(
"^Core")) {
860 FileName temp(core[
"^Core"][0]);
862 if (!temp.originalPath().startsWith(
"/")) {
877 else if (core.hasKeyword(
"^DnFile")) {
878 FileName dataFileName(core[
"^DnFile"][0]);
880 if (dataFileName.originalPath() ==
".") {
900 catch (IException &e) {
905 QIODevice::OpenModeFlag qtAccess = QIODevice::ReadOnly;
906 GDALAccess eAccess = GA_ReadOnly;
907 if (access ==
"rw") {
908 qtAccess = QIODevice::ReadWrite;
913 QString msg =
"Failed to open [" +
m_labelFile->fileName() +
"] with "
914 "access [" + access +
"]";
916 throw IException(IException::Io, msg, _FILEINFO_);
921 QString msg =
"Failed to open [" +
m_dataFile->fileName() +
"] with "
922 "access [" + access +
"]";
924 throw IException(IException::Io, msg, _FILEINFO_);
953 QString msg =
"Opening GDALDataset from [" +
m_dataFileName->name() +
"] failed with access [" + QString::number(eAccess) +
"]";
955 throw IException(IException::Io, msg, _FILEINFO_);
961 throw IException(IException::Programmer, msg, _FILEINFO_);
986 GDALAccess eAccess = GA_ReadOnly;
987 if (access ==
"rw") {
992 QString msg =
"Opening GDALDataset from [" +
m_dataFileName->name() +
"] failed with access [" + QString::number(eAccess) +
"]";
994 throw IException(IException::Io, msg, _FILEINFO_);
1012 QString msg =
"Cube has not been opened yet. The filename to re-open is "
1014 throw IException(IException::Programmer, msg, _FILEINFO_);
1025 open(filename.expanded(), access);
1027 if (virtualBandList.size()) {
1043 void Cube::read(Blob &blob,
const std::vector<PvlKeyword> keywords)
const {
1045 string msg =
"The cube is not opened so you can't read a blob from it";
1046 throw IException(IException::Programmer, msg, _FILEINFO_);
1055 QString blobKey = blob.Key();
1056 if (m_blobMap.contains(blobKey)) {
1057 blob = m_blobMap[blobKey];
1061 blob.ReadGdal(gdalDataset());
1064 QMutexLocker locker2(
m_ioHandler->dataFileMutex());
1065 blob.Read(cubeFile.toString(), *
label(), keywords);
1079 string msg =
"Try opening a file before you read it";
1080 throw IException(IException::Programmer, msg, _FILEINFO_);
1096 Blob historyBlob(name,
"History");
1101 catch (IException &) {
1115 Blob footprintBlob(
"Footprint",
"Polygon");
1118 read(footprintBlob);
1120 catch (IException &e) {
1121 QString msg =
"Footprintinit must be run prior to reading the footprint";
1122 msg +=
" with POLYGON=TRUE for cube [" +
fileName() +
"]";
1123 throw IException(e, IException::User, msg, _FILEINFO_);
1138 Blob origLabelBlob(name,
"OriginalLabel");
1140 read(origLabelBlob);
1142 catch (IException &e){
1143 QString msg =
"Unable to locate OriginalLabel in " +
fileName();
1144 throw IException(e, IException::User, msg, _FILEINFO_);
1161 Blob stretchBlob(name,
"Stretch");
1163 read(stretchBlob, keywords);
1165 catch (IException &e){
1166 QString msg =
"Unable to locate Stretch information in " +
fileName();
1167 throw IException(e, IException::User, msg, _FILEINFO_);
1180 Blob origXmlLabelBlob(
"IsisCube",
"OriginalXmlLabel");
1182 read(origXmlLabelBlob);
1184 catch (IException &e){
1185 QString msg =
"Unable to locate OriginalXmlLabel in " +
fileName();
1186 throw IException(e, IException::User, msg, _FILEINFO_);
1189 return origXmlLabel;
1201 Blob tableBlob(name,
"Table");
1205 catch (IException &e) {
1206 QString msg =
"Failed to read table [" + name +
"] from cube [" +
fileName() +
"].";
1207 throw IException(e, IException::Programmer, msg, _FILEINFO_);
1209 return Table(tableBlob);
1221 string msg =
"The cube is not opened so you can't write a blob to it";
1222 throw IException(IException::Programmer, msg, _FILEINFO_);
1226 string msg =
"The cube must be opened in read/write mode, not readOnly";
1227 throw IException(IException::Programmer, msg, _FILEINFO_);
1232 Pvl &cubeLabel = *
label();
1233 PvlObject &blobLabel = blob.Label();
1235 FileName blobFileName =
fileName();
1236 blobFileName = blobFileName.removeExtension();
1237 blobFileName = blobFileName.addExtension(blob.Type());
1238 blobFileName = blobFileName.addExtension(blob.Name());
1239 blobLabel += PvlKeyword(
"^" + blob.Type(), blobFileName.name());
1245 for (
int i = 0; i < cubeLabel.objects(); i++) {
1246 if (cubeLabel.object(i).name() == blobLabel.name()) {
1247 PvlObject &obj = cubeLabel.object(i);
1248 if ((QString)obj[
"Name"] == (QString)blobLabel[
"Name"]) {
1250 blobLabel[
"StartByte"] = obj[
"StartByte"];
1251 blobLabel[
"Bytes"] = obj[
"Bytes"];
1257 blobLabel[
"StartByte"] =
toString(0);
1258 cubeLabel.addObject(blobLabel);
1260 m_blobMap[blob.Key()] = blob;
1261 m_blobQueue.push_back(blob.Key());
1272 Blob labelBlob = lab.
toBlob();
1284 Blob labelBlob = lab.
toBlob();
1298 Blob tableBlob = table.toBlob();
1312 Blob cubeStretchBlob = cubeStretch.
toBlob();
1313 write(cubeStretchBlob);
1328 Blob histBlob = history.
toBlob(name);
1340 Blob polyBlob = polygon.
toBlob();
1353 string msg =
"Tried to write to a cube before opening/creating it";
1354 throw IException(IException::Programmer, msg, _FILEINFO_);
1358 QString msg =
"Cannot write to the cube [" + (QString)QFileInfo(
fileName()).fileName() +
1359 "] because it is opened read-only";
1360 throw IException(IException::Programmer, msg, _FILEINFO_);
1407 double x1 = 0.0, x2 = 0.0;
1452 if ((ns < 1) || (nl < 1) || (nb < 1)) {
1453 string msg =
"SetDimensions: Invalid number of sample, lines or bands";
1454 throw IException(IException::Programmer, msg, _FILEINFO_);
1475 catch (IException &e) {
1564 if (vbands.size() > 0) {
1565 QListIterator<QString> it(vbands);
1566 while (it.hasNext()) {
1590 for(
unsigned int i = 0; i < vbands.size(); i++)
1591 realVBands << vbands[i];
1604 throw IException(IException::Unknown,
1605 QString(
"Cannot relocate the DN data to [%1] for an external cube label "
1606 "file which is not open.")
1607 .arg(dnDataFile.original()),
1613 throw IException(IException::Unknown,
1614 QString(
"The cube [%1] stores DN data. It cannot be relocated to [%2] - "
1615 "this is only supported for external cube label files.")
1620 m_label->findObject(
"IsisCube").findObject(
"Core").findKeyword(
"^DnFile")[0] =
1621 dnDataFile.original();
1695 void Cube::attachSpiceFromIsd(nlohmann::json isd) {
1696 PvlGroup currentKernels = this->
group(
"Kernels");
1697 PvlKeyword lkKeyword = currentKernels[
"LeapSecond"];
1698 PvlKeyword pckKeyword = currentKernels[
"TargetAttitudeShape"];
1699 PvlKeyword targetSpkKeyword = currentKernels[
"TargetPosition"];
1700 PvlKeyword ckKeyword = currentKernels[
"InstrumentPointing"];
1701 PvlKeyword ikKeyword = currentKernels[
"Instrument"];
1702 PvlKeyword sclkKeyword = currentKernels[
"SpacecraftClock"];
1703 PvlKeyword spkKeyword = currentKernels[
"InstrumentPosition"];
1704 PvlKeyword iakKeyword = currentKernels[
"InstrumentAddendum"];
1705 PvlKeyword demKeyword = currentKernels[
"ShapeModel"];
1708 Table ckTable = spice.instrumentRotation()->Cache(
"InstrumentPointing");
1709 ckTable.Label() += PvlKeyword(
"Kernels");
1711 for (
int i = 0; i < ckKeyword.size(); i++)
1712 ckTable.Label()[
"Kernels"].addValue(ckKeyword[i]);
1714 this->
write(ckTable);
1716 Table spkTable = spice.instrumentPosition()->Cache(
"InstrumentPosition");
1717 spkTable.Label() += PvlKeyword(
"Kernels");
1718 for (
int i = 0; i < spkKeyword.size(); i++)
1719 spkTable.Label()[
"Kernels"].addValue(spkKeyword[i]);
1721 this->
write(spkTable);
1723 Table bodyTable = spice.bodyRotation()->Cache(
"BodyRotation");
1724 bodyTable.Label() += PvlKeyword(
"Kernels");
1725 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1726 bodyTable.Label()[
"Kernels"].addValue(targetSpkKeyword[i]);
1728 for (
int i = 0; i < pckKeyword.size(); i++)
1729 bodyTable.Label()[
"Kernels"].addValue(pckKeyword[i]);
1731 bodyTable.Label() += PvlKeyword(
"SolarLongitude",
1732 toString(spice.solarLongitude().degrees()));
1733 this->
write(bodyTable);
1735 Table sunTable = spice.sunPosition()->Cache(
"SunPosition");
1736 sunTable.Label() += PvlKeyword(
"Kernels");
1737 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1738 sunTable.Label()[
"Kernels"].addValue(targetSpkKeyword[i]);
1740 this->
write(sunTable);
1743 if (ckKeyword[0] !=
"Table") {
1744 currentKernels[
"InstrumentPointing"] =
"Table";
1745 for (
int i = 0; i < ckKeyword.size(); i++)
1746 currentKernels[
"InstrumentPointing"].addValue(ckKeyword[i]);
1749 if (spkKeyword[0] !=
"Table") {
1750 currentKernels[
"InstrumentPosition"] =
"Table";
1751 for (
int i = 0; i < spkKeyword.size(); i++)
1752 currentKernels[
"InstrumentPosition"].addValue(spkKeyword[i]);
1755 if (targetSpkKeyword[0] !=
"Table") {
1756 currentKernels[
"TargetPosition"] =
"Table";
1757 for (
int i = 0; i < targetSpkKeyword.size(); i++)
1758 currentKernels[
"TargetPosition"].addValue(targetSpkKeyword[i]);
1765 while (i < label->objects()) {
1766 PvlObject currObj =
label->object(i);
1767 if (currObj.isNamed(
"NaifKeywords")) {
1768 label->deleteObject(i);
1775 *(this->
label()) += spice.getStoredNaifKeywords();
1783 void Cube::attachLineScanTableFromIsd(nlohmann::json isd) {
1784 TableField ephTimeField(
"EphemerisTime", TableField::Double);
1785 TableField expTimeField(
"ExposureTime", TableField::Double);
1786 TableField lineStartField(
"LineStart", TableField::Integer);
1788 TableRecord timesRecord;
1789 timesRecord += ephTimeField;
1790 timesRecord += expTimeField;
1791 timesRecord += lineStartField;
1793 Table timesTable(
"LineScanTimes", timesRecord);
1794 for (
size_t i = 0; i < isd[
"line_scan_rate"].size(); ++i) {
1795 timesRecord[0] = isd[
"line_scan_rate"][i][1].get<
double>() + isd[
"center_ephemeris_time"].get<double>();
1796 timesRecord[1] = isd[
"line_scan_rate"][i][2].get<
double>();
1797 timesRecord[2] = (int)(isd[
"line_scan_rate"][i][0].get<double>() + 0.5);
1798 timesTable += timesRecord;
1800 this->
write(timesTable);
1812 throw IException(IException::Unknown,
1813 "An external cube label file must be opened in order to use "
1814 "Cube::getExternalCubeFileName",
1819 throw IException(IException::Unknown,
1820 "Cube::getExternalCubeFileName can only be called on an external cube label "
1826 PvlObject &core =
m_label->findObject(
"IsisCube").findObject(
"Core");
1827 return core[
"^DnFile"][0];
1874 return histogram(band, ValidMinimum, ValidMaximum, msg);
1904 const double &validMax, QString msg) {
1907 QString msg =
"Cannot create histogram object for an unopened cube";
1908 throw IException(IException::Programmer, msg, _FILEINFO_);
1912 if ((band < 0) || (band >
bandCount())) {
1913 QString msg =
"Invalid band in [CubeInfo::Histogram]";
1914 throw IException(IException::Programmer, msg, _FILEINFO_);
1917 int bandStart = band;
1918 int bandStop = band;
1935 double binMin = validMin;
1936 double binMax = validMax;
1937 if (binMin == ValidMinimum) {
1938 binMin = hist->BinRangeStart();
1941 if (binMax == ValidMaximum) {
1942 binMax = hist->BinRangeEnd();
1953 for(
int useBand = bandStart ; useBand <= bandStop ; useBand++) {
2051 if ((virtualBand < 1) ||
2053 QString msg =
"Out of array bounds [" +
toString(virtualBand) +
"]";
2054 throw IException(IException::Programmer, msg, _FILEINFO_);
2105 return statistics(band, ValidMinimum, ValidMaximum, msg);
2126 const double &validMax, QString msg) {
2129 QString msg =
"Cannot create statistics object for an unopened cube";
2130 throw IException(IException::Programmer, msg, _FILEINFO_);
2134 if ((band < 0) || (band >
bandCount())) {
2135 string msg =
"Invalid band in [CubeInfo::Statistics]";
2136 throw IException(IException::Programmer, msg, _FILEINFO_);
2143 stats->SetValidRange(validMin, validMax);
2145 int bandStart = band;
2146 int bandStop = band;
2160 for(
int useBand = bandStart ; useBand <= bandStop ; useBand++) {
2192 QString msg =
"Cannot add a caching algorithm until the cube is open";
2193 throw IException(IException::Programmer, msg, _FILEINFO_);
2220 for(
int i = 0; i <
m_label->objects(); i++) {
2221 PvlObject obj =
m_label->object(i);
2222 if (obj.name().compare(BlobType) == 0) {
2223 if (obj.findKeyword(
"Name")[0] == BlobName) {
2225 QString key = BlobType +
"_" + BlobName;
2227 if (gdalDataset()) {
2228 CPLStringList metadata = CPLStringList(gdalDataset()->GetMetadata(
"json:ISIS3"),
false);
2229 const char *metadataJsonString = metadata[0];
2230 nlohmann::ordered_json jsonblob = nlohmann::ordered_json::parse(metadataJsonString);
2232 bool keyErased = jsonblob.erase(key.toStdString());
2233 string jsonblobstr = jsonblob.dump();
2235 char **outputMetadata =
new char*[1];
2236 outputMetadata[0] = jsonblobstr.data();
2237 gdalDataset()->SetMetadata(outputMetadata,
"json:ISIS3");
2238 delete []outputMetadata;
2243 if (m_blobMap.contains(key)) {
2244 m_blobMap.remove(key);
2245 m_blobQueue.removeOne(key);
2264 PvlObject &isiscube =
label()->findObject(
"IsisCube");
2265 if (!isiscube.hasGroup(
group))
return;
2266 isiscube.deleteGroup(
group);
2278 PvlObject &isiscube =
label()->findObject(
"IsisCube");
2279 return isiscube.findGroup(
group);
2291 const PvlObject &isiscube =
label()->findObject(
"IsisCube");
2292 if (isiscube.hasGroup(
group))
return true;
2308 for(
int o = 0; o <
label()->objects(); o++) {
2309 PvlObject &obj =
label()->object(o);
2310 if (obj.isNamed(type)) {
2311 if (obj.hasKeyword(
"Name")) {
2312 QString temp = (QString) obj[
"Name"];
2313 temp = temp.toUpper();
2314 QString temp2 = name;
2315 temp2 = temp2.toUpper();
2316 if (temp == temp2)
return true;
2332 return hasBlob(name,
"Table");
2346 QString msg =
"Cannot add a group to the label of cube [" + (QString)QFileInfo(
fileName()).fileName() +
2347 "] because it is opened read-only";
2348 throw IException(IException::Programmer, msg, _FILEINFO_);
2352 PvlObject &isiscube =
label()->findObject(
"IsisCube");
2353 if (isiscube.hasGroup(
group.name())) {
2357 isiscube.addGroup(
group);
2367 PvlObject &core =
m_label->findObject(
"IsisCube").findObject(
"Core");
2370 if (
m_label->findObject(
"IsisCube").hasGroup(
"BandBin")) {
2371 PvlGroup &bandBin =
m_label->findObject(
"IsisCube").findGroup(
"BandBin");
2372 for (
int k = 0;k < bandBin.keywords();k++) {
2374 PvlKeyword temp = bandBin[k];
2466 new FileName(
"$ISISROOT/appdata/templates/labels/CubeFormatTemplate.pft");
2486 GDALDataset *Cube::gdalDataset()
const {
2511 QDir dir(guess.toString());
2518 dir2.cd(guess.path());
2519 guess = dir2.absolutePath() +
"/" + guess.name();
2522 Cube dataCube(guess.expanded());
2523 Pvl guessLabel = *(dataCube.
label());
2525 if (guessLabel.hasObject(
"IsisCube")) {
2526 PvlObject &core = guessLabel.findObject(
"IsisCube").findObject(
"Core");
2528 if (core.hasKeyword(
"^DnFile")) {
2529 FileName currentGuess = guess;
2530 guess = core[
"^DnFile"][0];
2532 if (!guess.path().startsWith(
"/")) {
2533 guess = currentGuess.path() +
"/" + guess.original();
2536 else if (core.hasKeyword(
"^Core")) {
2537 result = core[
"^Core"][0];
2547 while (result.name() ==
"");
2591 initLabelState(
label);
2592 const PvlObject &core =
label.findObject(
"IsisCube").findObject(
"Core");
2596 const PvlGroup &dims = core.findGroup(
"Dimensions");
2602 const PvlGroup &pixelsGroup = core.findGroup(
"Pixels");
2603 m_byteOrder = ByteOrderEnumeration(pixelsGroup[
"ByteOrder"]);
2604 m_base = pixelsGroup[
"Base"];
2606 m_pixelType = PixelTypeEnumeration(pixelsGroup[
"Type"]);
2609 if ((QString) core[
"Format"] ==
"BandSequential") {
2612 else if ((QString) core[
"Format"] ==
"Tile") {
2615 else if ((QString) core[
"Format"] ==
"GTiff") {
2619 QString msg =
"Unknown format [" + (QString)core[
"Format"] +
"]";
2620 throw IException(IException::Io, msg, _FILEINFO_);
2624 FileName temp(core[
"^DnFile"][0]);
2625 if (!temp.expanded().startsWith(
"/")) {
2631 catch (IException &e) {
2632 initCoreFromGdal(temp.toString());
2635 initLabelState(
label);
2640 void Cube::initCoreFromGdal(
const QString &labelFile) {
2641 GDALDataset *geodataSet = GDALDataset::FromHandle(GDALOpen(labelFile.toStdString().c_str(), GA_ReadOnly));
2643 QString msg =
"Gdal failed to open [" + labelFile +
"]";
2644 throw IException(IException::Programmer, msg, _FILEINFO_);
2648 setDimensions(geodataSet->GetRasterXSize(), geodataSet->GetRasterYSize(), geodataSet->GetRasterCount());
2650 GDALRasterBand *band = geodataSet->GetRasterBand(1);
2651 setPixelType(GdalPixelToIsis(band->GetRasterDataType()));
2653 GDALClose(geodataSet);
2667 if (labelFileName.fileExists()) {
2668 m_label =
new Pvl(labelFileName.expanded());
2674 catch(IException &) {
2683 FileName tmp(labelFileName);
2684 tmp = tmp.addExtension(
"cub");
2685 if (tmp.fileExists()) {
2686 m_label =
new Pvl(tmp.expanded());
2690 labelFileName = tmp;
2694 catch(IException &e) {
2703 FileName tmp(labelFileName);
2704 tmp = tmp.setExtension(
"lbl");
2705 if (tmp.fileExists()) {
2706 m_label =
new Pvl(tmp.expanded());
2710 labelFileName = tmp;
2714 catch(IException &e) {
2723 FileName tmp(labelFileName);
2724 tmp = tmp.addExtension(
"ecub");
2725 if (tmp.fileExists()) {
2726 m_label =
new Pvl(tmp.expanded());
2730 labelFileName = tmp;
2734 catch(IException &e) {
2742 QString msg = Message::FileOpen(labelFileName.original());
2743 throw IException(IException::Io, msg, _FILEINFO_);
2750 if (
m_label->hasKeyword(
"CCSD3ZF0000100000001NJPL3IF0PDS200000001")) {
2756 " because it is an ISIS2 cube.";
2758 throw IException(IException::Io, msg, _FILEINFO_);
2772 string msg =
"Sorry you can't do a SetMethod after the cube is opened";
2773 throw IException(IException::Programmer, msg, _FILEINFO_);
2785 PvlObject *core = NULL;
2788 core = &
label.findObject(
"IsisCube").findObject(
"Core");
2790 if (core->hasKeyword(
"^DnFile")) {
2792 FileName temp((*core)[
"^DnFile"][0]);
2793 if (!temp.expanded().startsWith(
"/")) {
2797 label = Pvl(temp.toString());
2814 QString parameters =
"from=" + oldCube;
2815 FileName oldName(oldCube);
2816 FileName tempCube = FileName::createTempFile(
"Temporary_" + oldName.name() +
".cub");
2817 parameters +=
" to=" + tempCube.expanded();
2820 QString command =
"$ISISROOT/bin/pds2isis " + parameters;
2824 QString prog =
"pds2isis";
2848 bool isGood =
false;
2849 bool useProj =
true;
2860 catch(IException &e) {
2861 QString msg =
"Cannot calculate lat/lon range without a camera or projection";
2862 throw IException(e, IException::User, msg, _FILEINFO_);
2869 catch(IException &e) {
2870 QString msg =
"Unable to create camera when calculating a lat/lon range.";
2871 throw IException(e, IException::User, msg, _FILEINFO_);
2876 minLatitude = 99999;
2877 minLongitude = 99999;
2878 maxLatitude = -99999;
2879 maxLongitude = -99999;
2881 for (
double sample = 0.5; sample <
sampleCount() + 0.5; sample++) {
2883 for (
double line = 0.5; line <
lineCount() + 0.5; line++) {
2885 isGood = proj->
SetWorld(sample, line);
2888 isGood = cam->
SetImage(sample, line);
2903 if (lat < minLatitude) {
2906 else if (lat > maxLatitude) {
2910 if (lon < minLongitude) {
2913 else if (lon > maxLongitude) {
2919 if ( (minLatitude == 99999) || (minLongitude == 99999) || (maxLatitude == -99999) ||
2920 (maxLongitude == -99999) ) {
2921 QString msg =
"Unable to calculate a minimum or maximum latitutde or longitude.";
2922 throw IException(IException::Unknown, msg, _FILEINFO_);
2932 string msg =
"Cube must be opened first before writing labels";
2933 throw IException(IException::Programmer, msg, _FILEINFO_);
2937 string msg =
"The cube must be opened in read/write mode, not readOnly";
2938 throw IException(IException::Programmer, msg, _FILEINFO_);
2943 nlohmann::ordered_json jsonOut;
2946 CPLStringList metadata = CPLStringList(gdalDataset()->GetMetadata(
"json:ISIS3"),
false);
2948 if (metadata[0] !=
nullptr) {
2949 const char *metadataJsonString = metadata[0];
2950 jsonOut = nlohmann::ordered_json::parse(metadataJsonString);
2954 nlohmann::ordered_json jsonblob = this->
label()->toJson()[
"Root"];
2955 for (
auto& [key, val] : jsonblob.items()) {
2956 if (!val.contains(
"Bytes") || key ==
"Label") {
2961 for (QString blobKey : m_blobQueue) {
2962 Blob &blob = m_blobMap[blobKey];
2964 std::string blobJsonStr =
"{}";
2965 blob.WriteGdal(blobJsonStr);
2966 nlohmann::ordered_json blobJson = nlohmann::ordered_json::parse(blobJsonStr);
2967 jsonOut.update(blobJson);
2970 m_blobQueue.clear();
2971 std::string jsonOutStr = jsonOut.dump();
2973 char ** outputMetadata =
new char*[1];
2974 outputMetadata[0] = jsonOutStr.data();
2975 gdalDataset()->SetMetadata(outputMetadata,
"json:ISIS3");
2976 delete []outputMetadata;
2978 if (this->
label()->findObject(
"IsisCube").
hasGroup(
"Mapping")) {
2979 PvlGroup &mappingGroup = this->
label()->findObject(
"IsisCube").findGroup(
"Mapping");
2981 if (mappingGroup.hasKeyword(
"ProjStr")) {
2982 OGRSpatialReference *oSRS =
new OGRSpatialReference();
2983 oSRS->SetFromUserInput(mappingGroup.findKeyword(
"ProjStr")[0].toStdString().c_str());
2985 gdalDataset()->SetSpatialRef(oSRS);
2987 double dfRes = (double)mappingGroup.findKeyword(
"PixelResolution") / oSRS->GetLinearUnits();
2988 double upperLeftX = (double) mappingGroup.findKeyword(
"UpperLeftCornerX");
2989 double upperLeftY = (double) mappingGroup.findKeyword(
"UpperLeftCornerY");
2990 double *padfTransform =
new double[6];
2991 padfTransform[1] = dfRes;
2992 padfTransform[5] = -dfRes;
2993 padfTransform[0] = upperLeftX;
2994 padfTransform[3] = upperLeftY;
2995 gdalDataset()->SetGeoTransform(padfTransform);
2997 delete[] padfTransform;
3011 QMutexLocker locker2(
m_ioHandler->dataFileMutex());
3016 ios::in | ios::out | ios::binary);
3022 maxbyte += (streampos)
m_ioHandler->getDataSize();
3024 for (QString blobKey : m_blobQueue) {
3025 Blob &blob = m_blobMap[blobKey];
3027 stream.seekp(0, ios::end);
3030 streampos endByte = stream.tellp();
3033 if (endByte < maxbyte) {
3034 stream.seekp(maxbyte, ios::beg);
3037 streampos eofbyte = stream.tellp();
3040 PvlObject &blobLabel = blob.Label();
3042 BigInt oldSbyte = blobLabel[
"StartByte"];
3043 int oldNbytes = (int) blobLabel[
"Bytes"];
3045 if (oldSbyte == 0) {
3046 blobLabel[
"StartByte"] =
toString((BigInt)eofbyte);
3050 if (blob.Size() <= oldNbytes) {
3051 stream.seekp(oldSbyte - 1, ios::beg);
3054 else if ((oldSbyte + oldNbytes) == eofbyte) {
3055 stream.seekp(oldSbyte - 1, ios::beg);
3061 blob.Write(*
label(), stream);
3063 catch (IException &e) {
3064 QString msg =
"Failed to write blob [" + blob.Type() +
", " + blob.Name() +
"]";
3065 throw IException(e, IException::Io, msg, _FILEINFO_);
3071 m_blobQueue.clear();
3076 string tempstr = temp.str();
3080 QByteArray labelUnpaddedContents(tempstr.c_str(), tempstr.length());
3081 labelArea.replace(0, labelUnpaddedContents.size(), labelUnpaddedContents);
3088 QString msg =
"Label space is full in [" +
3089 (QString)FileName(*m_labelFileName).name() +
3090 "] unable to write labels";
3092 throw IException(IException::Io, msg, _FILEINFO_);
3097 for (QString blobKey : m_blobQueue) {
3098 Blob &blob = m_blobMap[blobKey];
3100 FileName blobFileName(blob.Label().findKeyword(
"^" + blob.Type())[0]);
3101 QString blobFile(blobFileName.expanded());
3102 ios::openmode flags = ios::in | ios::binary | ios::out | ios::trunc;
3103 fstream detachedStream;
3104 detachedStream.open(blobFile.toLatin1().data(), flags);
3105 if (!detachedStream) {
3106 QString message =
"Unable to open data file [" +
3107 blobFileName.expanded() +
"]";
3108 throw IException(IException::Io, message, _FILEINFO_);
3112 blob.Write(*
label(), detachedStream);
3114 catch (IException &e) {
3115 QString msg =
"Failed to write blob [" + blob.Type() +
", " + blob.Name() +
"]";
3116 throw IException(e, IException::Io, msg, _FILEINFO_);
3117 detachedStream.close();
3119 detachedStream.flush();
3120 detachedStream.close();
3123 m_blobQueue.clear();
3129 void Cube::initLabelState(
const Pvl &label) {
3130 const PvlObject &core =
label.findObject(
"IsisCube").findObject(
"Core");
3132 if (core.hasKeyword(
"^DnFile")) {
3135 else if (core.hasKeyword(
"^Core")) {
Buffer for reading and writing cube data.
int size() const
Returns the total number of pixels in the shape buffer.
double * DoubleBuffer() const
Returns the value of the shape buffer.
void Copy(const Buffer &in, bool includeRawBuf=true)
Allows copying of the buffer contents to another Buffer.
Manages a Buffer over a cube.
bool begin()
Moves the shape buffer to the first position.
bool end() const
Returns true if the shape buffer has accessed the end of the cube.
bool next()
Moves the shape buffer to the next position.
static Camera * Create(Cube &cube)
Creates a Camera object using Pvl Specifications.
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Manipulate and parse attributes of output cube filenames.
double minimum() const
Return the output cube attribute minimum.
ByteOrder byteOrder() const
Return the byte order as an Isis::ByteOrder.
double maximum() const
Return the output cube attribute maximum.
bool propagateMinimumMaximum() const
Return true if the min/max are to be propagated from an input cube.
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
Cube::Format fileFormat() const
Return the file format an Cube::Format.
PixelType pixelType() const
Return the pixel type as an Isis::PixelType.
IO Handler for Isis Cubes using the BSQ format.
This is the parent of the caching algorithms.
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.
FileName realDataFileName() const
This gets the file name of the file which actually contains the DN data.
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...
GDALDataset * m_geodataSet
TODO: Write description.
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...
LabelAttachment
Input cube label type tracker.
@ ExternalLabel
The label is pointing to an external DN file - the label is also external to the data.
@ AttachedLabel
The input label is embedded in the image file.
@ DetachedLabel
The input label is in a separate data file from the image.
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.
void putGroup(const PvlGroup &group)
Adds a group in a Label to the cube.
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.
LabelAttachment m_attached
True if labels are attached.
void openGdal(const QString &cubeFileName, QString access)
This method will open an existing geotiff for reading or reading/writing.
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.
ImageIoHandler * m_ioHandler
This does the heavy lifting for cube DN IO and is always allocated when isOpen() is true.
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 openCube(const QString &cubeFileName, QString access)
This method will open an existing isis cube for reading or reading/writing.
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 ...
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.
PixelType pixelType() const
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.
LabelAttachment labelsAttached() const
Test if labels are attached.
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()
void setLabelsAttached(LabelAttachment attached)
Use prior to calling create, this sets whether or not to use separate label and data files.
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.
Stores stretch information for a cube.
Isis::Blob toBlob() const
Serialize the CubeStretch to a Blob.
IO Handler for Isis Cubes using the tile format.
Handles converting buffers to and from disk.
Container of a cube histogram.
void SetValidRange(const double minimum=Isis::ValidMinimum, const double maximum=Isis::ValidMaximum)
Changes the range of the bins.
virtual void AddData(const double *data, const unsigned int count)
Add an array of doubles to the histogram counters.
Blob toBlob(const QString &name="IsisCube")
Converts a history object into a new blob object.
Container of a cube histogram.
Create cube polygons, read/write polygons to blobs.
Blob toBlob() const
Serialize the ImagePolygon to a Blob.
Buffer manager, for moving through a cube in lines.
bool SetLine(const int line, const int band=1)
Positions the buffer at the requested line and returns a status indicator if the set was succesful or...
Read and store original labels.
Isis::Blob toBlob()
Serialize the OriginalLabel data to a Blob.
Read and store original Xml labels.
Blob toBlob() const
Serialize the OriginalXmlLabel to a Blob.
static void RunIsisProgram(QString isisProgramName, QString arguments)
Executes the Isis program with the given arguments.
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
Program progress reporter.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
void CheckStatus()
Checks and updates the status.
static Isis::Projection * CreateFromCube(Isis::Cube &cube)
This method is a helper method.
Base class for Map Projections.
virtual bool SetWorld(const double x, const double y)
This method is used to set a world coordinate.
virtual double UniversalLatitude() const
Returns the planetocentric latitude, in degrees, at the surface intersection point in the body fixed ...
virtual double UniversalLongitude() const
Returns the positive east, 0-360 domain longitude, in degrees, at the surface intersection point in t...
Obtain SPICE information for a spacecraft.
This class is used to accumulate statistics on double arrays.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Base class for Map TProjections.
virtual double UniversalLongitude()
This returns a universal longitude (positive east in 0 to 360 domain).
virtual double UniversalLatitude()
This returns a universal latitude (planetocentric).
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
QString LabelAttachmentName(Cube::LabelAttachment labelType)
Return the string representation of the contents of a variable of type LabelAttachment.
Namespace for the standard library.