Skip to content

Commit

Permalink
Blob Refactor (#4348)
Browse files Browse the repository at this point in the history
* Updated to new blob structure

* Clean up after being able to look at all of the changes at once

* Changed the history read to return a history object rather than a pointer

* Addressed PR feedback

* Imagepolygon Update (#4308)

* Converted Imagepolygon to no longer be a subclass of blob

* Updated Imagepolygon with constructor chaining

* Fixed error message

* Refactor OriginalLabel class to remove inheritance from Blob (#4309)

* Initial refactor of OriginalLabel class

* Addressed PR feedback

* Fixed error message

Co-authored-by: Jesse Mapel <jmapel@usgs.gov>

* Modified Table to not inherit from Blob anymore (#4312)

* Ported Table test to gtest

* Table refactor

* Fixed merge issue

* Fixed merge issues

* Removes blob inheritance from OriginalXmlLabel (#4316)

* Initial refactor of OriginalLabel class

* Addressed PR feedback

* Fixed error message

* Remove blob inheritance from originalxmllabel

* Removed commented / old code

* Added byte order specification

* History object tests (#4314)

* Adds History object tests

* Updated blob tests to use a non-pointer variable

* Removed gisblob from isis (#4329)

* Removed blob inheritance from stretchblob (#4331)

* Removed blob inheritance from stretchblob

* Addressed feedback + working read/write

* Updated cubestretch with the stretch blob functionality

* Removed stretchBlob and updated cubestretch/cube with read write functionality

* Replaced readStretchBlob with readCubeStretch

* Fixed segfault

* Removed debug print statements

* Added check for existence of OriginalLabel before attempting to propagate

* Addressed PR feedback

Co-authored-by: Adam Paquette <acpaquette@usgs.gov>

* Removed StringBlob Class (#4321)

* Converted StringBlob

* Removed StretchBlob class

* Changed Blob setData to copy

* Added csminit change and docs

* Removed old memcopy

* History Blob Old Implementation (#4342)

* Implemented old history functionality

* Removed old history unit test

* Fixed original label reading

* Fixed Blob branch test failures (#4344)

* Fixed test failures

* More clean-up

* Fixed marci2isis test

* Blob final clean-up (#4346)

* Redid Blob writing

* Added docs

* Review feedback

* Fixed int comparison

Co-authored-by: Adam Paquette <acpaquette@usgs.gov>
Co-authored-by: AustinSanders <arsanders@usgs.gov>
  • Loading branch information
3 people authored Mar 9, 2021
1 parent a394b82 commit dbfb004
Show file tree
Hide file tree
Showing 122 changed files with 1,940 additions and 2,322 deletions.
9 changes: 4 additions & 5 deletions isis/src/apollo/apps/apollofindrx/apollofindrx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
2 changes: 0 additions & 2 deletions isis/src/apollo/apps/apollopaninit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 2 additions & 8 deletions isis/src/base/apps/caminfo/CamTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 2 additions & 4 deletions isis/src/base/apps/caminfo/caminfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions isis/src/base/apps/cathist/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
20 changes: 3 additions & 17 deletions isis/src/base/apps/copylabel/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -279,4 +266,3 @@ bool copyBlob(Cube * from, Cube * to, QString name, QString type, QString fname)
return false;
}
}

42 changes: 22 additions & 20 deletions isis/src/base/apps/csminit/csminit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -465,7 +465,9 @@ namespace Isis {
cube->write(originalCameraStatistics);
}

if (originalFootprint.Size() != 0) {

if (originalFootprint.Polys() != NULL &&
originalFootprint.Polys()->getNumGeometries() != 0) {
cube->write(originalFootprint);
}

Expand Down
8 changes: 2 additions & 6 deletions isis/src/base/apps/cubeit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion isis/src/base/apps/demprep/demprep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 10 additions & 12 deletions isis/src/base/apps/desmile/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(),
Expand Down Expand Up @@ -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;
}

14 changes: 3 additions & 11 deletions isis/src/base/apps/editlab/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
Loading

0 comments on commit dbfb004

Please sign in to comment.