diff --git a/isis/src/apollo/apps/apollofindrx/apollofindrx.cpp b/isis/src/apollo/apps/apollofindrx/apollofindrx.cpp index c933e58e83..1514400336 100644 --- a/isis/src/apollo/apps/apollofindrx/apollofindrx.cpp +++ b/isis/src/apollo/apps/apollofindrx/apollofindrx.cpp @@ -169,15 +169,14 @@ namespace Isis { } if (cube->label()->hasObject("History")) { - PvlObject histObj = cube->label()->findObject("History"); // Record apollofindrx history to the cube + QString histName = (QString)cube->label()->findObject("History")["Name"]; // create a History Blob with value found in the History PvlObject's Name keyword - Isis::History histBlob( (QString)histObj["Name"] ); // read cube's History PvlObject data into the History Blob - cube->read(histBlob); + History hist = cube->readHistory(histName); // add apollofindrx History PvlObject into the History Blob and write to cube - histBlob.AddEntry(); - cube->write(histBlob); + hist.AddEntry(); + cube->write(hist); cube->close(); } } diff --git a/isis/src/apollo/apps/apollopaninit/main.cpp b/isis/src/apollo/apps/apollopaninit/main.cpp index fc347871f9..269b1b2263 100644 --- a/isis/src/apollo/apps/apollopaninit/main.cpp +++ b/isis/src/apollo/apps/apollopaninit/main.cpp @@ -261,8 +261,6 @@ void IsisMain() { //create a table from starttime to endtime (stretched by 3%) with NODES entries spPos->LoadCache(time0-0.015*(time1-time0), time1+0.015*(time1-time0), NODES); Table tableSunPos = spPos->Cache("SunPosition"); - tableSunPos.Label() += PvlKeyword("SpkTableStartTime", toString(time0-0.015*(time1-time0))); - tableSunPos.Label() += PvlKeyword("SpkTablleEndTime", toString(time1+0.015*(time1-time0))); tableSunPos.Label() += PvlKeyword("Description", "Created by apollopaninit"); panCube.write(tableSunPos); //attach the table to the cube diff --git a/isis/src/base/apps/caminfo/CamTools.cpp b/isis/src/base/apps/caminfo/CamTools.cpp index 20a2660726..040af2c635 100644 --- a/isis/src/base/apps/caminfo/CamTools.cpp +++ b/isis/src/base/apps/caminfo/CamTools.cpp @@ -334,14 +334,8 @@ namespace Isis { if (getFootBlob && band == 0) { // Read the footprint from the image labels - ImagePolygon poly; - try { - cube.read(poly); - } - catch (IException &e) { - QString msg = "Error reading footprint blob from image labels"; - throw IException(e, IException::User, msg, _FILEINFO_); - } + ImagePolygon poly = cube.readFootprint(); + cube.close(); geos::geom::MultiPolygon *multiP = poly.Polys(); _polys.push_back(multiP->clone()); _combined = multiP->clone(); diff --git a/isis/src/base/apps/caminfo/caminfo.cpp b/isis/src/base/apps/caminfo/caminfo.cpp index 55dfd57454..c581645110 100644 --- a/isis/src/base/apps/caminfo/caminfo.cpp +++ b/isis/src/base/apps/caminfo/caminfo.cpp @@ -13,7 +13,6 @@ #include "iTime.h" #include "LineManager.h" #include "OriginalLabel.h" -#include "Process.h" #include "ProgramLauncher.h" #include "Progress.h" #include "Pvl.h" @@ -82,8 +81,7 @@ namespace Isis{ // Add the orginal label blob if(ui.GetBoolean("ORIGINALLABEL") && incube->label()->hasObject("OriginalLabel")) { - OriginalLabel orig; - incube->read(orig); + OriginalLabel orig = incube->readOriginalLabel(); Pvl p = orig.ReturnLabels(); p.setName("OriginalLabel"); params.addObject(p); @@ -372,7 +370,7 @@ namespace Isis{ if (getFootBlob) { // Need to read history to obtain parameters that were used to // create the footprint - History hist("IsisCube", incube->fileName()); + History hist = incube->readHistory(); Pvl pvl = hist.ReturnHist(); PvlObject::PvlObjectIterator objIter; bool found = false; diff --git a/isis/src/base/apps/cathist/main.cpp b/isis/src/base/apps/cathist/main.cpp index 39b32f0bed..f873fd353c 100644 --- a/isis/src/base/apps/cathist/main.cpp +++ b/isis/src/base/apps/cathist/main.cpp @@ -5,7 +5,7 @@ #include "FileName.h" #include "IString.h" #include "History.h" -#include "Pvl.h" +#include "Pvl.h" #include "TextFile.h" using namespace Isis; @@ -26,7 +26,8 @@ void IsisMain() { } // Extract history from file - History hist("IsisCube", fromfile.expanded()); + Blob historyBlob("IsisCube", "History", fromfile.expanded()); + History hist(historyBlob); Pvl pvl = hist.ReturnHist(); // Print full history diff --git a/isis/src/base/apps/copylabel/main.cpp b/isis/src/base/apps/copylabel/main.cpp index ac1379a4f5..27008fb2d9 100644 --- a/isis/src/base/apps/copylabel/main.cpp +++ b/isis/src/base/apps/copylabel/main.cpp @@ -3,6 +3,7 @@ #include "Application.h" #include "Cube.h" #include "History.h" +#include "Process.h" #include "Pvl.h" #include "PvlGroup.h" #include "PvlObject.h" @@ -227,22 +228,8 @@ void IsisMain() { subarea.UpdateLabel(&inOut, &inOut, results); } - // Add History - bool found = false; - for (int i = 0; i < mergeTo->objects() && !found; i++) { - if (mergeTo->object(i).isNamed("History")) { - History his((QString)mergeTo->object(i)["Name"]); - inOut.read(his); - his.AddEntry(); - inOut.write(his); - found = true; - } - } - if (!found) { - History his("IsisCube"); - his.AddEntry(); - inOut.write(his); - } + Process process; + process.WriteHistory(inOut); inOut.close(); sourceCube.close(); @@ -279,4 +266,3 @@ bool copyBlob(Cube * from, Cube * to, QString name, QString type, QString fname) return false; } } - diff --git a/isis/src/base/apps/csminit/csminit.cpp b/isis/src/base/apps/csminit/csminit.cpp index bc697f81fe..ef3e8dc007 100644 --- a/isis/src/base/apps/csminit/csminit.cpp +++ b/isis/src/base/apps/csminit/csminit.cpp @@ -29,7 +29,6 @@ find files of those names at the top level of this repository. **/ #include "Pvl.h" #include "PvlGroup.h" #include "PvlKeyword.h" -#include "StringBlob.h" using namespace std; @@ -364,54 +363,55 @@ namespace Isis { } // Save off all old Blobs to restore in the case of csminit failure - StringBlob originalCsmStateBlob("", "CSMState"); - if (cube->hasBlob("String", "CSMState")) { + Blob originalCsmStateBlob("CSMState", "String"); + if (cube->hasBlob("CSMState", "String")) { cube->read(originalCsmStateBlob); } Table originalInstrumentPointing("InstrumentPointing"); if (cube->hasTable("InstrumentPointing")) { - cube->read(originalInstrumentPointing); + originalInstrumentPointing = cube->readTable("InstrumentPointing"); } Table originalInstrumentPosition("InstrumentPosition"); if (cube->hasTable("InstrumentPosition")) { - cube->read(originalInstrumentPosition); + originalInstrumentPosition = cube->readTable("InstrumentPosition"); } Table originalBodyRotation("BodyRotation"); if (cube->hasTable("BodyRotation")) { - cube->read(originalBodyRotation); + originalBodyRotation = cube->readTable("BodyRotation"); } Table originalSunPosition("SunPosition"); if (cube->hasTable("SunPosition")) { - cube->read(originalSunPosition); + originalSunPosition = cube->readTable("SunPosition"); } Table originalCameraStatistics("CameraStatistics"); if (cube->hasTable("CameraStatistics")) { - cube->read(originalCameraStatistics); + originalCameraStatistics = cube->readTable("CameraStatistics"); } ImagePolygon originalFootprint; - if (cube->hasBlob("Polygon", "ImageFootprint")) { - cube->read(originalFootprint); + if (cube->hasBlob("ImageFootprint", "Polygon")) { + originalFootprint = cube->readFootprint(); } // Remove blob from old csminit run - cube->deleteBlob("String", "CSMState"); + cube->deleteBlob("CSMState", "String"); // Remove tables from spiceinit before writing to the cube - cube->deleteBlob("Table", "InstrumentPointing"); - cube->deleteBlob("Table", "InstrumentPosition"); - cube->deleteBlob("Table", "BodyRotation"); - cube->deleteBlob("Table", "SunPosition"); - cube->deleteBlob("Table", "CameraStatistics"); - cube->deleteBlob("Polygon", "Footprint"); + cube->deleteBlob("InstrumentPointing", "Table"); + cube->deleteBlob("InstrumentPosition", "Table"); + cube->deleteBlob("BodyRotation", "Table"); + cube->deleteBlob("SunPosition", "Table"); + cube->deleteBlob("CameraStatistics", "Table"); + cube->deleteBlob("Footprint", "Polygon"); // Create our CSM State blob as a string and add the CSM string to the Blob. - StringBlob csmStateBlob(modelState, "CSMState"); + Blob csmStateBlob("CSMState", "String"); + csmStateBlob.setData(modelState.c_str(), modelState.size()); PvlObject &blobLabel = csmStateBlob.Label(); blobLabel += PvlKeyword("ModelName", modelName); blobLabel += PvlKeyword("PluginName", pluginName); @@ -438,7 +438,7 @@ namespace Isis { cube->putGroup(originalCsmInfo); } - cube->deleteBlob("String", "CSMState"); + cube->deleteBlob("CSMState", "String"); // Restore the original blobs if (originalCsmStateBlob.Size() != 0) { @@ -465,7 +465,9 @@ namespace Isis { cube->write(originalCameraStatistics); } - if (originalFootprint.Size() != 0) { + + if (originalFootprint.Polys() != NULL && + originalFootprint.Polys()->getNumGeometries() != 0) { cube->write(originalFootprint); } diff --git a/isis/src/base/apps/cubeit/main.cpp b/isis/src/base/apps/cubeit/main.cpp index 971245e190..971cbe4c16 100644 --- a/isis/src/base/apps/cubeit/main.cpp +++ b/isis/src/base/apps/cubeit/main.cpp @@ -179,9 +179,7 @@ void IsisMain() { } // Delete any tracking tables from the input label if necessary - if (ocube->hasTable("InputImages")) { - ocube->deleteBlob("Table", "InputImages"); - } + ocube->deleteBlob("InputImages", "Table"); // Delete the Tracking group if it exists (3.6.0 and up) // The tracking group could be transfered from the first input cube, but it does not @@ -220,9 +218,7 @@ void IsisMain() { Cube *icube = m.SetInputCube(newcubeList[i].toString(), attrib, 1, 1, 1, -1, -1, -1); // Delete any tracking tables from the input cube if necessary - if (icube->hasTable("InputImages")) { - icube->deleteBlob("Table", "InputImages"); - } + icube->deleteBlob("InputImages", "Table"); m.SetImageOverlay(ProcessMosaic::PlaceImagesOnTop); m.StartProcess(1, 1, sband); diff --git a/isis/src/base/apps/demprep/demprep.cpp b/isis/src/base/apps/demprep/demprep.cpp index c0df1aa2f1..488e142428 100644 --- a/isis/src/base/apps/demprep/demprep.cpp +++ b/isis/src/base/apps/demprep/demprep.cpp @@ -5,7 +5,6 @@ #include "TProjection.h" #include "SpecialPixel.h" #include "LineManager.h" -#include "OriginalLabel.h" #include "History.h" #include "Table.h" #include "Pvl.h" diff --git a/isis/src/base/apps/desmile/main.cpp b/isis/src/base/apps/desmile/main.cpp index 8ac601f8b6..0722c72b28 100644 --- a/isis/src/base/apps/desmile/main.cpp +++ b/isis/src/base/apps/desmile/main.cpp @@ -16,7 +16,7 @@ #include "History.h" #include "Spectel.h" -#include "SpectralDefinition.h" +#include "SpectralDefinition.h" #include "SpectralDefinitionFactory.h" #include "SpectralDefinition1D.h" #include "SpectralDefinition2D.h" @@ -40,14 +40,14 @@ void IsisMain() { Cube *inCube = procSpectra.SetInputCube("FROM"); // Get the spectral information for the input cube - FileName smileDef = ui.GetFileName("SMILEDEF"); + FileName smileDef = ui.GetFileName("SMILEDEF"); // TODO: May want to add the cube to the constructor args so some error checks can be done - SpectralDefinition* inputSpectralDef = SpectralDefinitionFactory::NewSpectralDefinition(smileDef); + SpectralDefinition* inputSpectralDef = SpectralDefinitionFactory::NewSpectralDefinition(smileDef); // Get the spectral information for the output cube FileName smileObjective = ui.GetFileName("OBJECTIVE"); - SpectralDefinition* outputSpectralDef = - SpectralDefinitionFactory::NewSpectralDefinition(smileObjective); + SpectralDefinition* outputSpectralDef = + SpectralDefinitionFactory::NewSpectralDefinition(smileObjective); // Set up the output cube. It may have a different number of bands than the input cube. Cube *outCube = procSpectra.SetOutputCube("TO", inCube->sampleCount(), inCube->lineCount(), @@ -98,17 +98,15 @@ void IsisMain() { // Record apollofindrx history to the cube // create a History Blob with value found in the History PvlObject's Name keyword - PvlObject &histObj = inCube->label()->findObject("History"); - Isis::History histBlob( (QString)histObj["Name"] ); - // read cube's History PvlObject data into the History Blob - inCube->read(histBlob); + QString histName = (QString)inCube->label()->findObject("History")["Name"]; + // read cube's History PvlObject data into the History Object + History histBlob = inCube->readHistory(histName); histBlob.AddEntry(); - outCube->write(histBlob); + outCube->write(histBlob, histName); procSpectra.Finalize(); delete outputSpectralDef; outputSpectralDef = NULL; - delete inputSpectralDef; + delete inputSpectralDef; inputSpectralDef = NULL; } - diff --git a/isis/src/base/apps/editlab/main.cpp b/isis/src/base/apps/editlab/main.cpp index 05ebe07b7e..4e402aeb36 100644 --- a/isis/src/base/apps/editlab/main.cpp +++ b/isis/src/base/apps/editlab/main.cpp @@ -100,15 +100,7 @@ void IsisMain() { // Add history, write, and clean the data if(cube) { - History hist = History("IsisCube"); - try { - // read history from cube, if it exists. - cube->read(hist); - } - catch(IException &e) { - // if the history does not exist in the cube, continue. In this case, - // editlab will be the first History entry. - } + History hist = cube->readHistory(); hist.AddEntry(); cube->write(hist); @@ -128,10 +120,10 @@ void IsisMain() { /** * Modifies the given keyword with the user entered value, units, and/or * comment. - * + * * @param ui UserInterface object for this application. * @param keyword PvlKeyword to be modified. - * + * * @return PvlKeyword Modified keyword. */ PvlKeyword &modifyKeyword(UserInterface &ui, PvlKeyword &keyword) { diff --git a/isis/src/base/apps/findrx/main.cpp b/isis/src/base/apps/findrx/main.cpp index 5f5e2aec51..4b62cb1cf6 100644 --- a/isis/src/base/apps/findrx/main.cpp +++ b/isis/src/base/apps/findrx/main.cpp @@ -8,6 +8,7 @@ #include "Cube.h" #include "History.h" #include "IException.h" +#include "Process.h" #include "Progress.h" #include "PvlGroup.h" #include "UserInterface.h" @@ -15,13 +16,11 @@ using namespace std; using namespace Isis; -void writeHistory(Cube &cube); - void IsisMain() { // Import cube data & PVL information - Cube cube; UserInterface &ui = Application::GetUserInterface(); - cube.open(ui.GetFileName("FROM"), "rw"); + Process process; + Cube *cube = process.SetInputCube("FROM", Isis::ReadWrite); Pvl *regdef; // If regdef was supplied by the user, use it. else, use the template. if (ui.WasEntered("REGDEF")) { @@ -30,7 +29,7 @@ void IsisMain() { else { regdef = new Pvl("$ISISROOT/appdata/templates/autoreg/findrx.def"); } - PvlGroup &reseaus = cube.label()->findGroup("Reseaus", Pvl::Traverse); + PvlGroup &reseaus = cube->label()->findGroup("Reseaus", Pvl::Traverse); // If the Keyword sizes don't match up, throw errors. int nres = reseaus["Line"].size(); @@ -79,7 +78,7 @@ void IsisMain() { for (int res = 0; res < nres; ++res) { // Output chips ar->SearchChip()->TackCube(toDouble(reseaus["Sample"][res]), toDouble(reseaus["Line"][res])); - ar->SearchChip()->Load(cube); + ar->SearchChip()->Load(*cube); ar->PatternChip()->Load(pattern, 0, 1.0, res + 1); int type = toInt(reseaus["Type"][res]); // If the reseaus is in the center (type 5) use full percent value @@ -114,7 +113,7 @@ void IsisMain() { double line = toDouble(reseaus["Line"][res]); double sample = toDouble(reseaus["Sample"][res]); white->SetBasePosition(int(sample), int(line), 1); - cube.write(*white); + cube->write(*white); } prog.CheckStatus(); @@ -124,32 +123,6 @@ void IsisMain() { reseaus["Status"] = "Refined"; pattern.close(); - writeHistory(cube); - cube.close(); -} - - -/** - * Writes out the History blob to a cube - * - * @param cube Cube to add History blob to - */ -void writeHistory(Cube &cube) { - bool addedHist = false; - Isis::Pvl *inlabel = cube.label(); - for (int i = 0; i < inlabel->objects(); i++) { - if (inlabel->object(i).isNamed("History") && Isis::iApp != NULL) { - Isis::History h( (QString)inlabel->object(i)["Name"] ); - cube.read(h); - h.AddEntry(); - cube.write(h); - addedHist = true; - } - } - - if (!addedHist && Isis::iApp != NULL) { - Isis::History h("IsisCube"); - h.AddEntry(); - cube.write(h); - } + process.WriteHistory(*cube); + cube->close(); } diff --git a/isis/src/base/apps/footprintinit/footprintinit.cpp b/isis/src/base/apps/footprintinit/footprintinit.cpp index d3db7743a2..5cc018c065 100644 --- a/isis/src/base/apps/footprintinit/footprintinit.cpp +++ b/isis/src/base/apps/footprintinit/footprintinit.cpp @@ -137,7 +137,7 @@ namespace Isis { } } - cube->deleteBlob("Polygon", sn); + cube->deleteBlob(sn, "Polygon"); cube->write(poly); if (precision) { diff --git a/isis/src/base/apps/footprintmerge/main.cpp b/isis/src/base/apps/footprintmerge/main.cpp index 8c2df1a96d..a9bdc25f66 100644 --- a/isis/src/base/apps/footprintmerge/main.cpp +++ b/isis/src/base/apps/footprintmerge/main.cpp @@ -53,21 +53,13 @@ void IsisMain() { } // Make sure cube has been run through footprintinit - ImagePolygon *poly = new ImagePolygon; - try { - cube.read(*poly); - cube.close(); - } - catch(IException &e) { - QString msg = "Footprintinit must be run prior to running footprintmerge"; - msg += " for cube [" + imageList[img].toString() + "]"; - throw IException(IException::User, msg, _FILEINFO_); - } + ImagePolygon poly = cube.readFootprint(); + cube.close(); // If more than 1 poly, set conv360 for later conversion to 180 and merging - if(poly->Polys()->getNumGeometries() > 1) conv360 = true; + if(poly.Polys()->getNumGeometries() > 1) conv360 = true; - allPolys.push_back(PolygonTools::CopyMultiPolygon(poly->Polys())); + allPolys.push_back(PolygonTools::CopyMultiPolygon(poly.Polys())); files.push_back(imageList[img].toString()); diff --git a/isis/src/base/apps/maplab/main.cpp b/isis/src/base/apps/maplab/main.cpp index 88e397a855..b8a666ba52 100644 --- a/isis/src/base/apps/maplab/main.cpp +++ b/isis/src/base/apps/maplab/main.cpp @@ -113,12 +113,7 @@ void IsisMain() { o.addGroup(mapGrp); // keep track of change to labels in history - History hist = History("IsisCube"); - try { - cube.read(hist); - } - catch(IException &e) { - } + History hist = cube.readHistory(); hist.AddEntry(); cube.write(hist); diff --git a/isis/src/base/apps/pca/main.cpp b/isis/src/base/apps/pca/main.cpp index e51dc01981..e52d80ccca 100644 --- a/isis/src/base/apps/pca/main.cpp +++ b/isis/src/base/apps/pca/main.cpp @@ -68,8 +68,7 @@ void IsisMain() { QString m = "The input cube has not been transformed into its principal components"; throw IException(IException::Programmer, m, _FILEINFO_); } - Isis::Table table("Transform Matrix"); - icube->read(table); + Isis::Table table = icube->readTable("Transform Matrix"); numDimensions = table.Records(); TNT::Array2D transform(numDimensions, numDimensions); for(int i = 0; i < numDimensions; i++) { diff --git a/isis/src/base/apps/shadow/ShadowFunctor.cpp b/isis/src/base/apps/shadow/ShadowFunctor.cpp index 7fc951e0a1..b06db8b76c 100644 --- a/isis/src/base/apps/shadow/ShadowFunctor.cpp +++ b/isis/src/base/apps/shadow/ShadowFunctor.cpp @@ -38,8 +38,7 @@ namespace Isis { m_inputDem = inputDem; try { - Table shapeModelStats("ShapeModelStatistics"); - inputDem->read(shapeModelStats); + Table shapeModelStats = inputDem->readTable("ShapeModelStatistics"); // We store this in KM, not M, in this class. m_inputDemMax = (double)shapeModelStats[0]["MaximumRadius"] * 1000.0; diff --git a/isis/src/base/apps/spiceinit/SpiceClient.cpp b/isis/src/base/apps/spiceinit/SpiceClient.cpp index 1566197421..6142b701aa 100644 --- a/isis/src/base/apps/spiceinit/SpiceClient.cpp +++ b/isis/src/base/apps/spiceinit/SpiceClient.cpp @@ -11,6 +11,7 @@ #include #include "Application.h" +#include "Blob.h" #include "Constants.h" #include "IException.h" #include "IString.h" @@ -634,9 +635,9 @@ namespace Isis { Pvl lab; tableStream >> lab; - - Table *table = new Table(tableName); - table->Read(lab, tableStream); + Blob tableBlob(tableName, "Table"); + tableBlob.Read(lab, tableStream); + Table *table = new Table(tableBlob); return table; diff --git a/isis/src/base/apps/spiceinit/spiceinit.cpp b/isis/src/base/apps/spiceinit/spiceinit.cpp index f6b3245dc6..957f0d4feb 100644 --- a/isis/src/base/apps/spiceinit/spiceinit.cpp +++ b/isis/src/base/apps/spiceinit/spiceinit.cpp @@ -17,7 +17,7 @@ #include "PvlToPvlTranslationManager.h" #include "SpiceClient.h" #include "SpiceClientStarter.h" -#include "StringBlob.h" +#include "Blob.h" #include "Table.h" #include "UserInterface.h" #include "spiceinit.h" @@ -379,13 +379,13 @@ namespace Isis { currentKernels.addKeyword(demKeyword, Pvl::Replace); // Save off the CSM State so it can be restored if spiceinit fails - StringBlob csmState("", "CSMState"); - if (icube->hasBlob("String", "CSMState")) { + Blob csmState("CSMState", "String"); + if (icube->hasBlob("CSMState", "String")) { icube->read(csmState); } // Delete the CSM State blob so that CameraFactory doesn't try to instantiate a CSMCamera - icube->deleteBlob("String", "CSMState"); + icube->deleteBlob("CSMState", "String"); // report qualities PvlKeyword spkQuality("InstrumentPositionQuality"); @@ -673,7 +673,7 @@ namespace Isis { continue; } } - + if (ui.GetString("SHAPE") == "USER") { kernelsGroup["ShapeModel"] = ui.GetFileName("MODEL"); } diff --git a/isis/src/base/apps/spiceserver/spiceserver.cpp b/isis/src/base/apps/spiceserver/spiceserver.cpp index 1cc3e65ef8..a9dc5dd622 100644 --- a/isis/src/base/apps/spiceserver/spiceserver.cpp +++ b/isis/src/base/apps/spiceserver/spiceserver.cpp @@ -8,6 +8,7 @@ #include #include +#include "Blob.h" #include "Camera.h" #include "CameraFactory.h" #include "Cube.h" @@ -74,7 +75,7 @@ namespace Isis { // Get the single line of encoded XML from the input file that the client, spiceinit, sent us. TextFile inFile( ui.GetFileName("FROM") ); QString hexCode; - + // GetLine returns false if it was the last line... so we can't check for problems really inFile.GetLine(hexCode); @@ -159,7 +160,7 @@ namespace Isis { } } - + // This next section looks a lot like spiceinit, its semi-duplicated because // I did not want users to be able to spiceinit a label without cube // data. @@ -247,7 +248,7 @@ namespace Isis { } FileName inputLabels; - + while (ck.at(0).size() != 0 && !kernelSuccess) { // create an empty kernel Kernel realCkKernel; @@ -282,7 +283,7 @@ namespace Isis { } realCkKernel.setKernels(ckKernelList); - + /* * Create a dummy cube from the labels that spiceinit sent. We do this because the camera * classes take a cube instead of a pvl as input. @@ -455,7 +456,7 @@ namespace Isis { if (errPvl.groups() > 0) currentKernels += PvlKeyword("Error", errPvl.group(errPvl.groups() - 1)["Message"][0]); - + if (log) { log->addGroup(currentKernels); } @@ -468,7 +469,7 @@ namespace Isis { for (int i = 0; i < ckKeyword.size(); i++) ckTable.Label()["Kernels"].addValue(ckKeyword[i]); - ckTable.Write(ui.GetFileName("TO") + ".pointing"); + ckTable.toBlob().Write(ui.GetFileName("TO") + ".pointing"); Table spkTable = cam->instrumentPosition()->Cache("InstrumentPosition"); spkTable.Label() += PvlKeyword("Description", "Created by spiceinit"); @@ -476,7 +477,7 @@ namespace Isis { for (int i = 0; i < spkKeyword.size(); i++) spkTable.Label()["Kernels"].addValue(spkKeyword[i]); - spkTable.Write(ui.GetFileName("TO") + ".position"); + spkTable.toBlob().Write(ui.GetFileName("TO") + ".position"); Table bodyTable = cam->bodyRotation()->Cache("BodyRotation"); bodyTable.Label() += PvlKeyword("Description", "Created by spiceinit"); @@ -488,7 +489,7 @@ namespace Isis { bodyTable.Label()["Kernels"].addValue(pckKeyword[i]); bodyTable.Label() += PvlKeyword( "SolarLongitude", toString( cam->solarLongitude().degrees() ) ); - bodyTable.Write(ui.GetFileName("TO") + ".bodyrot"); + bodyTable.toBlob().Write(ui.GetFileName("TO") + ".bodyrot"); Table sunTable = cam->sunPosition()->Cache("SunPosition"); sunTable.Label() += PvlKeyword("Description", "Created by spiceinit"); @@ -496,7 +497,7 @@ namespace Isis { for (int i = 0; i < targetSpkKeyword.size(); i++) sunTable.Label()["Kernels"].addValue(targetSpkKeyword[i]); - sunTable.Write(ui.GetFileName("TO") + ".sun"); + sunTable.toBlob().Write(ui.GetFileName("TO") + ".sun"); // Save original kernels in keyword before changing to Table PvlKeyword origCk = currentKernels["InstrumentPointing"]; diff --git a/isis/src/base/apps/table2cube/main.cpp b/isis/src/base/apps/table2cube/main.cpp index ef67433096..c30673b695 100644 --- a/isis/src/base/apps/table2cube/main.cpp +++ b/isis/src/base/apps/table2cube/main.cpp @@ -23,8 +23,7 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); // Get Parameters - g_table = new Table(ui.GetString("TABLENAME")); - g_table->Read(ui.GetFileName("FROM")); + g_table = new Table(ui.GetString("TABLENAME"), ui.GetFileName("FROM")); g_field = ui.GetString("FIELD"); g_startRecord = ui.GetInteger("STARTREC"); diff --git a/isis/src/base/apps/topds4/topds4.cpp b/isis/src/base/apps/topds4/topds4.cpp index abef32c0be..f4ded56442 100644 --- a/isis/src/base/apps/topds4/topds4.cpp +++ b/isis/src/base/apps/topds4/topds4.cpp @@ -64,15 +64,13 @@ namespace Isis { // Add the original label (from an ingestion app) to the template engine data // Wrap it in an OriginalLabel so existing elements don't get overwritten if (cubeLabel.hasObject("OriginalLabel")) { - OriginalLabel origBlob; - icube->read(origBlob); - Pvl origLabel; - origLabel = origBlob.ReturnLabels(); - dataSource["OriginalLabel"].update(pvlToJSON(origLabel)); + OriginalLabel origLabel = icube->readOriginalLabel(); + Pvl pvlOrigLabel; + pvlOrigLabel = origLabel.ReturnLabels(); + dataSource["OriginalLabel"].update(pvlToJSON(pvlOrigLabel)); } else if (cubeLabel.hasObject("OriginalXmlLabel")) { - OriginalXmlLabel origXmlBlob; - icube->read(origXmlBlob); + OriginalXmlLabel origXmlBlob = icube->readOriginalXmlLabel(); QDomDocument doc = origXmlBlob.ReturnLabels(); dataSource["OriginalLabel"].update(xmlToJson(doc)); } diff --git a/isis/src/base/apps/trackextract/main.cpp b/isis/src/base/apps/trackextract/main.cpp index b29593e3ba..f0bfb66ff9 100644 --- a/isis/src/base/apps/trackextract/main.cpp +++ b/isis/src/base/apps/trackextract/main.cpp @@ -77,17 +77,17 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); QString inputName = ui.GetFileName("FROM"); QString outputName = ui.GetFileName("TO"); - + // Confirm that the input mosaic is of pixel-type "Real" as trackextract does not work on other // bit types due to corruption of these files Cube inputCube = Cube(inputName); PixelType pixelType = inputCube.pixelType(); if (pixelType != Real) { - QString msg = "The input mosaic [" + inputName + "] is of pixel type [" + QString msg = "The input mosaic [" + inputName + "] is of pixel type [" + PixelTypeName(pixelType) + "]. This application only works for mosaics of pixel type Real."; throw IException(IException::User, msg, _FILEINFO_); } - + QVector copyBands; int trackBand; findTrackBand(inputName, copyBands, trackBand); @@ -170,7 +170,7 @@ void createMosaicCube(QString inputName, QString outputName, QVector ba _FILEINFO_); } - if (!mosaicCube.deleteBlob("Table", "InputImages")) { + if (!mosaicCube.deleteBlob("InputImages", "Table")) { QString msg = "The input cube [" + inputName + "] does not have a tracking table."; throw IException(IException::Programmer, msg, _FILEINFO_); } @@ -255,8 +255,7 @@ void createTrackCube(QString inputName, QString ouputName, int trackBand) { // Create new tracking table with updated data and delete the old table if (trackCube.hasTable("InputImages")) { - Table oldTable("InputImages"); - trackCube.read(oldTable); + Table oldTable = trackCube.readTable("InputImages"); trackCube.deleteBlob("Table", "InputImages"); TrackingTable newTrackTable(oldTable); diff --git a/isis/src/base/objs/Blob/Blob.cpp b/isis/src/base/objs/Blob/Blob.cpp index 439d2b378f..42791b03d9 100644 --- a/isis/src/base/objs/Blob/Blob.cpp +++ b/isis/src/base/objs/Blob/Blob.cpp @@ -46,7 +46,7 @@ namespace Isis { * @param type The blob type * @param file The filename to read from. */ - Blob::Blob(const QString &name, const QString &type, + Blob::Blob(const QString &name, const QString &type, const QString &file) { p_blobName = name; p_buffer = NULL; @@ -87,7 +87,7 @@ namespace Isis { * * @param other Blob to be copied * - * @return Copied Blob + * @return Copied Blob */ Blob &Blob::operator=(const Blob &other) { p_blobPvl = other.p_blobPvl; @@ -116,54 +116,54 @@ namespace Isis { if (p_buffer != NULL) delete [] p_buffer; } - /** + /** * Accessor method that returns a string containing the Blob type. - * + * * @return @b string Type of blob. - */ + */ QString Blob::Type() const { return p_type; } - /** + /** * Accessor method that returns a string containing the Blob name. - * + * * @return @b string The name of the blob. - */ + */ QString Blob::Name() const { return p_blobName; } - /** + /** * Accessor method that returns the number of bytes in the blob data. - * + * * @return @b int Number of bytes in the blob data. - */ + */ int Blob::Size() const { return p_nbytes; } - /** + /** * Accessor method that returns a PvlObject containing the Blob label. - * + * * @return @b PvlObject The label of the blob. - */ + */ PvlObject &Blob::Label() { return p_blobPvl; } - /** + /** * This method searches the given Pvl for the Blob by the Blob's type and * name. If found, the start byte, number of bytes are read from the Pvl. * Also, if a keyword label pointer is found, the filename for the detached * blob is stored and the pointer is removed from the blob pvl. - * + * * @param pvl The Pvl to be searched * @param keywords A list of keyword, value pairs to match inside the blob's * PVL object. Only if all the keyword match is the blob processed. This is used - * when there are multiple blobs with the same name, but different keywords that + * when there are multiple blobs with the same name, but different keywords that * define the exact blob (see Stretch with a band number) - */ + */ void Blob::Find(const Pvl &pvl, const std::vector keywords) { bool found = false; try { @@ -303,7 +303,7 @@ namespace Isis { } /** - * This method reads the Blob data from an open input file stream. + * This method reads the Blob data from an open input file stream. * * @param pvl A Pvl containing the label information. * @param istm The input file stream containing the blob data to be read. @@ -335,9 +335,9 @@ namespace Isis { /** - * This virtual method for classes that inherit Blob. It is not defined in + * This virtual method for classes that inherit Blob. It is not defined in * the Blob class. - */ + */ void Blob::ReadInit(){ } @@ -368,6 +368,43 @@ namespace Isis { } } + + /** + * Set the data stored in the BLOB. + * + * This function will copy the data buffer, if you want to avoid that use + * takeData which will take ownership of the buffer. + * + * @param buffer The buffer of data. The BLOB does not take ownership of this, + * the caller is still responsible for cleaning it up. + * @param nbytes The amount of data in the buffer + */ + void Blob::setData(const char *buffer, int nbytes) { + char *buf = new char[nbytes]; + memcpy(buf, buffer, nbytes); + takeData(buf, nbytes); + } + + + /** + * Set the data stored in the BLOB without copying it. + * + * This function takes ownership of the data buffer and will delete is when the BLOB + * is cleaned up. + * + * @param buffer The buffer of data. The BLOB takes ownership of this. + * @param nbytes The amount of data in the buffer + */ + void Blob::takeData(char *buffer, int nbytes) { + p_nbytes = nbytes; + + if (p_buffer != NULL) { + delete [] p_buffer; + } + + p_buffer = buffer; + } + /** * Write the blob data out to a file. * @@ -449,9 +486,9 @@ namespace Isis { p_blobPvl["StartByte"] = toString((BigInt)sbyte); p_blobPvl["Bytes"] = toString(p_nbytes); - + // See if the blob is already in the file - bool found = false; + bool found = false; if (overwrite) { for (int i = 0; i < pvl.objects(); i++) { @@ -502,9 +539,18 @@ namespace Isis { } /** - * This virtual method for classes that inherit Blob. It is not defined in + * Get the internal data buff of the Blob. + * + * @return @b char* A data buffer containing Blob::Size bytes + */ + char *Blob::getBuffer() { + return p_buffer; + } + + /** + * This virtual method for classes that inherit Blob. It is not defined in * the Blob class. - */ + */ void Blob::WriteInit(){ } @@ -536,4 +582,3 @@ namespace Isis { return false; } } // end namespace isis - diff --git a/isis/src/base/objs/Blob/Blob.h b/isis/src/base/objs/Blob/Blob.h index 94e11f9a66..1abf7828e4 100644 --- a/isis/src/base/objs/Blob/Blob.h +++ b/isis/src/base/objs/Blob/Blob.h @@ -54,6 +54,7 @@ namespace Isis { Blob(const QString &name, const QString &type, const QString &file); Blob(const Blob &other); + Blob() = default; Blob &operator=(const Blob &other); virtual ~Blob(); @@ -65,15 +66,20 @@ namespace Isis { void Read(const QString &file, const std::vector keywords=std::vector()); - void Read(const QString &file, const Pvl &pvlLabels, + void Read(const QString &file, const Pvl &pvlLabels, const std::vector keywords = std::vector()); - virtual void Read(const Pvl &pvl, std::istream &is, + virtual void Read(const Pvl &pvl, std::istream &is, const std::vector keywords = std::vector()); void Write(const QString &file); void Write(Pvl &pvl, std::fstream &stm, const QString &detachedFileName = "", bool overwrite=true); + + char *getBuffer(); + void setData(const char *buffer, int nbytes); + void takeData(char *buffer, int nbytes); + protected: void Find(const Pvl &pvl, const std::vector keywords = std::vector()); virtual void ReadInit(); diff --git a/isis/src/base/objs/Blobber/Blobber.cpp b/isis/src/base/objs/Blobber/Blobber.cpp index a447acc0c5..15603bc887 100644 --- a/isis/src/base/objs/Blobber/Blobber.cpp +++ b/isis/src/base/objs/Blobber/Blobber.cpp @@ -138,8 +138,7 @@ namespace Isis { * opened or created in the Cube object. */ void Blobber::load(Cube &cube) { - Table tbl(getBlobName()); - cube.read(tbl); + Table tbl = cube.readTable(getBlobName()); TableField data = tbl[0][getFieldName()]; if (data.isDouble()) { loadDouble(tbl); diff --git a/isis/src/base/objs/CSMCamera/CSMCamera.cpp b/isis/src/base/objs/CSMCamera/CSMCamera.cpp index f649241331..427d44a690 100644 --- a/isis/src/base/objs/CSMCamera/CSMCamera.cpp +++ b/isis/src/base/objs/CSMCamera/CSMCamera.cpp @@ -19,6 +19,7 @@ find files of those names at the top level of this repository. **/ #include #include +#include "Blob.h" #include "CameraDetectorMap.h" #include "CameraDistortionMap.h" #include "CameraFocalPlaneMap.h" @@ -32,7 +33,6 @@ find files of those names at the top level of this repository. **/ #include "LinearAlgebra.h" #include "NaifStatus.h" #include "SpecialPixel.h" -#include "StringBlob.h" #include "csm/Warning.h" #include "csm/Error.h" @@ -52,12 +52,13 @@ namespace Isis { * ISIS Camera Model. */ CSMCamera::CSMCamera(Cube &cube) : Camera(cube) { - StringBlob state("","CSMState"); + Blob state("CSMState", "String"); cube.read(state); PvlObject &blobLabel = state.Label(); QString pluginName = blobLabel.findKeyword("PluginName")[0]; QString modelName = blobLabel.findKeyword("ModelName")[0]; - init(cube, pluginName, modelName, QString::fromStdString(state.string())); + QString stateString = QString::fromUtf8(state.getBuffer(), state.Size()); + init(cube, pluginName, modelName, stateString); } diff --git a/isis/src/base/objs/CSMCamera/CSMCamera.h b/isis/src/base/objs/CSMCamera/CSMCamera.h index 65dbde302f..a2d50664b1 100644 --- a/isis/src/base/objs/CSMCamera/CSMCamera.h +++ b/isis/src/base/objs/CSMCamera/CSMCamera.h @@ -21,7 +21,6 @@ find files of those names at the top level of this repository. **/ #include "csm/RasterGM.h" namespace Isis { - class StringBlob; class CSMCamera : public Camera { public: diff --git a/isis/src/base/objs/CameraFactory/CameraFactory.cpp b/isis/src/base/objs/CameraFactory/CameraFactory.cpp index 605d890e0c..e32b7a1d48 100644 --- a/isis/src/base/objs/CameraFactory/CameraFactory.cpp +++ b/isis/src/base/objs/CameraFactory/CameraFactory.cpp @@ -50,7 +50,7 @@ namespace Isis { try { // Is there a CSM blob on the cube? - if (cube.hasBlob("String", "CSMState")) { + if (cube.hasBlob("CSMState", "String")) { // Create ISIS CSM Camera Model try { return new CSMCamera(cube); diff --git a/isis/src/base/objs/Cube/Cube.cpp b/isis/src/base/objs/Cube/Cube.cpp index 5956137bbc..95e265df68 100644 --- a/isis/src/base/objs/Cube/Cube.cpp +++ b/isis/src/base/objs/Cube/Cube.cpp @@ -17,22 +17,29 @@ find files of those names at the top level of this repository. **/ #include #include "Application.h" +#include "Blob.h" #include "Camera.h" #include "CameraFactory.h" #include "CubeAttribute.h" #include "CubeBsqHandler.h" #include "CubeTileHandler.h" +#include "CubeStretch.h" #include "Endian.h" #include "FileName.h" +#include "History.h" #include "ImageHistogram.h" +#include "ImagePolygon.h" #include "IException.h" #include "LineManager.h" #include "Message.h" +#include "OriginalLabel.h" +#include "OriginalXmlLabel.h" #include "Preference.h" #include "ProgramLauncher.h" #include "Projection.h" #include "SpecialPixel.h" #include "Statistics.h" +#include "Table.h" #include "TProjection.h" #include "Longitude.h" @@ -830,6 +837,131 @@ namespace Isis { } + /** + * Read the History from the Cube. + * + * @param name The name of the History Blob to read. This is used for reading + * History from Cubes made prior to the History Blob name being + * standardized. + */ + History Cube::readHistory(const QString &name) const { + Blob historyBlob(name, "History"); + try { + // read history from cube, if it exists. + read(historyBlob); + } + catch (IException &) { + // if the history does not exist in the cube, this function creates it. + } + History history(historyBlob); + return history; + } + + + /** + * Read the footprint polygon for the Cube. + * + * @return @b ImagePolygon + */ + ImagePolygon Cube::readFootprint() const { + Blob footprintBlob("Footprint", "Polygon"); + try { + // read history from cube, if it exists. + read(footprintBlob); + } + catch (IException &e) { + QString msg = "Footprintinit must be run prior to reading the footprint"; + msg += " with POLYGON=TRUE for cube [" + fileName() + "]"; + throw IException(e, IException::User, msg, _FILEINFO_); + } + ImagePolygon footprint(footprintBlob); + return footprint; + } + + + /** + * Read the original PDS3 label from a cube. + * + * @param name The name of the OriginalLabel Blob + * + * @return @b OriginalLabel The original PDS3 label as a PVL document + */ + OriginalLabel Cube::readOriginalLabel(const QString &name) const { + Blob origLabelBlob(name, "OriginalLabel"); + try { + read(origLabelBlob); + } + catch (IException &e){ + QString msg = "Unable to locate OriginalLabel in " + fileName(); + throw IException(e, IException::User, msg, _FILEINFO_); + } + OriginalLabel origLabel(origLabelBlob); + return origLabel; + } + + + /** + * Read a Stretch from a cube. + * + * @param name The name of the Stretch Blob + * @param keywords A set of keywords and values to match in the Stretch Blob label. + * This can be used to read the stretch for a specific band. + * + * @return @b CubeStretch + */ + CubeStretch Cube::readCubeStretch(QString name, const std::vector keywords) const { + Blob stretchBlob(name, "Stretch"); + try { + read(stretchBlob, keywords); + } + catch (IException &e){ + QString msg = "Unable to locate Stretch information in " + fileName(); + throw IException(e, IException::User, msg, _FILEINFO_); + } + CubeStretch cubeStretch(stretchBlob); + return stretchBlob; + } + + + /** + * Read the original PDS4 label from a cube. + * + * @return @b OriginalXmlLabel The original PDS4 label as an XML document + */ + OriginalXmlLabel Cube::readOriginalXmlLabel() const { + Blob origXmlLabelBlob("IsisCube", "OriginalXmlLabel"); + try { + read(origXmlLabelBlob); + } + catch (IException &e){ + QString msg = "Unable to locate OriginalXmlLabel in " + fileName(); + throw IException(e, IException::User, msg, _FILEINFO_); + } + OriginalXmlLabel origXmlLabel(origXmlLabelBlob); + return origXmlLabel; + } + + + /** + * Read a Table from the cube. + * + * @param name The name of the Table to read + * + * @return @b Table + */ + Table Cube::readTable(const QString &name) { + Blob tableBlob(name, "Table"); + try { + read(tableBlob); + } + catch (IException &e) { + QString msg = "Failed to read table [" + name + "] from cube [" + fileName() + "]."; + throw IException(e, IException::Programmer, msg, _FILEINFO_); + } + return Table(tableBlob); + } + + /** * This method will write a blob of data (e.g. History, Table, etc) * to the cube as specified by the contents of the Blob object. @@ -892,15 +1024,91 @@ namespace Isis { throw IException(IException::Io, message, _FILEINFO_); } -// Changed to work with mods to FileName class -// blob.Write(p_cube.label,detachedStream,blobFileName.baseName()+"."+ -// blob.Type()+"."+ -// blobFileName.extension()); blob.Write(*m_label, detachedStream, blobFileName.name()); } } + /** + * This method will write an OriginalLabel object. + * to the cube as specified by the contents of the Blob object. + * + * @param Original label data to be written + */ + void Cube::write(OriginalLabel &lab) { + Blob labelBlob = lab.toBlob(); + write(labelBlob); + } + + + /** + * This method will write an OriginalXmlLabel object. + * to the cube as specified by the contents of the Blob object. + * + * @param Original xml label data to be written + */ + void Cube::write(const OriginalXmlLabel &lab) { + Blob labelBlob = lab.toBlob(); + write(labelBlob); + } + + + /** + * Write a Table to the Cube. + * + * The Table will be written to the Cube as a BLOB and can be accessed + * using Cube::readTable. + * + * @param table The table to write to the Cube + */ + void Cube::write(const Table &table) { + Blob tableBlob = table.toBlob(); + write(tableBlob); + } + + + /** + * Write a Stretch to the Cube + * + * The stretch will be written to the Cube as a BLOB and can be accessed + * using Cube::readCubeStretch. + * + * @param cubeStretch The stretch to write to the Cube. + */ + void Cube::write(const CubeStretch &cubeStretch) { + Blob cubeStretchBlob = cubeStretch.toBlob(); + write(cubeStretchBlob); + } + + + /** + * Write an updated History to the Cube + * + * The History will be written to the Cube as a BLOB and can be accessed + * using Cube::readHistory. + * + * @param history The history to write to the Cube. + * @param name The name for the history BLOB. This is used for backwards compatibility + * with cubes from before the History BLOB name was standardized. + */ + void Cube::write(History &history, const QString &name) { + Blob histBlob = history.toBlob(name); + write(histBlob); + } + + + /** + * Write a polygon to the Cube + * + * The polygon will be written to the Cube as a BLOB and can be accessed + * using Cube::readFootprint. + */ + void Cube::write(const ImagePolygon &polygon) { + Blob polyBlob = polygon.toBlob(); + write(polyBlob); + } + + /** * This method will write a buffer of data from the cube as specified by the * contents of the Buffer object. @@ -1740,11 +1948,11 @@ namespace Isis { * Blob type and name. If blob does not exist it will do nothing and return * false. * - * @param BlobType type of blob to search for (Polygon, Table, etc) * @param BlobName blob to be deleted + * @param BlobType type of blob to search for (Polygon, Table, etc) * @return boolean if it found the blob and deleted it. */ - bool Cube::deleteBlob(QString BlobType, QString BlobName) { + bool Cube::deleteBlob(QString BlobName, QString BlobType) { for(int i = 0; i < m_label->objects(); i++) { PvlObject obj = m_label->object(i); if (obj.name().compare(BlobType) == 0) { @@ -1803,12 +2011,12 @@ namespace Isis { /** * Check to see if the cube contains a BLOB. * - * @param type The type of the BLOB to search for * @param name The name of the BLOB to search for + * @param type The type of the BLOB to search for * * @return bool True if the BLOB was found */ - bool Cube::hasBlob(const QString &type, const QString &name) { + bool Cube::hasBlob(const QString &name, const QString &type) { for(int o = 0; o < label()->objects(); o++) { PvlObject &obj = label()->object(o); if (obj.isNamed(type)) { @@ -1833,7 +2041,7 @@ namespace Isis { * @return bool True if the pvl table was found */ bool Cube::hasTable(const QString &name) { - return hasBlob("Table", name); + return hasBlob(name, "Table"); } diff --git a/isis/src/base/objs/Cube/Cube.h b/isis/src/base/objs/Cube/Cube.h index 010136e235..089e08c79d 100644 --- a/isis/src/base/objs/Cube/Cube.h +++ b/isis/src/base/objs/Cube/Cube.h @@ -31,12 +31,19 @@ namespace Isis { class CubeAttributeOutput; class CubeCachingAlgorithm; class CubeIoHandler; + class CubeStretch; class FileName; class Projection; class Pvl; class PvlGroup; class Statistics; + class Table; class Histogram; + class History; + class OriginalLabel; + class OriginalXmlLabel; + class ImagePolygon; + /** * @brief IO Handler for Isis Cubes. @@ -248,7 +255,20 @@ namespace Isis { void read(Blob &blob, const std::vector keywords = std::vector()) const; void read(Buffer &rbuf) const; + OriginalLabel readOriginalLabel(const QString &name="IsisCube") const; + CubeStretch readCubeStretch(QString name="CubeStretch", + const std::vector keywords = std::vector()) const; + OriginalXmlLabel readOriginalXmlLabel() const; + History readHistory(const QString &name = "IsisCube") const; + ImagePolygon readFootprint() const; + Table readTable(const QString &name); void write(Blob &blob, bool overwrite=true); + void write(const Table &table); + void write(const CubeStretch &cubeStretch); + void write(OriginalLabel &lab); + void write(const OriginalXmlLabel &lab); + void write(History &history, const QString &name = "IsisCube"); + void write(const ImagePolygon &polygon); void write(Buffer &wbuf); void setBaseMultiplier(double base, double mult); @@ -295,16 +315,17 @@ namespace Isis { void addCachingAlgorithm(CubeCachingAlgorithm *); void clearIoCache(); - bool deleteBlob(QString BlobType, QString BlobName); + bool deleteBlob(QString BlobName, QString BlobType); void deleteGroup(const QString &group); PvlGroup &group(const QString &group) const; bool hasGroup(const QString &group) const; bool hasTable(const QString &name); - bool hasBlob(const QString &type, const QString &name); + bool hasBlob(const QString &name, const QString &type); void putGroup(const PvlGroup &group); void latLonRange(double &minLatitude, double &maxLatitude, double &minLongitude, double &maxLongitude); + private: void applyVirtualBandsToLabel(); void cleanUp(bool remove); diff --git a/isis/src/base/objs/CubeStretch/CubeStretch.cpp b/isis/src/base/objs/CubeStretch/CubeStretch.cpp index 9c1727da12..a85b6eae1b 100644 --- a/isis/src/base/objs/CubeStretch/CubeStretch.cpp +++ b/isis/src/base/objs/CubeStretch/CubeStretch.cpp @@ -12,23 +12,28 @@ namespace Isis { /** * Constructs a CubeStretch object with default mapping of special pixel values to * themselves and a provided name, and a provided stretch type - * - * @param name Name to use for Stretch - * @param type Type of stretch + * + * @param name Name to use for Stretch + * @param type Type of stretch */ - CubeStretch::CubeStretch(QString name, QString stretchType, int bandNumber) : m_name(name), + CubeStretch::CubeStretch(QString name, QString stretchType, int bandNumber) : m_name(name), m_type(stretchType), m_bandNumber(bandNumber) { } - // Default destructor - CubeStretch::~CubeStretch() { + /** + * Copy constructor for a CubeStretch + */ + CubeStretch::CubeStretch(CubeStretch const& stretch): Stretch(stretch) { + m_name = stretch.getName(); + m_type = stretch.getType(); + m_bandNumber = stretch.getBandNumber(); } /** * Constructs a CubeStretch object from a normal Stretch. - * + * * @param Stretch Stretch to construct the CubeStretch from. */ CubeStretch::CubeStretch(Stretch const& stretch): Stretch(stretch) { @@ -40,7 +45,7 @@ namespace Isis { /** * Constructs a CubeStretch object from a normal Stretch. - * + * * @param Stretch Stretch to construct the CubeStretch from. */ CubeStretch::CubeStretch(Stretch const& stretch, QString stretchType): Stretch(stretch), m_type(stretchType) { @@ -49,33 +54,73 @@ namespace Isis { } + /** + * Constructs a CubeStretch from a Blob. + * + * @param blob The Blob to read data from. + */ + CubeStretch::CubeStretch(Blob blob) : Stretch() { + char *buff = blob.getBuffer(); + std::string stringFromBuffer(buff, blob.Size()); + setName(blob.Label()["Name"][0]); + setType(blob.Label()["StretchType"][0]); + Parse(QString::fromStdString(stringFromBuffer)); + setBandNumber(blob.Label()["BandNumber"][0].toInt()); + } + + + // CubeStretch destructor + CubeStretch::~CubeStretch() { + } + + + /** + * Serialize the CubeStretch to a Blob. + * + * The stretch will be serialized as a string. See Stretch::Text for more information. + * + * @return @b Blob a Blob containing the stretch data. + */ + Isis::Blob CubeStretch::toBlob() const { + Isis::Blob blob("CubeStretch", "Stretch"); + + blob.Label()["Name"] = getName(); + blob.Label() += PvlKeyword("StretchType", getType()); + blob.Label() += PvlKeyword("BandNumber", QString::number(getBandNumber())); + std::string blobString = Text().toStdString(); + blob.setData(blobString.c_str(), blobString.size()); + return blob; + } + + /** * Check if the CubeStretches are equal - * + * * @param stretch2 The stretch to compare with - * + * * @return bool True if stretches are equal. Else, false. */ bool CubeStretch::operator==(CubeStretch& stretch2) { - return (getBandNumber() == stretch2.getBandNumber()) && + return (getBandNumber() == stretch2.getBandNumber()) && (getName() == stretch2.getName()) && (Text() == stretch2.Text()); } + /** * Get the Type of Stretch. - * - * @return QString Type of Stretch. + * + * @return QString Type of Stretch. */ - QString CubeStretch::getType(){ + QString CubeStretch::getType() const{ return m_type; } /** * Set the type of Stretch. - * - * @param QString Type of Stretch. + * + * @param QString Type of Stretch. */ void CubeStretch::setType(QString stretchType){ m_type = stretchType; @@ -84,7 +129,7 @@ namespace Isis { /** * Set the Stretch name. - * + * * @param QString name for stretch */ void CubeStretch::setName(QString name){ @@ -94,32 +139,30 @@ namespace Isis { /** * Get the Stretch name. - * + * * @return QString name of stretch */ - QString CubeStretch::getName(){ + QString CubeStretch::getName() const{ return m_name; } /** * Get the band number for the stretch. - * + * * @return int band number */ - int CubeStretch::getBandNumber() { + int CubeStretch::getBandNumber() const{ return m_bandNumber; } /** * Set the band number for the stretch. - * + * * @param int band number */ void CubeStretch::setBandNumber(int bandNumber) { m_bandNumber = bandNumber; } } // end namespace isis - - diff --git a/isis/src/base/objs/CubeStretch/CubeStretch.h b/isis/src/base/objs/CubeStretch/CubeStretch.h index 90143362eb..977fad46f1 100644 --- a/isis/src/base/objs/CubeStretch/CubeStretch.h +++ b/isis/src/base/objs/CubeStretch/CubeStretch.h @@ -9,12 +9,13 @@ find files of those names at the top level of this repository. **/ /* SPDX-License-Identifier: CC0-1.0 */ #include "Stretch.h" +#include "Blob.h" namespace Isis { /** - * @brief Stores stretch information for a cube. Stores stretch pairs, - * band number associated with the stretch, and the stretch type from - * the Advanced Stretch Tool (or 'Default' if not specified) + * @brief Stores stretch information for a cube. Stores stretch pairs, + * band number associated with the stretch, and the stretch type from + * the Advanced Stretch Tool (or 'Default' if not specified) * * @ingroup Utility * @@ -23,31 +24,34 @@ namespace Isis { * @internal * @history 2020-07-28 Kristin Berry - Original Version */ - class CubeStretch : public Stretch { - public: + class CubeStretch : public Stretch { + public: CubeStretch(QString name="DefaultStretch", QString stretchType="Default", int bandNumber = 1); - ~CubeStretch(); + CubeStretch(CubeStretch const& stretch); CubeStretch(Stretch const& stretch); CubeStretch(Stretch const& stretch, QString type); + CubeStretch(Blob blob); + ~CubeStretch(); bool operator==(CubeStretch& stretch2); - QString getType(); + Isis::Blob toBlob() const; + + QString getType() const; void setType(QString stretchType); - QString getName(); + QString getName() const; void setName(QString name); - int getBandNumber(); + int getBandNumber() const; void setBandNumber(int bandNumber); - - private: - QString m_name; //! The name of the stretch. + + private: + QString m_name; //! The name of the stretch. QString m_type; //! Type of stretch. This is only currently used in the AdvancedStretchTool. int m_bandNumber; //! The band number associated with this stretch }; -}; +}; #endif - diff --git a/isis/src/base/objs/GisBlob/GisBlob.cpp b/isis/src/base/objs/GisBlob/GisBlob.cpp deleted file mode 100644 index db6f6d0edc..0000000000 --- a/isis/src/base/objs/GisBlob/GisBlob.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include "GisBlob.h" - -// Qt library -#include -#include - -// other ISIS -#include "Blob.h" -#include "Cube.h" - -namespace Isis { - - /** - * Constructs an Isis polygon-type Blob named "Footprint." - */ - GisBlob::GisBlob() : Blob("Footprint", "Polygon"), m_wkt() { - } - - - /** - * Constructs an Isis polygon-type Blob named "Footprint" and sets the - * well-known text string that defines the polygon by reading the - * given cube. - * @param cube - */ - GisBlob::GisBlob(Cube &cube) : Blob("Footprint", "Polygon"), m_wkt() { - cube.read(*this); - m_wkt = scrub(p_buffer, p_nbytes); - } - - - /** - * Destroys the GisBlob object. - */ - GisBlob::~GisBlob() { - } - - - /** - * Accesses the well-known text string that defines the polygon. - * - * @return QString A well-known text string containing the polygon definition. - */ - QString GisBlob::polygon() const { - return (m_wkt); - } - - - /** - * Sets the polygon using the given well-known text string. - * - * @param wkt A string containing the well-known text that defines a polygon. - */ - void GisBlob::setPolygon(const QString &wkt) { - delete [] p_buffer; - p_nbytes = wkt.size(); - p_buffer = new char[p_nbytes+1]; - for (int i = 0 ; i < p_nbytes ; i++) { - p_buffer[i] = wkt[i].toLatin1(); - } - p_buffer[p_nbytes] = 0; - m_wkt = scrub(p_buffer, p_nbytes); - return; - } - - - /** - * This method will scrub all zeros that prefix the given buffer and convert - * it to a string using the number of allocated bytes given. - * - * @param rawbuf A pointer containing the raw buffer to be converted. - * @param rbytes The number of bytes to be read in. - * - * @return QString A string converted from the given raw buffer. - */ - QString GisBlob::scrub(const char *rawbuf, int rbytes) const { - int i; - for (i = 0 ; i < rbytes ; i++) { - if (rawbuf[i] != 0) break; - } - int nbytes = rbytes - i; - return (QString::fromLatin1(&rawbuf[i], nbytes)); - } - -} // Namespace Isis diff --git a/isis/src/base/objs/GisBlob/GisBlob.h b/isis/src/base/objs/GisBlob/GisBlob.h deleted file mode 100644 index 6ca28e6242..0000000000 --- a/isis/src/base/objs/GisBlob/GisBlob.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef GisBlob_h -#define GisBlob_h -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ - -// parent class -#include "Blob.h" - -// Qt library -#include - -namespace Isis { - class Cube; - - /** - * This class creates a polygon-type Isis Blob named "Footprint". It inherits - * from the Isis Blob class. This Blob may be read from a given cube or the - * polygon maybe set using a wkt polygon string. - * - * @author 2012-07-15 Kris Becker - * @internal - * @history 2012-07-15 Kris Becker - Original version. - * @history 2015-03-18 Jeannie Backer - Brought class files closer to ISIS coding standards. - * @history 2015-03-31 Jeannie Backer - Updated documentation. - * @history 2016-03-02 Ian Humphrey - Updated for coding standards compliance in preparation - * for adding this class to ISIS. Fixes #2398. - */ - class GisBlob : public Blob { - public: - GisBlob(); - - GisBlob(Cube &cube); - - ~GisBlob(); - - QString polygon() const; - - void setPolygon(const QString &wkt); - - private: - QString scrub(const char *rawbuf, int rbytes) const; - - QString m_wkt; //!< Well-known text string containing the polygon defintion for this GIS blob. - }; -} // Namespace Isis - -#endif - - diff --git a/isis/src/base/objs/GisBlob/GisBlob.truth b/isis/src/base/objs/GisBlob/GisBlob.truth deleted file mode 100644 index ee75776376..0000000000 --- a/isis/src/base/objs/GisBlob/GisBlob.truth +++ /dev/null @@ -1,9 +0,0 @@ - -Testing GisBlob's constructor from cube... - Polygon = "MULTIPOLYGON (((291.6482444065063646 54.0748894594413585, 291.7020280173438778 54.0296213291622252, 291.7549863030990878 53.9855163702604841, 291.8077241043083063 53.9408969996877730, 291.8597668189949559 53.8946553693238144, 291.9115817220681492 53.8481113710558290, 291.9632972250017247 53.8015908846553899, 292.0149168432692477 53.7550951640192096, 292.0663616370068212 53.7084560328413261, 292.1175651154498496 53.6615584860058590, 292.1685668928934660 53.6145070190250905, 292.2194413771372865 53.5674528855087715, 292.2702805486716215 53.5205538615438172, 292.3211200787451389 53.4738490257722603, 292.3718951696537829 53.4272104110366328, 292.4225915190824026 53.3806060588361007, 292.4731960443905336 53.3340102581895863, 292.5235491233975154 53.2871937647895280, 292.5737242366652140 53.2402789357434756, 292.6237816497238668 53.1933537780923942, 292.6739185641310428 53.1466663964377020, 292.7240335911182001 53.1000657976819284, 292.7739222679502973 53.0533009388871761, 292.8232431340212543 53.0060022579488432, 292.8720776771814371 52.9583140917663684, 292.9205947272178037 52.9104549807315365, 292.9693168006734822 52.8629718702368621, 293.0180243131512725 52.8156123812802676, 293.0664607895325844 52.7681230400179473, 293.1152230547680801 52.7210579699985686, 293.1641964887326139 52.6742723067946770, 293.2131949281665584 52.6275784848334709, 293.2619983325158728 52.5807860608043711, 293.3106949564739807 52.5339721869144824, 293.3593726059783080 52.4872032262072921, 293.4080105056222578 52.4404570781291142, 293.4564648886776581 52.3936281659687495, 293.5048154773041347 52.3467767520141436, 293.5532286649856815 52.3000111651323678, 293.6016151052821215 52.2532636570787332, 293.6496102604362477 52.2063096901261545, 293.6972856371680223 52.1592109716392258, 293.7448142048647810 52.1120784019265457, 293.7921346113900540 52.0648815632344082, 293.8392722446478729 52.0176397744607399, 293.8863180705967579 51.9704024852086377, 293.9335962428397693 51.9233227111062661, 293.9808809459452732 51.8762775325007652, 294.0278825655254309 51.8291340534371301, 294.0748257771958833 51.7819966404094458, 294.1217863418343086 51.7348933433405946, 294.1686076850560312 51.6877577856796790, 294.2154245767899283 51.6406415633166205, 294.2621689200627770 51.5935160974246045, 294.3088424299793928 51.5463808135885628, 294.3554786257141132 51.4992452332349870, 294.4020474869581676 51.4520976068226830, 294.4487032212942950 51.4049811909859713, 294.4952914913296240 51.3578458802051472, 294.5418969895747523 51.3107127023418883, 294.5884347400872798 51.2635564562394208, 294.6348785316565682 51.2163704162111344, 294.6813714906026576 51.1691860297657186, 294.7276923109479299 51.1219529737556186, 294.7738344522448415 51.0746736215991461, 294.8197718395178981 51.0273470951758696, 294.8654929360217238 50.9799761011058834, 294.9112626249865343 50.9326058392748848, 294.9571326309937263 50.8852385824861955, 295.0028081042060535 50.8378299359886867, 295.0483599950314328 50.7903921654531985, 295.0938159376023577 50.7429295926595358, 295.1394393952502355 50.6954672716803998, 295.1849886311760542 50.6479769473739339, 295.2302510328869403 50.6004433494925010, 295.2751700987382151 50.5528698438340527, 295.3200302318319359 50.5052789709472236, 295.3651817746400638 50.4576837161567440, 295.4102514173258101 50.4100616461730695, 295.4554187475314393 50.3624162955004522, 295.5005451617301446 50.3147411900532333, 295.5454941248207774 50.2670354744187762, 295.5901264260956509 50.2193036524553094, 295.6345902381398218 50.1715496780019024, 295.6788486553651296 50.1237772068778114, 295.7231187033184483 50.0759813438211268, 295.7673408602476002 50.0281624317159554, 295.8116127406512987 49.9803140857962518, 295.8560810864870518 49.9324232409902393, 295.9005769971004156 49.8844953496522550, 295.9446838645065441 49.8365625667986407, 295.9886221285325405 49.7886128304107629, 296.0323211243245396 49.7406556427859172, 296.0759910747153185 49.6926722818829845, 296.1194565103898526 49.6446821048827829, 296.1624897088751709 49.5967167487294276, 296.2054086607993213 49.5487424737293551, 296.2484396719925712 49.5007281817789533, 296.2915134711480505 49.4526796665121608, 296.3350389573967618 49.4045300978008015, 296.3786114499501991 49.3563338330455679, 296.4222302019360313 49.3080883623094124, 296.4656892412461389 49.2598280749685955, 296.4782574023010966 49.2419677041339625, 296.4032185014780225 49.2138422027338365, 296.3291599281647564 49.1861284721513243, 296.2549758604650378 49.1584150628567116, 296.1805181984752267 49.1307377732130348, 296.1059958275960753 49.1030596410174311, 296.0319753508879330 49.0752577913664254, 295.9588442320529111 49.0472336740290160, 295.8861134027861226 49.0190860042944365, 295.8124228918390486 48.9911441745806684, 295.7382596561083119 48.9633095596598835, 295.6644117428859886 48.9353885153610904, 295.5913488263511795 48.9072473769558513, 295.5188683870677551 48.8789250825906123, 295.4460786412217885 48.8506686873925204, 295.3732701352031427 48.8224019007348673, 295.2999915852694244 48.7942691567235656, 295.2264283102026639 48.7662284257375518, 295.1533647828368316 48.7380309852390639, 295.0810040310718705 48.7095944639431977, 295.0091863998481472 48.6809554786322849, 294.9373959127930220 48.6522880295360594, 294.8652730269428730 48.6237309200630392, 294.7932479399684667 48.5951308767385797, 294.7213583334407758 48.5664725545892892, 294.6494236802788578 48.5378302049381105, 294.5773206088004486 48.5092633660961496, 294.5054333742040171 48.4806113445442151, 294.4346026686405366 48.4514789854476291, 294.3647067933559924 48.4218794804552743, 294.2947492459967975 48.3922649000824663, 294.2238142620729491 48.3631107066558954, 294.1527610573676839 48.3340145652618460, 294.0815147202526987 48.3050286789722350, 294.0099980936771544 48.2762131959080136, 293.9382460173290497 48.2475698037275080, 293.8668697140522568 48.2187474532939362, 293.7962609736145509 48.1894822988117610, 293.7255394666512416 48.1603063113648275, 293.6547781318735133 48.1311843990246970, 293.5843065515867352 48.1018949307871537, 293.5141586740939488 48.0723985331187009, 293.4444700902735121 48.0425737339503200, 293.3749064547343437 48.0126509102984969, 293.3050575999341731 47.9829593986607890, 293.2352034076224072 47.9532950309601915, 293.1654531168650806 47.9235700964377784, 293.0958477939764748 47.8937448880645533, 293.0263787567034228 47.8638207881203996, 292.9568858384029113 47.8339501037519241, 292.8874362986734923 47.8040757589463183, 292.8180445861410703 47.7741872572646500, 292.7487592169084678 47.7442337012970270, 292.6796079813448159 47.7141793537199916, 292.6105254595862561 47.6840965526444549, 292.5414489407279461 47.6540678195429379, 292.4724300337906016 47.6240374558369268, 292.4035989135194882 47.5938277490541424, 292.3350381260194695 47.5632960657097072, 292.2666059363026534 47.5326200150254294, 292.1981252697848390 47.5020738206643074, 292.1295887369751654 47.4716991949019018, 292.0611460375269530 47.4412605827019220, 291.9928009984063806 47.4107468251615103, 291.9245641102601780 47.3801307584919442, 291.8563543684800266 47.3495759935504452, 291.7882006024591419 47.3190364969257899, 291.7201019385726113 47.2885256469011352, 291.6521393383902705 47.2578461482878325, 291.5843787631462760 47.2267846937686215, 291.5168317396303905 47.1952282052031080, 291.4492464832235896 47.1638894034807024, 291.3816293898299818 47.1328167907642452, 291.3140627606528597 47.1017797901754420, 291.2465582098835739 47.0707529404682532, 291.1791118217741996 47.0397717627595284, 291.1117364145860620 47.0087996190138426, 291.0444662616026221 46.9776521074006155, 290.9772966918184238 46.9463014906870910, 290.9102084353484088 46.9148200635959469, 290.8431866098990213 46.8832984418343415, 290.7762173982538911 46.8519018482588834, 290.7093152517370527 46.8205640770849811, 290.6424914170170837 46.7891699520966071, 290.5757490817570670 46.7575740040825778, 290.5090796708282710 46.7257398497000977, 290.4424748469443784 46.6939354890210154, 290.3759385704620968 46.6621558917914996, 290.3094735853126735 46.6303799301904860, 290.2430782179271773 46.5985395060219361, 290.1767412655061662 46.5665028466696711, 290.1104620752193455 46.5343432693806136, 290.0442657086978215 46.5023241289388807, 289.9781432507954264 46.4703032081830543, 289.9120787066955813 46.4381525977341951, 289.8460907244865439 46.4060177803553273, 289.7802251110452403 46.3741527167005287, 289.7144742069608583 46.3424423196200763, 289.6488095562927469 46.3107023232924249, 289.5832003916290205 46.2787873333416186, 289.5176388907983096 46.2466885757636845, 289.4520462285495341 46.2141017607484343, 289.3864267339227467 46.1811141464289676, 289.3618561776004867 46.1711714273995071, 289.3147779156129218 46.2173242257311614, 289.2682700210863231 46.2625948223290919, 289.2216498274489140 46.3077334989910909, 289.1748745355735650 46.3526214941802124, 289.1280376293947256 46.3975741281184426, 289.0812223379438706 46.4428210011357905, 289.0343472417508792 46.4880973442382484, 288.9874257852919186 46.5334322049573217, 288.9405044417976569 46.5789322394382452, 288.8934837043753419 46.6243341170829027, 288.8463427575331366 46.6695988190028146, 288.7991799003812048 46.7149574330253188, 288.7519302493046780 46.7602581950852993, 288.7044789857983460 46.8052713999669052, 288.6569388683359421 46.8502485880938977, 288.6094424913905527 46.8954406931386885, 288.5620397675693312 46.9409105839929666, 288.5146096371197473 46.9864133831112767, 288.4669533014785543 47.0316098743400701, 288.4189979084742959 47.0764138053209535, 288.3708092782399603 47.1209678506684355, 288.3225205926835883 47.1654960549336408, 288.2743455744467838 47.2103062528499819, 288.2260406104195454 47.2550301230308776, 288.1776038116196332 47.2996724655994498, 288.1290910621896728 47.3443118275832120, 288.0806004866909689 47.3890679637712893, 288.0320864200181177 47.4338721088212836, 287.9835128725551385 47.4786755144914636, 287.9348544417925382 47.5234476156226791, 287.8860935537533692 47.5681703825700382, 287.8372773616805489 47.6128949787879847, 287.7883288015262906 47.6575421974380475, 287.7393085634204795 47.7021757070334687, 287.6902605832405015 47.7468350283393193, 287.6410876324868013 47.7914283366073178, 287.5917481486421821 47.8359242643672431, 287.5423471737791488 47.8804175478147940, 287.4929818798205474 47.9249836617375706, 287.4435300772136657 47.9695183131695515, 287.3939311769159985 48.0139770798353211, 287.3442363755654014 48.0584018935020794, 287.2944182676178571 48.1027748648423952, 287.2447020877938826 48.1472485026180692, 287.1950591428314397 48.1917908022441068, 287.1452952545445783 48.2362713471827362, 287.0953441578890875 48.2806539821297562, 287.0451863503462278 48.3249349211713550, 286.9949077614967337 48.3691695420140064, 286.9444735218841629 48.4133416921263873, 286.8940363669749445 48.4575332864047326, 286.8434760753363548 48.5016805430202851, 286.7926138665326903 48.5457016207637011, 286.7414943640096112 48.5896286026594737, 286.6903929526483807 48.6335896342714165, 286.6393507379582388 48.6775956709724866, 286.5883160953767970 48.7216182199543653, 286.5371352461281163 48.7655935946100314, 286.4858893720233937 48.8095542615773539, 286.4345830897714222 48.8535006122709063, 286.3831420753027146 48.8974063618426840, 286.3313949286018101 48.9412186275038579, 286.2794287606336638 48.9849733476629297, 286.2271237527501171 49.0286407173921361, 286.1747934942748657 49.0723176450905072, 286.1226207794685479 49.1160491477687486, 286.0705778239361052 49.1598179149401204, 286.0185387849462586 49.2035851470715215, 285.9663555293917057 49.2473136664860647, 285.9139828228739475 49.2909956681908312, 285.8615048751227050 49.3346515723928292, 285.8089409308830682 49.3782853448059882, 285.7561709971500932 49.4218750455458391, 285.7033744198886325 49.4654544937027154, 285.6505294182767898 49.5090178755621935, 285.5977727123407135 49.5525837744106425, 285.5447446092979362 49.5960970702829229, 285.4914875549942508 49.6395684556400170, 285.4379846370865152 49.6829997262990304, 285.3843843052756597 49.7264110256648948, 285.3308342690713175 49.7698167182288245, 285.2773646050080174 49.8132152409817408, 285.2239238309639404 49.8565975374196668, 285.1703158928399375 49.8999460743720107, 285.1164481902447960 49.9432567010531869, 285.0625323547681660 49.9865451770147544, 285.0082665476087413 50.0297957865672416, 284.9537084881674787 50.0730166730696595, 284.8991894805907918 50.1162226853946606, 284.8446182125073278 50.1594081318238167, 284.7898601929547908 50.2025694147422996, 284.7349043728681863 50.2457080812009522, 284.6799771552385323 50.2888265780296280, 284.6248540494665917 50.3319228431918049, 284.5695238923811416 50.3749986845891300, 284.5144490571994993 50.4180478736866817, 284.4593856466942725 50.4610690021459973, 284.4040790806055838 50.5040674495806385, 284.3484586308211988 50.5470482927714784, 284.2935341408388581 50.5899723488597601, 284.2391049473005182 50.6328348676932407, 284.1837853403296208 50.6757005534934777, 284.1663273815096318 50.6919534014300766, 284.2345597693270065 50.7277015503154161, 284.3020640473581579 50.7628777224099892, 284.3702656899958470 50.7979746069000484, 284.4387418467628663 50.8330150873104074, 284.5071713340328188 50.8680245376072975, 284.5755687379514143 50.9030045092247363, 284.6443164345435548 50.9379171054902500, 284.7135533824027220 50.9727405217829670, 284.7829461739408430 51.0075059628211491, 284.8521768237749825 51.0422529775025851, 284.9213779308003609 51.0769691887487411, 284.9906032701824756 51.1116495917477351, 285.0598819033065183 51.1462913063788349, 285.1294270280205865 51.1808602737040772, 285.1992202696198433 51.2153549031564808, 285.2689486693911363 51.2498278200912978, 285.3385407699790335 51.2842969395446175, 285.4080991362617965 51.3187480716453166, 285.4778056611060606 51.3531464893620608, 285.5483833920509369 51.3873301698831071, 285.6193015406489053 51.4213979996852473, 285.6897321570879740 51.4555427015166273, 285.7594982587881987 51.4898277189353308, 285.8295266909508996 51.5240324011132174, 285.8995795188444049 51.5582171669147584, 285.9694603052748789 51.5924415814695649, 286.0394555568004762 51.6266293964584264, 286.1098454748561153 51.6606923298506473, 286.1806846868420280 51.6946012555894825, 286.2515634685805139 51.7284818757417852, 286.3217610437835106 51.7625925450240558, 286.3918947636801136 51.7967386371245837, 286.4624479942411881 51.8307423644522842, 286.5336661467025579 51.8644918118881932, 286.6050516772942274 51.8981677383684854, 286.6765569414309311 51.9317872895232000, 286.7481309225292421 51.9653721726498503, 286.8199530521117708 51.9988397589956506, 286.8920127214390163 52.0321867072350770, 286.9640676739491596 52.0655270933311627, 287.0361337373960282 52.0988579772036928, 287.1084521342681342 52.1320521938549248, 287.1808429436290453 52.1652016017904359, 287.2528037265199146 52.1986044777616200, 287.3251766498365214 52.2317791050783669, 287.3976852881675086 52.2648798818484437, 287.4697242670244464 52.2983072795676875, 287.5421226029587842 52.3315320485897573, 287.6148867344307405 52.3645289209294447, 287.6877004396365578 52.3975127478532059, 287.7605440724607888 52.4305033881260840, 287.8332983279560722 52.4636054057247634, 287.9057493954031202 52.4970217668427779, 287.9780316068848265 52.5306795409256608, 288.0504439921309086 52.5643367368246146, 288.1234401644522904 52.5975550143054207, 288.1976382829452064 52.6296474297664219, 288.2721681013861144 52.6613877226737159, 288.3463897438006143 52.6934494034029157, 288.4202322563753569 52.7259736328181674, 288.4939397938130696 52.7587388913465958, 288.5678468760376063 52.7913568215394164, 288.6419218814429541 52.8238536973012103, 288.7165029135949794 52.8557306608363362, 288.7912456624506490 52.8874137480644535, 288.8656727128577586 52.9196471844023790, 288.9400718311589458 52.9520515232037781, 289.0145695908635162 52.9844388557765029, 289.0890412533441349 53.0170554947797967, 289.1635635592601830 53.0497993040304365, 289.2382911325804002 53.0823639878877032, 289.3132195813146836 53.1147272726123987, 289.3882373382535889 53.1471368006245015, 289.4633522768713192 53.1795932616528120, 289.5386395897923535 53.2118916057759463, 289.6140551665824887 53.2441442933252560, 289.6895157143202368 53.2766587857948153, 289.7651099666896926 53.3091747733643402, 289.8409073665112601 53.3413820299417480, 289.9168235491238192 53.3736136015565563, 289.9928758081005071 53.4057942992804442, 290.0690425949051701 53.4380804602550015, 290.1453574173241918 53.4702653414589975, 290.2218095760875372 53.5024220046409624, 290.2983878999274339 53.5347670501741035, 290.3751182413015499 53.5670164502047257, 290.4519987557255263 53.5988030640775577, 290.5290061844957563 53.6305483723634140, 290.6061466002392422 53.6623930165058809, 290.6834140633079642 53.6940874221143645, 290.7608043693315949 53.7256675476979808, 290.8382970713091709 53.7569901973408975, 290.9159587660024044 53.7886645754515271, 290.9938283926157396 53.8207705659212365, 291.0717891428241728 53.8524693735371756, 291.1498394700072367 53.8838731934801629, 291.2279334662110841 53.9148453185582071, 291.3061172279390689 53.9456783680282825, 291.3844357241167131 53.9765654329084370, 291.4627282140606894 54.0069110349376871, 291.5408564454050975 54.0363542888421122, 291.6190588029043624 54.0657945141910190, 291.6482444065063646 54.0748894594413585)))" - -Testing GisBlob's default constructor... - Polygon = "" - -Adding WKT polygon to GisBlob... - Polygon = "MULTIPOLYGON (((291.6482444065063646 54.0748894594413585, 291.7020280173438778 54.0296213291622252, 291.7549863030990878 53.9855163702604841, 291.8077241043083063 53.9408969996877730, 291.8597668189949559 53.8946553693238144, 291.9115817220681492 53.8481113710558290, 291.9632972250017247 53.8015908846553899, 292.0149168432692477 53.7550951640192096, 292.0663616370068212 53.7084560328413261, 292.1175651154498496 53.6615584860058590, 292.1685668928934660 53.6145070190250905, 292.2194413771372865 53.5674528855087715, 292.2702805486716215 53.5205538615438172, 292.3211200787451389 53.4738490257722603, 292.3718951696537829 53.4272104110366328, 292.4225915190824026 53.3806060588361007, 292.4731960443905336 53.3340102581895863, 292.5235491233975154 53.2871937647895280, 292.5737242366652140 53.2402789357434756, 292.6237816497238668 53.1933537780923942, 292.6739185641310428 53.1466663964377020, 292.7240335911182001 53.1000657976819284, 292.7739222679502973 53.0533009388871761, 292.8232431340212543 53.0060022579488432, 292.8720776771814371 52.9583140917663684, 292.9205947272178037 52.9104549807315365, 292.9693168006734822 52.8629718702368621, 293.0180243131512725 52.8156123812802676, 293.0664607895325844 52.7681230400179473, 293.1152230547680801 52.7210579699985686, 293.1641964887326139 52.6742723067946770, 293.2131949281665584 52.6275784848334709, 293.2619983325158728 52.5807860608043711, 293.3106949564739807 52.5339721869144824, 293.3593726059783080 52.4872032262072921, 293.4080105056222578 52.4404570781291142, 293.4564648886776581 52.3936281659687495, 293.5048154773041347 52.3467767520141436, 293.5532286649856815 52.3000111651323678, 293.6016151052821215 52.2532636570787332, 293.6496102604362477 52.2063096901261545, 293.6972856371680223 52.1592109716392258, 293.7448142048647810 52.1120784019265457, 293.7921346113900540 52.0648815632344082, 293.8392722446478729 52.0176397744607399, 293.8863180705967579 51.9704024852086377, 293.9335962428397693 51.9233227111062661, 293.9808809459452732 51.8762775325007652, 294.0278825655254309 51.8291340534371301, 294.0748257771958833 51.7819966404094458, 294.1217863418343086 51.7348933433405946, 294.1686076850560312 51.6877577856796790, 294.2154245767899283 51.6406415633166205, 294.2621689200627770 51.5935160974246045, 294.3088424299793928 51.5463808135885628, 294.3554786257141132 51.4992452332349870, 294.4020474869581676 51.4520976068226830, 294.4487032212942950 51.4049811909859713, 294.4952914913296240 51.3578458802051472, 294.5418969895747523 51.3107127023418883, 294.5884347400872798 51.2635564562394208, 294.6348785316565682 51.2163704162111344, 294.6813714906026576 51.1691860297657186, 294.7276923109479299 51.1219529737556186, 294.7738344522448415 51.0746736215991461, 294.8197718395178981 51.0273470951758696, 294.8654929360217238 50.9799761011058834, 294.9112626249865343 50.9326058392748848, 294.9571326309937263 50.8852385824861955, 295.0028081042060535 50.8378299359886867, 295.0483599950314328 50.7903921654531985, 295.0938159376023577 50.7429295926595358, 295.1394393952502355 50.6954672716803998, 295.1849886311760542 50.6479769473739339, 295.2302510328869403 50.6004433494925010, 295.2751700987382151 50.5528698438340527, 295.3200302318319359 50.5052789709472236, 295.3651817746400638 50.4576837161567440, 295.4102514173258101 50.4100616461730695, 295.4554187475314393 50.3624162955004522, 295.5005451617301446 50.3147411900532333, 295.5454941248207774 50.2670354744187762, 295.5901264260956509 50.2193036524553094, 295.6345902381398218 50.1715496780019024, 295.6788486553651296 50.1237772068778114, 295.7231187033184483 50.0759813438211268, 295.7673408602476002 50.0281624317159554, 295.8116127406512987 49.9803140857962518, 295.8560810864870518 49.9324232409902393, 295.9005769971004156 49.8844953496522550, 295.9446838645065441 49.8365625667986407, 295.9886221285325405 49.7886128304107629, 296.0323211243245396 49.7406556427859172, 296.0759910747153185 49.6926722818829845, 296.1194565103898526 49.6446821048827829, 296.1624897088751709 49.5967167487294276, 296.2054086607993213 49.5487424737293551, 296.2484396719925712 49.5007281817789533, 296.2915134711480505 49.4526796665121608, 296.3350389573967618 49.4045300978008015, 296.3786114499501991 49.3563338330455679, 296.4222302019360313 49.3080883623094124, 296.4656892412461389 49.2598280749685955, 296.4782574023010966 49.2419677041339625, 296.4032185014780225 49.2138422027338365, 296.3291599281647564 49.1861284721513243, 296.2549758604650378 49.1584150628567116, 296.1805181984752267 49.1307377732130348, 296.1059958275960753 49.1030596410174311, 296.0319753508879330 49.0752577913664254, 295.9588442320529111 49.0472336740290160, 295.8861134027861226 49.0190860042944365, 295.8124228918390486 48.9911441745806684, 295.7382596561083119 48.9633095596598835, 295.6644117428859886 48.9353885153610904, 295.5913488263511795 48.9072473769558513, 295.5188683870677551 48.8789250825906123, 295.4460786412217885 48.8506686873925204, 295.3732701352031427 48.8224019007348673, 295.2999915852694244 48.7942691567235656, 295.2264283102026639 48.7662284257375518, 295.1533647828368316 48.7380309852390639, 295.0810040310718705 48.7095944639431977, 295.0091863998481472 48.6809554786322849, 294.9373959127930220 48.6522880295360594, 294.8652730269428730 48.6237309200630392, 294.7932479399684667 48.5951308767385797, 294.7213583334407758 48.5664725545892892, 294.6494236802788578 48.5378302049381105, 294.5773206088004486 48.5092633660961496, 294.5054333742040171 48.4806113445442151, 294.4346026686405366 48.4514789854476291, 294.3647067933559924 48.4218794804552743, 294.2947492459967975 48.3922649000824663, 294.2238142620729491 48.3631107066558954, 294.1527610573676839 48.3340145652618460, 294.0815147202526987 48.3050286789722350, 294.0099980936771544 48.2762131959080136, 293.9382460173290497 48.2475698037275080, 293.8668697140522568 48.2187474532939362, 293.7962609736145509 48.1894822988117610, 293.7255394666512416 48.1603063113648275, 293.6547781318735133 48.1311843990246970, 293.5843065515867352 48.1018949307871537, 293.5141586740939488 48.0723985331187009, 293.4444700902735121 48.0425737339503200, 293.3749064547343437 48.0126509102984969, 293.3050575999341731 47.9829593986607890, 293.2352034076224072 47.9532950309601915, 293.1654531168650806 47.9235700964377784, 293.0958477939764748 47.8937448880645533, 293.0263787567034228 47.8638207881203996, 292.9568858384029113 47.8339501037519241, 292.8874362986734923 47.8040757589463183, 292.8180445861410703 47.7741872572646500, 292.7487592169084678 47.7442337012970270, 292.6796079813448159 47.7141793537199916, 292.6105254595862561 47.6840965526444549, 292.5414489407279461 47.6540678195429379, 292.4724300337906016 47.6240374558369268, 292.4035989135194882 47.5938277490541424, 292.3350381260194695 47.5632960657097072, 292.2666059363026534 47.5326200150254294, 292.1981252697848390 47.5020738206643074, 292.1295887369751654 47.4716991949019018, 292.0611460375269530 47.4412605827019220, 291.9928009984063806 47.4107468251615103, 291.9245641102601780 47.3801307584919442, 291.8563543684800266 47.3495759935504452, 291.7882006024591419 47.3190364969257899, 291.7201019385726113 47.2885256469011352, 291.6521393383902705 47.2578461482878325, 291.5843787631462760 47.2267846937686215, 291.5168317396303905 47.1952282052031080, 291.4492464832235896 47.1638894034807024, 291.3816293898299818 47.1328167907642452, 291.3140627606528597 47.1017797901754420, 291.2465582098835739 47.0707529404682532, 291.1791118217741996 47.0397717627595284, 291.1117364145860620 47.0087996190138426, 291.0444662616026221 46.9776521074006155, 290.9772966918184238 46.9463014906870910, 290.9102084353484088 46.9148200635959469, 290.8431866098990213 46.8832984418343415, 290.7762173982538911 46.8519018482588834, 290.7093152517370527 46.8205640770849811, 290.6424914170170837 46.7891699520966071, 290.5757490817570670 46.7575740040825778, 290.5090796708282710 46.7257398497000977, 290.4424748469443784 46.6939354890210154, 290.3759385704620968 46.6621558917914996, 290.3094735853126735 46.6303799301904860, 290.2430782179271773 46.5985395060219361, 290.1767412655061662 46.5665028466696711, 290.1104620752193455 46.5343432693806136, 290.0442657086978215 46.5023241289388807, 289.9781432507954264 46.4703032081830543, 289.9120787066955813 46.4381525977341951, 289.8460907244865439 46.4060177803553273, 289.7802251110452403 46.3741527167005287, 289.7144742069608583 46.3424423196200763, 289.6488095562927469 46.3107023232924249, 289.5832003916290205 46.2787873333416186, 289.5176388907983096 46.2466885757636845, 289.4520462285495341 46.2141017607484343, 289.3864267339227467 46.1811141464289676, 289.3618561776004867 46.1711714273995071, 289.3147779156129218 46.2173242257311614, 289.2682700210863231 46.2625948223290919, 289.2216498274489140 46.3077334989910909, 289.1748745355735650 46.3526214941802124, 289.1280376293947256 46.3975741281184426, 289.0812223379438706 46.4428210011357905, 289.0343472417508792 46.4880973442382484, 288.9874257852919186 46.5334322049573217, 288.9405044417976569 46.5789322394382452, 288.8934837043753419 46.6243341170829027, 288.8463427575331366 46.6695988190028146, 288.7991799003812048 46.7149574330253188, 288.7519302493046780 46.7602581950852993, 288.7044789857983460 46.8052713999669052, 288.6569388683359421 46.8502485880938977, 288.6094424913905527 46.8954406931386885, 288.5620397675693312 46.9409105839929666, 288.5146096371197473 46.9864133831112767, 288.4669533014785543 47.0316098743400701, 288.4189979084742959 47.0764138053209535, 288.3708092782399603 47.1209678506684355, 288.3225205926835883 47.1654960549336408, 288.2743455744467838 47.2103062528499819, 288.2260406104195454 47.2550301230308776, 288.1776038116196332 47.2996724655994498, 288.1290910621896728 47.3443118275832120, 288.0806004866909689 47.3890679637712893, 288.0320864200181177 47.4338721088212836, 287.9835128725551385 47.4786755144914636, 287.9348544417925382 47.5234476156226791, 287.8860935537533692 47.5681703825700382, 287.8372773616805489 47.6128949787879847, 287.7883288015262906 47.6575421974380475, 287.7393085634204795 47.7021757070334687, 287.6902605832405015 47.7468350283393193, 287.6410876324868013 47.7914283366073178, 287.5917481486421821 47.8359242643672431, 287.5423471737791488 47.8804175478147940, 287.4929818798205474 47.9249836617375706, 287.4435300772136657 47.9695183131695515, 287.3939311769159985 48.0139770798353211, 287.3442363755654014 48.0584018935020794, 287.2944182676178571 48.1027748648423952, 287.2447020877938826 48.1472485026180692, 287.1950591428314397 48.1917908022441068, 287.1452952545445783 48.2362713471827362, 287.0953441578890875 48.2806539821297562, 287.0451863503462278 48.3249349211713550, 286.9949077614967337 48.3691695420140064, 286.9444735218841629 48.4133416921263873, 286.8940363669749445 48.4575332864047326, 286.8434760753363548 48.5016805430202851, 286.7926138665326903 48.5457016207637011, 286.7414943640096112 48.5896286026594737, 286.6903929526483807 48.6335896342714165, 286.6393507379582388 48.6775956709724866, 286.5883160953767970 48.7216182199543653, 286.5371352461281163 48.7655935946100314, 286.4858893720233937 48.8095542615773539, 286.4345830897714222 48.8535006122709063, 286.3831420753027146 48.8974063618426840, 286.3313949286018101 48.9412186275038579, 286.2794287606336638 48.9849733476629297, 286.2271237527501171 49.0286407173921361, 286.1747934942748657 49.0723176450905072, 286.1226207794685479 49.1160491477687486, 286.0705778239361052 49.1598179149401204, 286.0185387849462586 49.2035851470715215, 285.9663555293917057 49.2473136664860647, 285.9139828228739475 49.2909956681908312, 285.8615048751227050 49.3346515723928292, 285.8089409308830682 49.3782853448059882, 285.7561709971500932 49.4218750455458391, 285.7033744198886325 49.4654544937027154, 285.6505294182767898 49.5090178755621935, 285.5977727123407135 49.5525837744106425, 285.5447446092979362 49.5960970702829229, 285.4914875549942508 49.6395684556400170, 285.4379846370865152 49.6829997262990304, 285.3843843052756597 49.7264110256648948, 285.3308342690713175 49.7698167182288245, 285.2773646050080174 49.8132152409817408, 285.2239238309639404 49.8565975374196668, 285.1703158928399375 49.8999460743720107, 285.1164481902447960 49.9432567010531869, 285.0625323547681660 49.9865451770147544, 285.0082665476087413 50.0297957865672416, 284.9537084881674787 50.0730166730696595, 284.8991894805907918 50.1162226853946606, 284.8446182125073278 50.1594081318238167, 284.7898601929547908 50.2025694147422996, 284.7349043728681863 50.2457080812009522, 284.6799771552385323 50.2888265780296280, 284.6248540494665917 50.3319228431918049, 284.5695238923811416 50.3749986845891300, 284.5144490571994993 50.4180478736866817, 284.4593856466942725 50.4610690021459973, 284.4040790806055838 50.5040674495806385, 284.3484586308211988 50.5470482927714784, 284.2935341408388581 50.5899723488597601, 284.2391049473005182 50.6328348676932407, 284.1837853403296208 50.6757005534934777, 284.1663273815096318 50.6919534014300766, 284.2345597693270065 50.7277015503154161, 284.3020640473581579 50.7628777224099892, 284.3702656899958470 50.7979746069000484, 284.4387418467628663 50.8330150873104074, 284.5071713340328188 50.8680245376072975, 284.5755687379514143 50.9030045092247363, 284.6443164345435548 50.9379171054902500, 284.7135533824027220 50.9727405217829670, 284.7829461739408430 51.0075059628211491, 284.8521768237749825 51.0422529775025851, 284.9213779308003609 51.0769691887487411, 284.9906032701824756 51.1116495917477351, 285.0598819033065183 51.1462913063788349, 285.1294270280205865 51.1808602737040772, 285.1992202696198433 51.2153549031564808, 285.2689486693911363 51.2498278200912978, 285.3385407699790335 51.2842969395446175, 285.4080991362617965 51.3187480716453166, 285.4778056611060606 51.3531464893620608, 285.5483833920509369 51.3873301698831071, 285.6193015406489053 51.4213979996852473, 285.6897321570879740 51.4555427015166273, 285.7594982587881987 51.4898277189353308, 285.8295266909508996 51.5240324011132174, 285.8995795188444049 51.5582171669147584, 285.9694603052748789 51.5924415814695649, 286.0394555568004762 51.6266293964584264, 286.1098454748561153 51.6606923298506473, 286.1806846868420280 51.6946012555894825, 286.2515634685805139 51.7284818757417852, 286.3217610437835106 51.7625925450240558, 286.3918947636801136 51.7967386371245837, 286.4624479942411881 51.8307423644522842, 286.5336661467025579 51.8644918118881932, 286.6050516772942274 51.8981677383684854, 286.6765569414309311 51.9317872895232000, 286.7481309225292421 51.9653721726498503, 286.8199530521117708 51.9988397589956506, 286.8920127214390163 52.0321867072350770, 286.9640676739491596 52.0655270933311627, 287.0361337373960282 52.0988579772036928, 287.1084521342681342 52.1320521938549248, 287.1808429436290453 52.1652016017904359, 287.2528037265199146 52.1986044777616200, 287.3251766498365214 52.2317791050783669, 287.3976852881675086 52.2648798818484437, 287.4697242670244464 52.2983072795676875, 287.5421226029587842 52.3315320485897573, 287.6148867344307405 52.3645289209294447, 287.6877004396365578 52.3975127478532059, 287.7605440724607888 52.4305033881260840, 287.8332983279560722 52.4636054057247634, 287.9057493954031202 52.4970217668427779, 287.9780316068848265 52.5306795409256608, 288.0504439921309086 52.5643367368246146, 288.1234401644522904 52.5975550143054207, 288.1976382829452064 52.6296474297664219, 288.2721681013861144 52.6613877226737159, 288.3463897438006143 52.6934494034029157, 288.4202322563753569 52.7259736328181674, 288.4939397938130696 52.7587388913465958, 288.5678468760376063 52.7913568215394164, 288.6419218814429541 52.8238536973012103, 288.7165029135949794 52.8557306608363362, 288.7912456624506490 52.8874137480644535, 288.8656727128577586 52.9196471844023790, 288.9400718311589458 52.9520515232037781, 289.0145695908635162 52.9844388557765029, 289.0890412533441349 53.0170554947797967, 289.1635635592601830 53.0497993040304365, 289.2382911325804002 53.0823639878877032, 289.3132195813146836 53.1147272726123987, 289.3882373382535889 53.1471368006245015, 289.4633522768713192 53.1795932616528120, 289.5386395897923535 53.2118916057759463, 289.6140551665824887 53.2441442933252560, 289.6895157143202368 53.2766587857948153, 289.7651099666896926 53.3091747733643402, 289.8409073665112601 53.3413820299417480, 289.9168235491238192 53.3736136015565563, 289.9928758081005071 53.4057942992804442, 290.0690425949051701 53.4380804602550015, 290.1453574173241918 53.4702653414589975, 290.2218095760875372 53.5024220046409624, 290.2983878999274339 53.5347670501741035, 290.3751182413015499 53.5670164502047257, 290.4519987557255263 53.5988030640775577, 290.5290061844957563 53.6305483723634140, 290.6061466002392422 53.6623930165058809, 290.6834140633079642 53.6940874221143645, 290.7608043693315949 53.7256675476979808, 290.8382970713091709 53.7569901973408975, 290.9159587660024044 53.7886645754515271, 290.9938283926157396 53.8207705659212365, 291.0717891428241728 53.8524693735371756, 291.1498394700072367 53.8838731934801629, 291.2279334662110841 53.9148453185582071, 291.3061172279390689 53.9456783680282825, 291.3844357241167131 53.9765654329084370, 291.4627282140606894 54.0069110349376871, 291.5408564454050975 54.0363542888421122, 291.6190588029043624 54.0657945141910190, 291.6482444065063646 54.0748894594413585)))" diff --git a/isis/src/base/objs/GisBlob/Makefile b/isis/src/base/objs/GisBlob/Makefile deleted file mode 100644 index f122bc8822..0000000000 --- a/isis/src/base/objs/GisBlob/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -ifeq ($(ISISROOT), $(BLANK)) -.SILENT: -error: - echo "Please set ISISROOT"; -else - include $(ISISROOT)/make/isismake.objs -endif \ No newline at end of file diff --git a/isis/src/base/objs/GisBlob/unitTest.cpp b/isis/src/base/objs/GisBlob/unitTest.cpp deleted file mode 100644 index 69d2861870..0000000000 --- a/isis/src/base/objs/GisBlob/unitTest.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include -#include -#include -#include - -#include "Cube.h" -#include "GisBlob.h" -#include "IException.h" -#include "IString.h" -#include "Preference.h" - -using namespace Isis; -using namespace std; - -/** - * Unit test for GisBlob class - * - * - * @author 2016-02-23 Jeannie Backer - * - * @internal - * @history 2016-02-23 Jeannie Backer - Original version. - * - */ -int main() { - try { - Preference::Preferences(true); - qDebug() << ""; - qDebug() << "Testing GisBlob's constructor from cube..."; - QString inputFile = "$ISISTESTDATA/isis/src/messenger/unitTestData/EW0211286081G.lev1.cub"; - Cube cube; - cube.open(inputFile); - GisBlob cubeBlob(cube); - qDebug() << " Polygon = " << cubeBlob.polygon(); - - qDebug() << ""; - qDebug() << "Testing GisBlob's default constructor..."; - GisBlob blob; - qDebug() << " Polygon = " << blob.polygon(); - - qDebug() << ""; - qDebug() << "Adding WKT polygon to GisBlob..."; - /* - QFile file("unitTest.wkt"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - throw IException(IException::Io, "Unable to open wkt file, [unitTest.wkt]", _FILEINFO_); - } - QString wkt; - QTextStream stream(&file); - wkt.append(stream.readAll()); - */ - QString wkt = cubeBlob.polygon(); - blob.setPolygon(wkt); - qDebug() << " Polygon = " << blob.polygon(); - } - catch (IException &e) { - qDebug() << ""; - qDebug() << ""; - QString msg = "**************** UNIT TEST FAILED! **************** "; - IException(e, IException::Unknown, msg, _FILEINFO_).print(); - } -} - - diff --git a/isis/src/base/objs/GisGeometry/GisGeometry.cpp b/isis/src/base/objs/GisGeometry/GisGeometry.cpp index 5524746c35..ab1e870e6b 100644 --- a/isis/src/base/objs/GisGeometry/GisGeometry.cpp +++ b/isis/src/base/objs/GisGeometry/GisGeometry.cpp @@ -17,7 +17,7 @@ find files of those names at the top level of this repository. **/ // other ISIS #include "Cube.h" #include "IException.h" -#include "GisBlob.h" +#include "ImagePolygon.h" #include "GisTopology.h" #include "SpecialPixel.h" @@ -27,62 +27,62 @@ using namespace std; namespace Isis { - /** + /** * Fundamental constructor of an empty object - */ - GisGeometry::GisGeometry() : m_type(None), m_geom(0), m_preparedGeom(0) { + */ + GisGeometry::GisGeometry() : m_type(None), m_geom(0), m_preparedGeom(0) { // Must ensure GEOS is initialized GisTopology::instance(); } - - /** - * @brief Construct a point geometry - * - * This constructor will create a point geometry. Note this can either be used - * to create a geometric geometry with a longitude/latitude or a grid geometry - * in any system with an X/Y value. It is up to the caller to maintain the - * coordinate system. - * + + /** + * @brief Construct a point geometry + * + * This constructor will create a point geometry. Note this can either be used + * to create a geometric geometry with a longitude/latitude or a grid geometry + * in any system with an X/Y value. It is up to the caller to maintain the + * coordinate system. + * * @param xlongitude X or longitude coordinate * @param ylatitude Y or latitude coordinate - */ + */ GisGeometry::GisGeometry(const double xlongitude, const double ylatitude) : m_type(GeosGis), m_geom(0), m_preparedGeom(0){ - + GisTopology::instance(); m_geom = makePoint(xlongitude, ylatitude); m_preparedGeom = makePrepared(this->m_geom); return; } - - - /** - * @brief Create a geometry from a cube file. - * - * This constructor will read the contents of the Polygon blob of an ISIS cube - * file and create a geometry from its contents. - * + + + /** + * @brief Create a geometry from a cube file. + * + * This constructor will read the contents of the Polygon blob of an ISIS cube + * file and create a geometry from its contents. + * * @param cube Cube object to create the geomtery from - */ + */ GisGeometry::GisGeometry(Cube &cube) : m_type(IsisCube), m_geom(0), m_preparedGeom(0) { - + GisTopology::instance(); m_geom = fromCube(cube); m_preparedGeom = makePrepared(this->m_geom); return; } - - /** - * @brief Create a geometry from a character WKT/WKB source - * - * @param gisSource String containing the text representation of a GIS + + /** + * @brief Create a geometry from a character WKT/WKB source + * + * @param gisSource String containing the text representation of a GIS * geometry. This can be either a WKT or WKB formatted string * @param t Type of GisGeometry - WKT or WKB - * - */ - GisGeometry::GisGeometry(const QString &gisSource, const GisGeometry::Type t) : + * + */ + GisGeometry::GisGeometry(const QString &gisSource, const GisGeometry::Type t) : m_type(t), m_geom(0), m_preparedGeom(0) { GisTopology *gis(GisTopology::instance()); if (WKT == t) { @@ -97,70 +97,70 @@ namespace Isis { m_geom = fromCube(cube); } else { - throw IException(IException::Programmer, - QString("Unknown GIS type given [%1]").arg(typeToString(t)), + throw IException(IException::Programmer, + QString("Unknown GIS type given [%1]").arg(typeToString(t)), _FILEINFO_); } - + // Get the prepared geometry m_preparedGeom = makePrepared(this->m_geom); m_type = t; return; } - - /** - * @brief Create a geometry from another geometry by cloning - * - * This contructor uses the GISTopology clone method to generate a new - * geometry. - * + + /** + * @brief Create a geometry from another geometry by cloning + * + * This contructor uses the GISTopology clone method to generate a new + * geometry. + * * @param geom GISGeometry to create new geometry from - */ + */ GisGeometry::GisGeometry(const GisGeometry &geom) : m_type(geom.m_type), m_geom(0), m_preparedGeom(0) { - + GisTopology *gis(GisTopology::instance()); if ( geom.isDefined() ) { m_geom = gis->clone(geom.m_geom); m_preparedGeom = makePrepared(this->m_geom); } } - - /** - * @brief Create a GISGeometry directly from a GEOS-C GEOSGeometry - * - * This constructor will create a new GISGeometry object that takes ownership - * from the caller and is managed for the life of this new object. - * + + /** + * @brief Create a GISGeometry directly from a GEOS-C GEOSGeometry + * + * This constructor will create a new GISGeometry object that takes ownership + * from the caller and is managed for the life of this new object. + * * @param geom GEOSGeometry instance to use - */ + */ GisGeometry::GisGeometry(GEOSGeometry *geom) : m_type(GeosGis), m_geom(geom), m_preparedGeom(0) { GisTopology::instance(); m_preparedGeom = makePrepared(this->m_geom); return; } - - /** + + /** * Destructor - */ - GisGeometry::~GisGeometry() { - destroy(); + */ + GisGeometry::~GisGeometry() { + destroy(); } - - /** - * @brief Assignment operator for GISGeomtries - * - * This assignment operator essentially clones the right side geomemtry - * + + /** + * @brief Assignment operator for GISGeomtries + * + * This assignment operator essentially clones the right side geomemtry + * * @param geom Geometry to assign to current object * @return GisGeometry New geometry - */ + */ GisGeometry &GisGeometry::operator=(GisGeometry const &geom) { if ( this != &geom ) { destroy(); @@ -173,15 +173,15 @@ namespace Isis { } return (*this); } - - + + /** - * @brief Set the geometry directly taking ownership - * - * This method will replace the current geoemetry with the geom parameter - * contents. The existing contents of this object is destroyed before taking - * ownership of the geom paramter object. - * + * @brief Set the geometry directly taking ownership + * + * This method will replace the current geoemetry with the geom parameter + * contents. The existing contents of this object is destroyed before taking + * ownership of the geom paramter object. + * * @param geom GEOSGeometry to incoporate into this object */ void GisGeometry::setGeometry(GEOSGeometry *geom) { @@ -190,40 +190,40 @@ namespace Isis { m_preparedGeom = makePrepared(this->m_geom); return; } - - - /** - * Determines if the current geometry is valid - * + + + /** + * Determines if the current geometry is valid + * * @return bool True if contents are valid, otherwise false - */ + */ bool GisGeometry::isDefined() const { return (m_geom != 0); } - - /** + + /** * Determines validity of the geometry contained in this object - * + * * First determines if it contains a geometry and then validates with the * GEOS toolkit. - * + * * @return bool True if valid, false if invalid or non-existant - */ + */ bool GisGeometry::isValid() const { if (!isDefined()) { return (false); } - + return (1 == GEOSisValid(this->m_geom)); } - - /** + + /** * Returns a string describing reason for invalid geometry - * + * * @return QString Description of the reason the geometry is invalid - */ + */ QString GisGeometry::isValidReason() const { QString result = "Not defined!"; if ( isDefined() ) { @@ -234,25 +234,25 @@ namespace Isis { } return (result); } - - /** + + /** * Returns the type (origin) of the geometry - * + * * @return GisGeometry::Type Enum type of geometry origin - */ + */ GisGeometry::Type GisGeometry::type() const { return (m_type); } - - /** + + /** * Returns enum representation of the geometry origin from string type - * + * * @see type(QString) * @param gstrType Character representation of geometry origin - * @return GisGeometry::Type Enum type of origin - */ + * @return GisGeometry::Type Enum type of origin + */ GisGeometry::Type GisGeometry::type(const QString &gstrType) { QString gtype = gstrType.toLower(); if ("wkt" == gtype) return (WKT); @@ -267,13 +267,13 @@ namespace Isis { } - /** - * Returns the type of the Geometry as a QString. + /** + * Returns the type of the Geometry as a QString. * * @see type(QString) * @param gstrType Enum type of origin * @return GisGeometry::Type Character representation of geometry or origin - */ + */ QString GisGeometry::typeToString(const GisGeometry::Type &type) { if (WKT == type) return "WKT"; if (WKB == type) return "WKB"; @@ -281,149 +281,149 @@ namespace Isis { if (GeosGis == type) return "GeosGis"; return "None"; } - - /** + + /** * Returns the GEOSGeometry object to extend functionality * * @return GEOSGeometry Pointer to GEOSGeometry structure - */ + */ const GEOSGeometry *GisGeometry::geometry() const { return (m_geom); } - - /** + + /** * @brief Returns special GEOS prepared geometry if it exists - * + * * This method will return a pointer to the prepared version of the * GEOSGeometry data. Caller should test for a NULL pointer as it may be * disabled or non-existant. - * + * * @return GEOSPreparedGeometry Pointer to prepared geometry - */ + */ const GEOSPreparedGeometry *GisGeometry::preparedGeometry() const { return (m_preparedGeom); } - - + + /** * @brief Clones the contents of this geometry to a new instance - * + * * This method will clone the contents of this geometry and return a new * instance to the caller. - * + * * @return GisGeometry Geometry to clone - */ + */ GisGeometry *GisGeometry::clone() const { if (!isDefined()) { return (new GisGeometry()); } - + GisTopology *gis(GisTopology::instance()); QScopedPointer geom(new GisGeometry()); - + geom->m_type = m_type; geom->m_geom = gis->clone(m_geom); geom->m_preparedGeom = makePrepared(geom->m_geom); return (geom.take()); } - - - /** + + + /** * Tests for a defined but empty geometry - * + * * @return bool True if empty, false if has content - */ + */ bool GisGeometry::isEmpty() const { - if ( !isValid() ) { - return (true); + if ( !isValid() ) { + return (true); } return (1 == GEOSisEmpty(this->m_geom)); } - - /** + + /** * @brief Computes the area of a geometry - * + * * This method will compute the area of a geometry. Note the area is in the * units of the coordinates. For example, if the coordinates of the geometry * are in latitude/longitude, then the units are in degrees. Callers must * maintain the units of the coordinates. - * + * * Point geometries will have 0 area. - * - * @return double Area of the geometry in units of data coordinates of the + * + * @return double Area of the geometry in units of data coordinates of the * geometry - */ + */ double GisGeometry::area( ) const { - if ( !isValid() ) { - return (0.0); + if ( !isValid() ) { + return (0.0); } - + int result = 0; double gisArea = 0.0; result = GEOSArea(this->m_geom, &gisArea); - if (1 != result) { - gisArea = 0.0; + if (1 != result) { + gisArea = 0.0; } return (gisArea); } - - /** + + /** * @brief Computes the length of a geometry - * + * * This method will compute the length of a geometry. This is suitable for * Linestring and spatial geometries. - * + * * @return double Length of the geometry in units of the coordinates - */ + */ double GisGeometry::length( ) const { - if ( !isValid() ) { - return (0.0); + if ( !isValid() ) { + return (0.0); } - + int result = 0; double gisLength = 0.0; result = GEOSLength(this->m_geom, &gisLength); - if (1 != result) { - gisLength = 0.0; + if (1 != result) { + gisLength = 0.0; } return (gisLength); } - - /** + + /** * @brief Computes the distance between two geometries - * + * * This method computes the distance between two geometries. Refer to the * GEOS documentation as to the details of this computation. - * + * * @param target Target geometry to compute distance to * @return double Distance in units of geometry coordinates - */ + */ double GisGeometry::distance(const GisGeometry &target) const { - if ( !isValid() ) { - return (false); + if ( !isValid() ) { + return (false); } - if ( !target.isValid() ) { - return (false); + if ( !target.isValid() ) { + return (false); } - + int result = 0; double dist = Null; result = GEOSDistance(this->m_geom, target.geometry(), &dist); - if ( 1 != result ) { - dist = Null; + if ( 1 != result ) { + dist = Null; } return (dist); } - - /** - * Get number of points in geometry - * + + /** + * Get number of points in geometry + * * @return int Number of points contained in the geometry */ int GisGeometry::points() const { @@ -439,50 +439,50 @@ namespace Isis { } - /** + /** * @brief Computes a new geometry from the intersection of the two geomtries - * + * * This method will compute the union of two geometries and return a new * geometry that represents the combination of them. - * + * * @param target Other geometry to combine by union opertor * @return bool True if operation is successful, false otherwise - */ + */ bool GisGeometry::intersects(const GisGeometry &target) const { - if ( !isValid() ) { + if ( !isValid() ) { return (false); } - if ( !target.isValid() ) { - return (false); + if ( !target.isValid() ) { + return (false); } - + int result = 0; if ( 0 != this->m_preparedGeom) { - result = GEOSPreparedIntersects(this->m_preparedGeom, target.geometry()); + result = GEOSPreparedIntersects(this->m_preparedGeom, target.geometry()); } else { result = GEOSIntersects(this->m_geom, target.geometry()); } - + return (1 == result); } - - /** + + /** * Test if the target geometry is contained within this geometry - * + * * @param target Other geometry to test - * @return bool True if target is contained with this geometry, false + * @return bool True if target is contained with this geometry, false * otherwise - */ + */ bool GisGeometry::contains(const GisGeometry &target) const { - if ( !isValid() ) { - return (false); + if ( !isValid() ) { + return (false); } - if ( !target.isValid() ) { + if ( !target.isValid() ) { return (false); } - + int result = 0; if ( 0 != this->m_preparedGeom) { result = GEOSPreparedContains(this->m_preparedGeom, target.geometry()); @@ -490,25 +490,25 @@ namespace Isis { else { result = GEOSContains(this->m_geom, target.geometry()); } - + return (1 == result); } - - /** + + /** * Tests for disjoint geometries - * + * * @param target Other geometry to test * @return bool True if geometries are disjoint, false otherwise - */ + */ bool GisGeometry::disjoint(const GisGeometry &target) const { - if ( !isValid() ) { - return (false); + if ( !isValid() ) { + return (false); } - if ( !target.isValid() ) { - return (false); + if ( !target.isValid() ) { + return (false); } - + int result = 0; if ( 0 != m_preparedGeom) { result = GEOSPreparedDisjoint(m_preparedGeom, target.geometry()); @@ -516,26 +516,26 @@ namespace Isis { else { result = GEOSDisjoint(m_geom, target.geometry()); } - + return (1 == result); } - - /** + + /** * Test for overlapping geometries - * + * * @param target Geometry to test for overlap with this geometry - * @return bool True if target geometry overlaps with this geometry, false + * @return bool True if target geometry overlaps with this geometry, false * otherwise - */ + */ bool GisGeometry::overlaps(const GisGeometry &target) const { - if ( !isValid() ) { - return (false); + if ( !isValid() ) { + return (false); } - if ( !target.isValid() ) { - return (false); + if ( !target.isValid() ) { + return (false); } - + int result = 0; if ( 0 != m_preparedGeom) { result = GEOSPreparedOverlaps(m_preparedGeom, target.geometry()); @@ -543,52 +543,52 @@ namespace Isis { else { result = GEOSOverlaps(m_geom, target.geometry()); } - + return (1 == result); } - -/** + +/** * Test if target and this geometry are equal - * + * * @param target Geometry to test for equality * @return bool True if geometries are equal, false if not */ - bool GisGeometry::equals(const GisGeometry &target) const { - if ( !isValid() ) { - return (false); + bool GisGeometry::equals(const GisGeometry &target) const { + if ( !isValid() ) { + return (false); } - if ( !target.isValid() ) { - return (false); + if ( !target.isValid() ) { + return (false); } - + int result = GEOSEquals(this->m_geom, target.geometry()); return ( 1 == result ); } - /** + /** * @brief Computes intersect ratio between two geometries - * + * * This method computes the intersection of two geometries and the returns * the ratio of the area of intersection with this geometry. Units must be * the same for both geometries or result will not be valid. - * + * * @param target Geometry to compute intersect ratio for - * @return double Area of common intersection of two geometries in units of + * @return double Area of common intersection of two geometries in units of * the two geometries. - */ + */ double GisGeometry::intersectRatio(const GisGeometry &target) const { - if ( !isValid() ) { - return (0.0); + if ( !isValid() ) { + return (0.0); } - if ( !target.isValid() ) { - return (0.0); + if ( !target.isValid() ) { + return (0.0); } - + // Check for any intersection at all - // if ( !intersects(target) ) { + // if ( !intersects(target) ) { // return (0.0); // } @@ -596,64 +596,64 @@ namespace Isis { if (this->area() == 0) { return (0.0); } - + QScopedPointer inCommon(intersection(target)); double ratio = inCommon->area() / this->area(); return (ratio); } - - - /** + + + /** * @brief Computes the envelope or bounding box of this geometry - * + * * This method computes the envelope or bounding box of the geometry in this * object. A new geometry is computed and a pointer is returned to the * caller. The caller assumes ownership of this geometry. - * + * * A null geometry will be returned if an error is occured or the current * geometry is invalid. - * - * @return GisGeometry Pointer to envelope/bounding box. A null geometry, not + * + * @return GisGeometry Pointer to envelope/bounding box. A null geometry, not * NULL pointer, is returned in problems occur. - */ + */ GisGeometry *GisGeometry::envelope() const { - if ( !isValid() ) { - return (new GisGeometry()); + if ( !isValid() ) { + return (new GisGeometry()); } - + GEOSGeometry *geom = GEOSEnvelope(m_geom); return (new GisGeometry(geom)); } - + /** * Computes the convex hull of the geometry - * - * @return GisGeometry Pointer to new geometry that represents the convex + * + * @return GisGeometry Pointer to new geometry that represents the convex * hull of this geometry. A null geometry, not NULL * pointer is returned if problems occur. - */ + */ GisGeometry *GisGeometry::convexHull() const { - if ( !isValid() ) { - return (new GisGeometry()); + if ( !isValid() ) { + return (new GisGeometry()); } - + GEOSGeometry *geom = GEOSConvexHull(m_geom); return (new GisGeometry(geom)); } - + /** - * @brief Simplify complex or overdetermined geoemtry - * - * This method will simplify a geometry with a Douglas -Peucker algorithm using - * a tolerance specifying the maximum distance from the original (multi)polygon. - * The use of this algorithm is designed to prevent oversimplification - * - * + * @brief Simplify complex or overdetermined geoemtry + * + * This method will simplify a geometry with a Douglas -Peucker algorithm using + * a tolerance specifying the maximum distance from the original (multi)polygon. + * The use of this algorithm is designed to prevent oversimplification + * + * * @param tolerance Maximum distance from the original geometry expressed in the * coordinate system of the geometry. - * + * * @return GisGeometry* Simplified geometry */ GisGeometry *GisGeometry::simplify(const double &tolerance) const { @@ -669,63 +669,63 @@ namespace Isis { } - /** + /** * @brief Computes the intersection of two geometries - * + * * The area of common interesction of the target geometry and this geometry * are computed and returned to the caller. - * + * * @param target Other geometry to compute intersection * @return GisGeometry Intersection geometry - */ + */ GisGeometry *GisGeometry::intersection(const GisGeometry &target) const { // Non-valid geometries return empty geometries - if ( !isValid() ) { - return (new GisGeometry()); + if ( !isValid() ) { + return (new GisGeometry()); } - if ( !target.isValid() ) { - return (new GisGeometry()); + if ( !target.isValid() ) { + return (new GisGeometry()); } - + GEOSGeometry *geom = GEOSIntersection(m_geom, target.geometry()); return (new GisGeometry(geom)); } - - /** + + /** * Computes the union of two geometries - * + * * @param target Other geometry to union with this geometry * @return GisGeometry Result of unioning the two geometries - */ + */ GisGeometry *GisGeometry::g_union(const GisGeometry &target) const { - if ( !isValid() ) { - return (new GisGeometry()); + if ( !isValid() ) { + return (new GisGeometry()); } - if ( !target.isValid() ) { - return (new GisGeometry()); + if ( !target.isValid() ) { + return (new GisGeometry()); } - + GEOSGeometry *geom = GEOSUnion(m_geom, target.geometry()); return (new GisGeometry(geom)); } - - /** + + /** * @brief Computes the centroid of a spatial geometry - * + * * This method will compute the coordinate centroid of a spatial geometry. - * + * * @param xlongitude X/longitude coordinate of centroid * @param ylatitude Y/latitude coordinate of centroid * @return bool True if successful, false if failed - */ + */ bool GisGeometry::centroid(double &xlongitude, double &ylatitude) const { xlongitude = ylatitude = Null; - if ( !isValid() ) { - return (false); + if ( !isValid() ) { + return (false); } - + GEOSGeometry *center = GEOSGetCentroid(m_geom); if ( 0 != center ) { GEOSGeomGetX(center, &xlongitude); @@ -733,33 +733,33 @@ namespace Isis { GisTopology::instance()->destroy(center); return (true); } - + return (false); } - - /** + + /** * Computes the centroid of the geometry and returns it as a new geometry - * + * * @return GisGeometry Pointer to point geometry of centroid of this geometry - */ - GisGeometry *GisGeometry::centroid() const { - if ( !isValid() ) { - return (new GisGeometry()); + */ + GisGeometry *GisGeometry::centroid() const { + if ( !isValid() ) { + return (new GisGeometry()); } - + GEOSGeometry *center = GEOSGetCentroid(m_geom); return (new GisGeometry(center)); } - - /** + + /** * Creates a prepared geometry of current geometry - * + * * @param geom * @return GEOSPreparedGeometry - */ - GEOSPreparedGeometry const *GisGeometry::makePrepared(const GEOSGeometry *geom) + */ + GEOSPreparedGeometry const *GisGeometry::makePrepared(const GEOSGeometry *geom) const { #if defined(DISABLE_PREPARED_GEOMETRY) return (0); @@ -768,40 +768,41 @@ namespace Isis { return (gis->preparedGeometry(geom)); #endif } - - /** + + /** * Create a point geometry - * + * * @param y Y or latitude coordinate * @return GEOSGeometry Pointer to point geometry. Caller assumes ownership - */ + */ GEOSGeometry *GisGeometry::makePoint(const double x, const double y) const { - + GEOSCoordSequence *point = GEOSCoordSeq_create(1, 2); GEOSCoordSeq_setX(point, 0, x); GEOSCoordSeq_setY(point, 0, y); - + return (GEOSGeom_createPoint(point)); } - - /** + + /** * Reads Polygon from ISIS Cube and returns geometry from contents * * @param cube ISIS Cube contaning a Polygon geometry object * @return GEOSGeometry Pointer to GEOS-C type geometry from Polygon BLOB - */ + */ GEOSGeometry *GisGeometry::fromCube(Cube &cube) const { - GisBlob myGis(cube); + ImagePolygon myGis = cube.readFootprint(); GisTopology *gis(GisTopology::instance()); - return (gis->geomFromWKT(myGis.polygon())); + QString polyStr = QString::fromStdString(myGis.polyStr()); + return (gis->geomFromWKT(polyStr)); } - - /** - * Destroys the GEOS elements of this geometry object - */ + + /** + * Destroys the GEOS elements of this geometry object + */ void GisGeometry::destroy() { GisTopology *gis(GisTopology::instance()); gis->destroy(m_geom); diff --git a/isis/src/base/objs/GisGeometry/unitTest.cpp b/isis/src/base/objs/GisGeometry/unitTest.cpp index 92b31de53e..3c8f70d325 100644 --- a/isis/src/base/objs/GisGeometry/unitTest.cpp +++ b/isis/src/base/objs/GisGeometry/unitTest.cpp @@ -13,10 +13,10 @@ find files of those names at the top level of this repository. **/ #include #include "Cube.h" -#include "GisBlob.h" #include "GisGeometry.h" #include "GisTopology.h" #include "IException.h" +#include "ImagePolygon.h" #include "IString.h" #include "Preference.h" @@ -37,7 +37,7 @@ void printTypes(); * @history 2016-02-23 Jeannie Backer - Original version. * @history 2016-03-02 Ian Humphrey - Added tests for remaining untested methods. * References #2398. - * @history 2016-03-04 Ian Humphrey - Updated test and truthdata for equals() method. + * @history 2016-03-04 Ian Humphrey - Updated test and truthdata for equals() method. * References #2398. * * @@ -47,12 +47,12 @@ void printTypes(); * For the other methods, if (0 != this->m_preparedGeom)'s else clause * is untested. Only the default constructor will create a GisGeometry * without a prepared geometry being instantiated. All the other constructors - * as well as setGeometry() instantiate prepared geometries. + * as well as setGeometry() instantiate prepared geometries. * So, to test the else clause, the prepared geometry would have to be NULL after - * instantiation. + * instantiation. * The prepared geometry is created with makePrepared(), which calls * GisTopology::preparedGeometry(). This method throws an exception - * if the prepared geometry is NULL. + * if the prepared geometry is NULL. * * NOTE - setGeometry() is also untested. */ @@ -69,20 +69,20 @@ int main() { double xlongitude = 0; double ylatitude = 0; GisGeometry geomLatLon(xlongitude, ylatitude); - printBasicInfo(geomLatLon, + printBasicInfo(geomLatLon, "Construct Geometry from Lat/Lon"); QString inputFile = "$ISISTESTDATA/isis/src/messenger/unitTestData/EW0211286081G.lev1.cub"; Cube cube; cube.open(inputFile); GisGeometry geomCube(cube); - printBasicInfo(geomCube, + printBasicInfo(geomCube, "Construct Geometry from Cube"); - GisBlob footprint(cube); - QString wkt = footprint.polygon(); + ImagePolygon footprint = cube.readFootprint(); + QString wkt = QString::fromStdString(footprint.polyStr()); GisGeometry geomGisWKT(wkt, GisGeometry::WKT); - printBasicInfo(geomGisWKT, + printBasicInfo(geomGisWKT, "Construct Geometry from WKT GIS source"); const GEOSGeometry *g = geomCube.geometry(); @@ -90,18 +90,18 @@ int main() { //QString wkb = topo->wkb(clone, GisTopology::DestroyGeometry); QString wkb = topo->wkb(clone); GisGeometry geomGisWKB(wkb, GisGeometry::WKB); - printBasicInfo(geomGisWKB, + printBasicInfo(geomGisWKB, "Construct Geometry from WKB GIS source"); GisGeometry geomGisIsisCube("$ISISTESTDATA/isis/src/messenger/unitTestData/EW0213634118G.lev1.cub", GisGeometry::IsisCube); - printBasicInfo(geomGisIsisCube, + printBasicInfo(geomGisIsisCube, "Construct Geometry from IsisCube GIS source"); GEOSGeometry *geos = topo->geomFromWKT(wkt); GisGeometry geomGEOS(geos); - printBasicInfo(geomGEOS, + printBasicInfo(geomGEOS, "Construct Geometry from GEOSGeometry"); //??? GisGeometry geomDefault; @@ -152,7 +152,7 @@ int main() { // Test intersectRatio where target has area of 0 qDebug() << "Intersect Ratio of WKT Geometry with Lat/Lon (single point) Geometry: " - << geomGisWKT.intersectRatio(geomLatLon); + << geomGisWKT.intersectRatio(geomLatLon); qDebug() << ""; GisGeometry *envelopeGeom = geomCube.envelope(); @@ -179,14 +179,14 @@ int main() { // These two tests below should output empty geometries GisGeometry *intersectionInvalidSourceGeometry = geomDefault.intersection(geomGisWKT); - printBasicInfo(*intersectionInvalidSourceGeometry, + printBasicInfo(*intersectionInvalidSourceGeometry, "Intersection Geometry of Invalid Geometry with WKT Geometry as target"); GisGeometry *intersectionInvalidTargetGeometry = geomGisWKT.intersection(geomDefault); printBasicInfo(*intersectionInvalidTargetGeometry, "Intersection Geometry of WKT Geometry with Invalid Geometry as target"); - + GisGeometry *intersectionGeom = geomGisIsisCube.intersection(geomGisWKT); printBasicInfo(*intersectionGeom, "Intersection Geometry of GisIsisCube Geometry with WKT Geometry"); @@ -204,7 +204,7 @@ int main() { GisGeometry *unionGeom = geomGisIsisCube.g_union(geomGisWKT); printBasicInfo(*unionGeom, "Union Geometry of GisIsisCube Geometry with WKT Geometry"); - + GisGeometry *centroidInvalidGeom = geomDefault.centroid(); printBasicInfo(*centroidInvalidGeom, "Centroid Geometry of Invalid Geometry"); @@ -246,8 +246,8 @@ int main() { } -/** - * Method to print basic information about the given geometry +/** + * Method to print basic information about the given geometry */ void printBasicInfo(GisGeometry geom, QString description) { qDebug() << description; @@ -263,8 +263,8 @@ void printBasicInfo(GisGeometry geom, QString description) { } -/** - * Method to print information about this GisGeometry with relation to another +/** + * Method to print information about this GisGeometry with relation to another */ void printTargetInfo(GisGeometry geom, GisGeometry target, QString description) { qDebug() << description; @@ -275,11 +275,11 @@ void printTargetInfo(GisGeometry geom, GisGeometry target, QString description) qDebug() << " overlaps? " << toString(geom.overlaps(target)); qDebug() << " equals? " << toString(geom.equals(target)); qDebug() << " intersect ratio? " << toString(geom.intersectRatio(target)); - qDebug() << ""; + qDebug() << ""; } -/** +/** * Method to test the static type() and typeToString() methods. */ void printTypes() { @@ -296,4 +296,3 @@ void printTypes() { qDebug() << ""; } - diff --git a/isis/src/base/objs/GisTopology/unitTest.cpp b/isis/src/base/objs/GisTopology/unitTest.cpp index 7cbd8133a9..b112003e58 100644 --- a/isis/src/base/objs/GisTopology/unitTest.cpp +++ b/isis/src/base/objs/GisTopology/unitTest.cpp @@ -10,10 +10,10 @@ find files of those names at the top level of this repository. **/ #include #include "Cube.h" -#include "GisBlob.h" #include "GisGeometry.h" #include "GisTopology.h" #include "IException.h" +#include "ImagePolygon.h" #include "IString.h" #include "Preference.h" @@ -30,7 +30,7 @@ using namespace std; * @history 2016-02-23 Jeannie Backer - Original version. * @history 2016-03-01 Ian Humphrey - Added a few more tests for clone(), wkb() and wkt()'s * scope coverage. References #2398. - * + * */ int main() { try { @@ -45,8 +45,8 @@ int main() { QString inputFile = "$ISISTESTDATA/isis/src/messenger/unitTestData/EW0211286081G.lev1.cub"; Cube cube; cube.open(inputFile); - GisBlob footprint(cube); - QString wktFromCube = footprint.polygon(); + ImagePolygon footprint = cube.readFootprint(); + QString wktFromCube = QString::fromStdString(footprint.polyStr()); qDebug() << "wkt from cube: " << wktFromCube; // create geometry from wkt string and make sure the output string matches @@ -61,7 +61,7 @@ int main() { qDebug() << "=============================================================================="; qDebug() << ""; - // get wkb string from previous geometry and use it to create a new geometry from wkb + // get wkb string from previous geometry and use it to create a new geometry from wkb QString wkbFromGeom = topo->wkb(fromWKT, GisTopology::PreserveGeometry); qDebug() << "WKB: " << wkbFromGeom; qDebug() << "wkt from cube == wkb from geometry? " << (wktFromCube == wkbFromGeom); @@ -104,7 +104,7 @@ int main() { qDebug() << "=============================================================================="; qDebug() << ""; - + // create a "clone" using NULL GEOSGeometry *nullClone = topo->clone(NULL); if (!nullClone) @@ -152,7 +152,7 @@ int main() { catch (IException &e) { e.print(); } - + qDebug() << ""; qDebug() << "Try to get a GEOSGeometry from bad wkt..."; try { @@ -163,7 +163,7 @@ int main() { e.print(); } */ - + } catch (IException &e) { qDebug() << ""; @@ -171,5 +171,5 @@ int main() { QString msg = "**************** UNIT TEST FAILED! **************** "; IException(e, IException::Unknown, msg, _FILEINFO_).print(); } - + } diff --git a/isis/src/base/objs/History/History.cpp b/isis/src/base/objs/History/History.cpp index 9ff2bdcc6b..742fdfa1ac 100644 --- a/isis/src/base/objs/History/History.cpp +++ b/isis/src/base/objs/History/History.cpp @@ -16,29 +16,36 @@ find files of those names at the top level of this repository. **/ using namespace std; namespace Isis { - /** - * Constructor for reading a history blob - * @param name + * Default Constructor for history */ - History::History(const QString &name) : Isis::Blob(name, "History") { + History::History() { p_history.setTerminator(""); } + /** - * Constructor for reading a history blob - * @param name - * @param file + * Constructor for reading a blob + * @param blob */ - History::History(const QString &name, const QString &file) : - Isis::Blob(name, "History") { - Blob::Read(file); + History::History(Isis::Blob &blob) { + p_history.setTerminator(""); + + char *blob_buffer = blob.getBuffer(); + p_bufferSize = blob.Size(); + p_histBuffer = new char[p_bufferSize]; + memcpy(p_histBuffer, blob_buffer, p_bufferSize); } + //! Destructor History::~History() { + if (p_histBuffer != NULL) { + delete [] p_histBuffer; + } } + /** * Adds History PvlObject */ @@ -47,6 +54,7 @@ namespace Isis { AddEntry(hist); } + /** * Adds given PvlObject to History Pvl * @@ -56,50 +64,47 @@ namespace Isis { p_history.addObject(obj); } + /** + * Converts a history object into a new blob object + * + * @param name Name of the History object to create * + * @return @b Blob */ - void History::WriteInit() { + Blob History::toBlob(const QString &name) { ostringstream ostr; - if (p_nbytes > 0) ostr << std::endl; + if (p_bufferSize > 0) ostr << std::endl; ostr << p_history; string histStr = ostr.str(); int bytes = histStr.size(); - char *temp = p_buffer; - p_buffer = new char[p_nbytes+bytes]; - if (temp != NULL) memcpy(p_buffer, temp, p_nbytes); + int blobBufferSize = p_bufferSize+bytes; + char *blobBuffer = new char[blobBufferSize]; + if (p_histBuffer != NULL) memcpy(blobBuffer, p_histBuffer, p_bufferSize); const char *ptr = histStr.c_str(); - memcpy(&p_buffer[p_nbytes], (void *)ptr, bytes); - p_nbytes += bytes; + memcpy(&blobBuffer[p_bufferSize], (void *)ptr, bytes); - if (temp != NULL) delete [] temp; + Blob newBlob(name, "History"); + newBlob.takeData(blobBuffer, blobBufferSize); + return newBlob; } + /** - * Reads p_buffer into a pvl + * Reads p_histBuffer into a pvl * * @return @b Pvl */ Pvl History::ReturnHist() { Pvl pvl; stringstream os; - for (int i = 0; i < p_nbytes; i++) os << p_buffer[i]; - os >> pvl; - return pvl; - } + for (int i = 0; i < p_bufferSize; i++) os << p_histBuffer[i]; - /** - * Reads input stream into Pvl. - * - * @param pvl Pvl into which the input stream will be read. - * @param is Input stream. - */ - void History::Read(const Isis::Pvl &pvl, std::istream &is) { - try { - Blob::Read(pvl, is); - } - catch (IException &e) { + for (int i = 0; i < p_history.objects(); i++) { + os << p_history.object(i); } + os >> pvl; + return pvl; } } diff --git a/isis/src/base/objs/History/History.h b/isis/src/base/objs/History/History.h index e0b1afbcbf..4a085c2d15 100644 --- a/isis/src/base/objs/History/History.h +++ b/isis/src/base/objs/History/History.h @@ -16,7 +16,7 @@ namespace Isis { /** * @author ????-??-?? Unknown * - * @internal + * @internal * @history 2006-12-11 Kris Becker Fixed bug in WriteInit method using a * temporary string to reference a char pointer to * its contents. The string remain after the @@ -29,27 +29,29 @@ namespace Isis { * include for Pvl since the include for Pvl was * removed from Blob.h. Added padding to control * statements. References #1169 - * + * @history 2021-03-05 Adam Paquette - Refactored History to no longer be a + * child class of a blob for a cleaner definition + * of responsabilities for the object + * * @todo This class needs documentation. */ - class History : public Isis::Blob { + class History { public: - History(const QString &name); - History(const QString &name, const QString &file); + History(); + History(Isis::Blob &blob); ~History(); void AddEntry(); void AddEntry(Isis::PvlObject &obj); Pvl ReturnHist(); - void Read(const Isis::Pvl &pvl, std::istream &is); - protected: - void WriteInit(); + Blob toBlob(const QString &name = "IsisCube"); private: Pvl p_history; //!< History Pvl + char *p_histBuffer = nullptr; //!< Store for read in history data + int p_bufferSize = 0; }; }; #endif - diff --git a/isis/src/base/objs/History/History.truth b/isis/src/base/objs/History/History.truth deleted file mode 100644 index 89daefdf80..0000000000 --- a/isis/src/base/objs/History/History.truth +++ /dev/null @@ -1,18 +0,0 @@ -Object = Root - Object = hist - IsisVersion = "3.0.16 beta | 2006-03-22" - ProgramVersion = 2011-08-19 - ExecutionDateTime = 2006-03-29T14:39:39 - HostName = orkin - UserName = janderso - Description = "Unit test for History class" - - Group = UserParameters - FROM = unitTest.cub - TO = $temporary/isisprocess_01.cub - TO2 = $temporary/isisprocess_02.cub - TO3 = $temporary/isisprocess_03.cub - TO4 = $temporary/isisprocess_04.cub - End_Group - End_Object -End_Object diff --git a/isis/src/base/objs/History/unitTest.cpp b/isis/src/base/objs/History/unitTest.cpp deleted file mode 100644 index 67c0297365..0000000000 --- a/isis/src/base/objs/History/unitTest.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include "Isis.h" - -#include -#include - -#include "Pvl.h" -#include "History.h" -#include "Preference.h" - -using namespace std; -void IsisMain() { - Isis::Preference::Preferences(true); - - Isis::History h("Haha");; - h.AddEntry(); - QString file = "unitTest.tttt"; - h.Write(file); - - Isis::History h2("Haha", file); - Isis::PvlObject o = h2.ReturnHist(); - std::cout << o << std::endl; - - remove(file.toLatin1().data()); -} diff --git a/isis/src/base/objs/History/unitTest.exclude b/isis/src/base/objs/History/unitTest.exclude deleted file mode 100644 index c0b4c410ba..0000000000 --- a/isis/src/base/objs/History/unitTest.exclude +++ /dev/null @@ -1,6 +0,0 @@ -ProgramPath -DateTime -User -HostName -IsisVersion - diff --git a/isis/src/base/objs/History/unitTest.xml b/isis/src/base/objs/History/unitTest.xml deleted file mode 100644 index 5573fa954f..0000000000 --- a/isis/src/base/objs/History/unitTest.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - Unit test for History class - - - - Just a test only a test - - - - Scripting - - - - - Original Version - - - Replaced test cube path /tmp/... with $temporary/... - - - - - - - cube - input - - Test cube - - - Test cube - - - *.cub - - unitTest.cub - - - cube - output - - Test cube - - - Test cube - - - *.cub - - $temporary/isisprocess_01.cub - - - cube - output - - Test cube - - - Test cube - - - *.cub - - $temporary/isisprocess_02.cub - - - cube - output - - Test cube - - - Test cube - - - *.cub - - $temporary/isisprocess_03.cub - - - cube - output - - Test cube - - - Test cube - - - *.cub - - $temporary/isisprocess_04.cub - - - - diff --git a/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp b/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp index 982e37462f..216cffaf71 100644 --- a/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp +++ b/isis/src/base/objs/ImageOverlapSet/ImageOverlapSet.cpp @@ -91,15 +91,11 @@ namespace Isis { } // Read the bounding polygon - ImagePolygon *poly = new ImagePolygon(); - cube.read(*poly); + ImagePolygon poly = cube.readFootprint(); cube.close(); // Create an ImageOverlap with the serial number and the bounding // polygon and save it - geos::geom::MultiPolygon *tmp = PolygonTools::MakeMultiPolygon(poly->Polys()); - - delete poly; - poly = NULL; + geos::geom::MultiPolygon *tmp = PolygonTools::MakeMultiPolygon(poly.Polys()); geos::geom::MultiPolygon *mp = NULL; diff --git a/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp b/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp index 6f36cf4d5e..4f5ddd4920 100644 --- a/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp +++ b/isis/src/base/objs/ImagePolygon/ImagePolygon.cpp @@ -37,7 +37,7 @@ namespace Isis { * Constructs a Polygon object, setting the polygon name * */ - ImagePolygon::ImagePolygon() : Blob("Footprint", "Polygon") { + ImagePolygon::ImagePolygon() { p_polygons = NULL; p_cube = NULL; @@ -59,6 +59,29 @@ namespace Isis { } + /** + * Constructs a Polygon object from a Blob + * + */ + ImagePolygon::ImagePolygon(Blob &blob) : ImagePolygon() { + p_polyStr = string(blob.getBuffer(), blob.Size()); + + geos::io::WKTReader *wkt = new geos::io::WKTReader(&(*globalFactory)); + p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr)); + + p_pts = new geos::geom::CoordinateArraySequence; + + for (auto poly : *p_polygons) { + geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(poly->getCoordinates())); + for (size_t i = 0; i < coordArray.getSize(); i++) { + p_pts->add(geos::geom::Coordinate(coordArray.getAt(i))); + } + } + + delete wkt; + } + + //! Destroys the Polygon object ImagePolygon::~ImagePolygon() { delete p_polygons; @@ -255,6 +278,7 @@ namespace Isis { p_gMap->Camera()->IgnoreElevationModel(false); } + void ImagePolygon::Create(std::vector> polyCoordinates) { p_pts = new geos::geom::CoordinateArraySequence(); @@ -271,6 +295,8 @@ namespace Isis { Fix360Poly(); } + + /** * Finds the next point on the image using a left hand rule walking algorithm. To * initiate the walk pass it the same point for both currentPoint and lastPoint. @@ -406,6 +432,7 @@ namespace Isis { return result; } + /** * This method ensures sample/line after sinc/linc have been applied is inside * the image. If not, it snaps to the edge of the image - given we didn't start @@ -608,7 +635,6 @@ namespace Isis { * WARNING: Very large pixel increments for cubes that have cameras/projections * with no data at any of the 4 corners can still fail in this algorithm. */ - void ImagePolygon::WalkPoly() { vector points; double lat, lon, prevLat, prevLon; @@ -1312,56 +1338,13 @@ namespace Isis { /** - * Reads Multipolygon from cube blob - * - * @param[in] is (std::fstream) Input stream to read from + * Serialize the ImagePolygon to a Blob. * - * throws Isis::IException::Io - Error reading data from stream + * The polygon will be serialized as a WKT srtring. * + * @return @b Blob */ - void ImagePolygon::ReadData(std::istream &is) { - - streampos sbyte = p_startByte - 1; - is.seekg(sbyte, std::ios::beg); - if (!is.good()) { - QString msg = "Error preparing to read data from " + p_type + - " [" + p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - - char *buf = new char[p_nbytes+1]; - memset(buf, 0, p_nbytes + 1); - - is.read(buf, p_nbytes); - - p_polyStr = buf; - - delete [] buf; - - if (!is.good()) { - QString msg = "Error reading data from " + p_type + " [" + - p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - - geos::io::WKTReader *wkt = new geos::io::WKTReader(&(*globalFactory)); - p_polygons = PolygonTools::MakeMultiPolygon(wkt->read(p_polyStr)); - - p_pts = new geos::geom::CoordinateArraySequence; - - for (auto poly : *p_polygons) { - geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(poly->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { - p_pts->add(geos::geom::Coordinate(coordArray.getAt(i))); - } - } - - delete wkt; - } - - - //! Initializes for writing polygon to cube blob - void ImagePolygon::WriteInit() { + Blob ImagePolygon::toBlob() const { geos::io::WKTWriter *wkt = new geos::io::WKTWriter(); // Check to see p_polygons is valid data @@ -1369,22 +1352,13 @@ namespace Isis { string msg = "Cannot write a NULL polygon!"; throw IException(IException::Programmer, msg, _FILEINFO_); } - p_polyStr = wkt->write(p_polygons); - p_nbytes = p_polyStr.size(); + string polyStr = wkt->write(p_polygons); delete wkt; - } - - /** - * Writes polygon to cube blob - * - * @param[in] os (std::fstream &) Output steam blob data will be written to - * - * @throws Isis::iException::Io - Error writing data to stream - */ - void ImagePolygon::WriteData(std::fstream &os) { - os.write(p_polyStr.c_str(), p_nbytes); + Blob newBlob("Footprint", "Polygon"); + newBlob.setData(polyStr.c_str(), polyStr.size()); + return newBlob; } diff --git a/isis/src/base/objs/ImagePolygon/ImagePolygon.h b/isis/src/base/objs/ImagePolygon/ImagePolygon.h index b12cc408f5..6dc43d0b24 100644 --- a/isis/src/base/objs/ImagePolygon/ImagePolygon.h +++ b/isis/src/base/objs/ImagePolygon/ImagePolygon.h @@ -14,6 +14,7 @@ find files of those names at the top level of this repository. **/ #include "IException.h" #include "Cube.h" #include "Brick.h" +#include "Blob.h" #include "Camera.h" #include "Projection.h" #include "UniversalGroundMap.h" @@ -149,10 +150,11 @@ namespace Isis { * Fixes #994. */ - class ImagePolygon : public Isis::Blob { + class ImagePolygon { public: ImagePolygon(); + ImagePolygon(Blob &blob); ~ImagePolygon(); void Create(Cube &cube, int sinc = 1, int linc = 1, @@ -209,6 +211,11 @@ namespace Isis { return p_polygons; }; + //! Return a geos Multipolygon + std::string polyStr() const { + return p_polyStr; + }; + double validSampleDim(); double validLineDim(); @@ -226,10 +233,7 @@ namespace Isis { return p_pts->size(); } - protected: - void ReadData(std::istream &is); - void WriteInit(); - void WriteData(std::fstream &os); + Blob toBlob() const; private: // Please do not add new polygon manipulation methods to this class. diff --git a/isis/src/base/objs/OriginalLabel/OriginalLabel.cpp b/isis/src/base/objs/OriginalLabel/OriginalLabel.cpp index ac5ff7f54e..3e16d330b3 100644 --- a/isis/src/base/objs/OriginalLabel/OriginalLabel.cpp +++ b/isis/src/base/objs/OriginalLabel/OriginalLabel.cpp @@ -16,28 +16,39 @@ namespace Isis { /** * Constructor for creating an original blob with a given name */ - OriginalLabel::OriginalLabel() : Isis::Blob("IsisCube", "OriginalLabel") { + OriginalLabel::OriginalLabel() { m_originalLabel.setTerminator(""); } + + /** + * Constructor for creating an original label from a blob object. + */ + OriginalLabel::OriginalLabel(Isis::Blob &blob) { + fromBlob(blob); + } + + /** * Constructor for creating an original blob with a given name and file to * read labels from. * * @param file File to read labels from */ - OriginalLabel::OriginalLabel(const QString &file) : - Isis::Blob("IsisCube", "OriginalLabel") { - Blob::Read(file); + OriginalLabel::OriginalLabel(const QString &file){ + Blob blob = Blob("IsisCube", "OriginalLabel"); + blob.Read(file); + fromBlob(blob); } + /** * Constructor for creating an original blob with a given name and Pvl * container. * * @param pvl Pvl containing labels of the source */ - OriginalLabel::OriginalLabel(Pvl pvl) : Isis::Blob("IsisCube", "OriginalLabel") { + OriginalLabel::OriginalLabel(Pvl pvl){ m_originalLabel = pvl; } @@ -45,39 +56,45 @@ namespace Isis { OriginalLabel::~OriginalLabel() { } + /** - * Prepare labels for writing to the output cube. + * Initialize the OriginalLabel from a Blob. + * + * @param blob The Blob to extract data from */ - void OriginalLabel::WriteInit() { - ostringstream ostr; - if(p_nbytes > 0) ostr << std::endl; - - // store labels - ostr << m_originalLabel; - string orglblStr = ostr.str(); - int bytes = orglblStr.size(); + void OriginalLabel::fromBlob(Isis::Blob blob) { + Pvl pvl; + stringstream os; + char *buff = blob.getBuffer(); + for(int i = 0; i < blob.Size(); i++){ + os << buff[i]; + } + os >> pvl; + m_originalLabel = pvl; + } - // Copy label data to bytes variable - char *temp = p_buffer; - p_buffer = new char[p_nbytes+bytes]; - if(temp != NULL) memcpy(p_buffer, temp, p_nbytes); - const char *ptr = orglblStr.c_str(); - memcpy(&p_buffer[p_nbytes], (void *)ptr, bytes); - p_nbytes += bytes; - if(temp != NULL) delete [] temp; + /** + * Serialize the OriginalLabel data to a Blob. + * + * @return @b Blob + */ + Isis::Blob OriginalLabel::toBlob() { + std::stringstream sstream; + sstream << m_originalLabel; + string orglblStr = sstream.str(); + Isis::Blob blob("IsisCube", "OriginalLabel"); + blob.setData(orglblStr.c_str(), orglblStr.size()); + return blob; } + /** * Returns the labels in a Pvl object * * @return (Isis::Pvl) original labels */ - Pvl OriginalLabel::ReturnLabels() { - Pvl pvl; - stringstream os; - for(int i = 0; i < p_nbytes; i++) os << p_buffer[i]; - os >> pvl; - return pvl; + Pvl OriginalLabel::ReturnLabels() const { + return m_originalLabel; } } diff --git a/isis/src/base/objs/OriginalLabel/OriginalLabel.h b/isis/src/base/objs/OriginalLabel/OriginalLabel.h index a953f713a0..7e1310efbb 100644 --- a/isis/src/base/objs/OriginalLabel/OriginalLabel.h +++ b/isis/src/base/objs/OriginalLabel/OriginalLabel.h @@ -32,15 +32,17 @@ namespace Isis { * @history 2008-06-18 Steven Koechle - Fixed Documentation Errors * */ - class OriginalLabel : public Isis::Blob { + class OriginalLabel { public: OriginalLabel(); OriginalLabel(const QString &file); + OriginalLabel(Isis::Blob &blob); OriginalLabel(Pvl pvl); ~OriginalLabel(); // Return the original labels - Pvl ReturnLabels(); + Pvl ReturnLabels() const; + Isis::Blob toBlob(); protected: // prepare data for writing @@ -49,8 +51,8 @@ namespace Isis { private: // labels of original source Pvl m_originalLabel; + void fromBlob(Isis::Blob blob); }; }; #endif - diff --git a/isis/src/base/objs/OriginalLabel/unitTest.cpp b/isis/src/base/objs/OriginalLabel/unitTest.cpp index ff1de166dc..1d04e36e4e 100644 --- a/isis/src/base/objs/OriginalLabel/unitTest.cpp +++ b/isis/src/base/objs/OriginalLabel/unitTest.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { cout << p << endl; Isis::OriginalLabel ol(p); - ol.Write("olTemp"); + ol.toBlob().Write("olTemp"); Isis::OriginalLabel ol2("olTemp"); diff --git a/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.cpp b/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.cpp index 2c8873a2d3..70577336cf 100644 --- a/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.cpp +++ b/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.cpp @@ -20,8 +20,7 @@ namespace Isis { /** * Constructors a default OriginalXmlLabel with an empty label. */ - OriginalXmlLabel::OriginalXmlLabel() : Isis::Blob("IsisCube", "OriginalXmlLabel") { - p_blobPvl += Isis::PvlKeyword("ByteOrder", "NULL"); + OriginalXmlLabel::OriginalXmlLabel() { } @@ -30,70 +29,38 @@ namespace Isis { * * @param file Xml file to read labels from */ - OriginalXmlLabel::OriginalXmlLabel(const QString &file) : - Isis::Blob("IsisCube", "OriginalXmlLabel") { - p_blobPvl += Isis::PvlKeyword("ByteOrder", "NULL"); - Blob::Read(file); + OriginalXmlLabel::OriginalXmlLabel(const QString &file) { + Blob blob = Blob("IsisCube", "OriginalXmlLabel"); + blob.Read(file); + fromBlob(blob); } - /** - * Destructor + * Constructs an OriginalXmlLabel from a blob + * + * @param blob Blob from which to create the OriginalXmlLabel */ - OriginalXmlLabel::~OriginalXmlLabel() { + OriginalXmlLabel::OriginalXmlLabel(Isis::Blob &blob) { + fromBlob(blob); } /** - * Read the original label from an Xml file. - * - * @param FileName The Xml file containing the original label. - * - * @throws IException::Io "Could not open label file." - * @throws IException::Unknown "XML read/parse error in file." + * Destructor */ - void OriginalXmlLabel::readFromXmlFile(const FileName &xmlFileName) { - QFile xmlFile(xmlFileName.expanded()); - if ( !xmlFile.open(QIODevice::ReadOnly) ) { - QString msg = "Could not open label file [" + xmlFileName.expanded() + - "]."; - throw IException(IException::Io, msg, _FILEINFO_); - } - - QString errmsg; - int errline, errcol; - if ( !m_originalLabel.setContent(&xmlFile, false, &errmsg, &errline, &errcol) ) { - xmlFile.close(); - QString msg = "XML read/parse error in file [" + xmlFileName.expanded() - + "] at line [" + toString(errline) + "], column [" + toString(errcol) - + "], message: " + errmsg; - throw IException(IException::Unknown, msg, _FILEINFO_); - } - - xmlFile.close(); + OriginalXmlLabel::~OriginalXmlLabel() { } - /** - * Read the xml file data from an input stream. - * - * @param stream The input stream to read from. - * - * @throws IException::Unknown "XML read/parse error when parsing original label." - * - * @see Blob::Read(const Pvl &pvl, std::istream &is) + /* + * Load blob data into m_originalLabel */ - void OriginalXmlLabel::ReadData(std::istream &stream) { - // Use Blob's ReadData to fill p_buffer - Blob::ReadData(stream); - - // Setup variables for error reproting in QT's xml parser + void OriginalXmlLabel::fromBlob(Isis::Blob blob) { QString errorMessage; int errorLine; int errorColumn; - // Attempt to use QT's xml parser to internalize the label - if ( !m_originalLabel.setContent( QByteArray(p_buffer, p_nbytes) ) ) { + if ( !m_originalLabel.setContent( QByteArray(blob.getBuffer(), blob.Size()) ) ) { QString msg = "XML read/parse error when parsing original label. " "Error at line [" + toString(errorLine) + "], column [" + toString(errorColumn) + @@ -104,32 +71,54 @@ namespace Isis { /** - * Prepare to write the label out. - * - * @see Blob::Write + * Serialize the OriginalXmlLabel to a Blob. + * + * @return @b Blob */ - void OriginalXmlLabel::WriteInit() { - p_nbytes = m_originalLabel.toByteArray(0).size(); - + Blob OriginalXmlLabel::toBlob() const { + std::stringstream sstream; + sstream << m_originalLabel.toString(); + string orglblStr = sstream.str(); + Isis::Blob blob("IsisCube", "OriginalXmlLabel"); + blob.setData((char*)orglblStr.data(), orglblStr.length()); + blob.Label() += Isis::PvlKeyword("ByteOrder", "NULL"); if (Isis::IsLsb()) { - p_blobPvl["ByteOrder"] = Isis::ByteOrderName(Isis::Lsb); + blob.Label()["ByteOrder"] = Isis::ByteOrderName(Isis::Lsb); } else { - p_blobPvl["ByteOrder"] = Isis::ByteOrderName(Isis::Msb); + blob.Label()["ByteOrder"] = Isis::ByteOrderName(Isis::Msb); } + return blob; } /** - * Write the label out to a stream. - * - * @param os The stream to write the label out to. - * - * @see Blob::Write + * Read the original label from an Xml file. + * + * @param FileName The Xml file containing the original label. + * + * @throws IException::Io "Could not open label file." + * @throws IException::Unknown "XML read/parse error in file." */ - void OriginalXmlLabel::WriteData(std::fstream &os) { - QByteArray labelByteArray = m_originalLabel.toByteArray(0); - os.write( labelByteArray.data(), labelByteArray.size() ); + void OriginalXmlLabel::readFromXmlFile(const FileName &xmlFileName) { + QFile xmlFile(xmlFileName.expanded()); + if ( !xmlFile.open(QIODevice::ReadOnly) ) { + QString msg = "Could not open label file [" + xmlFileName.expanded() + + "]."; + throw IException(IException::Io, msg, _FILEINFO_); + } + + QString errmsg; + int errline, errcol; + if ( !m_originalLabel.setContent(&xmlFile, false, &errmsg, &errline, &errcol) ) { + xmlFile.close(); + QString msg = "XML read/parse error in file [" + xmlFileName.expanded() + + "] at line [" + toString(errline) + "], column [" + toString(errcol) + + "], message: " + errmsg; + throw IException(IException::Unknown, msg, _FILEINFO_); + } + + xmlFile.close(); } @@ -138,7 +127,7 @@ namespace Isis { * * @return @b QDomDocument The parsed original label */ - const QDomDocument &OriginalXmlLabel::ReturnLabels() const { + const QDomDocument &OriginalXmlLabel::ReturnLabels() const{ return m_originalLabel; } } diff --git a/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.h b/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.h index de085b07f4..ff17a77316 100644 --- a/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.h +++ b/isis/src/base/objs/OriginalXmlLabel/OriginalXmlLabel.h @@ -29,19 +29,21 @@ namespace Isis { * OriginalLabel. Fixes #4584. * */ - class OriginalXmlLabel : public Isis::Blob { + class OriginalXmlLabel { public: OriginalXmlLabel(); OriginalXmlLabel(const QString &file); + OriginalXmlLabel(Blob &blob); ~OriginalXmlLabel(); + Blob toBlob() const; + + void fromBlob(Isis::Blob blob); void readFromXmlFile(const FileName &xmlFileName); const QDomDocument &ReturnLabels() const; protected: void ReadData(std::istream &stream); - void WriteData(std::fstream &os); - void WriteInit(); private: QDomDocument m_originalLabel; //!< Original Xml Label. @@ -49,4 +51,3 @@ namespace Isis { }; #endif - diff --git a/isis/src/base/objs/Process/Process.cpp b/isis/src/base/objs/Process/Process.cpp index fec9b72743..0f196837b1 100644 --- a/isis/src/base/objs/Process/Process.cpp +++ b/isis/src/base/objs/Process/Process.cpp @@ -189,7 +189,7 @@ namespace Isis { * * @throws Isis::iException::Message */ - void Process::SetInputCube(Cube *cube, + void Process::SetInputCube(Cube *cube, int requirements) { // Test for same size or one in all dimensions if(requirements & Isis::AllMatchOrOne) { @@ -628,8 +628,7 @@ Isis::Cube *Process::SetOutputCubeStretch(const QString ¶meter, const int ns Isis::Pvl &inlab = *InputCubes[0]->label(); for(int i = 0; i < inlab.objects(); i++) { if(inlab.object(i).isNamed("OriginalLabel")) { - Isis::OriginalLabel ol; - InputCubes[0]->read(ol); + Isis::OriginalLabel ol = InputCubes[0]->readOriginalLabel(inlab.object(i)["Name"]); cube->write(ol); } } @@ -882,18 +881,19 @@ Isis::Cube *Process::SetOutputCubeStretch(const QString ¶meter, const int ns Isis::Pvl & inlab = *InputCubes[0]->label(); for(int i = 0; i < inlab.objects(); i++) { if(inlab.object(i).isNamed("History") && Isis::iApp != NULL) { - Isis::History h((QString)inlab.object(i)["Name"]); - InputCubes[0]->read(h); + QString histBlobName = (QString)inlab.object(i)["Name"]; + History h = InputCubes[0]->readHistory(histBlobName); h.AddEntry(); - cube.write(h); + cube.write(h, histBlobName); addedHist = true; } } } if(!addedHist && Isis::iApp != NULL) { - Isis::History h("IsisCube"); + Isis::History h = cube.readHistory(); h.AddEntry(); + cube.write(h); } } diff --git a/isis/src/base/objs/Process/unitTest.cpp b/isis/src/base/objs/Process/unitTest.cpp index f2763618e3..580ffdbcc4 100644 --- a/isis/src/base/objs/Process/unitTest.cpp +++ b/isis/src/base/objs/Process/unitTest.cpp @@ -230,8 +230,7 @@ void IsisMain() { Isis::Process p5; p5.SetInputCube("FROM"); Isis::Cube *ocube6 = p5.SetOutputCube("TO"); - Isis::Table table("Table"); - ocube6->read(table); + Isis::Table table = ocube6->readTable("Table"); cout << "Number of record = " << table.Records() << endl; cout << "Record Size = " << table.RecordSize() << endl; @@ -261,11 +260,10 @@ void IsisMain() { cout << "Does output cube have \"Table2\" ? " << std::boolalpha << ocubeTableNames->hasTable("Table2") << endl; - Isis::Table table2("Table2"); - ocubeTableNames->read(table2); + Isis::Table table2 = ocubeTableNames->readTable("Table2"); cout << "Number of records = " << table2.Records() << endl; cout << "Record Size = " << table2.RecordSize() << endl; - + pTableNames.EndProcess(); cout << endl; diff --git a/isis/src/base/objs/ProcessMosaic/ProcessMosaic.cpp b/isis/src/base/objs/ProcessMosaic/ProcessMosaic.cpp index 1b602cecc5..71b3f751c9 100644 --- a/isis/src/base/objs/ProcessMosaic/ProcessMosaic.cpp +++ b/isis/src/base/objs/ProcessMosaic/ProcessMosaic.cpp @@ -345,9 +345,7 @@ namespace Isis { SerialNumber::Compose(*(InputCubes[0]))); // Write the tracking table to the tracking cube, overwriting if need-be - if (m_trackingCube->hasTable(Isis::trackingTableName)) { - m_trackingCube->deleteBlob("Table", Isis::trackingTableName); - } + m_trackingCube->deleteBlob(Isis::trackingTableName, "Table"); Table table = trackingTable->toTable(); m_trackingCube->write(table); } diff --git a/isis/src/base/objs/ProcessMosaic/unitTest.cpp b/isis/src/base/objs/ProcessMosaic/unitTest.cpp index 80c0d68e98..28c998820b 100644 --- a/isis/src/base/objs/ProcessMosaic/unitTest.cpp +++ b/isis/src/base/objs/ProcessMosaic/unitTest.cpp @@ -20,20 +20,20 @@ void testIn(int iss, int isl, int isb, int ins = 0, int inl = 0, int inb = 0); void testOut(int piSamples, int piLines, int piBands, int piPriority, int originBand); /** - * Unit test for ProcessMosaic. - * - * Tests for correct area drop, tracking origin, origin band, - * priorities input, mosaic and band, options to allow HS, LS - * and NULL pixels from input to mosaic, each time displaying - * the contents of the input and mosaic pixels for the area - * under consideration + * Unit test for ProcessMosaic. + * + * Tests for correct area drop, tracking origin, origin band, + * priorities input, mosaic and band, options to allow HS, LS + * and NULL pixels from input to mosaic, each time displaying + * the contents of the input and mosaic pixels for the area + * under consideration * * Also tests for exceptions like number of input and output images to * be exactly one each, band cannot be priority if Track is set off and * more * - * @author 2009-10-14 Sharmila Prasad - * + * @author 2009-10-14 Sharmila Prasad + * * @internal * @history 2018-06-06 Jeannie Backer - Removed file paths from error message written to * test output. @@ -64,7 +64,7 @@ void IsisMain() { m1.StartProcess(5, 2, 1); // This should be overwritten by the next StartProcess call m1.StartProcess(2, 2, 1); - + // Test for "Tracking" group in the mosaic cube if (mosaicCube1->hasGroup("Tracking")) { qDebug() << ""; @@ -79,8 +79,7 @@ void IsisMain() { QString trackingBase = FileName(mosaicCube1->fileName()).removeExtension().expanded().split("/").last(); Cube *trackingCube1 = new Cube(FileName(trackingBase + "_tracking.cub")); try { - Table trackTable(ProcessMosaic::TRACKING_TABLE_NAME); - trackingCube1->read(trackTable); + Table trackTable = trackingCube1->readTable(ProcessMosaic::TRACKING_TABLE_NAME); qDebug() << "b. SUCCESS - Track Table Exists in [" << trackingCube1->fileName() << "]"; qDebug().noquote() << Table::toString( trackTable, "\t" ); } @@ -169,7 +168,7 @@ void IsisMain() { qDebug() << "5. Test for mosaic priority with existing mosaic"; ProcessMosaic m5; m5.SetImageOverlay(ProcessMosaic::PlaceImagesBeneath); - + m5.SetInputCube("FROM", 1, 1, 1, 5, 5, 1); m5.SetOutputCube("TO"); @@ -472,7 +471,7 @@ void IsisMain() { p.EndProcess(); qDebug() << ""; } - + // *********************************************************** // Test tracking with ontop priotirty and multiple bands qDebug() << "Test tracking with ontop priotirty and multiple bands"; @@ -514,8 +513,8 @@ void IsisMain() { } remove("isisMosaic_01.cub"); remove("isisMosaic_01_tracking.cub"); - - + + // *********************************************************** // Testing errors that can occur qDebug() << "***********************************************************************************"; @@ -523,19 +522,19 @@ void IsisMain() { qDebug() << " Create output mosaic"; qDebug() << " Modify Group [BandBin] so it will differ"; qDebug() << " Mosaic the same cube to verify proper error is thrown"; - + p.SetOutputCube("TO", 5, 5, 1); p.EndProcess(); - + ProcessMosaic m13; - m13.SetInputCube("FROM", 1, 1, 1, -1, -1, -1); + m13.SetInputCube("FROM", 1, 1, 1, -1, -1, -1); Cube *c = m13.SetOutputCube("TO"); m13.StartProcess(1, 1, 1); Pvl *pvl = c->label(); PvlKeyword &key = pvl->findKeyword("OriginalBand", Pvl::Traverse); key[0] = "3"; m13.EndProcess(); - + try { ProcessMosaic m; m.SetOutputCube("TO"); @@ -682,18 +681,18 @@ void testOut(int piSamples, int piLines, break; } } - + // Test the tracking cube if (cOutCube.hasGroup("Tracking")) { - + qDebug() << ""; - + qDebug() << "*** Tracking Cube *** "; - + QString trackingBase = FileName(cOutCube.fileName()).removeExtension().expanded().split("/").last(); trackingCube.open(trackingBase + "_tracking.cub"); Portal trackingPortal(5, 1, trackingCube.pixelType()); - + for (int line = 1; line <= 5; line++) { trackingPortal.SetPosition(1, line, 1); //sample, line, band position trackingCube.read(trackingPortal); @@ -701,7 +700,7 @@ void testOut(int piSamples, int piLines, QString pixelString; QString fileIndex; - + if (IsSpecial(trackingPortal[iPixel])) { if (trackingPortal[iPixel] == Isis::Null) { pixelString = "Null"; @@ -728,8 +727,8 @@ void testOut(int piSamples, int piLines, pixelString = Isis::toString((unsigned int)trackingPortal[iPixel]); fileIndex = Isis::toString((unsigned int)trackingPortal[iPixel] - 2); } - - qDebug() << "(" << Isis::toString(line) + + qDebug() << "(" << Isis::toString(line) << "," << Isis::toString(iPixel + 1) << ")=" << pixelString << ", " << fileIndex; @@ -738,7 +737,7 @@ void testOut(int piSamples, int piLines, } qDebug() << ""; } - + cOutCube.close(); trackingCube.close(); } diff --git a/isis/src/base/objs/Spice/Spice.cpp b/isis/src/base/objs/Spice/Spice.cpp index b4cbf44b23..5631742718 100644 --- a/isis/src/base/objs/Spice/Spice.cpp +++ b/isis/src/base/objs/Spice/Spice.cpp @@ -63,7 +63,7 @@ namespace Isis { // TODO: DOCUMENT EVERYTHING Spice::Spice(Cube &cube) { Pvl &lab = *cube.label(); - if (cube.hasBlob("String", "CSMState")) { + if (cube.hasBlob("CSMState", "String")) { csmInit(cube, lab); } else { diff --git a/isis/src/base/objs/StretchBlob/Makefile b/isis/src/base/objs/StretchBlob/Makefile deleted file mode 100644 index f122bc8822..0000000000 --- a/isis/src/base/objs/StretchBlob/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -ifeq ($(ISISROOT), $(BLANK)) -.SILENT: -error: - echo "Please set ISISROOT"; -else - include $(ISISROOT)/make/isismake.objs -endif \ No newline at end of file diff --git a/isis/src/base/objs/StretchBlob/StretchBlob.cpp b/isis/src/base/objs/StretchBlob/StretchBlob.cpp deleted file mode 100644 index 5ea0ada823..0000000000 --- a/isis/src/base/objs/StretchBlob/StretchBlob.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ - -#include -#include - -#include "StretchBlob.h" -#include "IException.h" - -using namespace std; -namespace Isis { - - /** - * Default constructor - */ - StretchBlob::StretchBlob() : Blob("CubeStretch", "Stretch"), m_stretch() { - } - - - /** - * Construct a StretchBlob from a CubeStretch. - */ - StretchBlob::StretchBlob(CubeStretch stretch) : Blob("CubeStretch", "Stretch"), m_stretch(stretch){ - p_blobPvl["Name"] = m_stretch.getName(); - p_blobPvl += PvlKeyword("StretchType", m_stretch.getType()); - p_blobPvl += PvlKeyword("BandNumber", QString::number(m_stretch.getBandNumber())); - } - - - /** - * Construct a StretchBlob with provided name. - * - * @param name Name to use for Stretch - */ - StretchBlob::StretchBlob(QString name) : Blob(name, "Stretch"), m_stretch(name) { - } - - - /** - * Default Destructor - */ - StretchBlob::~StretchBlob() { - } - - - CubeStretch StretchBlob::getStretch() { - return m_stretch; - } - - /** - * Read saved Stretch data from a Cube into this object. - * - * This is called by Blob::Read() and is the actual data reading function - * ultimately called when running something like cube->read(stretch); - * - * @param is input stream containing the saved Stretch information - */ - void StretchBlob::ReadData(std::istream &is) { - // Set the Stretch Type - m_stretch.setType(p_blobPvl["StretchType"][0]); - m_stretch.setBandNumber(p_blobPvl["BandNumber"][0].toInt()); - - // Read in the Stretch Pairs - streampos sbyte = p_startByte - 1; - is.seekg(sbyte, std::ios::beg); - if (!is.good()) { - QString msg = "Error preparing to read data from " + m_stretch.getType() + - " [" + p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - - char *buf = new char[p_nbytes+1]; - memset(buf, 0, p_nbytes + 1); - - is.read(buf, p_nbytes); - - // Read buffer data into a QString so we can call Parse() - std::string stringFromBuffer(buf); - m_stretch.Parse(QString::fromStdString(stringFromBuffer)); - - delete [] buf; - - if (!is.good()) { - QString msg = "Error reading data from " + p_type + " [" + - p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - } - - - /** - * Initializes for writing stretch to cube blob - */ - void StretchBlob::WriteInit() { - p_nbytes = m_stretch.Text().toStdString().size(); - } - - - /** - * Writes the stretch information to a cube. - * - * This is called by Blob::write() and is ultimately the function - * called when running something like cube->write(stretch); - * - * @param os output stream to write the stretch data to. - */ - void StretchBlob::WriteData(std::fstream &os) { - os.write(m_stretch.Text().toStdString().c_str(), p_nbytes); - } - -} // end namespace isis - - diff --git a/isis/src/base/objs/StretchBlob/StretchBlob.h b/isis/src/base/objs/StretchBlob/StretchBlob.h deleted file mode 100644 index dbf3959287..0000000000 --- a/isis/src/base/objs/StretchBlob/StretchBlob.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef StretchBlob_h -#define StretchBlob_h - -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ - -#include -#include -#include - -#include "Blob.h" -#include "CubeStretch.h" - -namespace Isis { - /** - * @brief Blob to store stretch information for a cube, on a cube. - * - * @ingroup Utility - * - * @author 2020-07-28 Kristin Berry and Stuart Sides - * - * @internal - * @history 2020-07-28 Kristin Berry and Stuart Sides - Original Version - */ - class StretchBlob : public Isis::Blob { - public: - StretchBlob(); - StretchBlob(CubeStretch stretch); - StretchBlob(QString name); - ~StretchBlob(); - - CubeStretch getStretch(); - - protected: - void WriteInit(); - void ReadData(std::istream &is); - void WriteData(std::fstream &os); - - private: - CubeStretch m_stretch; //! Stretch associated with the blob - }; -}; - -#endif - diff --git a/isis/src/base/objs/StringBlob/Makefile b/isis/src/base/objs/StringBlob/Makefile deleted file mode 100644 index f122bc8822..0000000000 --- a/isis/src/base/objs/StringBlob/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -ifeq ($(ISISROOT), $(BLANK)) -.SILENT: -error: - echo "Please set ISISROOT"; -else - include $(ISISROOT)/make/isismake.objs -endif \ No newline at end of file diff --git a/isis/src/base/objs/StringBlob/StringBlob.cpp b/isis/src/base/objs/StringBlob/StringBlob.cpp deleted file mode 100644 index fb754ca905..0000000000 --- a/isis/src/base/objs/StringBlob/StringBlob.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/** This is free and unencumbered software released into the public domain. - -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include -#include "StringBlob.h" -#include "Application.h" - -using namespace std; -namespace Isis { - /** - * Constructor for creating a string blob with no arguments - */ - StringBlob::StringBlob() : Isis::Blob("IsisCube", "String") { - m_string = ""; - } - - /** - * Constructor for creating a string blob with a file to - * read labels from. - * - * @param file File to read labels from - */ - StringBlob::StringBlob(const QString &file) : - Isis::Blob("IsisCube", "String") { - Blob::Read(file); - } - - /** - * Constructor for creating a string blob with a standard string - * - * @param string String to read/write from the cube. - */ - StringBlob::StringBlob(std::string str, QString name) : Isis::Blob(name, "String") { - m_string = str; - } - - // Destructor - StringBlob::~StringBlob() { - } - - /** - * Prepare to write string to output cube - */ - void StringBlob::WriteInit() { - p_nbytes = m_string.size(); - - if (p_buffer != NULL) { - delete p_buffer; - } - - p_buffer = new char[p_nbytes]; - const char *ptr = m_string.c_str(); - memcpy(p_buffer, (void *)ptr, p_nbytes); - } - - /** - * Read binary data from an input stream into the string. - * - * @param stream The input stream to read from. - * - * @throws IException::Io - Error reading data from stream - */ - void StringBlob::ReadData(std::istream &stream) { - // Read the binary data - if (p_buffer != NULL) delete [] p_buffer; - p_buffer = new char[p_nbytes]; - - streampos sbyte = p_startByte - 1; - stream.seekg(sbyte, std::ios::beg); - if (!stream.good()) { - QString msg = "Error preparing to read data from " + p_type + - " [" + p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - - stream.read(p_buffer, p_nbytes); - if (!stream.good()) { - QString msg = "Error reading data from " + p_type + " [" + p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - - m_string = std::string(p_buffer, p_nbytes); - } -} diff --git a/isis/src/base/objs/StringBlob/StringBlob.h b/isis/src/base/objs/StringBlob/StringBlob.h deleted file mode 100644 index ab0723b4b6..0000000000 --- a/isis/src/base/objs/StringBlob/StringBlob.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef StringBlob_h -#define StringBlob_h - -/** This is free and unencumbered software released into the public domain. - -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ - -#include - -#include "Blob.h" - -namespace Isis { - /** - * @brief Read and store std::strings on the cube. - * - * - * @ingroup LowLevelCubeIO - * - * @author 2020-11-19 Kristin Berry - Original Version - * - * @internal - * @history 2020-11-19 Kristin Berry - Original Version - */ - class StringBlob : public Isis::Blob { - public: - StringBlob(); - StringBlob(const QString &file); - StringBlob(std::string str, QString name); - ~StringBlob(); - - std::string string() { - return m_string; - } - - protected: - // prepare data for writing - void WriteInit(); - void ReadData(std::istream &stream); - - private: - std::string m_string; - }; -}; - -#endif - diff --git a/isis/src/base/objs/Table/Table.cpp b/isis/src/base/objs/Table/Table.cpp index aebfdbaf43..4c6b47afd7 100644 --- a/isis/src/base/objs/Table/Table.cpp +++ b/isis/src/base/objs/Table/Table.cpp @@ -9,107 +9,118 @@ find files of those names at the top level of this repository. **/ #include #include +#include "Blob.h" #include "Endian.h" #include "IException.h" -#include "Pvl.h" #include "TableField.h" using namespace std; namespace Isis { + Table::Table(Blob &blob) { + initFromBlob(blob); + } + + /** - * This constructor creates a new table using the given name and record. - * - * Note that the record is not added to this table. It is used to read the - * TableField names and set the record size (i.e. the number of bytes per - * record). Thus any records added to this table will be required to match - * this size. - * + * This constructor creates a new table using the given name and record. + * + * Note that the record is not added to this table. It is used to read the + * TableField names and set the record size (i.e. the number of bytes per + * record). Thus any records added to this table will be required to match + * this size. + * * In this constructor, the Table::Association is set to None, the ByteOrder - * keyword in the labels is set to NULL, and the record information is added - * to the table. - * - * This constructor also calls the parent constructor Blob(tableName, - * "Table"). + * keyword in the labels is set to NULL, and the record information is added + * to the table. + * + * This constructor also calls the parent constructor Blob(tableName, + * "Table"). * * @param tableName Name of the Table to be read * @param rec Name of the TableRecord to be read into the Table */ - Table::Table(const QString &tableName, Isis::TableRecord &rec) : - Blob(tableName, "Table") { + Table::Table(const QString &tableName, Isis::TableRecord &rec) { + p_name = tableName; p_assoc = Table::None; - p_blobPvl += Isis::PvlKeyword("Records", 0); - p_blobPvl += Isis::PvlKeyword("ByteOrder", "NULL"); - for (int f = 0; f < rec.Fields(); f++) p_blobPvl.addGroup(rec[f].pvlGroup()); + p_label += Isis::PvlKeyword("Records", 0); + p_label += Isis::PvlKeyword("ByteOrder", "NULL"); + for (int f = 0; f < rec.Fields(); f++) { + p_label.addGroup(rec[f].pvlGroup()); + } p_record = rec; } + /** - * This constructor creates an empty table from an existing table name - * to be read in when the Read() method is called. It should not be - * used to construct a new table object whose data will be filled - * in later since the record size will be set to 0. This constructor - * sets the Table::Association to None. - * - * This constructor also calls the parent constructor + * This constructor creates an empty table from an existing table name + * to be read in when the Read() method is called. It should not be + * used to construct a new table object whose data will be filled + * in later since the record size will be set to 0. This constructor + * sets the Table::Association to None. + * + * This constructor also calls the parent constructor * Blob(tableName, "Table"). * * @param tableName Name of the Table to be read */ - Table::Table(const QString &tableName) : - Isis::Blob(tableName, "Table") { + Table::Table(const QString &tableName) { + p_name = tableName; p_assoc = Table::None; } + /** - * This constructor reads an existing table using the given table name and + * This constructor reads an existing table using the given table name and * file containing the table. This constructor sets the Table::Association * to the Association keyword value in the Blob Pvl read from the file, if * the keyword exists. - * - * This constructor also calls the parent constructor + * + * This constructor also calls the parent constructor * Blob(tableName, "Table"). - * + * * @param tableName Name of the Table to be read - * @param file Name of the file to be read into the Table - * - * @see Blob::Read() + * @param file Name of the file to be read into the Table + * + * @see Blob::Read() */ - Table::Table(const QString &tableName, const QString &file) : - Blob(tableName, "Table") { - p_assoc = Table::None; - Read(file); + Table::Table(const QString &tableName, const QString &file) { + Blob blob(tableName, "Table", file); + initFromBlob(blob); } + /** - * This constructor reads an existing table using the given table name and - * file containing the table and pvl labels. This constructor sets the - * Table::Association to the Association keyword value in the Blob Pvl - * read from the file, if the keyword exists. - * - * This constructor also calls the parent constructor + * This constructor reads an existing table using the given table name and + * file containing the table and pvl labels. This constructor sets the + * Table::Association to the Association keyword value in the Blob Pvl + * read from the file, if the keyword exists. + * + * This constructor also calls the parent constructor * Blob(tableName, "Table"). * * @param tableName The name of the Table to be read * @param file The name of the file to be read into the Table * @param fileHeader Pvl labels. - * - * @see Blob::Read() + * + * @see Blob::Read() */ - Table::Table(const QString &tableName, const QString &file, - const Pvl &fileHeader) : Blob(tableName, "Table") { - p_assoc = Table::None; - Read(file, fileHeader); + Table::Table(const QString &tableName, const QString &file, const Pvl &fileHeader) { + Blob blob(tableName, "Table"); + blob.Read(file, fileHeader); + initFromBlob(blob); } /** * Copy constructor for an Table object. This constructor copies TableRecords - * and the member variable values for record, records, assoc, and swap. + * and the member variable values for record, records, assoc, and swap. * * @param other The table to copy from */ - Table::Table(const Table &other) : Blob(other) { + Table::Table(const Table &other) { + p_name = other.p_name; + p_label = other.p_label; p_record = other.p_record; p_records = other.p_records; p_assoc = other.p_assoc; @@ -126,18 +137,70 @@ namespace Isis { } } + /** - * Sets the Table equal to the input Table object. This method copies - * TableRecords and the member variable values for record, records, assoc, and - * swap. + * Initialize a Table from a Blob that has been read from a file. + * + * @param blob The blob to extract the data for the Table from. + */ + void Table::initFromBlob(Blob &blob) { + Clear(); + + p_label = blob.Label(); + + p_name = p_label["Name"][0]; + p_records = p_label["Records"]; + + Isis::TableRecord rec; + for (int g = 0; g < p_label.groups(); g++) { + if (p_label.group(g).isNamed("Field")) { + Isis::TableField f(p_label.group(g)); + rec += f; + } + } + + p_record = rec; + + p_assoc = Table::None; + if (p_label.hasKeyword("Association")) { + QString temp = (QString) p_label["Association"]; + temp = temp.toUpper(); + if (temp == "SAMPLES") p_assoc = Table::Samples; + if (temp == "LINES") p_assoc = Table::Lines; + if (temp == "BANDS") p_assoc = Table::Bands; + } + + // Determine if we need to swap stuff when we read the data + Isis::ByteOrder bo = Isis::ByteOrderEnumeration(p_label["ByteOrder"]); + p_swap = false; + if (Isis::IsLsb() && (bo == Isis::Msb)) p_swap = true; + if (Isis::IsMsb() && (bo == Isis::Lsb)) p_swap = true; + + for (int rec = 0; rec < p_records; rec++) { + size_t bufferPos = rec * RecordSize(); + + char *buf = new char[RecordSize()]; + memcpy(buf, &blob.getBuffer()[bufferPos], RecordSize()); + + if (p_swap) p_record.Swap(buf); + p_recbufs.push_back(buf); + } + } + + + /** + * Sets the Table equal to the input Table object. This method copies + * TableRecords and the member variable values for record, records, assoc, and + * swap. + * + * @param other The table to copy from * - * @param other The table to copy from - * * @return @b Table The copied table. */ Table &Table::operator=(const Isis::Table &other) { Clear(); - *((Isis::Blob *)this) = *((Isis::Blob *)&other); + p_name = other.p_name; + p_label = other.p_label; p_record = other.p_record; p_records = other.p_records; p_assoc = other.p_assoc; @@ -156,11 +219,49 @@ namespace Isis { return *this; } + //! Destroys the Table object Table::~Table() { Clear(); } + + /** + * Write the Table to a file. + * + * This uses a Blob to serialize the Table data, see Blob::Write. + * + * @param file The file to write the Table to. + */ + void Table::Write(const QString &file) { + Blob blob = toBlob(); + blob.Write(file); + } + + + /** + * The Table's name + * + * @return @b QString the name of the Table + */ + QString Table::Name() const { + return p_name; + } + + + /** + * The Table's label + * + * Additional information can be stored on the Table's label and will be serialized + * in the Blob's label when written out to a file. + * + * @return @b PvlObject A reference to the label that can be modified + */ + PvlObject &Table::Label() { + return p_label; + } + + /** * Sets the association to the input parameter * @@ -170,36 +271,40 @@ namespace Isis { p_assoc = assoc; } + /** * Checks to see if association is Samples * - * @return @b bool Returns true if association is Samples, and false if it is + * @return @b bool Returns true if association is Samples, and false if it is * not */ bool Table::IsSampleAssociated() { return (p_assoc == Table::Samples); } + /** * Checks to see if association is Lines * - * @return @b bool Returns true if association is Lines, and false if it is + * @return @b bool Returns true if association is Lines, and false if it is * not */ bool Table::IsLineAssociated() { return (p_assoc == Table::Lines); } + /** * Checks to see if association is Bands * - * @return @b bool Returns true if association is Bands, and false if it is + * @return @b bool Returns true if association is Bands, and false if it is * not */ bool Table::IsBandAssociated() { return (p_assoc == Table::Bands); } + /** * Returns the number of records * @@ -209,6 +314,7 @@ namespace Isis { return p_recbufs.size(); } + /** * Returns the number of fields per record * @@ -218,6 +324,7 @@ namespace Isis { return p_record.Fields(); } + /** * Returns the number of bytes per record * @@ -227,6 +334,7 @@ namespace Isis { return p_record.RecordSize(); } + /** * Reads a TableRecord from the Table * @@ -239,6 +347,7 @@ namespace Isis { return p_record; } + /** * Adds a TableRecord to the Table * @@ -246,15 +355,15 @@ namespace Isis { */ void Table::operator+=(Isis::TableRecord &rec) { if (RecordSize() == 0) { - IString msg = "Unable to add records to Isis Table [" - + p_blobName + "]. Bytes per record = [0 bytes]."; + IString msg = "Unable to add records to Isis Table [" + + p_name + "]. Bytes per record = [0 bytes]."; throw IException(IException::Unknown, msg, _FILEINFO_); } if (RecordSize() != rec.RecordSize()) { - QString msg = "Unable to add the given record with size = [" - + Isis::toString(rec.RecordSize()) + " bytes] to to Isis Table [" - + p_blobName + "] with record size = [" + QString msg = "Unable to add the given record with size = [" + + Isis::toString(rec.RecordSize()) + " bytes] to to Isis Table [" + + p_name + "] with record size = [" + Isis::toString(RecordSize()) + " bytes]. Record sizes must match."; throw IException(IException::Unknown, msg, _FILEINFO_); } @@ -263,6 +372,7 @@ namespace Isis { p_recbufs.push_back(newbuf); } + /** * Updates a TableRecord * @@ -273,6 +383,7 @@ namespace Isis { rec.Pack(p_recbufs[index]); } + /** * Deletes a TableRecord from the Table * @@ -285,6 +396,7 @@ namespace Isis { p_recbufs.erase(it); } + /** * Clear the table of all records */ @@ -293,107 +405,74 @@ namespace Isis { p_recbufs.clear(); } - //! Virtual function to validate PVL table information - void Table::ReadInit() { - p_records = p_blobPvl["Records"]; - - Isis::TableRecord rec; - for (int g = 0; g < p_blobPvl.groups(); g++) { - if (p_blobPvl.group(g).isNamed("Field")) { - Isis::TableField f(p_blobPvl.group(g)); - rec += f; - } - } - - p_record = rec; - - if (p_blobPvl.hasKeyword("Association")) { - QString temp = (QString) p_blobPvl["Association"]; - temp = temp.toUpper(); - if (temp == "SAMPLES") p_assoc = Table::Samples; - if (temp == "LINES") p_assoc = Table::Lines; - if (temp == "BANDS") p_assoc = Table::Bands; - } - - // Determine if we need to swap stuff when we read the data - Isis::ByteOrder bo = Isis::ByteOrderEnumeration(p_blobPvl["ByteOrder"]); - p_swap = false; - if (Isis::IsLsb() && (bo == Isis::Msb)) p_swap = true; - if (Isis::IsMsb() && (bo == Isis::Lsb)) p_swap = true; - - // Cleanup in case of a re-read - Clear(); - } /** - * Virtual function to Read the data + * Serialze the Table to a Blob that can be written to a file. * - * @param stream InputStream to read data in from - * - * @throws Isis::IException::Io - Error reading or preparing to read a record + * @return @b Blob The Blob contaning the Table's data */ - void Table::ReadData(std::istream &stream) { - for (int rec = 0; rec < p_records; rec++) { - streampos sbyte = (streampos)(p_startByte - 1) + - (streampos)(rec * RecordSize()); - stream.seekg(sbyte, std::ios::beg); - if (!stream.good()) { - QString msg = "Error preparing to read record [" + Isis::toString(rec + 1) + - "] from Table [" + p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } - - char *buf = new char[RecordSize()]; - stream.read(buf, RecordSize()); - if (!stream.good()) { - QString msg = "Error reading record [" + Isis::toString(rec + 1) + - "] from Table [" + p_blobName + "]"; - throw IException(IException::Io, msg, _FILEINFO_); - } + Blob Table::toBlob() const { + Blob tableBlob(Name(), "Table"); + PvlObject &blobLabel = tableBlob.Label(); - if (p_swap) p_record.Swap(buf); - p_recbufs.push_back(buf); - } - } - - //! Virtual Function to prepare labels for writing - void Table::WriteInit() { - p_blobPvl["Records"] = Isis::toString(Records()); - p_nbytes = Records() * RecordSize(); + // Label setup + blobLabel += PvlKeyword("Records", Isis::toString(Records())); + int nbytes = Records() * RecordSize(); if (Isis::IsLsb()) { - p_blobPvl["ByteOrder"] = Isis::ByteOrderName(Isis::Lsb); + blobLabel+= PvlKeyword("ByteOrder", Isis::ByteOrderName(Isis::Lsb)); } else { - p_blobPvl["ByteOrder"] = Isis::ByteOrderName(Isis::Msb); + blobLabel+= PvlKeyword("ByteOrder", Isis::ByteOrderName(Isis::Msb)); } - if (p_blobPvl.hasKeyword("Association")) { - p_blobPvl.deleteKeyword("Association"); - } if (p_assoc == Samples) { - p_blobPvl += Isis::PvlKeyword("Association", "Samples"); + blobLabel += Isis::PvlKeyword("Association", "Samples"); } else if (p_assoc == Lines) { - p_blobPvl += Isis::PvlKeyword("Association", "Lines"); + blobLabel += Isis::PvlKeyword("Association", "Lines"); } else if (p_assoc == Bands) { - p_blobPvl += Isis::PvlKeyword("Association", "Bands"); + blobLabel += Isis::PvlKeyword("Association", "Bands"); } - } - /** - * Virtual function to write the data - * - * @param os Outputstream to write the data to - */ - void Table::WriteData(std::fstream &os) { + for (int i = 0; i < p_label.keywords(); i++) { + if (!blobLabel.hasKeyword(p_label[i].name())) { + blobLabel += p_label[i]; + } + } + + for (int g = 0; g < p_label.groups(); g++) { + blobLabel += p_label.group(g); + } + + // Binary data setup + char *buf = new char[nbytes]; + for (int rec = 0; rec < Records(); rec++) { - os.write(p_recbufs[rec], RecordSize()); + size_t bufferPos = rec * RecordSize(); + + memcpy(&buf[bufferPos], p_recbufs[rec], RecordSize()); } + + tableBlob.takeData(buf, nbytes); + + return tableBlob; } + /** + * Convert the data from a Table into a string. + * + * This method will convert all of the Table's records and fields into a + * string but will not serialze any label information. See TableRecord::toString + * for how the records are converted into a string. + * + * @param table The Table to serialize + * @param fieldDelimiter The delimiter to use between fields + * + * @return @b QString The Table data as a string + */ QString Table::toString(Table table, QString fieldDelimiter) { QString tableValues; // add the first record with header, the given delimiter, and a new line after each record diff --git a/isis/src/base/objs/Table/Table.h b/isis/src/base/objs/Table/Table.h index 8bae494d75..c5db233568 100644 --- a/isis/src/base/objs/Table/Table.h +++ b/isis/src/base/objs/Table/Table.h @@ -6,12 +6,12 @@ For more details about the LICENSE terms and the AUTHORS, you will find files of those names at the top level of this repository. **/ /* SPDX-License-Identifier: CC0-1.0 */ -#include "Blob.h" +#include "Pvl.h" #include #include "TableRecord.h" namespace Isis { - class Pvl; + class Blob; /** * @brief Class for storing Table blobs information. * @@ -19,7 +19,7 @@ namespace Isis { * general, records correspond to rows and fields correspond to columns. Thus * the TableRecord class corresponds to a vector of row entries and * TableField class corresponds to a specific entry of the table for a given - * record. Isis Table objects are record based, N records in a table. Each + * record. Isis Table objects are record based, N records in a table. Each * record will have the same number of fields, F. The fields can be of * different types including Integer, Double, Text, and Real. The class * uses PVL to store the structure of the table N, F, and Field types and @@ -58,7 +58,7 @@ namespace Isis { * overhaul of the mosaic tracking now being handled in a separate * tracking cube. */ - class Table : public Isis::Blob { + class Table { public: /** * @@ -72,6 +72,7 @@ namespace Isis { // Constructors and Destructors Table(); + Table(Blob &blob); Table(const QString &tableName, TableRecord &rec); Table(const QString &tableName);// Only use this constructor for reading in an existing table Table(const QString &tableName, const QString &file); @@ -83,8 +84,10 @@ namespace Isis { ~Table(); - friend std::istream&operator>>(std::istream &is, Table &table); - friend std::ostream&operator<<(std::ostream &os, Table &table); + void Write(const QString &file); + + QString Name() const; + PvlObject &Label(); void SetAssociation(const Table::Association assoc); bool IsSampleAssociated(); @@ -109,14 +112,15 @@ namespace Isis { void Clear(); + Blob toBlob() const; + static QString toString(Table table, QString fieldDelimiter=","); + protected: - void ReadInit(); - void ReadData(std::istream &stream); - void WriteInit(); - void WriteData(std::fstream &os); + + void initFromBlob(Blob &blob); TableRecord p_record; //!< The current table record std::vector p_recbufs; //!< Buffers containing record values @@ -126,6 +130,9 @@ namespace Isis { Association p_assoc; //!< Association Type of the table bool p_swap; //!< Only used for reading + + QString p_name; //!< The name of the Table + PvlObject p_label; //!< The label for storing additional information }; }; diff --git a/isis/src/base/objs/Table/Table.truth b/isis/src/base/objs/Table/Table.truth deleted file mode 100644 index e9b502b775..0000000000 --- a/isis/src/base/objs/Table/Table.truth +++ /dev/null @@ -1,52 +0,0 @@ -Testing Table(name, record) constructor and Write(filename) method... - -Testing Table(name) constructor and Read(filename) method... -5 3.14 PI 3.14159 --1 0.5 HI -0.55 - -Testing accessor methods... -Number of Records = 2 -Number of Fields = 4 -Record Size = 30 - -Testing Association Checks -Sample Associated? 0 -Line Associated? 1 -Band Associated? 0 - -Testing Table(name, filename) constructor and Update(record, index) method... -19 2.2 Blob 4.4 --1 0.5 HI -0.55 - -Testing Record Delete method... -Number of Records Before Delete = 2 -Number of Fields Before Delete = 4 -Number of Records After Delete = 1 -Number of Fields After Delete = 4 - -Testing operator= method with empty table... --1 0.5 HI -0.55 - -Testing operator= method with non empty table... --1 0.5 HI -0.55 - -Testing Clear method... -Number of Records = 0 -Number of Fields = 4 - -InstrumentPointing Table... -0.596902, -0.444323, 0.137533, 0.653735, -1.80464e+08, - -Camera Statistics Table... -Latitude, -80.7077, -80.1075, -80.4042, 0.159275, -Longitude, 137.758, 140.629, 139.157, 0.688553, -SampleResolution, 366.342, 369.421, 367.879, 0.900358, -LineResolution, 366.342, 369.421, 367.879, 0.900358, -Resolution, 366.342, 369.421, 367.879, 0.900358, -AspectRatio, 1, 1, 1, 0, -PhaseAngle, 43.0603, 43.6753, 43.3679, 0.134822, -EmissionAngle, 41.9388, 42.9951, 42.4658, 0.295943, -IncidenceAngle, 81.0203, 81.6498, 81.3315, 0.156168, -LocalSolarTime, 11.4007, 11.5921, 11.4939, 0.0459036, -LocalRadius, 1.73386e+06, 1.73541e+06, 1.73471e+06, 346.622, -NorthAzimuth, 104.165, 109.023, 106.801, 1.04151, diff --git a/isis/src/base/objs/Table/unitTest.cpp b/isis/src/base/objs/Table/unitTest.cpp deleted file mode 100644 index ba2133683e..0000000000 --- a/isis/src/base/objs/Table/unitTest.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include - -#include "IException.h" -#include "Preference.h" -#include "Table.h" -#include "TableField.h" -#include "TableRecord.h" - -using namespace std; -using namespace Isis; - -int main(int argc, char *argv[]) { - Preference::Preferences(true); - - try { - TableField f1("Column1", TableField::Integer); - TableField f2("Column2", TableField::Double); - TableField f3("Column3", TableField::Text, 10); - TableField f4("Column4", TableField::Double); - TableRecord rec; - rec += f1; - rec += f2; - rec += f3; - rec += f4; - cout << "Testing Table(name, record) constructor and Write(filename) method..." << endl << endl; - Table t("UNITTEST", rec); - - rec[0] = 5; - rec[1] = 3.14; - rec[2] = "PI"; - rec[3] = 3.14159; - t += rec; - - rec[0] = -1; - rec[1] = 0.5; - rec[2] = "HI"; - rec[3] = -0.55; - t += rec; - - // write first table to tTest - t.Write("tTest"); - - // Use constructor that takes existing file name - case insensitive - cout << "Testing Table(name) constructor and Read(filename) method..." << endl; - Table t2("UnitTest"); - // Read table from tTest file - t2.Read("tTest"); - for (int i = 0; i < t2.Records(); i++) { - for (int j = 0; j < t2.RecordFields(); j++) { - if (j == 0) { - cout << (int) t2[i][j] << "\t"; - } - else if (j == 1 || j == 3) { - cout << (double) t2[i][j] << "\t"; - } - else if (j == 2) { - cout << QString(t2[i][j]) << "\t"; - } - } - cout << endl; - } - cout << endl; - - cout << "Testing accessor methods..." << endl; - cout << "Number of Records = " << t2.Records() << endl; - cout << "Number of Fields = " << t2.RecordFields() << endl; - cout << "Record Size = " << t2.RecordSize() << endl; - - rec[0] = 19; - rec[1] = 2.2; - rec[2] = "Blob"; - rec[3] = 4.4; - t2.Update(rec, 0); - t2.SetAssociation(Table::Lines); - t2.Write("tTest"); - - cout << endl << "Testing Association Checks" << endl; - cout << "Sample Associated? " << t2.IsSampleAssociated() << endl; - cout << "Line Associated? " << t2.IsLineAssociated() << endl; - cout << "Band Associated? " << t2.IsBandAssociated() << endl; - cout << endl; - - // use constructor that takes name and file - cout << "Testing Table(name, filename) constructor and Update(record, index) method..." << endl; - Table t3("UnitTest", "tTest"); - for (int i = 0; i < t3.Records(); i++) { - for (int j = 0; j < t3.RecordFields(); j++) { - if (j == 0) { - cout << (int) t3[i][j] << "\t"; - } - else if (j == 1 || j == 3) { - cout << (double) t3[i][j] << "\t"; - } - else if (j == 2) { - cout << QString(t3[i][j]) << "\t"; - } - } - cout << endl; - } - cout << endl; - - cout << "Testing Record Delete method..." << endl; - cout << "Number of Records Before Delete = " << t3.Records() << endl; - cout << "Number of Fields Before Delete = " << t3.RecordFields() << endl; - t3.Delete(0); - cout << "Number of Records After Delete = " << t3.Records() << endl; - cout << "Number of Fields After Delete = " << t3.RecordFields() << endl << endl; - - // use operator= - Table t4 = t3; - cout << "Testing operator= method with empty table..." << endl; - for (int i = 0; i < t4.Records(); i++) { - for (int j = 0; j < t4.RecordFields(); j++) { - if (j == 0) { - cout << (int) t4[i][j] << "\t"; - } - else if (j == 1 || j == 3) { - cout << (double) t4[i][j] << "\t"; - } - else if (j == 2) { - cout << QString(t4[i][j]) << "\t"; - } - } - cout << endl; - } - cout << endl; - - Table t5 = t2; - t5 = t4; - cout << "Testing operator= method with non empty table..." << endl; - for (int i = 0; i < t5.Records(); i++) { - for (int j = 0; j < t5.RecordFields(); j++) { - if (j == 0) { - cout << (int) t5[i][j] << "\t"; - } - else if (j == 1 || j == 3) { - cout << (double) t5[i][j] << "\t"; - } - else if (j == 2) { - cout << QString(t5[i][j]) << "\t"; - } - } - cout << endl; - } - cout << endl; - - cout << "Testing Clear method..." << endl; - t4.Clear(); - cout << "Number of Records = " << t4.Records() << endl; - cout << "Number of Fields = " << t4.RecordFields() << endl << endl; - remove("tTest"); - - cout << "InstrumentPointing Table..." << endl; - QString name1 = "InstrumentPointing"; - Table instPoint(name1, "$ISISTESTDATA/isis/src/base/unitTestData/Table/truth.cub"); - for(int i = 0; i < instPoint.Records(); i++) { - for(int j = 0; j < instPoint[i].Fields(); j++) { - if(instPoint[i][j].isText()) { - cout << (QString)instPoint[i][j] << ", "; - } - else if(instPoint[i][j].isDouble()) { - cout << (double)instPoint[i][j] << ", "; - } - } - cout << endl; - } - cout << endl; - cout << "Camera Statistics Table..." << endl; - QString name2 = "CameraStatistics"; - Table camStats(name2, "$ISISTESTDATA/isis/src/base/unitTestData/Table/truth.cub"); - for(int i = 0; i < camStats.Records(); i++) { - for(int j = 0; j < camStats[i].Fields(); j++) { - if(camStats[i][j].isText()) { - cout << (QString)camStats[i][j] << ", "; - } - else if(camStats[i][j].isDouble()) { - cout << (double)camStats[i][j] << ", "; - } - } - cout << endl; - } - - } - catch(IException &e) { - e.print(); - } -} diff --git a/isis/src/base/objs/UniversalGroundMap/UniversalGroundMap.cpp b/isis/src/base/objs/UniversalGroundMap/UniversalGroundMap.cpp index 56c4611b58..fb5ca41ad9 100644 --- a/isis/src/base/objs/UniversalGroundMap/UniversalGroundMap.cpp +++ b/isis/src/base/objs/UniversalGroundMap/UniversalGroundMap.cpp @@ -335,8 +335,7 @@ namespace Isis { // If we have a footprint, use it try { if (cube) { - ImagePolygon poly; - cube->read(poly); + ImagePolygon poly = cube->readFootprint(); geos::geom::MultiPolygon *footprint = PolygonTools::MakeMultiPolygon( poly.Polys()->clone()); diff --git a/isis/src/cassini/apps/cisscal/main.cpp b/isis/src/cassini/apps/cisscal/main.cpp index e78a490006..dac7af11c8 100644 --- a/isis/src/cassini/apps/cisscal/main.cpp +++ b/isis/src/cassini/apps/cisscal/main.cpp @@ -669,8 +669,7 @@ vector gbl::OverclockFit() { // -col 3 is the "average" of the overclocked pixels // -if there are 2 overclocks, columns 1 and 2 contain them // -otherwise column 1 is all null and we use column 2 - Table overClkTable("ISS Prefix Pixels"); - gbl::incube->read(overClkTable); + Table overClkTable = gbl::incube->readTable("ISS Prefix Pixels"); for(int i = 0; i < overClkTable.Records(); i++) { overclocks.push_back(overClkTable[i]["OverclockPixels"]); } diff --git a/isis/src/control/apps/autoseed/autoseed.cpp b/isis/src/control/apps/autoseed/autoseed.cpp index c49717efd0..e663f8324c 100644 --- a/isis/src/control/apps/autoseed/autoseed.cpp +++ b/isis/src/control/apps/autoseed/autoseed.cpp @@ -17,6 +17,7 @@ find files of those names at the top level of this repository. **/ #include "Application.h" #include "Brick.h" +#include "Camera.h" #include "CameraFactory.h" #include "ControlMeasure.h" #include "ControlNet.h" @@ -26,12 +27,12 @@ find files of those names at the top level of this repository. **/ #include "IException.h" #include "ImageOverlap.h" #include "ImageOverlapSet.h" -#include "ImagePolygon.h" #include "IString.h" #include "PolygonSeeder.h" #include "PolygonSeederFactory.h" #include "PolygonTools.h" -#include "Process.h" +#include "Progress.h" +#include "ProjectionFactory.h" #include "Pvl.h" #include "PvlGroup.h" #include "PvlKeyword.h" diff --git a/isis/src/control/apps/cnetadd/main.cpp b/isis/src/control/apps/cnetadd/main.cpp index ddebf1d7e6..294169273a 100644 --- a/isis/src/control/apps/cnetadd/main.cpp +++ b/isis/src/control/apps/cnetadd/main.cpp @@ -397,15 +397,7 @@ void setControlPointLatLon(SerialNumberList &snl, ControlNet &cnet) { QList getValidPoints(Cube &cube, STRtree &coordTree) { - ImagePolygon poly; - try { - cube.read(poly); - } - catch (IException &e) { - QString msg = "Footprintinit must be run prior to running cnetadd"; - msg += " with POLYGON=TRUE for cube [" + cube.fileName() + "]"; - throw IException(e, IException::User, msg, _FILEINFO_); - } + ImagePolygon poly = cube.readFootprint(); std::vector matches; MultiPolygon *polys = poly.Polys(); diff --git a/isis/src/control/apps/deltack/main.cpp b/isis/src/control/apps/deltack/main.cpp index 97f4b5b782..c7b6c86f7d 100644 --- a/isis/src/control/apps/deltack/main.cpp +++ b/isis/src/control/apps/deltack/main.cpp @@ -82,14 +82,7 @@ void IsisMain() { // we will check for target name inside the SetTarget() call // Prepare for update to the cube history - History hist = History("IsisCube"); - try { - // read history from cube, if it exists. - c.read(hist); - } - catch (IException &e) { - // if the history does not exist in the cube, the cube's write method will add it. - } + History hist = c.readHistory(); //---------------------------------------------------------------------------------- // Execute the requested method diff --git a/isis/src/control/apps/sumspice/SumFinder.cpp b/isis/src/control/apps/sumspice/SumFinder.cpp index 9b0b372730..a550e71e52 100644 --- a/isis/src/control/apps/sumspice/SumFinder.cpp +++ b/isis/src/control/apps/sumspice/SumFinder.cpp @@ -180,14 +180,14 @@ namespace Isis { return ( m_closest ); } - void SumFinder::setCube(const QString &name) { - + void SumFinder::resetCube() { // Always close out the kernels and cubes. m_kernels.reset(); m_cube.reset(); + } - // Empty string clears cube from state - if ( name.isEmpty() ) { return; } + void SumFinder::setCube(const QString &name) { + resetCube(); m_cubename = name; m_cube.reset( new Cube(name, "rw") ); @@ -687,28 +687,5 @@ namespace Isis { } return (ndeleted); } - - /** - * Writes out the History blob to m_cube - */ - void SumFinder::writeHistory() { - bool addedHist = false; - Isis::Pvl &inlab = *m_cube->label(); - for (int i = 0; i < inlab.objects(); i++) { - if ( inlab.object(i).isNamed("History") && Isis::iApp != NULL ) { - Isis::History h( (QString) inlab.object(i)["Name"] ); - m_cube->read(h); - h.AddEntry(); - m_cube->write(h); - addedHist = true; - } - } - - if (!addedHist && Isis::iApp != NULL) { - Isis::History h("IsisCube"); - h.AddEntry(); - m_cube->write(h); - } - } } // namespace Isis diff --git a/isis/src/control/apps/sumspice/SumFinder.h b/isis/src/control/apps/sumspice/SumFinder.h index 5a1588bbe1..d7d20ae699 100644 --- a/isis/src/control/apps/sumspice/SumFinder.h +++ b/isis/src/control/apps/sumspice/SumFinder.h @@ -79,7 +79,8 @@ namespace Isis { double deltaT() const; double closest() const; - void setCube(const QString &name = ""); + void resetCube(); + void setCube(const QString &name); const Cube *cube() const; const QString &name() const; @@ -89,8 +90,6 @@ namespace Isis { bool update(const unsigned int options); - void writeHistory(); - protected: virtual bool calculateTimes(Cube &cube, iTime &startTime, diff --git a/isis/src/control/apps/sumspice/main.cpp b/isis/src/control/apps/sumspice/main.cpp index e487256447..2404d95b21 100644 --- a/isis/src/control/apps/sumspice/main.cpp +++ b/isis/src/control/apps/sumspice/main.cpp @@ -31,6 +31,7 @@ find files of those names at the top level of this repository. **/ #include "IString.h" #include "Kernels.h" #include "NaifStatus.h" +#include "Process.h" #include "Progress.h" #include "Pvl.h" #include "PvlGroup.h" @@ -157,6 +158,7 @@ void IsisMain() { ListOfFinders resultSet; QStringList warnings; + Process process; for (int cubeIndex = 0; cubeIndex < cubeNameList.size(); cubeIndex++) { @@ -181,11 +183,16 @@ void IsisMain() { // This will update the history blob and close the cube, // but retain all the pertinent info - cubesum->writeHistory(); - cubesum->setCube(); + cubesum->resetCube(); resultSet.append(cubesum); + + Isis::CubeAttributeInput att(filename); + Cube *cube = process.SetInputCube(filename, att, Isis::ReadWrite); + process.WriteHistory(*cube); + progress.CheckStatus(); } + process.EndProcess(); if (warnings.size() > 0) { PvlKeyword message("Unmatched"); diff --git a/isis/src/galileo/apps/gllnims2isis/main.cpp b/isis/src/galileo/apps/gllnims2isis/main.cpp index b270ae909f..b27c56b746 100644 --- a/isis/src/galileo/apps/gllnims2isis/main.cpp +++ b/isis/src/galileo/apps/gllnims2isis/main.cpp @@ -15,7 +15,6 @@ find files of those names at the top level of this repository. **/ #include "FileName.h" #include "IException.h" #include "iTime.h" -#include "OriginalLabel.h" #include "Message.h" #include "ProcessImportPds.h" #include "ProcessByLine.h" @@ -146,7 +145,6 @@ void importQubs(QString coreParamName, QString suffixParamName) { } // Create holder for original label - OriginalLabel origLabel(*pdsLabel); //pdsLabel->write(fi.baseName()+".pvl"); //QFileInfo inputFileInfo(inFile.expanded()); diff --git a/isis/src/lo/apps/lopdsgen/main.cpp b/isis/src/lo/apps/lopdsgen/main.cpp index 9a9a047261..3e07736a80 100644 --- a/isis/src/lo/apps/lopdsgen/main.cpp +++ b/isis/src/lo/apps/lopdsgen/main.cpp @@ -85,8 +85,7 @@ void IsisMain() { pdsLabel.addKeyword(productId); // Translate the keywords from the original labels that go in this label - OriginalLabel origBlob; - iCube->read(origBlob); + OriginalLabel origBlob = iCube->readOriginalLabel(); Pvl origLabel; PvlObject origLabelObj = origBlob.ReturnLabels(); origLabelObj.setName("OriginalLabelObject"); diff --git a/isis/src/lro/apps/lronac2isis/lronac2isis.cpp b/isis/src/lro/apps/lronac2isis/lronac2isis.cpp index 536f4ce3dc..6f209d5632 100644 --- a/isis/src/lro/apps/lronac2isis/lronac2isis.cpp +++ b/isis/src/lro/apps/lronac2isis/lronac2isis.cpp @@ -119,7 +119,7 @@ namespace Isis { // Add History if (iApp) { - History history("IsisCube"); + History history = g_ocube->readHistory(); history.AddEntry(); g_ocube->write(history); } diff --git a/isis/src/lro/apps/lrowac2isis/main.cpp b/isis/src/lro/apps/lrowac2isis/main.cpp index 0fa3f8ad09..cf56421e94 100644 --- a/isis/src/lro/apps/lrowac2isis/main.cpp +++ b/isis/src/lro/apps/lrowac2isis/main.cpp @@ -228,7 +228,7 @@ void IsisMain() { uveven->putGroup(isis3UvEvenLab.group(grp)); } - History history("IsisCube"); + History history; history.AddEntry(); uveven->write(history); uveven->write(origLabel); @@ -243,7 +243,7 @@ void IsisMain() { uvodd->putGroup(isis3UvOddLab.group(grp)); } - History history("IsisCube"); + History history; history.AddEntry(); uvodd->write(history); uvodd->write(origLabel); @@ -258,7 +258,7 @@ void IsisMain() { viseven->putGroup(isis3VisEvenLab.group(grp)); } - History history("IsisCube"); + History history; history.AddEntry(); viseven->write(history); viseven->write(origLabel); @@ -273,7 +273,7 @@ void IsisMain() { visodd->putGroup(isis3VisOddLab.group(grp)); } - History history("IsisCube"); + History history; history.AddEntry(); visodd->write(history); visodd->write(origLabel); diff --git a/isis/src/lro/apps/mrf2pds/main.cpp b/isis/src/lro/apps/mrf2pds/main.cpp index f7ab8a4d2d..b4d5789ef7 100644 --- a/isis/src/lro/apps/mrf2pds/main.cpp +++ b/isis/src/lro/apps/mrf2pds/main.cpp @@ -84,8 +84,7 @@ void IsisMain() { // Translate the keywords from the original EDR PDS label that go in // this RDR PDS label for Level2 images only if(bLevel2) { - OriginalLabel cOriginalBlob; - cInCube->read(cOriginalBlob); + OriginalLabel cOriginalBlob = cInCube->readOriginalLabel(); Pvl cOrigLabel; PvlObject cOrigLabelObj = cOriginalBlob.ReturnLabels(); cOrigLabelObj.setName("OriginalLabelObject"); diff --git a/isis/src/messenger/apps/mdis2pds/main.cpp b/isis/src/messenger/apps/mdis2pds/main.cpp index b835412fd0..b8b98c579d 100644 --- a/isis/src/messenger/apps/mdis2pds/main.cpp +++ b/isis/src/messenger/apps/mdis2pds/main.cpp @@ -198,18 +198,17 @@ void IsisMain() { // Translate the keywords from the original EDR PDS label that go in // this RDR PDS label - OriginalLabel origBlob; - incube->read(origBlob); - Pvl origLabel; - PvlObject origLabelObj = origBlob.ReturnLabels(); + OriginalLabel origLabel = incube->readOriginalLabel(); + Pvl pvlOrigLabel; + PvlObject origLabelObj = origLabel.ReturnLabels(); origLabelObj.setName("OriginalLabelObject"); - origLabel.addObject(origLabelObj); + pvlOrigLabel.addObject(origLabelObj); p.CheckStatus(); // Translates the ISIS labels along with the original EDR labels - origLabel.addObject(*(incube->label())); - PvlToPvlTranslationManager labels(origLabel, + pvlOrigLabel.addObject(*(incube->label())); + PvlToPvlTranslationManager labels(pvlOrigLabel, "$ISISROOT/appdata/translations/MessengerMdisCdrLabel.trn"); labels.Auto(pdsLabel); diff --git a/isis/src/messenger/apps/mdisddr/main.cpp b/isis/src/messenger/apps/mdisddr/main.cpp index 6ee844ced4..5e0a917775 100644 --- a/isis/src/messenger/apps/mdisddr/main.cpp +++ b/isis/src/messenger/apps/mdisddr/main.cpp @@ -196,8 +196,7 @@ void IsisMain() { // output PDS file (required for 5 band IMAGE object). Cube from; from.open(input.expanded()); - OriginalLabel origBlob; - from.read(origBlob); + OriginalLabel origBlob = from.readOriginalLabel(); Pvl origLabel; PvlObject origLabelObj = origBlob.ReturnLabels(); origLabelObj.setName("OriginalLabelObject"); diff --git a/isis/src/mro/apps/ctxcal/ctxcal.cpp b/isis/src/mro/apps/ctxcal/ctxcal.cpp index a15af93087..74958b896b 100644 --- a/isis/src/mro/apps/ctxcal/ctxcal.cpp +++ b/isis/src/mro/apps/ctxcal/ctxcal.cpp @@ -26,7 +26,7 @@ using namespace Isis; namespace Isis { // Working functions and parameters static void Calibrate(Buffer &in, Buffer &out); - + static Brick *flat; static vector dcA; static vector dcB; @@ -35,7 +35,7 @@ namespace Isis { static int sum; // Summing mode static int firstSamp; // First sample static double iof; // conversion from counts/ms to IOF - + void ctxcal(UserInterface &ui) { Cube icube(ui.GetFileName("FROM")); ctxcal(&icube, ui); @@ -44,7 +44,7 @@ namespace Isis { void ctxcal(Cube *icube, UserInterface &ui) { // We will be processing by line ProcessByLine p; - + Isis::Pvl lab(icube->fileName()); Isis::PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse); @@ -90,8 +90,7 @@ namespace Isis { if(firstSamp > 0) firstSamp -= 38; // Read dark current info, if no dc exit? - Table dcTable("Ctx Prefix Dark Pixels"); - icube->read(dcTable); + Table dcTable = icube->readTable("Ctx Prefix Dark Pixels"); // TODO:: make sure dc records match cube nlines. // If summing mode = 1 , average odd & even dc pixels separately for @@ -142,14 +141,14 @@ namespace Isis { // iof = conversion factor from counts/ms to i/f bool convertIOF = ui.GetBoolean("IOF"); if(convertIOF) { - double dist1 = 1; + double dist1 = 1; try { Camera *cam; cam = icube->camera(); cam->setTime(startTime); dist1 = cam->sunToBodyDist(); } - catch(IException &e) { + catch(IException &e) { // Get the distance between Mars and the Sun at the given time in // Astronomical Units (AU) QString bspKernel = p.MissionData("base", "/kernels/spk/de???.bsp", true); @@ -168,14 +167,14 @@ namespace Isis { NaifStatus::CheckErrors(); dist1 = vnorm_c(sunpos); - + NaifStatus::CheckErrors(); unload_c(bspKernel.toLatin1().data()); unload_c(satKernel.toLatin1().data()); unload_c(pckKernel.toLatin1().data()); NaifStatus::CheckErrors(); } - + double dist = 2.07E8; double w0 = 3660.5; double w1 = w0 * ((dist * dist) / (dist1 * dist1)); @@ -200,7 +199,7 @@ namespace Isis { ocube->putGroup(calgrp); - + // Start the line-by-line calibration sequence p.StartProcess(Calibrate); p.EndProcess(); diff --git a/isis/src/mro/apps/hicolormos/hicolormos.cpp b/isis/src/mro/apps/hicolormos/hicolormos.cpp index f0f9c583b4..50ba3e1119 100644 --- a/isis/src/mro/apps/hicolormos/hicolormos.cpp +++ b/isis/src/mro/apps/hicolormos/hicolormos.cpp @@ -270,8 +270,7 @@ void hicolormos(Cube *from1, Cube* from2, UserInterface &ui) { mos += specialProcessingFlag; //get the orginal label - OriginalLabel from1OrgLab; - from1OrgLab.Blob::Read(from1->fileName()); + OriginalLabel from1OrgLab(from1->fileName()); Cube c; c.open(ui.GetFileName("TO"), "rw"); diff --git a/isis/src/mro/apps/hicubeit/hicubeit.cpp b/isis/src/mro/apps/hicubeit/hicubeit.cpp index b5b532e462..16a10b44a2 100644 --- a/isis/src/mro/apps/hicubeit/hicubeit.cpp +++ b/isis/src/mro/apps/hicubeit/hicubeit.cpp @@ -118,12 +118,9 @@ namespace Isis { } // Concatenate all TDIs into one keyword - OriginalLabel redOrgLab; - redOrgLab.Blob::Read(redFile); - OriginalLabel irOrgLab; - irOrgLab.Blob::Read(irFile); - OriginalLabel bgOrgLab; - bgOrgLab.Blob::Read(bgFile); + OriginalLabel redOrgLab(redFile); + OriginalLabel irOrgLab(irFile); + OriginalLabel bgOrgLab(bgFile); PvlGroup redGrp = redOrgLab.ReturnLabels().findGroup("INSTRUMENT_SETTING_PARAMETERS", Pvl::Traverse); PvlGroup irGrp = irOrgLab.ReturnLabels().findGroup("INSTRUMENT_SETTING_PARAMETERS", Pvl::Traverse); diff --git a/isis/src/mro/apps/hideal2pds/main.cpp b/isis/src/mro/apps/hideal2pds/main.cpp index 4473cf4375..13df74fdef 100644 --- a/isis/src/mro/apps/hideal2pds/main.cpp +++ b/isis/src/mro/apps/hideal2pds/main.cpp @@ -180,8 +180,7 @@ void IsisMain() { cubeLab.Auto(pdsLabel); // get original label information - OriginalLabel origBlob; - inputCube->read(origBlob); + OriginalLabel origBlob = inputCube->readOriginalLabel(); Pvl origLabel; PvlObject origLabelObj = origBlob.ReturnLabels(); origLabelObj.setName("OriginalLabelObject"); diff --git a/isis/src/mro/apps/higlob/main.cpp b/isis/src/mro/apps/higlob/main.cpp index 93d45b12f0..886772d4ec 100644 --- a/isis/src/mro/apps/higlob/main.cpp +++ b/isis/src/mro/apps/higlob/main.cpp @@ -50,13 +50,13 @@ void IsisMain() { Cube *icube = p.SetInputCube("FROM"); // Get the cube prefix and suffix table - icube->read(hifix); + hifix = icube->readTable("HiRISE Ancillary"); // Get the calibration prefix and suffix table - icube->read(calfix); + calfix = icube->readTable("HiRISE Calibration Ancillary"); // Get the calibration image table - icube->read(calimg); + calimg = icube->readTable("HiRISE Calibration Image"); // Add the number of buffer pixels and dark pixels to the ouput NS samples += hifix[0]["BufferPixels"].size() + hifix[0]["DarkPixels"].size(); diff --git a/isis/src/mro/apps/himos/himos.cpp b/isis/src/mro/apps/himos/himos.cpp index aae9f68c4c..e28247a985 100644 --- a/isis/src/mro/apps/himos/himos.cpp +++ b/isis/src/mro/apps/himos/himos.cpp @@ -183,8 +183,7 @@ namespace Isis { QString startTime; QString stopTime; for(int i = 0; i < (int)clist.size(); i++) { - OriginalLabel origLab; - clist[i]->read(origLab); + OriginalLabel origLab = clist[i]->readOriginalLabel(); PvlGroup timegrp = origLab.ReturnLabels().findGroup("TIME_PARAMETERS", Pvl::Traverse); if(i == 0) { startClock = (QString)timegrp["SpacecraftClockStartCount"]; @@ -219,8 +218,7 @@ namespace Isis { for(int i = 0; i < (int)clist.size(); i++) { Pvl *clab = clist[i]->label(); PvlGroup cInst = clab->findGroup("Instrument", Pvl::Traverse); - OriginalLabel cOrgLab; - clist[i]->read(cOrgLab); + OriginalLabel cOrgLab = clist[i]->readOriginalLabel(); PvlGroup cGrp = cOrgLab.ReturnLabels().findGroup("INSTRUMENT_SETTING_PARAMETERS", Pvl::Traverse); cpmmTdiFlag[(int)cInst["CpmmNumber"]] = (QString) cGrp["MRO:TDI"]; cpmmSummingFlag[(int)cInst["CpmmNumber"]] = (QString) cGrp["MRO:BINNING"]; @@ -236,8 +234,7 @@ namespace Isis { } // Get the blob of original labels from first image in list - OriginalLabel org; - clist[0]->read(org); + OriginalLabel org = clist[0]->readOriginalLabel(); //close all cubes for(int i = 0; i < (int)clist.size(); i++) { diff --git a/isis/src/mro/apps/hirdrgen/main.cpp b/isis/src/mro/apps/hirdrgen/main.cpp index 70e9c402de..17deab8c83 100644 --- a/isis/src/mro/apps/hirdrgen/main.cpp +++ b/isis/src/mro/apps/hirdrgen/main.cpp @@ -182,8 +182,7 @@ void IsisMain() { // Translate the keywords from the original EDR PDS label that go in // this RDR PDS label - OriginalLabel origBlob; - icube2->read(origBlob); + OriginalLabel origBlob = icube2->readOriginalLabel(); Pvl origLabel; PvlObject origLabelObj = origBlob.ReturnLabels(); origLabelObj.setName("OriginalLabelObject"); diff --git a/isis/src/mro/apps/histat/main.cpp b/isis/src/mro/apps/histat/main.cpp index 8592611d8b..4394d74da7 100644 --- a/isis/src/mro/apps/histat/main.cpp +++ b/isis/src/mro/apps/histat/main.cpp @@ -73,8 +73,7 @@ void IsisMain() { Cube *icube = p.SetInputCube("FROM"); // Get statistics from the cube prefix and suffix data - Table hifix("HiRISE Ancillary"); - icube->read(hifix); + Table hifix = icube->readTable("HiRISE Ancillary"); Statistics darkStats, bufStats, rampDarkStats; int tdi = icube->group("Instrument")["Tdi"]; int binning_mode = icube->group("Instrument")["Summing"]; @@ -134,8 +133,7 @@ void IsisMain() { int rampStart = maskLines; int rampLines = tdi / binning_mode; - Table calimg("HiRISE Calibration Image"); - icube->read(calimg); + Table calimg = icube->readTable("HiRISE Calibration Image"); Statistics calStats; //Statistics for the Reverse readout lines of the cal image Statistics reverseStats; @@ -212,8 +210,7 @@ void IsisMain() { } // Get statistics from the calibration prefix and suffix data - Table calfix("HiRISE Calibration Ancillary"); - icube->read(calfix); + Table calfix = icube->readTable("HiRISE Calibration Ancillary"); Statistics calDarkStats, calBufStats; int rampLine0 = rampStart + 1; int rampLineN = (rampStart + rampLines - 1) - 1; diff --git a/isis/src/mro/apps/marcical/main.cpp b/isis/src/mro/apps/marcical/main.cpp index fdb99c2583..04183f77f4 100644 --- a/isis/src/mro/apps/marcical/main.cpp +++ b/isis/src/mro/apps/marcical/main.cpp @@ -8,6 +8,7 @@ find files of those names at the top level of this repository. **/ #include "Isis.h" #include "SpecialPixel.h" +#include "Blob.h" #include "CubeAttribute.h" #include "Cube.h" #include "LineManager.h" diff --git a/isis/src/mro/apps/marciflip/main.cpp b/isis/src/mro/apps/marciflip/main.cpp index 85743c9cdb..46d7e49695 100644 --- a/isis/src/mro/apps/marciflip/main.cpp +++ b/isis/src/mro/apps/marciflip/main.cpp @@ -52,8 +52,7 @@ void IsisMain() { } if(icube->label()->hasObject("OriginalLabel")) { - OriginalLabel origLabel; - icube->read(origLabel); + OriginalLabel origLabel = icube->readOriginalLabel(); outputCube->write(origLabel); } diff --git a/isis/src/qisis/apps/qtie/QtieTool.cpp b/isis/src/qisis/apps/qtie/QtieTool.cpp index adbbe4a75c..f4c07ca76e 100644 --- a/isis/src/qisis/apps/qtie/QtieTool.cpp +++ b/isis/src/qisis/apps/qtie/QtieTool.cpp @@ -916,18 +916,7 @@ namespace Isis { // Update the cube history p_matchCube->write(*cmatrix); - History h("IsisCube"); - try { - p_matchCube->read(h); - } - catch (IException &e) { - QString message = "Could not read cube history, " - "will not update history.\n"; - QString errors = e.toString(); - message += errors; - QMessageBox::warning((QWidget *)parent(), "Warning", message); - return; - } + History h = p_matchCube->readHistory(); PvlObject history("qtie"); history += PvlKeyword("IsisVersion", Application::Version()); QString path = QCoreApplication::applicationDirPath(); diff --git a/isis/src/qisis/objs/AdvancedTrackTool/AdvancedTrackTool.cpp b/isis/src/qisis/objs/AdvancedTrackTool/AdvancedTrackTool.cpp index 1344583d72..27c84d0c5b 100644 --- a/isis/src/qisis/objs/AdvancedTrackTool/AdvancedTrackTool.cpp +++ b/isis/src/qisis/objs/AdvancedTrackTool/AdvancedTrackTool.cpp @@ -648,8 +648,7 @@ namespace Isis { unsigned int currentPixel = trackingPortal[0]; if (currentPixel != NULLUI4) { // If from an image - Table table(trackingTableName); // trackingTableName from TrackingTable - trackingCube->read(table); + Table table = trackingCube->readTable(trackingTableName); // trackingTableName from TrackingTable TrackingTable trackingTable(table); FileName trackingFileName = trackingTable.pixelToFileName(currentPixel); @@ -694,8 +693,7 @@ namespace Isis { } // Get the input file name and serial number - Table cFileTable(trackingTableName); - cCube->read(cFileTable); + Table cFileTable = cCube->readTable(trackingTableName); int iRecs = cFileTable.Records(); if(piOrigin >= 0 && piOrigin < iRecs) { psSrcFileName = QString(cFileTable[piOrigin][0]); diff --git a/isis/src/qisis/objs/FileTool/FileTool.cpp b/isis/src/qisis/objs/FileTool/FileTool.cpp index 864c3d5498..078052aaa6 100644 --- a/isis/src/qisis/objs/FileTool/FileTool.cpp +++ b/isis/src/qisis/objs/FileTool/FileTool.cpp @@ -637,8 +637,7 @@ namespace Isis { inlab = *icube->label(); for(int i = 0; i < inlab.objects(); i++) { if (inlab.object(i).isNamed("OriginalLabel")) { - OriginalLabel ol; - icube->read(ol); + OriginalLabel ol = icube->readOriginalLabel(); ocube->write(ol); } } diff --git a/isis/src/qisis/objs/Image/Image.cpp b/isis/src/qisis/objs/Image/Image.cpp index e5df8db783..58a08bd853 100644 --- a/isis/src/qisis/objs/Image/Image.cpp +++ b/isis/src/qisis/objs/Image/Image.cpp @@ -104,7 +104,7 @@ namespace Isis { /** * @brief Create an image from a cube file on disk including the footprint - * @param imageFileName The name of a cube on disk - /work/users/.../blah.cub + * @param imageFileName The name of a cube on disk - /work/users/.../blah.cub * @param footprint The calculated footprint * @param parent The Qt-relationship parent */ @@ -253,12 +253,12 @@ namespace Isis { bool Image::isFootprintable() const { bool result = false; - if (m_footprint) + if (m_footprint) { result = true; + } if (!result && m_cube) { - // TODO: Move this to Blob! - ImagePolygon example; + Blob example = ImagePolygon().toBlob(); QString blobType = example.Type(); QString blobName = example.Name(); @@ -361,7 +361,7 @@ namespace Isis { QString Image::serialNumber() { if (m_serialNumber.isEmpty()) { m_serialNumber = SerialNumber::Compose(*(cube())); - } + } return m_serialNumber; } @@ -542,8 +542,8 @@ namespace Isis { if (m_fileName != newExternalLabelFileName.toString()) { // This cube copy creates a filename w/ecub extension in the new project root, but looks to - // be a cube(internal vs external). It changes the DnFile pointer to the old ecub, - // /tmp/tsucharski_ipce/tmpProject/images/import1/AS15-.ecub, but doing a less on file + // be a cube(internal vs external). It changes the DnFile pointer to the old ecub, + // /tmp/tsucharski_ipce/tmpProject/images/import1/AS15-.ecub, but doing a less on file // immediately after the following call indicates it is a binary file. QScopedPointer newExternalLabel( origImage.copy(newExternalLabelFileName, CubeAttributeOutput("+External"))); @@ -566,10 +566,10 @@ namespace Isis { if (origImage.externalCubeFileName().toString().contains(project->projectRoot())) { QString newExternalCubeFileName = origImage.externalCubeFileName().toString(); newExternalCubeFileName.replace(project->projectRoot(), project->newProjectRoot()); - newExternalLabel->relocateDnData(newExternalCubeFileName); + newExternalLabel->relocateDnData(newExternalCubeFileName); } else { - newExternalLabel->relocateDnData(origImage.externalCubeFileName()); + newExternalLabel->relocateDnData(origImage.externalCubeFileName()); } } } @@ -815,8 +815,7 @@ namespace Isis { * @see Isis::ImagePolygon */ void Image::initQuickFootprint() { - ImagePolygon poly; - cube()->read(poly); + ImagePolygon poly = cube()->readFootprint(); m_footprint = PolygonTools::MakeMultiPolygon(poly.Polys()->clone()); } diff --git a/isis/src/qisis/objs/Shape/Shape.cpp b/isis/src/qisis/objs/Shape/Shape.cpp index a9e020deaf..4a3bd0e39b 100644 --- a/isis/src/qisis/objs/Shape/Shape.cpp +++ b/isis/src/qisis/objs/Shape/Shape.cpp @@ -155,7 +155,7 @@ namespace Isis { PvlGroup kernels = cube()->group("Kernels"); if (kernels.hasKeyword("ShapeModel")) { - QString shapeFile = kernels["ShapeModel"]; + QString shapeFile = kernels["ShapeModel"]; if (shapeFile.contains("dem")) { m_radiusSource = ControlPoint::RadiusSource::DEM; } @@ -201,7 +201,7 @@ namespace Isis { initQuickFootprint(); } catch (IException &e) { - + } } @@ -298,8 +298,7 @@ namespace Isis { result = true; if (!result && m_cube) { - // TODO: Move this to Blob! - ImagePolygon example; + Blob example = ImagePolygon().toBlob(); QString blobType = example.Type(); QString blobName = example.Name(); @@ -814,8 +813,7 @@ namespace Isis { void Shape::initQuickFootprint() { - ImagePolygon poly; - cube()->read(poly); + ImagePolygon poly = cube()->readFootprint(); m_footprint = PolygonTools::MakeMultiPolygon(poly.Polys()->clone()); } @@ -1072,7 +1070,7 @@ namespace Isis { } else if (localName == "shape" && !m_shape->m_footprint) { try { - QMutex mutex; + QMutex mutex; m_shape->initFootprint(&mutex); m_shape->closeCube(); } diff --git a/isis/src/qisis/objs/StretchTool/StretchTool.cpp b/isis/src/qisis/objs/StretchTool/StretchTool.cpp index 3ce21c2ae2..4f0aec0a72 100644 --- a/isis/src/qisis/objs/StretchTool/StretchTool.cpp +++ b/isis/src/qisis/objs/StretchTool/StretchTool.cpp @@ -35,7 +35,6 @@ #include "Workspace.h" #include "CubeStretch.h" -#include "StretchBlob.h" using namespace std; @@ -292,7 +291,7 @@ namespace Isis { connect(m_flashButton, SIGNAL(released()), this, SLOT(stretchChanged())); // Buttons migrated out of Advanced Stretch Tool - QPushButton *saveToCubeButton = new QPushButton("Save"); + QPushButton *saveToCubeButton = new QPushButton("Save"); connect(saveToCubeButton, SIGNAL(clicked(bool)), this, SLOT(saveStretchToCube())); QPushButton *deleteFromCubeButton = new QPushButton("Delete"); @@ -406,11 +405,11 @@ namespace Isis { * Restores a saved stretch from the cube */ void StretchTool::loadStretchFromCube(){ - MdiCubeViewport *cvp = cubeViewport(); + MdiCubeViewport *cvp = cubeViewport(); Cube* icube = cvp->cube(); Pvl* lab = icube->label(); - QStringList namelist; + QStringList namelist; // Create a list of existing Stretch names if (cvp->isGray()) { @@ -420,8 +419,8 @@ namespace Isis { PvlKeyword tempKeyword = objIter->findKeyword("Name"); int bandNumber = int(objIter->findKeyword("BandNumber")); if (cvp->grayBand() == bandNumber) { - QString tempName = tempKeyword[0]; - namelist.append(tempName); + QString tempName = tempKeyword[0]; + namelist.append(tempName); } } } @@ -437,9 +436,9 @@ namespace Isis { if (objIter->name() == "Stretch") { PvlKeyword tempKeyword = objIter->findKeyword("Name"); int bandNumber = int(objIter->findKeyword("BandNumber")); - if (bandNumber == redBandNumber || bandNumber == greenBandNumber + if (bandNumber == redBandNumber || bandNumber == greenBandNumber || bandNumber == blueBandNumber) { - QString tempName = tempKeyword[0]; + QString tempName = tempKeyword[0]; if (tempNameMap.contains(tempName)) { tempNameMap[tempName].append(bandNumber); } @@ -460,38 +459,32 @@ namespace Isis { } } - bool ok; + bool ok = false; QString stretchName; // Only display load stretch dialog if there are stretches saved to the cube if (namelist.size() >=1) { - stretchName = QInputDialog::getItem((QWidget *)parent(), tr("Load Stretch"), + stretchName = QInputDialog::getItem((QWidget *)parent(), tr("Load Stretch"), tr("Name of Stretch to Load:"), namelist, 0, false, &ok); } else { - QMessageBox::information((QWidget *)parent(), "Information", + QMessageBox::information((QWidget *)parent(), "Information", "There are no saved stretches to restore."); } if (ok) { if (cvp->isGray()) { - StretchBlob stretchBlob(stretchName); - icube->read(stretchBlob); - CubeStretch cubeStretch = stretchBlob.getStretch(); + CubeStretch cubeStretch = icube->readCubeStretch(stretchName); if (m_advancedStretch->isVisible()) { m_advancedStretch->restoreGrayStretch(cubeStretch); } - // Get the current cube stretche and copy the new stretch pairs over so that the + // Get the current cube stretche and copy the new stretch pairs over so that the // special pixel values set in the viewport are maintained. CubeStretch grayOriginal = cvp->grayStretch(); grayOriginal.CopyPairs(cubeStretch); cvp->stretchGray(grayOriginal); } else { - StretchBlob redStretchBlob(stretchName); - StretchBlob greenStretchBlob(stretchName); - StretchBlob blueStretchBlob(stretchName); - std::vector keywordValueRed; keywordValueRed.push_back(PvlKeyword("BandNumber", QString::number(cvp->redBand()))); @@ -501,19 +494,15 @@ namespace Isis { std::vector keywordValueBlue; keywordValueBlue.push_back(PvlKeyword("BandNumber", QString::number(cvp->blueBand()))); - icube->read(redStretchBlob, keywordValueRed); - icube->read(greenStretchBlob, keywordValueGreen); - icube->read(blueStretchBlob, keywordValueBlue); - - CubeStretch redStretch = redStretchBlob.getStretch(); - CubeStretch greenStretch = greenStretchBlob.getStretch(); - CubeStretch blueStretch = blueStretchBlob.getStretch(); + CubeStretch redStretch = icube->readCubeStretch(stretchName, keywordValueRed); + CubeStretch greenStretch = icube->readCubeStretch(stretchName, keywordValueGreen); + CubeStretch blueStretch = icube->readCubeStretch(stretchName, keywordValueBlue); if (m_advancedStretch->isVisible()) { m_advancedStretch->restoreRgbStretch(redStretch, greenStretch, blueStretch); } - // Get the current cube stretches and copy the new stretch pairs over so that the + // Get the current cube stretches and copy the new stretch pairs over so that the // special pixel values set in the viewport are maintained. CubeStretch redOriginal = cvp->redStretch(); CubeStretch greenOriginal = cvp->greenStretch(); @@ -536,34 +525,34 @@ namespace Isis { * Deletes a saved stretch from the cube */ void StretchTool::deleteFromCube() { - MdiCubeViewport *cvp = cubeViewport(); + MdiCubeViewport *cvp = cubeViewport(); Cube* icube = cvp->cube(); Pvl* lab = icube->label(); // Create a list of existing Stretch names - QStringList namelist; + QStringList namelist; PvlObject::PvlObjectIterator objIter; for (objIter=lab->beginObject(); objIterendObject(); objIter++) { if (objIter->name() == "Stretch") { PvlKeyword tempKeyword = objIter->findKeyword("Name"); int bandNumber = int(objIter->findKeyword("BandNumber")); if (cvp->grayBand() == bandNumber) { - QString tempName = tempKeyword[0]; - namelist.append(tempName); + QString tempName = tempKeyword[0]; + namelist.append(tempName); } } } - bool ok; + bool ok = false; QString toDelete; // Only display list of stretches to delete if there are stretches saved to the cube if (namelist.size() >= 1) { - toDelete = QInputDialog::getItem((QWidget *)parent(), tr("Delete Stretch"), + toDelete = QInputDialog::getItem((QWidget *)parent(), tr("Delete Stretch"), tr("Name of Stretch to Delete:"), namelist, 0, false, &ok); } else { - QMessageBox::information((QWidget *)parent(), "Information", + QMessageBox::information((QWidget *)parent(), "Information", "There are no saved stretches to delete."); } @@ -574,25 +563,25 @@ namespace Isis { } catch(IException &) { cvp->cube()->reopen("r"); - QMessageBox::information((QWidget *)parent(), "Error", + QMessageBox::information((QWidget *)parent(), "Error", "Cannot open cube read/write to delete stretch"); return; } } - bool cubeDeleted = icube->deleteBlob("Stretch", toDelete); + bool cubeDeleted = icube->deleteBlob(toDelete, "Stretch"); if (!cubeDeleted) { QMessageBox msgBox; msgBox.setText("Stretch Could Not Be Deleted!"); - msgBox.setInformativeText("A stretch with name: \"" + toDelete + + msgBox.setInformativeText("A stretch with name: \"" + toDelete + "\" Could not be found, so there was nothing to delete from the Cube."); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); } - // Don't leave open rw -- not optimal. + // Don't leave open rw -- not optimal. cvp->cube()->reopen("r"); } } @@ -607,29 +596,29 @@ namespace Isis { Pvl* lab = icube->label(); // Create a list of existing Stretch names - QStringList namelist; + QStringList namelist; PvlObject::PvlObjectIterator objIter; for (objIter=lab->beginObject(); objIterendObject(); objIter++) { if (objIter->name() == "Stretch") { PvlKeyword tempKeyword = objIter->findKeyword("Name"); QString tempName = tempKeyword[0]; - namelist.append(tempName); + namelist.append(tempName); } } bool ok; - QString name; + QString name; - // - // At this time, it is NOT possible to save an RGB stretch with the same band number + // + // At this time, it is NOT possible to save an RGB stretch with the same band number // multiple times, if the saved stretch for each is different. If the saved stretch is the same // this is okay. - // + // // For example, r=1, g=1, b=1, with the same stretch for each is okay - // r=1, g=1, b=2, where the stretches for band 1 are the same, is okay + // r=1, g=1, b=2, where the stretches for band 1 are the same, is okay // r=1, g=1, b=1, where the the stretches for band 1 are different (red stretch != // green stretch) - // + // if (!cvp->isGray()) { CubeStretch redStretch, greenStretch, blueStretch; if (m_advancedStretch->isVisible()) { @@ -644,13 +633,13 @@ namespace Isis { } int redBand = cvp->redBand(); - int greenBand = cvp->greenBand(); + int greenBand = cvp->greenBand(); int blueBand = cvp->blueBand(); if (((redBand == greenBand) && !(redStretch == greenStretch)) || ((redBand == blueBand) && !(redBand == blueBand)) || ((greenBand == blueBand) && !(greenBand == blueBand))) { - QMessageBox::information((QWidget *)parent(), "Error", "Sorry, cannot save RGB stretches which include the same band multiple times, but have different stretches for each"); + QMessageBox::information((QWidget *)parent(), "Error", "Sorry, cannot save RGB stretches which include the same band multiple times, but have different stretches for each"); return; } } @@ -690,10 +679,10 @@ namespace Isis { if (icube->isReadOnly()) { // reOpen cube as read/write try { - cvp->cube()->reopen("rw"); + icube->reopen("rw"); } catch(IException &) { - cvp->cube()->reopen("r"); + icube->reopen("r"); QMessageBox::information((QWidget *)parent(), "Error", "Cannot open cube read/write to save stretch"); return; } @@ -706,17 +695,16 @@ namespace Isis { stretch = m_advancedStretch->getGrayStretch(); } else { - stretch = cvp->grayStretch(); + stretch = cvp->grayStretch(); } - + // Write single stretch to cube stretch.setName(text); stretch.setBandNumber(cvp->grayBand()); - StretchBlob stretchBlob(stretch); // Overwrite an existing stretch with the same name if it exists. The user was warned // and decided to overwrite. - icube->write(stretchBlob); + icube->write(stretch); } else { CubeStretch redStretch, greenStretch, blueStretch; @@ -733,21 +721,21 @@ namespace Isis { redStretch.setName(text); redStretch.setBandNumber(cvp->redBand()); - StretchBlob redStretchBlob(redStretch); - icube->write(redStretchBlob, false); + Blob stretchBlob = redStretch.toBlob(); + icube->write(stretchBlob, false); greenStretch.setName(text); greenStretch.setBandNumber(cvp->greenBand()); - StretchBlob greenStretchBlob(greenStretch); - icube->write(greenStretchBlob, false); + stretchBlob = greenStretch.toBlob(); + icube->write(stretchBlob, false); blueStretch.setName(text); blueStretch.setBandNumber(cvp->blueBand()); - StretchBlob blueStretchBlob(blueStretch); - icube->write(blueStretchBlob, false); + stretchBlob = blueStretch.toBlob(); + icube->write(stretchBlob, false); } - // Don't leave open rw -- not optimal. + // Don't leave open rw -- not optimal. cvp->cube()->reopen("r"); } } diff --git a/isis/src/tgo/apps/tgocassisstitch/main.cpp b/isis/src/tgo/apps/tgocassisstitch/main.cpp index 87dab73609..5134e23285 100644 --- a/isis/src/tgo/apps/tgocassisstitch/main.cpp +++ b/isis/src/tgo/apps/tgocassisstitch/main.cpp @@ -223,9 +223,9 @@ void stitchFrame(QList frameletList, FileName frameFileName) { Pvl &frameletLabel = *frameletCube->label(); for(int i = 0; i < frameletLabel.objects(); i++) { if( frameletLabel.object(i).isNamed("History") ) { - History frameletHist( (QString) frameletLabel.object(i)["Name"] ); - frameletCube->read(frameletHist); - frameCube.write(frameletHist); + Blob historyBlob((QString) frameletLabel.object(i)["Name"], "History" ); + frameletCube->read(historyBlob); + frameCube.write(historyBlob); } } } diff --git a/isis/src/tgo/apps/tgocassisunstitch/main.cpp b/isis/src/tgo/apps/tgocassisunstitch/main.cpp index 0475e79764..2003e999c9 100644 --- a/isis/src/tgo/apps/tgocassisunstitch/main.cpp +++ b/isis/src/tgo/apps/tgocassisunstitch/main.cpp @@ -101,7 +101,7 @@ void IsisMain() { // Collect the tables and history from the input stitched cube QList inputTables; - QScopedPointer inputHistory; + History inputHistory; for(int i = 0; i < inputLabel->objects(); i++) { if(inputLabel->object(i).isNamed("Table")) { Blob table((QString)inputLabel->object(i)["Name"], inputLabel->object(i).name()); @@ -109,9 +109,8 @@ void IsisMain() { inputTables.append(table); } if(inputLabel->object(i).isNamed("History") && Isis::iApp != NULL) { - inputHistory.reset( new History((QString)inputLabel->object(i)["Name"]) ); - cube->read(*inputHistory); - inputHistory->AddEntry(); + inputHistory = cube->readHistory((QString)inputLabel->object(i)["Name"]); + inputHistory.AddEntry(); } } @@ -212,7 +211,7 @@ void IsisMain() { } // Propagate History - g_outputCubes[i]->write(*inputHistory); + g_outputCubes[i]->write(inputHistory); // Close output cube g_outputCubes[i]->close(); diff --git a/isis/src/voyager/apps/voy2isis/main.cpp b/isis/src/voyager/apps/voy2isis/main.cpp index eba505707d..c4e35e758f 100644 --- a/isis/src/voyager/apps/voy2isis/main.cpp +++ b/isis/src/voyager/apps/voy2isis/main.cpp @@ -78,7 +78,7 @@ void IsisMain() { // Preparse the IMG to fix messed up labels - History *hist = new History("IsisCube"); + History *hist = new History(); QByteArray pdsData = fixLabels(in.expanded(), hist); QTextStream pdsTextStream(&pdsData); diff --git a/isis/tests/CSMCameraTests.cpp b/isis/tests/CSMCameraTests.cpp index 47f4f41315..5c3fedc3c8 100644 --- a/isis/tests/CSMCameraTests.cpp +++ b/isis/tests/CSMCameraTests.cpp @@ -11,7 +11,6 @@ #include "MockCsmPlugin.h" #include "Mocks.h" #include "TestUtilities.h" -#include "StringBlob.h" #include "FileName.h" #include "Fixtures.h" diff --git a/isis/tests/CubeStretchTest.cpp b/isis/tests/CubeStretchTest.cpp index 468ed532b9..d5d6eb5bd9 100644 --- a/isis/tests/CubeStretchTest.cpp +++ b/isis/tests/CubeStretchTest.cpp @@ -1,17 +1,18 @@ -#include "Stretch.h" #include "CubeStretch.h" +#include "Fixtures.h" #include "IException.h" +#include "Stretch.h" #include -#include +#include #include TEST(CubeStretch, DefaultConstructor) { Isis::CubeStretch cubeStretch; EXPECT_STREQ(cubeStretch.getName().toLatin1().data(), "DefaultStretch"); - EXPECT_STREQ(cubeStretch.getType().toLatin1().data(), "Default"); - EXPECT_EQ(cubeStretch.getBandNumber(), 1); + EXPECT_STREQ(cubeStretch.getType().toLatin1().data(), "Default"); + EXPECT_EQ(cubeStretch.getBandNumber(), 1); } TEST(CubeStretch, ConstructorWithName) { @@ -37,6 +38,39 @@ TEST(CubeStretch, CopyConstructor) { EXPECT_EQ(cubeStretch.getBandNumber(), copyStretch.getBandNumber()); } +TEST(CubeStretch, BlobConstructor) { + // Set Stretch + Isis::CubeStretch cubeStretch("TestStretch", "testType", 2); + Isis::CubeStretch cubeStretchFromBlob(cubeStretch); + + + EXPECT_STREQ(cubeStretchFromBlob.getName().toLatin1().data(), cubeStretch.getName().toLatin1().data()); + EXPECT_STREQ(cubeStretchFromBlob.getType().toLatin1().data(), cubeStretch.getType().toLatin1().data()); + + EXPECT_STREQ(cubeStretchFromBlob.getType().toLatin1().data(), cubeStretch.getType().toLatin1().data()); + EXPECT_EQ(cubeStretchFromBlob.getBandNumber(), cubeStretch.getBandNumber()); +}; + +TEST_F(SmallCube, CubeStretchWriteRead) { + // Set up Stretch to write + QString stretchName = "TestStretch"; + Isis::CubeStretch cubeStretch(stretchName, "testType", 2); + + // add pair(s) + cubeStretch.AddPair(0.0, 1.0); + cubeStretch.AddPair(0.25, 50.0); + cubeStretch.AddPair(1.0, 100.0); + + // Write to Cube + testCube->write(cubeStretch); + testCube->reopen("rw"); + + // Set up stretch and blob to restore to + Isis::CubeStretch restoredStretch = testCube->readCubeStretch(stretchName); + EXPECT_TRUE(restoredStretch == cubeStretch); +}; + + TEST(CubeStretch, Equality) { Isis::CubeStretch cubeStretch99("name", "type", 99); Isis::CubeStretch cubeStretch9("name", "type", 9); @@ -63,4 +97,3 @@ TEST(CubeStretch, GetSetBandNumber) { cubeStretch.setBandNumber(50); EXPECT_EQ(cubeStretch.getBandNumber(), 50); } - diff --git a/isis/tests/CubeTests.cpp b/isis/tests/CubeTests.cpp index 493c99c241..5d2fb3aaca 100644 --- a/isis/tests/CubeTests.cpp +++ b/isis/tests/CubeTests.cpp @@ -5,7 +5,7 @@ #include using json = nlohmann::json; -#include "StringBlob.h" +#include "Blob.h" #include "Cube.h" #include "Camera.h" @@ -234,8 +234,8 @@ TEST(CubeTest, TestCubeAttachSpiceFromIsd) { } TEST_F(SmallCube, TestCubeHasBlob) { - StringBlob testBlob("Test String", "TestBlob"); + Blob testBlob("TestBlob", "SomeBlob"); testCube->write(testBlob); - EXPECT_TRUE(testCube->hasBlob("String", "TestBlob")); - EXPECT_FALSE(testCube->hasBlob("String", "SomeOtherTestBlob")); + EXPECT_TRUE(testCube->hasBlob("TestBlob", "SomeBlob")); + EXPECT_FALSE(testCube->hasBlob("SomeOtherTestBlob", "SomeBlob")); } diff --git a/isis/tests/Fixtures.cpp b/isis/tests/Fixtures.cpp index 57961e0407..1d973b9047 100644 --- a/isis/tests/Fixtures.cpp +++ b/isis/tests/Fixtures.cpp @@ -4,11 +4,11 @@ #include "CubeAttribute.h" #include "FileName.h" +#include "Blob.h" #include "Fixtures.h" #include "Portal.h" #include "LineManager.h" #include "SpecialPixel.h" -#include "StringBlob.h" #include "TestUtilities.h" #include "ControlNet.h" @@ -508,7 +508,7 @@ namespace Isis { void MroCtxCube::SetUp() { TempTestingFiles::SetUp(); - + QString testPath = tempDir.path() + "/test.cub"; QFile::copy("data/mroCtxImage/ctxTestImage.cub", testPath); testCube.reset(new Cube(testPath)); @@ -1019,7 +1019,8 @@ namespace Isis { loadablePlugin.registerModel(mockModelName, &mockModel); // CSMState BLOB - StringBlob csmStateBlob(mockModelName, "CSMState"); + Blob csmStateBlob("CSMState", "String"); + csmStateBlob.setData(mockModelName.c_str(), mockModelName.size()); csmStateBlob.Label() += PvlKeyword("ModelName", QString::fromStdString(mockModelName)); csmStateBlob.Label() += PvlKeyword("PluginName", QString::fromStdString(loadablePlugin.getPluginName())); testCube->write(csmStateBlob); @@ -1091,6 +1092,37 @@ namespace Isis { testCam = testCube->camera(); } + void HistoryBlob::SetUp() { + TempTestingFiles::SetUp(); + + std::istringstream hss(R"( + Object = mroctx2isis + IsisVersion = "4.1.0 | 2020-07-01" + ProgramVersion = 2016-06-10 + ProgramPath = /Users/acpaquette/repos/ISIS3/build/bin + ExecutionDateTime = 2020-07-01T16:48:40 + HostName = Unknown + UserName = acpaquette + Description = "Import an MRO CTX image as an Isis cube" + + Group = UserParameters + FROM = /Users/acpaquette/Desktop/J03_045994_1986_XN_18N282W.IMG + TO = /Users/acpaquette/Desktop/J03_045994_1986_XN_18N282W_isis.cub + SUFFIX = 18 + FILLGAP = true + End_Group + End_Object)"); + + hss >> historyPvl; + + std::ostringstream ostr; + ostr << historyPvl; + std::string histStr = ostr.str(); + + historyBlob = Blob("IsisCube", "History"); + historyBlob.setData(histStr.c_str(), histStr.size()); + } + void MgsMocCube::SetUp() { TempTestingFiles::SetUp(); diff --git a/isis/tests/Fixtures.h b/isis/tests/Fixtures.h index 6d22a303f3..9bf12768c3 100644 --- a/isis/tests/Fixtures.h +++ b/isis/tests/Fixtures.h @@ -273,6 +273,14 @@ class CSMCameraDemFixture : public CSMCubeFixture { void SetUp() override; }; + +class HistoryBlob : public TempTestingFiles { + protected: + Blob historyBlob; + PvlObject historyPvl; + + void SetUp() override; +}; } #endif diff --git a/isis/tests/FunctionalTestFootprintinit.cpp b/isis/tests/FunctionalTestFootprintinit.cpp index 4e2b7c83f4..9db27862b7 100644 --- a/isis/tests/FunctionalTestFootprintinit.cpp +++ b/isis/tests/FunctionalTestFootprintinit.cpp @@ -25,8 +25,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitDefault) { footprintinit(testCube, footprintUi); ASSERT_TRUE(testCube->label()->hasObject("Polygon")); - ImagePolygon poly; - testCube->read(poly); + ImagePolygon poly = testCube->readFootprint(); ASSERT_EQ(49, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); @@ -48,8 +47,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitLincSinc) { footprintinit(testCube, footprintUi); ASSERT_TRUE(testCube->label()->hasObject("Polygon")); - ImagePolygon poly; - testCube->read(poly); + ImagePolygon poly = testCube->readFootprint(); ASSERT_EQ(95, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); @@ -71,8 +69,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitVertices) { footprintinit(testCube, footprintUi); ASSERT_TRUE(testCube->label()->hasObject("Polygon")); - ImagePolygon poly; - testCube->read(poly); + ImagePolygon poly = testCube->readFootprint(); ASSERT_EQ(43, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); @@ -94,8 +91,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitCamera) { footprintinit(testCube, footprintUi); ASSERT_TRUE(testCube->label()->hasObject("Polygon")); - ImagePolygon poly; - testCube->read(poly); + ImagePolygon poly = testCube->readFootprint(); ASSERT_EQ(34, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); @@ -117,8 +113,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitTestXY) { footprintinit(testCube, footprintUi); ASSERT_TRUE(testCube->label()->hasObject("Polygon")); - ImagePolygon poly; - testCube->read(poly); + ImagePolygon poly = testCube->readFootprint(); ASSERT_EQ(49, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); @@ -146,8 +141,7 @@ TEST_F(DefaultCube, FunctionalTestFootprintinitPrecision) { ASSERT_EQ(100, log.findGroup("Results").findKeyword("LINC")[0].toInt()); ASSERT_EQ(100, log.findGroup("Results").findKeyword("SINC")[0].toInt()); - ImagePolygon poly; - testCube->read(poly); + ImagePolygon poly = testCube->readFootprint(); ASSERT_EQ(49, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); diff --git a/isis/tests/FunctionalTestsCkwriter.cpp b/isis/tests/FunctionalTestsCkwriter.cpp index 3bae3e77b2..1cec98b6f5 100644 --- a/isis/tests/FunctionalTestsCkwriter.cpp +++ b/isis/tests/FunctionalTestsCkwriter.cpp @@ -57,8 +57,7 @@ TEST_F(DefaultCube, FunctionalTestsCkwriterDefault) { SpiceRotation *newKernelRotation = newCamera->instrumentRotation(); SpiceRotation *originalRotation = testCube->camera()->instrumentRotation(); - Table instPointingTable("InstrumentPointing"); - testCube->read(instPointingTable); + Table instPointingTable = testCube->readTable("InstrumentPointing"); double startTime = double(instPointingTable.Label()["CkTableStartTime"]); newKernelRotation->SetEphemerisTime(startTime); @@ -127,8 +126,7 @@ TEST_F(DefaultCube, FunctionalTestsCkwriterFromlist) { SpiceRotation *newKernelRotation = newCamera->instrumentRotation(); SpiceRotation *originalRotation = origCamera->instrumentRotation(); - Table instPointingTable("InstrumentPointing"); - testCube->read(instPointingTable); + Table instPointingTable = testCube->readTable("InstrumentPointing"); double startTime = double(instPointingTable.Label()["CkTableStartTime"]); newKernelRotation->SetEphemerisTime(startTime); diff --git a/isis/tests/FunctionalTestsCsminit.cpp b/isis/tests/FunctionalTestsCsminit.cpp index 3f191ba7c3..9d64f3b170 100644 --- a/isis/tests/FunctionalTestsCsminit.cpp +++ b/isis/tests/FunctionalTestsCsminit.cpp @@ -4,11 +4,11 @@ #include #include "AlternativeTestCsmModel.h" +#include "Blob.h" #include "TestCsmPlugin.h" #include "Fixtures.h" #include "TestUtilities.h" #include "TestCsmModel.h" -#include "StringBlob.h" #include "FileName.h" #include @@ -88,17 +88,16 @@ TEST_F(CSMPluginFixture, CSMInitDefault) { testCube->open(filename); // Get a model and a state string - StringBlob stateString("","CSMState"); + Blob stateString("CSMState", "String"); testCube->read(stateString); - // Verify contents of the StringBlob's PVL label + // Verify contents of the Blob's PVL label PvlObject blobPvl = stateString.Label(); - EXPECT_EQ(stateString.Name().toStdString(), "CSMState"); - EXPECT_EQ(stateString.Type().toStdString(), "String"); // Check that the plugin can create a model from the state string std::string modelName = QString(blobPvl.findKeyword("ModelName")).toStdString(); - EXPECT_TRUE(plugin->canModelBeConstructedFromState(modelName, stateString.string())); + std::string modelState(stateString.getBuffer(), stateString.Size()); + EXPECT_TRUE(plugin->canModelBeConstructedFromState(modelName, modelState)); // Check blob label ModelName and Plugin Name EXPECT_EQ(QString(blobPvl.findKeyword("PluginName")).toStdString(), plugin->getPluginName()); @@ -159,21 +158,18 @@ TEST_F(CSMPluginFixture, CSMInitRunTwice) { testCube->open(filename); - StringBlob stateString("", "CSMState"); + Blob stateString("CSMState", "String"); testCube->read(stateString); PvlObject blobPvl = stateString.Label(); - // Verify contents of the StringBlob's PVL label - EXPECT_EQ(stateString.Name().toStdString(), "CSMState"); - EXPECT_EQ(stateString.Type().toStdString(), "String"); - // Check blob label ModelName and Plugin Name EXPECT_EQ(QString(blobPvl.findKeyword("PluginName")).toStdString(), plugin->getPluginName()); EXPECT_EQ(QString(blobPvl.findKeyword("ModelName")).toStdString(), AlternativeTestCsmModel::SENSOR_MODEL_NAME); // Check that the plugin can create a model from the state string std::string modelName = QString(blobPvl.findKeyword("ModelName")).toStdString(); - EXPECT_TRUE(plugin->canModelBeConstructedFromState(modelName, stateString.string())); + std::string modelState(stateString.getBuffer(), stateString.Size()); + EXPECT_TRUE(plugin->canModelBeConstructedFromState(modelName, modelState)); // Make sure there is only one CSMState Blob on the label PvlObject *label = testCube->label(); @@ -222,17 +218,14 @@ TEST_F(CSMPluginFixture, CSMInitMultiplePossibleModels) { csminit(betterOptions); testCube->open(filename); - StringBlob stateString("", "CSMState"); + Blob stateString("CSMState", "String"); testCube->read(stateString); PvlObject blobPvl = stateString.Label(); - // Check blobPvl contents - EXPECT_EQ(stateString.Name().toStdString(), "CSMState"); - EXPECT_EQ(stateString.Type().toStdString(), "String"); - // Check that the plugin can create a model from the state string std::string modelName = QString(blobPvl.findKeyword("ModelName")).toStdString(); - EXPECT_TRUE(plugin->canModelBeConstructedFromState(modelName, stateString.string())); + std::string modelState(stateString.getBuffer(), stateString.Size()); + EXPECT_TRUE(plugin->canModelBeConstructedFromState(modelName, modelState)); // check blob label ModelName and Plugin Name EXPECT_EQ(QString(blobPvl.findKeyword("PluginName")).toStdString(), plugin->getPluginName()); @@ -471,12 +464,12 @@ TEST_F(CSMPluginFixture, CSMInitWithState) { testCube->open(filename); // Read blob off csminited cube, get state string and save off to compare - StringBlob state("","CSMState"); + Blob state("CSMState", "String"); testCube->read(state); testCube->close(); // Write the state out to a file - std::string stateBefore = state.string(); + std::string stateBefore(state.getBuffer(), state.Size()); QString statePath = tempDir.path() + "/state.json"; std::ofstream stateFile(statePath.toStdString()); stateFile << stateBefore; @@ -495,7 +488,8 @@ TEST_F(CSMPluginFixture, CSMInitWithState) { // Pull state string off. if ending state string = original state string these are functionally equiv. testCube->open(filename); - StringBlob stateAfter("","CSMState"); - testCube->read(stateAfter); - EXPECT_STREQ(stateBefore.c_str(), stateAfter.string().c_str()); + Blob stateBlobAfter("CSMState", "String"); + testCube->read(stateBlobAfter); + std::string stateAfter(stateBlobAfter.getBuffer(), stateBlobAfter.Size()); + EXPECT_EQ(stateBefore, stateAfter); } diff --git a/isis/tests/FunctionalTestsDemprep.cpp b/isis/tests/FunctionalTestsDemprep.cpp index 82dcad7551..c7c7b9ca18 100644 --- a/isis/tests/FunctionalTestsDemprep.cpp +++ b/isis/tests/FunctionalTestsDemprep.cpp @@ -74,8 +74,7 @@ TEST(Demprep, DemprepDefault){ ASSERT_NEAR(double(mapping["Scale"]), 1.21293, .00001); ASSERT_DOUBLE_EQ(double(mapping["CenterLatitude"]), 0.0); - Table shapeModel("ShapeModelStatistics"); - cube.read(shapeModel); + Table shapeModel = cube.readTable("ShapeModelStatistics"); // Assertion for minimum radius ASSERT_DOUBLE_EQ(double(shapeModel[0][0]), 1728.805); // Assertion for maximum radius diff --git a/isis/tests/FunctionalTestsMarci2isis.cpp b/isis/tests/FunctionalTestsMarci2isis.cpp index 407a36b7c4..1286383771 100644 --- a/isis/tests/FunctionalTestsMarci2isis.cpp +++ b/isis/tests/FunctionalTestsMarci2isis.cpp @@ -28,8 +28,7 @@ TEST(Marci2Isis, Marci2isisTestDefault) { Pvl *evenLabel = cubeEven.label(); Pvl *oddLabel = cubeOdd.label(); - ASSERT_EQ((int)evenLabel->findObject("OriginalLabel").findKeyword("Bytes"), 1846); - ASSERT_EQ((int)oddLabel->findObject("OriginalLabel").findKeyword("Bytes"), 3693); + ASSERT_EQ((int)evenLabel->findObject("OriginalLabel").findKeyword("Bytes"), (int)oddLabel->findObject("OriginalLabel").findKeyword("Bytes")); // Dimensions Group PvlGroup &evenDimensions = evenLabel->findGroup("Dimensions", Pvl::Traverse); diff --git a/isis/tests/FunctionalTestsShadow.cpp b/isis/tests/FunctionalTestsShadow.cpp index f88f6c242a..97464cff51 100644 --- a/isis/tests/FunctionalTestsShadow.cpp +++ b/isis/tests/FunctionalTestsShadow.cpp @@ -232,8 +232,7 @@ TEST_F(DemCube, FunctionalTestShadowErrors) { shadowArgs.push_back("match=" + testCube->fileName()); shadowUi = UserInterface(APP_XML, shadowArgs); - Table shapeModelStats("ShapeModelStatistics"); - demCube->read(shapeModelStats); + Table shapeModelStats = demCube->readTable("ShapeModelStatistics"); TableRecord originalRecord = shapeModelStats[0]; TableRecord badRecord = shapeModelStats[0]; diff --git a/isis/tests/FunctionalTestsSpiceinit.cpp b/isis/tests/FunctionalTestsSpiceinit.cpp index 416329c3f2..e59a817510 100644 --- a/isis/tests/FunctionalTestsSpiceinit.cpp +++ b/isis/tests/FunctionalTestsSpiceinit.cpp @@ -7,13 +7,13 @@ #include "spiceinit.h" #include "csminit.h" +#include "Blob.h" #include "Cube.h" #include "CubeAttribute.h" #include "PixelType.h" #include "Pvl.h" #include "PvlGroup.h" #include "PvlKeyword.h" -#include "StringBlob.h" #include "TestUtilities.h" #include "FileName.h" @@ -528,7 +528,7 @@ TEST(Spiceinit, TestSpiceinitPadding) { TEST_F(DefaultCube, TestSpiceinitCsmCleanup) { // Add stuff from csminit testCube->putGroup(PvlGroup("CsmInfo")); - StringBlob testBlob("test string", "CSMState"); + Blob testBlob("CSMState", "String"); testCube->write(testBlob); QVector args(0); @@ -536,13 +536,13 @@ TEST_F(DefaultCube, TestSpiceinitCsmCleanup) { spiceinit(testCube, options); EXPECT_FALSE(testCube->hasGroup("CsmInfo")); - EXPECT_ANY_THROW(testCube->read(testBlob)); + EXPECT_FALSE(testCube->hasBlob("CSMState", "String")); } TEST_F(DefaultCube, TestSpiceinitCsmNoCleanup) { // Add stuff from csminit testCube->putGroup(PvlGroup("CsmInfo")); - StringBlob testBlob("test string", "CSMState"); + Blob testBlob("CSMState", "String"); testCube->write(testBlob); // Mangle the cube so that spiceinit failes @@ -553,7 +553,7 @@ TEST_F(DefaultCube, TestSpiceinitCsmNoCleanup) { ASSERT_ANY_THROW(spiceinit(testCube, options)); EXPECT_TRUE(testCube->hasGroup("CsmInfo")); - EXPECT_NO_THROW(testCube->read(testBlob)); + EXPECT_TRUE(testCube->hasBlob("CSMState", "String")); } TEST_F(DemCube, FunctionalTestSpiceinitWebAndShapeModel) { @@ -691,7 +691,7 @@ TEST_F(SmallCube, FunctionalTestSpiceinitCsminitRestorationOnFail) { PvlGroup csmInfoGroup = testCube->group("CsmInfo"); testCube->close(); - // spiceinit + // spiceinit QVector spiceinitArgs = {"from="+cubeFile}; UserInterface spiceinitOptions(APP_XML, spiceinitArgs); @@ -700,7 +700,7 @@ TEST_F(SmallCube, FunctionalTestSpiceinitCsminitRestorationOnFail) { Cube outputCube(cubeFile); ASSERT_NO_THROW(outputCube.camera()); - EXPECT_TRUE(outputCube.hasBlob("String", "CSMState")); + EXPECT_TRUE(outputCube.hasBlob("CSMState", "String")); ASSERT_TRUE(outputCube.hasGroup("CsmInfo")); EXPECT_PRED_FORMAT2(AssertPvlGroupEqual, csmInfoGroup, outputCube.group("CsmInfo")); } diff --git a/isis/tests/FunctionalTestsSpkwriter.cpp b/isis/tests/FunctionalTestsSpkwriter.cpp index 34612df060..9ca6c75cbc 100644 --- a/isis/tests/FunctionalTestsSpkwriter.cpp +++ b/isis/tests/FunctionalTestsSpkwriter.cpp @@ -54,8 +54,7 @@ TEST_F(DefaultCube, FunctionalTestsSpkwriterDefault) { FAIL() << "Unable to generate camera with new spk kernel: " << e.toString().toStdString().c_str() << std::endl; } - Table oldInstPositionTable("InstrumentPosition"); - testCube->read(oldInstPositionTable); + Table oldInstPositionTable = testCube->readTable("InstrumentPosition"); Table newInstPositionTable = newKernelCube.camera()->instrumentPosition()->Cache("InstrumentPosition"); @@ -114,8 +113,7 @@ TEST_F(DefaultCube, FunctionalTestsSpkwriterFromlist) { FAIL() << "Unable to generate camera with new spk kernel: " << e.toString().toStdString().c_str() << std::endl; } - Table oldInstPositionTable("InstrumentPosition"); - testCube->read(oldInstPositionTable); + Table oldInstPositionTable = testCube->readTable("InstrumentPosition"); Table newInstPositionTable = newKernelCube.camera()->instrumentPosition()->Cache("InstrumentPosition"); diff --git a/isis/tests/FunctionalTestsTopds4.cpp b/isis/tests/FunctionalTestsTopds4.cpp index 341e75aa0a..6ba96fc7aa 100644 --- a/isis/tests/FunctionalTestsTopds4.cpp +++ b/isis/tests/FunctionalTestsTopds4.cpp @@ -427,4 +427,3 @@ TEST_F(SmallCube, FunctionalTestTopds4OutputFileSize) { std::getline(renderedStream, line); EXPECT_EQ("69536", line); } - diff --git a/isis/tests/HistoryTests.cpp b/isis/tests/HistoryTests.cpp new file mode 100644 index 0000000000..bced5eeb22 --- /dev/null +++ b/isis/tests/HistoryTests.cpp @@ -0,0 +1,48 @@ +#include "Fixtures.h" +#include "History.h" + +#include "gmock/gmock.h" + +using namespace Isis; + +TEST(HistoryTests, HistoryTestsDefaultConstructor) { + History history; + + Pvl historyPvl = history.ReturnHist(); + EXPECT_EQ(historyPvl.groups(), 0); +} + +TEST_F(HistoryBlob, HistoryTestsFromBlob) { + History readHistory(historyBlob); + + Pvl historyPvl = readHistory.ReturnHist(); + ASSERT_TRUE(historyPvl.hasObject("mroctx2isis")); + EXPECT_TRUE(historyPvl.findObject("mroctx2isis").hasGroup("UserParameters")); +} + +TEST_F(HistoryBlob, HistoryTestsAddEntry) { + History history; + + history.AddEntry(historyPvl); + + Pvl newHistoryPvl = history.ReturnHist(); + ASSERT_TRUE(newHistoryPvl.hasObject("mroctx2isis")); + EXPECT_TRUE(newHistoryPvl.findObject("mroctx2isis").hasGroup("UserParameters")); +} + +TEST_F(HistoryBlob, HistoryTeststoBlob) { + History history(historyBlob); + + Blob blob = history.toBlob(); + + std::stringstream os; + char *blob_buffer = blob.getBuffer(); + Pvl newHistoryPvl; + for (int i = 0; i < blob.Size(); i++) { + os << blob_buffer[i]; + } + os >> newHistoryPvl; + + ASSERT_TRUE(newHistoryPvl.hasObject("mroctx2isis")); + EXPECT_TRUE(newHistoryPvl.findObject("mroctx2isis").hasGroup("UserParameters")); +} diff --git a/isis/tests/StretchBlobTest.cpp b/isis/tests/StretchBlobTest.cpp deleted file mode 100644 index a2ff508ead..0000000000 --- a/isis/tests/StretchBlobTest.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "CubeStretch.h" -#include "StretchBlob.h" -#include "IException.h" -#include "Cube.h" -#include "TestUtilities.h" -#include "Fixtures.h" - -#include -#include - -#include -#include "gmock/gmock.h" - -using namespace Isis; - -TEST(StretchBlob, Constructors) { - // Default - StretchBlob stretchBlob; - - // Set Name - StretchBlob nameStretchBlob("name"); - - // Set Stretch - CubeStretch cubeStretch("TestStretch", "testType", 2); - StretchBlob stretchStretchBlob(cubeStretch); - - // Test retrieval of cubeStretch from StretchBlob - CubeStretch retrievedStretch = stretchStretchBlob.getStretch(); - - EXPECT_STREQ(stretchBlob.Name().toLatin1().data(), "CubeStretch"); - EXPECT_STREQ(stretchBlob.Type().toLatin1().data(), "Stretch"); - - EXPECT_STREQ(nameStretchBlob.Name().toLatin1().data(), "name"); - EXPECT_STREQ(nameStretchBlob.Type().toLatin1().data(), "Stretch"); - - EXPECT_STREQ(stretchStretchBlob.Name().toLatin1().data(), "CubeStretch"); - EXPECT_STREQ(stretchStretchBlob.Type().toLatin1().data(), "Stretch"); - - EXPECT_STREQ(retrievedStretch.getName().toLatin1().data(), cubeStretch.getName().toLatin1().data()); - EXPECT_STREQ(retrievedStretch.getType().toLatin1().data(), cubeStretch.getType().toLatin1().data()); - EXPECT_EQ(retrievedStretch.getBandNumber(), cubeStretch.getBandNumber()); -}; - - -TEST_F(DefaultCube, StretchBlobWriteRead) { - // Set up Stretch to write - QString stretchName = "TestStretch"; - CubeStretch cubeStretch(stretchName, "testType", 2); - - // add pair(s) - cubeStretch.AddPair(0.0, 1.0); - cubeStretch.AddPair(0.25, 50.0); - cubeStretch.AddPair(1.0, 100.0); - Isis::StretchBlob stretchBlob(cubeStretch); - - // Write to Cube - testCube->write(stretchBlob); - // Set up stretch and blob to restore to - StretchBlob restoreBlob(stretchName); - testCube->read(restoreBlob); - CubeStretch restoredStretch = stretchBlob.getStretch(); - EXPECT_TRUE(restoredStretch == cubeStretch); -}; diff --git a/isis/tests/TableTests.cpp b/isis/tests/TableTests.cpp new file mode 100644 index 0000000000..c2be04e128 --- /dev/null +++ b/isis/tests/TableTests.cpp @@ -0,0 +1,292 @@ +#include "Fixtures.h" +#include "Table.h" +#include "TableField.h" +#include "TableRecord.h" + +#include "gmock/gmock.h" + +using namespace Isis; + +TEST(TableTests, RecordConstructor) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + EXPECT_EQ(t.RecordFields(), rec.Fields()); + EXPECT_EQ(t.RecordSize(), rec.RecordSize()); +} + + +TEST(TableTests, Association) { + Table t("UNITTEST"); + + // Default initialization should be no association + EXPECT_FALSE(t.IsSampleAssociated()); + EXPECT_FALSE(t.IsLineAssociated()); + EXPECT_FALSE(t.IsBandAssociated()); + + t.SetAssociation(Table::Samples); + EXPECT_TRUE(t.IsSampleAssociated()); + EXPECT_FALSE(t.IsLineAssociated()); + EXPECT_FALSE(t.IsBandAssociated()); + + t.SetAssociation(Table::Lines); + EXPECT_FALSE(t.IsSampleAssociated()); + EXPECT_TRUE(t.IsLineAssociated()); + EXPECT_FALSE(t.IsBandAssociated()); + + t.SetAssociation(Table::Bands); + EXPECT_FALSE(t.IsSampleAssociated()); + EXPECT_FALSE(t.IsLineAssociated()); + EXPECT_TRUE(t.IsBandAssociated()); + + t.SetAssociation(Table::None); + EXPECT_FALSE(t.IsSampleAssociated()); + EXPECT_FALSE(t.IsLineAssociated()); + EXPECT_FALSE(t.IsBandAssociated()); +} + + +TEST(TableTests, UpdatingRecords) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + rec[0] = 5; + rec[1] = 3.14; + rec[2] = "PI"; + rec[3] = 3.14159; + t += rec; + + ASSERT_EQ(t.Records(), 1); + EXPECT_EQ(TableRecord::toString(t[0]).toStdString(), TableRecord::toString(rec).toStdString()); + + rec[0] = -1; + rec[1] = 0.5; + rec[2] = "HI"; + rec[3] = -0.55; + t.Update(rec, 0); + + ASSERT_EQ(t.Records(), 1); + EXPECT_EQ(TableRecord::toString(t[0]).toStdString(), TableRecord::toString(rec).toStdString()); +} + + +TEST(TableTests, AddingRecords) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + rec[0] = 5; + rec[1] = 3.14; + rec[2] = "PI"; + rec[3] = 3.14159; + t += rec; + + ASSERT_EQ(t.Records(), 1); + EXPECT_EQ(TableRecord::toString(t[0]).toStdString(), TableRecord::toString(rec).toStdString()); + + rec[0] = -1; + rec[1] = 0.5; + rec[2] = "HI"; + rec[3] = -0.55; + t += rec; + + ASSERT_EQ(t.Records(), 2); + EXPECT_EQ(TableRecord::toString(t[1]).toStdString(), TableRecord::toString(rec).toStdString()); +} + + +TEST(TableTests, ToFromBlob) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + t.SetAssociation(Table::Lines); + + rec[0] = 5; + rec[1] = 3.14; + rec[2] = "PI"; + rec[3] = 3.14159; + t += rec; + + rec[0] = -1; + rec[1] = 0.5; + rec[2] = "HI"; + rec[3] = -0.55; + t += rec; + + Blob tableBlob = t.toBlob(); + + Table t2(tableBlob); + + EXPECT_EQ(t.RecordFields(), t2.RecordFields()); + EXPECT_EQ(t.RecordSize(), t2.RecordSize()); + EXPECT_EQ(t.IsSampleAssociated(), t2.IsSampleAssociated()); + EXPECT_EQ(t.IsLineAssociated(), t2.IsLineAssociated()); + EXPECT_EQ(t.IsBandAssociated(), t2.IsBandAssociated()); + + ASSERT_EQ(t.Records(), t2.Records()); + for (int i = 0; i < t.Records(); i++) { + EXPECT_EQ(TableRecord::toString(t[i]).toStdString(), TableRecord::toString(t2[i]).toStdString()); + } +} + + +TEST_F(TempTestingFiles, TableTestsWriteRead) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + t.SetAssociation(Table::Lines); + + rec[0] = 5; + rec[1] = 3.14; + rec[2] = "PI"; + rec[3] = 3.14159; + t += rec; + + rec[0] = -1; + rec[1] = 0.5; + rec[2] = "HI"; + rec[3] = -0.55; + t += rec; + + QString tableFile = tempDir.path() + "/testTable.pvl"; + t.Write(tableFile); + Blob tableBlob("UNITTEST", "Table", tableFile); + Table t2(tableBlob); + + EXPECT_EQ(t.RecordFields(), t2.RecordFields()); + EXPECT_EQ(t.RecordSize(), t2.RecordSize()); + EXPECT_EQ(t.IsSampleAssociated(), t2.IsSampleAssociated()); + EXPECT_EQ(t.IsLineAssociated(), t2.IsLineAssociated()); + EXPECT_EQ(t.IsBandAssociated(), t2.IsBandAssociated()); + + ASSERT_EQ(t.Records(), t2.Records()); + for (int i = 0; i < t.Records(); i++) { + EXPECT_EQ(TableRecord::toString(t[i]).toStdString(), TableRecord::toString(t2[i]).toStdString()); + } + + Table t3("UNITTEST", tableFile); + + EXPECT_EQ(t.RecordFields(), t3.RecordFields()); + EXPECT_EQ(t.RecordSize(), t3.RecordSize()); + EXPECT_EQ(t.IsSampleAssociated(), t3.IsSampleAssociated()); + EXPECT_EQ(t.IsLineAssociated(), t3.IsLineAssociated()); + EXPECT_EQ(t.IsBandAssociated(), t3.IsBandAssociated()); + + ASSERT_EQ(t.Records(), t3.Records()); + for (int i = 0; i < t.Records(); i++) { + EXPECT_EQ(TableRecord::toString(t[i]).toStdString(), TableRecord::toString(t3[i]).toStdString()); + } + + Table t4("NOT_UNITTEST"); + + EXPECT_ANY_THROW(Table("NOT_UNITTEST", tableFile)); +} + + +TEST(TableTests, Assignment) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + rec[0] = 5; + rec[1] = 3.14; + rec[2] = "PI"; + rec[3] = 3.14159; + t += rec; + + rec[0] = -1; + rec[1] = 0.5; + rec[2] = "HI"; + rec[3] = -0.55; + t += rec; + + Table t2 = t; + + EXPECT_EQ(t.Name().toStdString(), t2.Name().toStdString()); + EXPECT_EQ(t.RecordFields(), t2.RecordFields()); + EXPECT_EQ(t.RecordSize(), t2.RecordSize()); + EXPECT_EQ(t.IsSampleAssociated(), t2.IsSampleAssociated()); + EXPECT_EQ(t.IsLineAssociated(), t2.IsLineAssociated()); + EXPECT_EQ(t.IsBandAssociated(), t2.IsBandAssociated()); + + ASSERT_EQ(t.Records(), t2.Records()); + for (int i = 0; i < t.Records(); i++) { + EXPECT_EQ(TableRecord::toString(t[i]).toStdString(), TableRecord::toString(t2[i]).toStdString()); + } +} + + +TEST(TableTests, Clear) { + TableField f1("Column1", TableField::Integer); + TableField f2("Column2", TableField::Double); + TableField f3("Column3", TableField::Text, 10); + TableField f4("Column4", TableField::Double); + TableRecord rec; + rec += f1; + rec += f2; + rec += f3; + rec += f4; + Table t("UNITTEST", rec); + + rec[0] = 5; + rec[1] = 3.14; + rec[2] = "PI"; + rec[3] = 3.14159; + t += rec; + + rec[0] = -1; + rec[1] = 0.5; + rec[2] = "HI"; + rec[3] = -0.55; + t += rec; + + t.Clear(); + + EXPECT_EQ(t.Records(), 0); +} \ No newline at end of file diff --git a/isis/tests/UnitTestImagePolygon.cpp b/isis/tests/UnitTestImagePolygon.cpp index 3500b3ac97..e8f9076cf6 100644 --- a/isis/tests/UnitTestImagePolygon.cpp +++ b/isis/tests/UnitTestImagePolygon.cpp @@ -32,7 +32,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonDefaultParams) { std::vector lats = {9.928429, 9.928429, 10.434929, 10.434929, 9.928429}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -59,7 +59,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonSubPoly) { std::vector lats = {10.039260, 10.039260, 10.213952, 10.213952, 10.039260}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -92,7 +92,7 @@ TEST_F(TempTestingFiles, UnitTestImagePolygonCross) { std::vector lats = {54.208706, 54.208706, 77.858556, 77.858556, 54.208706}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -149,7 +149,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonBoundary) { std::vector lats = {12.939325, 12.939325, 26.058469, 26.058469, 12.939325}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -196,7 +196,7 @@ TEST_F(TempTestingFiles, UnitTestImagePolygonMosaic) { std::vector lats = {-43.643248, -43.643248, -42.323638, -42.323638, -43.643248}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); } @@ -248,7 +248,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonOutlier) { throw IException(IException::Programmer, msg, _FILEINFO_); } footprintCube.close(); - + ASSERT_EQ(234, poly.numVertices()); geos::geom::Geometry* boundary = poly.Polys()->getEnvelope(); @@ -258,7 +258,7 @@ TEST_F(DefaultCube, UnitTestImagePolygonOutlier) { std::vector lats = {-66.783492, -66.783492, 5.718545, 5.718545, -66.783492}; geos::geom::CoordinateArraySequence coordArray = geos::geom::CoordinateArraySequence(*(boundary->getCoordinates())); - for (int i = 0; i < coordArray.getSize(); i++) { + for (size_t i = 0; i < coordArray.getSize(); i++) { EXPECT_NEAR(lons[i], coordArray.getAt(i).x, 1e-6); EXPECT_NEAR(lats[i], coordArray.getAt(i).y, 1e-6); }