diff --git a/isis/src/base/objs/EndianSwapper/EndianSwapper.cpp b/isis/src/base/objs/EndianSwapper/EndianSwapper.cpp index cfca7e461eadf9829791c7be0e15543bee06c800..a60f297a937fb6efd16ee6433448612f4584d21a 100644 --- a/isis/src/base/objs/EndianSwapper/EndianSwapper.cpp +++ b/isis/src/base/objs/EndianSwapper/EndianSwapper.cpp @@ -138,6 +138,28 @@ namespace Isis { return result; } + /** + * Swaps a 32bit unsigned integer. + * + * @param buf Input uint32 integer value to swap. + */ + uint32_t EndianSwapper::Uint32_t(void *buf) { + uint32_t result = *(uint32_t *)buf; + + if(p_needSwap) { + char *ptr = (char *)buf + (sizeof(uint32_t) - 1) * p_needSwap; + + for(unsigned int i = 0; i < sizeof(uint32_t); i++) { + p_swapper.p_char[i] = *ptr; + ptr += p_swapDirection; + } + + result = p_swapper.p_uint32; + } + + return result; + } + /** * Swaps an 8 byte integer value. * @@ -203,4 +225,3 @@ namespace Isis { return result; } } - diff --git a/isis/src/base/objs/EndianSwapper/EndianSwapper.h b/isis/src/base/objs/EndianSwapper/EndianSwapper.h index 7f52d9a500e01c97bc752b090ca3e6e009bc0426..bd6dc89ba63c30781af207c1d41406d68845db3b 100644 --- a/isis/src/base/objs/EndianSwapper/EndianSwapper.h +++ b/isis/src/base/objs/EndianSwapper/EndianSwapper.h @@ -50,6 +50,7 @@ namespace Isis { * not added because it is 4 bytes on 32-bit linux and 8 bytes on * 64-bit linux. * @history 2016-04-21 Makayla Shepherd - Added UnsignedWord pixel type handling. + * @history 2018-01-29 Adam Goins - Added uint32_t behavior to EndianSwapper. */ class EndianSwapper { private: @@ -67,6 +68,8 @@ namespace Isis { * byte format - all with swapped bytes. */ union { + //! Union containing the output uint32_t value with swapped bytes. + uint32_t p_uint32; //! Union containing the output double precision value with swapped bytes. double p_double; //! Union containing the output floating point value with swapped bytes. @@ -93,6 +96,7 @@ namespace Isis { float Float(void *buf); int ExportFloat(void *buf); int Int(void *buf); + uint32_t Uint32_t(void *buf); long long int LongLongInt(void *buf); short int ShortInt(void *buf); unsigned short int UnsignedShortInt(void *buf); diff --git a/isis/src/base/objs/EndianSwapper/EndianSwapper.truth b/isis/src/base/objs/EndianSwapper/EndianSwapper.truth index 8bac0d87579309913025df0ef5aabd14846420cf..1498b83e99ecd49a112f0ee2ea54be969a2ae8ce 100644 --- a/isis/src/base/objs/EndianSwapper/EndianSwapper.truth +++ b/isis/src/base/objs/EndianSwapper/EndianSwapper.truth @@ -1,5 +1,6 @@ Size of Double: 8 Double 0x12345678 to HOST: 3.0542e+08 Size of Float: 4 Float 0x1234 to HOST: 4660 +Size of Uint32_t: 4 Uint32_t 0x1234 to HOST: 4660 Size of Short Int: 2 Short Int 0x1234 to HOST: 4660 Size of Unsigned Short Int: 2 Unsigned Short Int 0x1234 to HOST: 4660 Size of Double: 8 Double 0x12345678 to HOST: 2.55354e-312 diff --git a/isis/src/base/objs/EndianSwapper/unitTest.cpp b/isis/src/base/objs/EndianSwapper/unitTest.cpp index 72fa45a38ee58b31781cd42b6040ea97cf1e0531..55583a7784a99305ea998f222f6d795bccd56157 100644 --- a/isis/src/base/objs/EndianSwapper/unitTest.cpp +++ b/isis/src/base/objs/EndianSwapper/unitTest.cpp @@ -12,6 +12,7 @@ int main(int argc, char *argv[]) { double DoubleValue; float FloatValue; + uint32_t UIntValue; short int ShortIntValue; unsigned short int UShortIntValue; int IntValue; @@ -19,6 +20,7 @@ int main(int argc, char *argv[]) { DoubleValue = 0x12345678; FloatValue = 0x1234; + UIntValue = 0x1234; ShortIntValue = 0x1234; UShortIntValue = 0x1234; IntValue = 0x12345678; @@ -30,6 +32,8 @@ int main(int argc, char *argv[]) { cout << " Double 0x12345678 to HOST: " << lsb.Double(&DoubleValue) << endl; cout << "Size of Float: " << sizeof(float); cout << " Float 0x1234 to HOST: " << lsb.Float(&FloatValue) << endl; + cout << "Size of Uint32_t: " << sizeof(uint32_t); + cout << " Uint32_t 0x1234 to HOST: " << lsb.Uint32_t(&UIntValue) << endl; cout << "Size of Short Int: " << sizeof(short int); cout << " Short Int 0x1234 to HOST: " << lsb.ShortInt(&ShortIntValue) << endl; cout << "Size of Unsigned Short Int: " << sizeof(unsigned short int); @@ -74,6 +78,8 @@ int main(int argc, char *argv[]) { cout << " Double 0x12345678 to HOST: " << msb.Double(&DoubleValue) << endl; cout << "Size of Float: " << sizeof(float); cout << " Float 0x1234 to HOST: " << msb.Float(&FloatValue) << endl; + cout << "Size of Uint32_t: " << sizeof(uint32_t); + cout << " Uint32_t 0x1234 to HOST: " << msb.Uint32_t(&UIntValue) << endl; cout << "Size of Short Int: " << sizeof(short int); cout << " Short Int 0x1234 to HOST: " << msb.ShortInt(&ShortIntValue) << endl; cout << "Size of Unsigned Short Int: " << sizeof(unsigned short int); diff --git a/isis/src/control/apps/cnetbin2pvl/assets/image/InputNetwork.png b/isis/src/control/apps/cnetbin2pvl/assets/image/InputNetwork.png new file mode 100644 index 0000000000000000000000000000000000000000..d244248e1c05d2e8e0863cbae7c6e44276bd4bcc Binary files /dev/null and b/isis/src/control/apps/cnetbin2pvl/assets/image/InputNetwork.png differ diff --git a/isis/src/control/apps/cnetbin2pvl/assets/image/OutputNetwork.png b/isis/src/control/apps/cnetbin2pvl/assets/image/OutputNetwork.png new file mode 100644 index 0000000000000000000000000000000000000000..d6768abe39bb7ef2ada20199458f6b2a6bfa93fc Binary files /dev/null and b/isis/src/control/apps/cnetbin2pvl/assets/image/OutputNetwork.png differ diff --git a/isis/src/control/apps/cnetbin2pvl/assets/image/cnetbin2pvlGUI.png b/isis/src/control/apps/cnetbin2pvl/assets/image/cnetbin2pvlGUI.png new file mode 100644 index 0000000000000000000000000000000000000000..bb366719b09ac3b04dad0122f8895e888ad001c9 Binary files /dev/null and b/isis/src/control/apps/cnetbin2pvl/assets/image/cnetbin2pvlGUI.png differ diff --git a/isis/src/control/apps/cnetbin2pvl/cnetbin2pvl.xml b/isis/src/control/apps/cnetbin2pvl/cnetbin2pvl.xml index bf8069148d19c851c6a6a4c289fc60745104b425..6daa77c8a6ac99d088aceb6e7224ecee3c2dda6f 100644 --- a/isis/src/control/apps/cnetbin2pvl/cnetbin2pvl.xml +++ b/isis/src/control/apps/cnetbin2pvl/cnetbin2pvl.xml @@ -7,8 +7,9 @@

- This program converts an Isis3 control network file from binary into an - ascii pvl formatted file. + This program converts an Isis3 control network file from binary into a human readable + utf8 pvl formatted file. The output pvl will be written as the latest Pvl version. + The most recent Pvl template can be found in the Control data directory under templates/controlnetworks.

@@ -26,6 +27,11 @@ Added a basic progress + + Updated Description to reflect utf file format. + Added link to current Pvl template. + Added user example. + @@ -57,6 +63,51 @@ *.cnet *.pvl - + + + + Converting a binary Control Network to a Pvl network. + A binary V0001 Control Network converted to the latest Pvl network. + + + from=/usgs/cpkgs/isis3/data/control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net to=PvlNetwork.pvl + + + In this example we are converting a binary V0001 network from the test data area to a Pvl network. + + + + + Input binary V0001 control network + + This is the input network that will be ingested by cnetbin2pvl. + + + FROM + + + + + Output Pvl network from cnetbin2pvl + + This is the Pvl network that results from running cnetbin2pvl. + + + TO + + + + + + Example Gui + + Screenshot of GUI with parameters filled to convert a binary Control Network to a Pvl network. + + + + + + + diff --git a/isis/src/control/apps/cnetcheck/cnetcheck.cpp b/isis/src/control/apps/cnetcheck/cnetcheck.cpp index 1f76338ca0af559262ab1ead917b24f2b7e40e8e..801d3b06873184e92fb7808b823228040eaa492c 100644 --- a/isis/src/control/apps/cnetcheck/cnetcheck.cpp +++ b/isis/src/control/apps/cnetcheck/cnetcheck.cpp @@ -22,7 +22,6 @@ #include "Camera.h" #include "CameraFactory.h" -#include "ControlCubeGraphNode.h" #include "ControlMeasure.h" #include "ControlNet.h" #include "ControlPoint.h" @@ -48,15 +47,12 @@ QVector< set > findIslands( set &index, QMap< QString, set > adjCubes); -QList< ControlCubeGraphNode * > checkSerialList( - SerialNumberList *serialNumbers, ControlNet * controlNet); - void writeOutput(SerialNumberList num2cube, QString filename, set sns, QMap< QString, set > cps); -double getControlFitness(const ControlCubeGraphNode * node, double tolerance, Cube * cube); +double getControlFitness(ControlNet &cnet, QString sn, double tolerance, Cube * cube); void noLatLonCheck(ControlNet &cnet, CubeManager &manager, Progress &progress, bool ignore, SerialNumberList &num2cube, set &noLatLonSerialNumbers, @@ -178,16 +174,16 @@ void IsisMain() { // Records if the currentsnum is not in the input cube list bool contains = false; - for (int sn = 0; - sn < (int)listedSerialNumbers.size() && !contains; + for (int sn = 0; + sn < (int)listedSerialNumbers.size() && !contains; sn++) { if (currentsn == listedSerialNumbers[sn]) { contains = true; } } // Check if already added - for (int sn = 0; - sn < (int)nonListedSerialNumbers.size() && !contains; + for (int sn = 0; + sn < (int)nonListedSerialNumbers.size() && !contains; sn++) { if (currentsn == nonListedSerialNumbers[sn]) { contains = true; @@ -220,7 +216,7 @@ void IsisMain() { bool hasList = false; for (set::iterator island = islands[i].begin(); - island != islands[i].end(); + island != islands[i].end(); island++) { if (num2cube.hasSerialNumber(*island)) { outputRow(out_stream, buildRow(num2cube, *island)); @@ -295,22 +291,21 @@ void IsisMain() { QString coverageOp = "LowCoverage"; int failedCoverageCheck = 0; if (ui.GetBoolean(QString(coverageOp).toUpper())) { - QList< ControlCubeGraphNode * > nodes = innet.GetCubeGraphNodes(); + QList< QString > netSerials = innet.GetCubeSerials(); - if (nodes.size() > 0) { + if (netSerials.size() > 0) { QString name(FileName(prefix + coverageOp + ".txt").expanded()); ofstream out_stream; out_stream.open(name.toLatin1().data(), std::ios::out); out_stream.seekp(0, std::ios::beg); // Start writing from file beginning double tolerance = ui.GetDouble("TOLERANCE"); - foreach (ControlCubeGraphNode * node, nodes) { - QString sn = node->getSerialNumber(); + foreach (QString sn, netSerials) { if (num2cube.hasSerialNumber(sn)) { // Create a convex hull Cube *cube = cbman.OpenCube(num2cube.fileName(sn)); - double controlFitness = getControlFitness(node, tolerance, cube); + double controlFitness = getControlFitness(innet, sn, tolerance, cube); if (controlFitness < tolerance) { outputRow(out_stream, buildRow(num2cube, sn, controlFitness)); @@ -375,8 +370,7 @@ void IsisMain() { out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file for (int sn = 0; sn < (int)nonListedSerialNumbers.size(); sn++) { - int validMeasureCount = innet.getGraphNode( - nonListedSerialNumbers[sn])->getValidMeasures().size(); + int validMeasureCount = innet.GetValidMeasuresInCube(nonListedSerialNumbers[sn]).size(); QString rowText = nonListedSerialNumbers[sn] + " (Valid Measures: " + toString(validMeasureCount) + ")"; outputRow(out_stream, rowText); @@ -504,8 +498,8 @@ QVector< set > findIslands(set & index, // Find the first connected unvisited node QString nextNode = ""; set neighbors = adjCubes[str_stack.top()]; - for (set::iterator i = neighbors.begin(); - i != neighbors.end(); + for (set::iterator i = neighbors.begin(); + i != neighbors.end(); i++) { if (index.count(*i) == 1) { nextNode = *i; @@ -542,7 +536,7 @@ void writeOutput(SerialNumberList num2cube, QString filename, out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file for (set::iterator sn = sns.begin(); - sn != sns.end(); + sn != sns.end(); sn++) { outputRow(out_stream, buildRow(num2cube, *sn, cps[*sn])); } @@ -551,12 +545,12 @@ void writeOutput(SerialNumberList num2cube, QString filename, } -double getControlFitness(const ControlCubeGraphNode * node, double tolerance, Cube * cube) { +double getControlFitness(ControlNet &cnet, QString sn, double tolerance, Cube * cube) { double controlFitness = 0; static geos::geom::GeometryFactory geosFactory; geos::geom::CoordinateSequence * pts = new geos::geom::CoordinateArraySequence(); - QList< ControlMeasure * > measures = node->getMeasures(); + QList< ControlMeasure * > measures = cnet.GetMeasuresInCube(sn); // Populate pts with a list of control points foreach (ControlMeasure * measure, measures) { @@ -572,7 +566,6 @@ double getControlFitness(const ControlCubeGraphNode * node, double tolerance, Cu // Calculate the area of the convex hull double convexArea = convexHull->getArea(); - QString sn = node->getSerialNumber(); double cubeArea = cube->sampleCount() * cube->lineCount(); controlFitness = convexArea / cubeArea; @@ -594,16 +587,14 @@ void noLatLonCheck(ControlNet &cnet, CubeManager &manager, Progress &progress, QMap< QString, set > &noLatLonControlPoints) { // Set calculating progress - QList graphNodes = cnet.GetCubeGraphNodes(); - if (graphNodes.size() > 0) { + QList< QString > netSerials = cnet.GetCubeSerials(); + if (netSerials.size() > 0) { progress.SetText("Checking for No Lat/Lon"); - progress.SetMaximumSteps(graphNodes.size()); + progress.SetMaximumSteps(netSerials.size()); progress.CheckStatus(); } - for (int sn = 0; sn < graphNodes.size(); sn++) { - ControlCubeGraphNode *graphNode = graphNodes[sn]; - QString serialNumber = graphNode->getSerialNumber(); + foreach (QString serialNumber, netSerials) { if (num2cube.hasSerialNumber(serialNumber)) { Cube *cube = manager.OpenCube(num2cube.fileName(serialNumber)); @@ -618,7 +609,7 @@ void noLatLonCheck(ControlNet &cnet, CubeManager &manager, Progress &progress, createdCamera = false; } - QList< ControlMeasure * > measures = graphNode->getMeasures(); + QList< ControlMeasure * > measures = cnet.GetMeasuresInCube(serialNumber); for (int cm = 0; cm < measures.size(); cm++) { ControlMeasure *measure = measures[cm]; ControlPoint *point = measure->Parent(); @@ -671,4 +662,3 @@ QString buildRow(SerialNumberList &serials, QString sn, double value) { void outputRow(ofstream &outStream, QString rowText) { outStream << rowText << "\n"; } - diff --git a/isis/src/control/apps/cnetedit/cnetedit.cpp b/isis/src/control/apps/cnetedit/cnetedit.cpp index 65ae762af7b8e54b5ce284a9dfcefcb140254bf2..7bcc4de68ebcba02c0dde4cf87494c9b7c4c47b3 100644 --- a/isis/src/control/apps/cnetedit/cnetedit.cpp +++ b/isis/src/control/apps/cnetedit/cnetedit.cpp @@ -8,7 +8,6 @@ #include #include -#include "ControlCubeGraphNode.h" #include "ControlMeasure.h" #include "ControlNet.h" #include "ControlNetValidMeasure.h" @@ -137,7 +136,7 @@ void IsisMain() { QString msg = "The control network [" + cnetInput.expanded() + "] entered for CNET does not exist."; throw IException(IException::User, msg, _FILEINFO_); } - + // If the user wants to keep a log, go ahead and populate it with all the // existing ignored points and measures ControlNet cnet(ui.GetFileName("CNET")); @@ -878,15 +877,13 @@ void lockMeasures(ControlNet &cnet, void checkAllMeasureValidity(ControlNet &cnet, QString cubeList) { SerialNumberList serialNumbers(cubeList); - QList graphNodes = cnet.GetCubeGraphNodes(); + QList cnetSerials = cnet.GetCubeSerials(); Progress progress; progress.SetText("Checking Measure Validity"); - progress.SetMaximumSteps(graphNodes.size()); + progress.SetMaximumSteps(cnetSerials.size()); progress.CheckStatus(); - for (int sn = 0; sn < graphNodes.size(); sn++) { - ControlCubeGraphNode *graphNode = graphNodes[sn]; - QString serialNumber = graphNode->getSerialNumber(); + foreach (QString serialNumber, cnetSerials) { Cube *cube = NULL; Camera *camera = NULL; @@ -911,7 +908,7 @@ void checkAllMeasureValidity(ControlNet &cnet, QString cubeList) { } } - QList measures = graphNode->getMeasures(); + QList measures = cnet.GetMeasuresInCube(serialNumber); for (int cm = 0; cm < measures.size(); cm++) { ControlMeasure *measure = measures[cm]; ControlPoint *point = measure->Parent(); @@ -1076,5 +1073,3 @@ void EditDefFile(void) { GuiEditFile::EditFile(ui, sDefFile); } - - diff --git a/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp b/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp index 724060c5c0d81d3da1e60f146b4d390e5a8bdf01..6510a966bc67d6d98b3122672f10a1ca0722c725 100644 --- a/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp +++ b/isis/src/control/apps/cnetwinnow/cnetwinnow.cpp @@ -22,7 +22,6 @@ #include "SerialNumber.h" #include "SerialNumberList.h" #include "UserInterface.h" -#include "ControlCubeGraphNode.h" #include "stdio.h" #include "string.h" @@ -30,7 +29,7 @@ using namespace std; using namespace Isis; -void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, int &validMeasures, +void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, int &validMeasures, QList *measToIgnor=NULL); @@ -41,14 +40,14 @@ void IsisMain() { //build a histogram from the control net Progress progress; - + //read the ControlNet ControlNet net(ui.GetFileName("CNET"), &progress); //read the file list SerialNumberList serialNumList(ui.GetFileName("FROMLIST"), true, &progress); //check to make sure all the serial numbers in the net have an associated file name QList cubeSerials = net.GetCubeSerials(); - bool serFlag=true; + bool serFlag=true; for (int i=0;i binHeight[i] && binHeight[i] < binHeight[i+1] ) { + if ( binHeight[i-1] > binHeight[i] && binHeight[i] < binHeight[i+1] ) { for (int j=i+1;j binHeight[j+1] ) { @@ -144,7 +143,7 @@ void IsisMain() { //calculate the height of the bump as a ratio of the height of the local minima if (binHeight[i] >0) ratio = (binHeight[j]-binHeight[i])/binHeight[i]; else ratio = DBL_MAX; - //if the first significant bumps save them + //if the first significant bumps save them if (ratio > suspectRatio && inocentSuspectB ==0) inocentSuspectB = binCenter[i]; if (ratio > guiltyRatio && suspectGuiltyB ==0) suspectGuiltyB = binCenter[i]; i=j; //advance to the j position @@ -156,26 +155,26 @@ void IsisMain() { if (inocentSuspectB != 0.0 && suspectGuiltyB != 0.0) break; } - + //rembering that the inocentSuspectB can not be less than the user defined floor - if ( inocentSuspectB < ui.GetDouble("SUSPECT_FLOOR") ) + if ( inocentSuspectB < ui.GetDouble("SUSPECT_FLOOR") ) inocentSuspectB = ui.GetDouble("SUSPECT_FLOOR"); //add also remembering that suspectGuiltyB can not be greater than the user defined ceiling - if ( suspectGuiltyB > ui.GetDouble("GUILTY_FLOOR") ) + if ( suspectGuiltyB > ui.GetDouble("GUILTY_FLOOR") ) suspectGuiltyB = ui.GetDouble("GUILTY_FLOOR"); //rembering that the suspectGuiltyB can not be less than the user defined floor either - if ( suspectGuiltyB < ui.GetDouble("SUSPECT_FLOOR") ) + if ( suspectGuiltyB < ui.GetDouble("SUSPECT_FLOOR") ) suspectGuiltyB = ui.GetDouble("SUSPECT_FLOOR"); //finally make sure that inocentSuspectB <= suspectGuiltyB if (inocentSuspectB > suspectGuiltyB) inocentSuspectB = suspectGuiltyB; //the boundaries between inocent, suspect, and guilty measures have been established //get an ordered list of all the suspect and guilty measures - QList suspectMeasures + QList suspectMeasures = net.sortedMeasureList(&ControlMeasure::GetResidualMagnitude,inocentSuspectB,DBL_MAX); - + //print csv column headers fprintf(guiltyFile,/*"Guilty points (Residual Magnitudes > %lf) that could not be ignored.\n" "PtID: Point ID Name\n" @@ -218,15 +217,15 @@ void IsisMain() { //we will need a hash of the image original convex hulls and //numbers of measures, it will be built on the fly QHash > originalCubeStats; - + //we will also need to know how many islands we started with - int numInitialIslands = net.GetNodeConnections().size(); + int numInitialIslands = net.GetSerialConnections().size(); //user parameters for allowing measure rejection double hullReductionLimit = ui.GetDouble("HULL_REDUCTION_PERCENT")/100.0; double measureReductionLimit = ui.GetDouble("MEASURE_REDUCTION_PERCENT")/100.0; - + //now work through the list from the end to the begining setting measures to ignor if we are able progress.SetText("Winnowing points"); @@ -234,7 +233,7 @@ void IsisMain() { progress.CheckStatus(); for (int i = suspectMeasures.size() - 1; i > -1; i--) { //if the measure to be ignored is one of the last two active measures of a point then both of - //the measures and the point must be ignored together so we need the flexibility to test + //the measures and the point must be ignored together so we need the flexibility to test //two points at a time QList measGroup; bool hullFlag[2]; //hull test pass flags @@ -251,7 +250,7 @@ void IsisMain() { if ( suspectMeasures[i]->Parent()->GetNumValidMeasures() <= 2) { QList tempList = suspectMeasures[i]->Parent()->getMeasures(); //pull the valid measures out of the list - for (int j=0;jIsIgnored()) measGroup.push_back(tempList[j]); } @@ -318,9 +317,9 @@ void IsisMain() { for (int j=0; jSetIgnored(true); } - + //if the number of islands has increased the network has split - if (net.GetNodeConnections().size() > numInitialIslands) islandFlag = false; //test failed + if (net.GetSerialConnections().size() > numInitialIslands) islandFlag = false; //test failed else islandFlag = true; //test passed //Check to see if the network has split @@ -367,10 +366,10 @@ void IsisMain() { measReduction[j]*100.0, measOriNum[j], measNum[j], - !islandFlag ? "Yes":"No", - ableToEditFlag[j] ? "Yes":"No", + !islandFlag ? "Yes":"No", + ableToEditFlag[j] ? "Yes":"No", !groupFlag ? "Yes":"No"); - + if (!groupFlag && measGroup[j]->GetResidualMagnitude() >= suspectGuiltyB) fputs(line, guiltyFile); else //print the stats of ingored points to the other report @@ -386,7 +385,7 @@ void IsisMain() { //of an object point then ignor the point too if (measGroup.size() >1) measGroup[0]->Parent()->SetIgnored(true); - } + } progress.CheckStatus(); } @@ -403,7 +402,7 @@ void IsisMain() { -void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, int &validMeasures, +void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, int &validMeasures, QList *measToIgnor) { int i,j,firstIndex=0; @@ -418,7 +417,7 @@ void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, //skip measure in the ToIgnor list ignorMeas=false; if (measToIgnor != NULL) { - for (j=0; jsize() && !ignorMeas; j++) { + for (j=0; jsize() && !ignorMeas; j++) { if (cubeMeasures[i] == (*measToIgnor)[j]) { ignorMeas = true; break; @@ -431,10 +430,10 @@ void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, firstIndex =i; } //build point sequence - pts->add(geos::geom::Coordinate(cubeMeasures[i]->GetSample(), cubeMeasures[i]->GetLine())); + pts->add(geos::geom::Coordinate(cubeMeasures[i]->GetSample(), cubeMeasures[i]->GetLine())); } //Adding the first active point again closes the "linestring" - pts->add(geos::geom::Coordinate(cubeMeasures[firstIndex]->GetSample(), + pts->add(geos::geom::Coordinate(cubeMeasures[firstIndex]->GetSample(), cubeMeasures[firstIndex]->GetLine())); if (pts->size() >= 4) { // Calculate the convex hull @@ -449,4 +448,3 @@ void cubeConvexHullAndMeasures(QString &serialNum,ControlNet &net, double &area, validMeasures = pts->size()-1; //subtract one because one point is in there twice return; } - diff --git a/isis/src/control/objs/ControlNet/ControlNet.cpp b/isis/src/control/objs/ControlNet/ControlNet.cpp index d9afdafee6457b7dd328e09d9f405e3bc3d1ca6c..c605525846e42f432c520999984db94637596f60 100644 --- a/isis/src/control/objs/ControlNet/ControlNet.cpp +++ b/isis/src/control/objs/ControlNet/ControlNet.cpp @@ -1051,6 +1051,17 @@ namespace Isis { } + /** + * Get all the valid measures pertaining to a given cube serial number + * + * @returns A list of all valid measures which are in a given cube + */ + QList< ControlMeasure * > ControlNet::GetValidMeasuresInCube(QString serialNumber) { + ValidateSerialNumber(serialNumber); + return (*cubeGraphNodes)[serialNumber]->getValidMeasures(); + } + + /** * Copies the content of the a ControlMeasureLessThanFunctor * diff --git a/isis/src/control/objs/ControlNet/ControlNet.h b/isis/src/control/objs/ControlNet/ControlNet.h index 119db799ae1ea894e57c6e5df1b681f4d589cf4f..f0ae6fb216e2f72cece5a7c2ada83e329fec14c1 100644 --- a/isis/src/control/objs/ControlNet/ControlNet.h +++ b/isis/src/control/objs/ControlNet/ControlNet.h @@ -203,12 +203,14 @@ namespace Isis { * import in constructor. Also removed p_invalid as it was no longer * being used anywhere. Fixes #5068. * @history 2017-12-12 Kristin Berry - Updated to use QMap and QVector rather than std::map - * and std::vector. Fixes #5259. + * and std::vector. Fixes #5259. * @history 2017-12-18 Adam Goins - Added GetLastModified() accessor. References #5258. * @history 2017-12-21 Jesse Mapel - Modified read and write methods to use the refactored * ControlNetVersioner instead of directly parsing the protobuf * objects from the LatestControlNetFile. * @history 2018-01-12 Adam Goins - Added Progress support back to Read methods. + * @history 2017-01-19 Jesse Mapel - Added a method to get all of the valid measures in an + * image. Previously, this had to be done throug the graph. */ class ControlNet : public QObject { Q_OBJECT @@ -245,6 +247,7 @@ namespace Isis { int getEdgeCount() const; QString CubeGraphToString() const; QList< ControlMeasure * > GetMeasuresInCube(QString serialNumber); + QList< ControlMeasure * > GetValidMeasuresInCube(QString serialNumber); QList< ControlMeasure * > sortedMeasureList(double(ControlMeasure::*statFunc)() const, double min,double max); void DeleteMeasuresWithId(QString serialNumber); diff --git a/isis/src/control/objs/ControlNetFilter/ControlNetFilter.cpp b/isis/src/control/objs/ControlNetFilter/ControlNetFilter.cpp index 4734773279d685f0ef1b835cf5c64fa8fa3f010c..a5e80cb740fce472b3b3ea30733f90a80a196e53 100644 --- a/isis/src/control/objs/ControlNetFilter/ControlNetFilter.cpp +++ b/isis/src/control/objs/ControlNetFilter/ControlNetFilter.cpp @@ -8,7 +8,6 @@ #include "ControlMeasure.h" #include "ControlMeasureLogData.h" #include "ControlNet.h" -#include "ControlCubeGraphNode.h" #include "ControlPoint.h" #include "FileName.h" #include "IString.h" @@ -99,9 +98,7 @@ namespace Isis { * @param serialNum - Serial Number */ void ControlNetFilter::FilterOutMeasuresBySerialNum(QString serialNum){ - QString sn(serialNum); - const ControlCubeGraphNode *csn = mCNet->getGraphNode(sn); - QList< ControlMeasure * > measures = csn->getMeasures(); + QList< ControlMeasure * > measures = mCNet->GetMeasuresInCube(serialNum); foreach(ControlMeasure * measure, measures) { bool pointEditFlag = false; @@ -111,7 +108,7 @@ namespace Isis { point->SetEditLock(false); pointEditFlag = true; } - ControlMeasure *msr = point->GetMeasure(sn); + ControlMeasure *msr = point->GetMeasure(serialNum); msr->SetEditLock(false); point->Delete(serialNum); if (pointEditFlag) { diff --git a/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp b/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp index ce7dd65db937d5be2f1dad7f767ba636f2ac3b17..487ee47386af9a9f679967c07f0fae63eb8c63ec 100644 --- a/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp +++ b/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.cpp @@ -15,7 +15,6 @@ #include "ControlPoint.h" #include "ControlMeasure.h" #include "ControlMeasureLogData.h" -#include "ControlCubeGraphNode.h" #include "Cube.h" #include "CubeManager.h" #include "FileName.h" @@ -216,15 +215,15 @@ namespace Isis { CubeManager cubeMgr; cubeMgr.SetNumOpenCubes(50); - mCubeGraphNodes = mCNet->GetCubeGraphNodes(); + QList cnetSerials = mCNet->GetCubeSerials(); if (mProgress != NULL) { mProgress->SetText("Generating Image Stats....."); - mProgress->SetMaximumSteps(mCubeGraphNodes.size()); + mProgress->SetMaximumSteps(cnetSerials.size()); mProgress->CheckStatus(); } - foreach (ControlCubeGraphNode * node, mCubeGraphNodes) { + foreach (QString sn, cnetSerials) { geos::geom::CoordinateSequence * ptCoordinates = new geos::geom::CoordinateArraySequence(); @@ -232,7 +231,6 @@ namespace Isis { QVector imgStats(numImageStats, 0); // Open the cube to get the dimensions - QString sn = node->getSerialNumber(); Cube *cube = cubeMgr.OpenCube(mSerialNumList.fileName(sn)); mSerialNumMap[sn] = true; @@ -242,7 +240,7 @@ namespace Isis { imgStats[imgLines] = cube->lineCount(); double cubeArea = imgStats[imgSamples] * imgStats[imgLines]; - QList< ControlMeasure * > measures = node->getMeasures(); + QList< ControlMeasure * > measures = mCNet->GetMeasuresInCube(sn); // Populate pts with a list of control points if (!measures.isEmpty()) { @@ -357,7 +355,7 @@ namespace Isis { QString msg = QObject::tr("Error writing to file: [%1]").arg(psImageFile); throw IException(IException::Io, msg, _FILEINFO_); } - ostm.close(); + ostm.close(); } @@ -610,4 +608,3 @@ namespace Isis { } } } - diff --git a/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.h b/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.h index eee72b733750fafdce27b30f12a4d85b1354ec45..79244cd53d5c1a6d4409b795348953b94181a9c6 100644 --- a/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.h +++ b/isis/src/control/objs/ControlNetStatistics/ControlNetStatistics.h @@ -35,7 +35,6 @@ namespace Isis { class ControlNet; - class ControlCubeGraphNode; class Progress; class PvlGroup; @@ -76,7 +75,6 @@ namespace Isis { * Fixes #996. * @history 2017-12-12 Kristin Berry - Updated std::map to QMap and std::vector to QVector. Fixes * #5259. - * */ class ControlNetStatistics { public: @@ -248,7 +246,6 @@ namespace Isis { SerialNumberList mSerialNumList; //!< Serial Number List ControlNet *mCNet; //!< Control Network Progress *mProgress; //!< Progress state - QList mCubeGraphNodes; private: QMap mPointIntStats; //!< Contains QMap of different count stats diff --git a/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp b/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp index d3760998e20c843642694b44e0b190fba2ef5bdb..f02c607873ca0537c9562ce24ad9341501adb3cd 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp +++ b/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.cpp @@ -15,6 +15,7 @@ #include "ControlNet.h" #include "ControlMeasureLogData.h" #include "Distance.h" +#include "EndianSwapper.h" #include "FileName.h" #include "IException.h" #include "Latitude.h" @@ -150,7 +151,7 @@ namespace Isis { /** * Returns the name of the last person or program to modify the network. * - * @retrun @b QString The name of the last person or program to modify the network. + * @return @b QString The name of the last person or program to modify the network. */ QString ControlNetVersioner::userName() const { return m_header.userName; @@ -172,7 +173,8 @@ namespace Isis { * of the point to the caller who is expected to delete it when done with it. * * @return @b ControlPoint* A pointer to the control point. The caller assumes ownership of the - * ControlPoint and is expected to delete it when done. + * ControlPoint and is expected to delete it when done. If there are no + * points to return, a NULL pointer is returned. */ ControlPoint *ControlNetVersioner::takeFirstPoint() { ControlPoint *point = NULL; @@ -187,7 +189,7 @@ namespace Isis { /** * Generates a Pvl file from the currently stored control points and header. * - * @return Pvl& The Pvl version of the network + * @return Pvl The Pvl version of the network */ Pvl ControlNetVersioner::toPvl(){ Pvl pvl; @@ -326,7 +328,8 @@ namespace Isis { pvlPoint += aprioriY; pvlPoint += aprioriZ; - symmetric_matrix aprioriCovarianceMatrix = aprioriSurfacePoint.GetRectangularMatrix(); + symmetric_matrix aprioriCovarianceMatrix = + aprioriSurfacePoint.GetRectangularMatrix(); if ( aprioriCovarianceMatrix.size1() > 0 ) { @@ -367,7 +370,7 @@ namespace Isis { || aprioriCovarianceMatrix(1, 2) != 0.0 || aprioriCovarianceMatrix(2, 2) != 0.0 ) { - pvlPoint += matrix; + pvlPoint += matrix; } } } @@ -387,9 +390,12 @@ namespace Isis { // adj surface point, convert to lat,lon,radius and output as comment SurfacePoint adjustedSurfacePoint = controlPoint->GetAdjustedSurfacePoint(); if ( adjustedSurfacePoint.Valid() ) { - PvlKeyword adjustedX("AdjustedX", toString(adjustedSurfacePoint.GetX().meters()), "meters"); - PvlKeyword adjustedY("AdjustedY", toString(adjustedSurfacePoint.GetY().meters()), "meters"); - PvlKeyword adjustedZ("AdjustedZ", toString(adjustedSurfacePoint.GetZ().meters()), "meters"); + PvlKeyword adjustedX("AdjustedX", + toString(adjustedSurfacePoint.GetX().meters()), "meters"); + PvlKeyword adjustedY("AdjustedY", + toString(adjustedSurfacePoint.GetY().meters()), "meters"); + PvlKeyword adjustedZ("AdjustedZ", + toString(adjustedSurfacePoint.GetZ().meters()), "meters"); adjustedX.addComment("AdjustedLatitude = " + toString(adjustedSurfacePoint.GetLatitude().degrees()) @@ -405,7 +411,8 @@ namespace Isis { pvlPoint += adjustedY; pvlPoint += adjustedZ; - symmetric_matrix adjustedCovarianceMatrix = adjustedSurfacePoint.GetRectangularMatrix(); + symmetric_matrix adjustedCovarianceMatrix = + adjustedSurfacePoint.GetRectangularMatrix(); if ( adjustedCovarianceMatrix.size1() > 0 ) { @@ -419,9 +426,9 @@ namespace Isis { if ( pvlRadii.hasKeyword("EquatorialRadius") && pvlRadii.hasKeyword("PolarRadius") ) { - adjustedSurfacePoint.SetRadii( Distance(pvlRadii["EquatorialRadius"], Distance::Meters), - Distance(pvlRadii["EquatorialRadius"], Distance::Meters), - Distance(pvlRadii["PolarRadius"], Distance::Meters) ); + adjustedSurfacePoint.SetRadii(Distance(pvlRadii["EquatorialRadius"], Distance::Meters), + Distance(pvlRadii["EquatorialRadius"], Distance::Meters), + Distance(pvlRadii["PolarRadius"], Distance::Meters) ); if ( adjustedSurfacePoint.GetLatSigmaDistance().meters() != Isis::Null && adjustedSurfacePoint.GetLonSigmaDistance().meters() != Isis::Null @@ -446,15 +453,14 @@ namespace Isis { || adjustedCovarianceMatrix(1, 2) != 0.0 || adjustedCovarianceMatrix(2, 2) != 0.0 ) { - pvlPoint += matrix; + pvlPoint += matrix; } } } for (int j = 0; j < controlPoint->GetNumMeasures(); j++) { PvlGroup pvlMeasure("ControlMeasure"); - const ControlMeasure & - controlMeasure = *controlPoint->GetMeasure(j); + const ControlMeasure &controlMeasure = *controlPoint->GetMeasure(j); pvlMeasure += PvlKeyword("SerialNumber", controlMeasure.GetCubeSerialNumber()); switch ( controlMeasure.GetType() ) { @@ -472,10 +478,10 @@ namespace Isis { break; } - if ( QString::compare(controlMeasure.GetChooserName(), "Null", Qt::CaseInsensitive) != 0 ) { + if (QString::compare(controlMeasure.GetChooserName(), "Null", Qt::CaseInsensitive) != 0) { pvlMeasure += PvlKeyword("ChooserName", controlMeasure.GetChooserName()); } - if ( QString::compare(controlMeasure.GetDateTime(), "Null", Qt::CaseInsensitive) != 0 ) { + if (QString::compare(controlMeasure.GetDateTime(), "Null", Qt::CaseInsensitive) != 0) { pvlMeasure += PvlKeyword("DateTime", controlMeasure.GetDateTime()); } if ( controlMeasure.IsEditLocked() ) { @@ -520,7 +526,8 @@ namespace Isis { if ( controlMeasure.GetSampleResidual() != Isis::Null && controlMeasure.GetSampleResidual() != 0. ) { - pvlMeasure += PvlKeyword("SampleResidual", toString(controlMeasure.GetSampleResidual()), + pvlMeasure += PvlKeyword("SampleResidual", + toString(controlMeasure.GetSampleResidual()), "pixels"); } @@ -538,9 +545,9 @@ namespace Isis { pvlMeasure += log.ToKeyword(); } - if ( controlPoint->HasRefMeasure() && - controlPoint->IndexOfRefMeasure() == j && - controlPoint->IsReferenceExplicit() ) { + if ( controlPoint->HasRefMeasure() + && controlPoint->IndexOfRefMeasure() == j + && controlPoint->IsReferenceExplicit() ) { pvlMeasure += PvlKeyword("Reference", "True"); } pvlPoint.addGroup(pvlMeasure); @@ -881,7 +888,9 @@ namespace Isis { * @param netFile The filename of the control network file. * @param progress The progress object to track reading points. */ - void ControlNetVersioner::readProtobuf(const Pvl &header, const FileName netFile, Progress *progress) { + void ControlNetVersioner::readProtobuf(const Pvl &header, + const FileName netFile, + Progress *progress) { int version = 1; const PvlObject &protoBuf = header.findObject("ProtoBuffer"); @@ -910,12 +919,15 @@ namespace Isis { /** * Read a protobuf version 1 control network and prepare the data to be - * converted into a control network. + * converted into a control network. * + * @param header The Pvl file header that contains byte offsets for the protobuf messages * @param netFile The filename of the control network file. * @param progress The progress object to track reading points. */ - void ControlNetVersioner::readProtobufV0001(const Pvl &header, const FileName netFile, Progress *progress) { + void ControlNetVersioner::readProtobufV0001(const Pvl &header, + const FileName netFile, + Progress *progress) { const PvlObject &protoBufferInfo = header.findObject("ProtoBuffer"); const PvlObject &protoBufferCore = protoBufferInfo.findObject("Core"); @@ -1032,10 +1044,13 @@ namespace Isis { * Read a protobuf version 2 control network and prepare the data to be * converted into a control network. * + * @param header The Pvl file header that contains byte offsets for the protobuf messages * @param netFile The filename of the control network file. * @param progress The progress object to track reading points. */ - void ControlNetVersioner::readProtobufV0002(const Pvl &header, const FileName netFile, Progress *progress) { + void ControlNetVersioner::readProtobufV0002(const Pvl &header, + const FileName netFile, + Progress *progress) { // read the header protobuf object const PvlObject &protoBufferInfo = header.findObject("ProtoBuffer"); const PvlObject &protoBufferCore = protoBufferInfo.findObject("Core"); @@ -1148,10 +1163,13 @@ namespace Isis { * Read a protobuf version 5 control network and prepare the data to be * converted into a control network. * + * @param header The Pvl file header that contains byte offsets for the protobuf messages * @param netFile The filename of the control network file. * @param progress The progress object to track reading points. */ - void ControlNetVersioner::readProtobufV0005(const Pvl &header, const FileName netFile, Progress *progress) { + void ControlNetVersioner::readProtobufV0005(const Pvl &header, + const FileName netFile, + Progress *progress) { // read the header protobuf object const PvlObject &protoBufferInfo = header.findObject("ProtoBuffer"); const PvlObject &protoBufferCore = protoBufferInfo.findObject("Core"); @@ -1227,8 +1245,8 @@ namespace Isis { BigInt numberOfPoints = 0; - if ( header.hasGroup("ControlNetworkInfo") ) { - const PvlGroup &networkInfo = header.findGroup("ControlNetworkInfo"); + if ( protoBufferInfo.hasGroup("ControlNetworkInfo") ) { + const PvlGroup &networkInfo = protoBufferInfo.findGroup("ControlNetworkInfo"); if ( networkInfo.hasKeyword("NumberOfPoints") ) { try { @@ -1246,6 +1264,7 @@ namespace Isis { progress->CheckStatus(); } + Isis::EndianSwapper lsb("LSB"); int pointIndex = -1; while (pointInStream.ByteCount() < pointsLength) { pointIndex += 1; @@ -1259,6 +1278,8 @@ namespace Isis { uint32_t size; pointCodedInStream.ReadRaw(reinterpret_cast(&size), sizeof(size)); + + size = lsb.Uint32_t(&size); CodedInputStream::Limit oldPointLimit = pointCodedInStream.PushLimit(size); newPoint->ParseFromCodedStream(&pointCodedInStream); @@ -1297,8 +1318,7 @@ namespace Isis { * * @param point The versioned control point to be updated. * - * @return The latest version ControlPoint constructed from the - * given point. + * @return @b ControlPoint* The ControlPoint constructed from the given point. */ ControlPoint *ControlNetVersioner::createPoint(ControlPointV0001 &point) { ControlPointV0002 newPoint(point); @@ -1315,8 +1335,7 @@ namespace Isis { * * @param point The versioned control point to be updated. * - * @return The latest version ControlPoint constructed from the - * given point. + * @return @b ControlPoint* The ControlPoint constructed from the given point. */ ControlPoint *ControlNetVersioner::createPoint(ControlPointV0002 &point) { @@ -1335,8 +1354,7 @@ namespace Isis { * * @param point The versioned control point to be updated. * - * @return The latest version ControlPoint constructed from the - * given point. + * @return @b ControlPoint* The ControlPoint constructed from the given point. */ ControlPoint *ControlNetVersioner::createPoint(ControlPointV0003 &point) { ControlPointFileEntryV0002 protoPoint = point.pointData(); @@ -1364,8 +1382,9 @@ namespace Isis { pointType = ControlPoint::Fixed; break; default: - QString msg = "Unable to create ControlPoint [" + toString(protoPoint.id().c_str()) + "] from file. " - "Type enumeration [" + toString((int)(protoPoint.type())) + "] is invalid."; + QString msg = "Unable to create ControlPoint [" + toString(protoPoint.id().c_str()) + + "] from file. Type enumeration [" + toString((int)(protoPoint.type())) + + "] is invalid."; throw IException(IException::Programmer, msg, _FILEINFO_); break; } @@ -1424,7 +1443,8 @@ namespace Isis { break; case ControlPointFileEntryV0002_AprioriSource_AverageOfMeasures: - controlPoint->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::AverageOfMeasures); + controlPoint->SetAprioriSurfacePointSource( + ControlPoint::SurfacePointSource::AverageOfMeasures); break; case ControlPointFileEntryV0002_AprioriSource_Reference: @@ -1436,7 +1456,8 @@ namespace Isis { break; case ControlPointFileEntryV0002_AprioriSource_BundleSolution: - controlPoint->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::BundleSolution); + controlPoint->SetAprioriSurfacePointSource( + ControlPoint::SurfacePointSource::BundleSolution); break; default: @@ -1447,7 +1468,8 @@ namespace Isis { } if ( protoPoint.has_apriorisurfpointsourcefile() ) { - controlPoint->SetAprioriSurfacePointSourceFile(protoPoint.apriorisurfpointsourcefile().c_str()); + controlPoint->SetAprioriSurfacePointSourceFile( + protoPoint.apriorisurfpointsourcefile().c_str()); } if ( protoPoint.has_apriorix() @@ -1480,9 +1502,9 @@ namespace Isis { && protoPoint.has_adjustedy() && protoPoint.has_adjustedz() ) { - SurfacePoint adjustedSurfacePoint(Displacement(protoPoint.adjustedx(), Displacement::Meters), - Displacement(protoPoint.adjustedy(), Displacement::Meters), - Displacement(protoPoint.adjustedz(), Displacement::Meters)); + SurfacePoint adjustedSurfacePoint(Displacement(protoPoint.adjustedx(),Displacement::Meters), + Displacement(protoPoint.adjustedy(),Displacement::Meters), + Displacement(protoPoint.adjustedz(),Displacement::Meters)); if ( protoPoint.adjustedcovar_size() > 0 ) { symmetric_matrix adjustedCovarianceMatrix; @@ -1503,8 +1525,12 @@ namespace Isis { if ( m_header.equatorialRadius.isValid() && m_header.polarRadius.isValid() ) { SurfacePoint aprioriSurfacePoint = controlPoint->GetAprioriSurfacePoint(); SurfacePoint adjustedSurfacePoint = controlPoint->GetAdjustedSurfacePoint(); - aprioriSurfacePoint.SetRadii(m_header.equatorialRadius, m_header.equatorialRadius, m_header.polarRadius); - adjustedSurfacePoint.SetRadii(m_header.equatorialRadius, m_header.equatorialRadius, m_header.polarRadius); + aprioriSurfacePoint.SetRadii(m_header.equatorialRadius, + m_header.equatorialRadius, + m_header.polarRadius); + adjustedSurfacePoint.SetRadii(m_header.equatorialRadius, + m_header.equatorialRadius, + m_header.polarRadius); controlPoint->SetAdjustedSurfacePoint(adjustedSurfacePoint); controlPoint->SetAprioriSurfacePoint(aprioriSurfacePoint); } @@ -1540,7 +1566,8 @@ namespace Isis { * @return The ControlMeasure constructed from the V0006 version * file. */ - ControlMeasure *ControlNetVersioner::createMeasure(const ControlPointFileEntryV0002_Measure &measure) { + ControlMeasure *ControlNetVersioner::createMeasure( + const ControlPointFileEntryV0002_Measure &measure) { ControlMeasure *newMeasure = new ControlMeasure; @@ -1594,7 +1621,7 @@ namespace Isis { newMeasure->SetLineSigma(measure.linesigma()); } if ( measure.has_sampleresidual() - && measure.has_lineresidual() ) { + && measure.has_lineresidual() ) { newMeasure->SetResidual(measure.sampleresidual(), measure.lineresidual()); } @@ -1674,10 +1701,9 @@ namespace Isis { delete [] blankLabel; int numMeasures = 0; - int numPoints = 0; + int numPoints = m_points.size(); foreach (ControlPoint *point, m_points) { numMeasures += point->GetNumMeasures(); - numPoints += 1; } streampos startCoreHeaderPos = output.tellp(); @@ -1772,11 +1798,11 @@ namespace Isis { /** - * This will write the first control point to a ZeroCopyOutputStream. - * The written point will be removed from the versioner and deleted if the versioner + * This will write the first control point to a file stream. + * The written point will be removed from the versioner and then deleted if the versioner * has ownership of it. * - * @param fileStream A pointer to the fileStream that we are writing the point to. + * @param output A pointer to the fileStream that we are writing the point to. * * @return @b int The number of bytes written to the filestream. */ @@ -1818,8 +1844,9 @@ namespace Isis { pointType = ControlPointFileEntryV0002_PointType_Fixed; break; default: - QString msg = "Unable to create ProtoPoint [" + toString(protoPoint.id().c_str()) + "] from file. " - "Type enumeration [" + toString((int)(controlPoint->GetType())) + "] is invalid."; + QString msg = "Unable to create ProtoPoint [" + toString(protoPoint.id().c_str()) + + "] from file. Type enumeration [" + + toString((int)(controlPoint->GetType())) + "] is invalid."; throw IException(IException::Programmer, msg, _FILEINFO_); break; } @@ -1851,20 +1878,25 @@ namespace Isis { protoPoint.set_apriorisurfpointsource(ControlPointFileEntryV0002_AprioriSource_User); break; case ControlPoint::SurfacePointSource::AverageOfMeasures: - protoPoint.set_apriorisurfpointsource(ControlPointFileEntryV0002_AprioriSource_AverageOfMeasures); + protoPoint.set_apriorisurfpointsource( + ControlPointFileEntryV0002_AprioriSource_AverageOfMeasures); break; case ControlPoint::SurfacePointSource::Reference: - protoPoint.set_apriorisurfpointsource(ControlPointFileEntryV0002_AprioriSource_Reference); + protoPoint.set_apriorisurfpointsource( + ControlPointFileEntryV0002_AprioriSource_Reference); break; case ControlPoint::SurfacePointSource::Basemap: protoPoint.set_apriorisurfpointsource(ControlPointFileEntryV0002_AprioriSource_Basemap); break; case ControlPoint::SurfacePointSource::BundleSolution: - protoPoint.set_apriorisurfpointsource(ControlPointFileEntryV0002_AprioriSource_BundleSolution); + protoPoint.set_apriorisurfpointsource( + ControlPointFileEntryV0002_AprioriSource_BundleSolution); break; default: - QString msg = "Unable to create ProtoPoint [" + toString(protoPoint.id().c_str()) + "] from file. " - "Type enumeration [" + toString((int)(controlPoint->GetAprioriSurfacePointSource())) + "] is invalid."; + QString msg = "Unable to create ProtoPoint [" + toString(protoPoint.id().c_str()) + + "] from file. Type enumeration [" + + toString((int)(controlPoint->GetAprioriSurfacePointSource())) + + "] is invalid."; throw IException(IException::Programmer, msg, _FILEINFO_); break; } @@ -1878,10 +1910,12 @@ namespace Isis { protoPoint.set_aprioriradiussource(ControlPointFileEntryV0002_AprioriSource_User); break; case ControlPoint::RadiusSource::AverageOfMeasures: - protoPoint.set_aprioriradiussource(ControlPointFileEntryV0002_AprioriSource_AverageOfMeasures); + protoPoint.set_aprioriradiussource( + ControlPointFileEntryV0002_AprioriSource_AverageOfMeasures); break; case ControlPoint::RadiusSource::BundleSolution: - protoPoint.set_aprioriradiussource(ControlPointFileEntryV0002_AprioriSource_BundleSolution); + protoPoint.set_aprioriradiussource( + ControlPointFileEntryV0002_AprioriSource_BundleSolution); break; case ControlPoint::RadiusSource::Ellipsoid: protoPoint.set_aprioriradiussource(ControlPointFileEntryV0002_AprioriSource_Ellipsoid); @@ -1890,8 +1924,10 @@ namespace Isis { protoPoint.set_aprioriradiussource(ControlPointFileEntryV0002_AprioriSource_DEM); break; default: - QString msg = "Unable to create ProtoPoint [" + toString(protoPoint.id().c_str()) + "] from file. " - "Type enumeration [" + toString((int)(controlPoint->GetAprioriRadiusSource())) + "] is invalid."; + QString msg = "Unable to create ProtoPoint [" + toString(protoPoint.id().c_str()) + + "] from file. Type enumeration [" + + toString((int)(controlPoint->GetAprioriRadiusSource())) + + "] is invalid."; throw IException(IException::Programmer, msg, _FILEINFO_); break; } @@ -1907,7 +1943,8 @@ namespace Isis { protoPoint.set_aprioriy(aprioriSurfacePoint.GetY().meters()); protoPoint.set_aprioriz(aprioriSurfacePoint.GetZ().meters()); - symmetric_matrix aprioriCovarianceMatrix = aprioriSurfacePoint.GetRectangularMatrix(); + symmetric_matrix aprioriCovarianceMatrix = + aprioriSurfacePoint.GetRectangularMatrix(); if ( aprioriCovarianceMatrix.size1() > 0 && aprioriSurfacePoint.GetLatSigmaDistance().meters() != Isis::Null && aprioriSurfacePoint.GetLonSigmaDistance().meters() != Isis::Null && @@ -1939,7 +1976,8 @@ namespace Isis { protoPoint.set_adjustedy(adjustedSurfacePoint.GetY().meters()); protoPoint.set_adjustedz(adjustedSurfacePoint.GetZ().meters()); - symmetric_matrix adjustedCovarianceMatrix = adjustedSurfacePoint.GetRectangularMatrix(); + symmetric_matrix adjustedCovarianceMatrix = + adjustedSurfacePoint.GetRectangularMatrix(); if ( adjustedCovarianceMatrix.size1() > 0 ) { protoPoint.add_adjustedcovar(adjustedCovarianceMatrix(0, 0)); protoPoint.add_adjustedcovar(adjustedCovarianceMatrix(0, 1)); @@ -1953,15 +1991,10 @@ namespace Isis { // Converting Measures for (int j = 0; j < controlPoint->GetNumMeasures(); j++) { - const ControlMeasure & - controlMeasure = *controlPoint->GetMeasure(j); + const ControlMeasure &controlMeasure = *controlPoint->GetMeasure(j); ControlPointFileEntryV0002_Measure protoMeasure; -//??? moved if ( controlPoint->HasRefMeasure() && controlPoint->IndexOfRefMeasure() == j ) { -//??? moved protoPoint.set_referenceindex(j); -//??? moved } - protoMeasure.set_serialnumber(controlMeasure.GetCubeSerialNumber().toLatin1().data()); switch ( controlMeasure.GetType() ) { @@ -1974,19 +2007,21 @@ namespace Isis { break; case (ControlMeasure::RegisteredPixel): - protoMeasure.set_type(ControlPointFileEntryV0002_Measure_MeasureType_RegisteredPixel); + protoMeasure.set_type( + ControlPointFileEntryV0002_Measure_MeasureType_RegisteredPixel); break; case (ControlMeasure::RegisteredSubPixel): - protoMeasure.set_type(ControlPointFileEntryV0002_Measure_MeasureType_RegisteredSubPixel); + protoMeasure.set_type( + ControlPointFileEntryV0002_Measure_MeasureType_RegisteredSubPixel); break; } - if ( QString::compare(controlMeasure.GetChooserName(), "Null", Qt::CaseInsensitive) != 0 ) { + if (QString::compare(controlMeasure.GetChooserName(), "Null", Qt::CaseInsensitive) != 0) { protoMeasure.set_choosername(controlMeasure.GetChooserName().toLatin1().data()); } - if ( QString::compare(controlMeasure.GetDateTime(), "Null", Qt::CaseInsensitive) != 0 ) { + if (QString::compare(controlMeasure.GetDateTime(), "Null", Qt::CaseInsensitive) != 0) { protoMeasure.set_datetime(controlMeasure.GetDateTime().toLatin1().data()); } @@ -2043,9 +2078,7 @@ namespace Isis { } QVector measureLogs = controlMeasure.GetLogDataEntries(); - for (int logEntry = 0; - logEntry < measureLogs.size(); // DNE? - logEntry ++) { + for (int logEntry = 0; logEntry < measureLogs.size(); logEntry ++) { const ControlMeasureLogData &log = measureLogs[logEntry]; @@ -2059,13 +2092,14 @@ namespace Isis { *protoMeasure.add_log() = logData; } -//??? if ( controlPoint->HasRefMeasure() && controlPoint->IndexOfRefMeasure() == j ) { -//??? protoPoint.set_referenceindex(j); -//??? } *protoPoint.add_measures() = protoMeasure; } uint32_t byteSize = protoPoint.ByteSize(); + + Isis::EndianSwapper lsb("LSB"); + byteSize = lsb.Uint32_t(&byteSize); + output->write(reinterpret_cast(&byteSize), sizeof(byteSize)); if ( !protoPoint.SerializeToOstream(output) ) { diff --git a/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.h b/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.h index 6324e1afbaab2e62f0ef30caa99ea4ec1658ea20..14f15a7e01179b3b1e34dcaae323059ea7448e04 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.h +++ b/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.h @@ -49,6 +49,8 @@ namespace Isis { /** * @brief Handle various control network file format versions. * + *

Overview

+ * * This class is used to read all versions of control networks and write out * the most recent version in Pvl and protobuf format. When reading a * control net file, the ControlNeVersioner is initialized with the @@ -59,23 +61,29 @@ namespace Isis { * formats. ControlNet can then interface with this class and only has to * work with the current ControlPoint object. * + *

Reading Control Network Files

* * The read routine is as follows: - * 1. Read the Pvl file header. - * 2. Determine if the network is stored in Pvl or protobuf format - * 3. Determine the version of the network - * 4. Read in the general ControlNet information such as network + *
    + *
  1. Read the Pvl file header
  2. + *
  3. Determine if the network is stored in Pvl or protobuf format
  4. + *
  5. Determine the version of the network
  6. + *
  7. Read in the general ControlNet information such as network * description, last modification date, etc. For Pvl networks, this * information is in a PvlObject at the start of the network. For * protobuf objects this information is stored in a header protobuf - * message after the Pvl file header. - * 5. For each control point do the following: - * a. Read the control point into the appropriate ControlPointV#### - * object. - * b. If the ControlPointV#### object is not the most recent version, - * upgrade it to the latest version. - * c. Convert the final ControlPointV#### object into a ControlPoint - * object and store it in the ControlNetVersioner. + * message after the Pvl file header.
  8. + *
  9. For each control point do the following: + *
      + *
    1. Read the control point into the appropriate ControlPointV#### + * object.
    2. + *
    3. If the ControlPointV#### object is not the most recent version, + * upgrade it to the latest version.
    4. + *
    5. Convert the final ControlPointV#### object into a ControlPoint + * object and store it in the ControlNetVersioner.
    6. + *
    + *
  10. + *
* * Once the ControlNet file is read into the ControlNetVersioner, the * ControlPoints can be accessed through the takeFirstPoint method. This @@ -85,28 +93,33 @@ namespace Isis { * information about the control network can be accessed directly from the * ControlNetVersioner. * + *

Writing Control Network Files

* * The protobuf file write routine is as follows: - * 1. Copy the general ControlNet information such as network description, - * last modification date, etc. into the ControlNetVersioner. - * 2. Copy the pointers to the ControlPoints and store them in the + *
    + *
  1. Copy the general ControlNet information such as network description, + * last modification date, etc. into the ControlNetVersioner.
  2. + *
  3. Copy the pointers to the ControlPoints and store them in the * ControlNetVersioner. The ControlNetVersioner does not assume * ownership of the ControlPoints when it does this. The ControlNet - * or what the ControlNet got the points from retains ownership. - * 3. Write a 65536 byte blank header to the file. - * 4. Write the general ControlNet information to a protobuf message header - * after the blank header. - * 5. For each control point do the following: - * a. Convert the control point into a protobuf message. - * b. Write the size of the protobuf message to the file. - * c. Write the protobuf message to the file. - * 6. Write a Pvl header into the original blank header at the start of the - * file. This header contains a flag indicating the network is a + * or what the ControlNet got the points from retains ownership.
  4. + *
  5. Write a 65536 byte blank header to the file.
  6. + *
  7. Write the general ControlNet information to a protobuf message header + * after the blank header.
  8. + *
  9. For each control point do the following: + *
      + *
    1. Convert the control point into a protobuf message.
    2. + *
    3. Write the size of the protobuf message to the file.
    4. + *
    5. Write the protobuf message to the file.
    6. + *
    + *
  10. + *
  11. Write a Pvl header into the original blank header at the start of the + * file. This header contains: a flag indicating the network is a * protobuf formatted network, the version of the format, the byte * offset and size of the protobuf header, the byte offset and * size of the block of protobuf control points, and general - * information about the control network. - * + * information about the control network.
  12. + *
* * Once the ControlNetVersioner is initialized from a file or a ControlNet, * a Pvl formatted version of the control network can be created by the @@ -114,27 +127,32 @@ namespace Isis { * Pvl format. From here, the Pvl network can be written to a file with * Pvl::write(filename). * + *

Modifying the Control Network File Format

* * If the control network file format is changed the following changes need * to be made to ControlNetVersioner and its supporting classes: - * + *
    + *
  • * New containers need to be added to interface with the new format. These * containers should try to match the format of the data in the file, then * the versioner will convert from that format to ControlNet, ControlPoint, * ControlMeasure, and ControlMeasureLogData. General information about the * control network should be stored in the ControlNetHeaderV#### structs. * Data for control points should be stored in ControlPointV#### objects. - * + *
  • + *
  • * If a new control point container was created, code needs to be added to * create ControlPoint objects from them. A new createPoint method that * takes the new container should be added to do this. The createMeasure * method should also be changed to create ControlMeasures from the new * containers. - * + *
  • + *
  • * If a new header container was created, code needs to be added to store its * information in the ControlNetVersioner. A new createHeader method that * takes the new header container should be added to do this. - * + *
  • + *
  • * New code needs to be added to update the previous containers to the new * containers. Updating control point containers should happen in the new * ControlPointV#### container class. It should have a constructor that @@ -144,18 +162,199 @@ namespace Isis { * Updating header containers should happen in the createHeader method that * takes the previous version. If the headers become more complicated, this * may need to change to match how control point containers are updated. - * + *
  • + *
  • * New methods need to be added to read the new file format. Methods for * reading Pvl formatted files and protobuf formatted files need to be * added; they should match the naming convention of readPvlV#### and * readProtobufV#### respectively. - * + *
  • + *
  • * New methods need to be added to write out the new file format. The write * method should be changed to write out the new protobuf format. If * a new header container is added, the writeHeader method should be * changed to write the new protobuf header to the file. If a new control * point container is added, the writeFirstPoint method should be changed * to write a new protobuf control point to the file. + *
  • + *
  • + * Update the documentation on this class under the Control Network File + * Format History heading. This should include a description of the new + * file format and how it differs from the previous version. + *
  • + *
+ * + *

Control Network File Format History

+ * + * Prior to the creation of this versioning class, which was released with + * ISIS 3.2.2, all control network files were Pvl formatted text files. + * Reading and writing these files was handled by the ControlNet, ControlPoint, + * and ControlMeasure classes. As the file format was changed, those + * classes were modified to account for the new format. Because of this, + * the history of the control network file format prior to ISIS 3.2.2 + * is not well documented. + * + * The following are descriptions of the different control network file + * format versions that are currently supported. Each description also + * describes how that version differs from the previous. + * + * Version 1 + * + * This version maintains backwards compatibility with all files created + * prior to versioning. If a control network file does not have a version + * flag, then it is assumed to be a version 1 file. Because this version + * supports all files created prior to ISIS 3.2.2, there is no standardized + * Pvl format associated with it. + * + * Originally, there was no version 1 binary format. When version 2 was + * added, version 1 was changed to use the version 2 binary format. + * + * Version 2 + * + * This version was the first to have a standardized format. The following + * were standardized with this format: + *
    + *
  • The Held flag was replaced by point types. Points could be either + * Tie points or Ground points. Points that were previously flagged as + * Held were changed to Ground points.
  • + *
  • A posteriori was replaced with adjusted in several keyword + * names.
  • + *
  • The a priori and adjusted ground points were changed from + * (latitude, longitude, radius) format to body fixed (X, Y, Z) format. + *
  • + *
  • Ground point sigmas were replaced with covariance matrices.
  • + *
  • Latitude, longitude, and radius constrained flags were added.
  • + *
  • Estimated measures were renamed to Candidate measures.
  • + *
  • Unmeasured measures were renamed to Candidate measures, had their + * line and sample set to 0, and were flagged as ignored.
  • + *
  • Automatic, ValidatedManual and AutomaticPixel measures were + * renamed to RegisteredPixel measures.
  • + *
  • ValidatedAutomatic and AutomaticSubPixel measures were renamed to + * RegisteredSubPixel measures.
  • + *
  • ErrorSample and ErrorLine were renamed to SampleResidual and + * LineResidual respectively.
  • + *
  • Diameter, ZScore, and ErrorMagnitude were no longer saved in + * measures.
  • + *
+ * + * Version 2 was the first version to support a binary protobuf format. + * Version 1 was retroactively changed to use the version 2 binary format. + * Version 2 binary control network files consist of three parts: + *
    + *
  1. + * Pvl File Header: The file starts with a Pvl formatted header + * that contains offsets to the binary components of the file and the + * version number of the file. This header may also contain general + * information about the control network that is only for user reference + * is not used when reading the file. + *
  2. + *
  3. + * Protobuf Core: After the Pvl header is the protobuf core that + * contains the majority of the network data. This is a hierarchical + * structure with general network information such as the network + * description at the top level. Below that is the control point + * information. The lowest level contains the control measure information. + * This structure is defined by ControlNetFileProtoV0001.proto. + *
  4. + *
  5. + * Protobuf Log Data: The final component of the file contains + * the control measure log data. This is structured the same as the + * protobuf core. So, the log data for the ith measure in the + * jth point in the core is in the ith measure of + * the jth point in this structure. This structure is defined + * by ControlNetLogDataProtoV0001.proto. + *
  6. + *
+ * + * Version 3 + * + * This version was created to avoid file size limits imposed by the + * version 2 binary file format. Protobuf messages are limited to 2GB for + * security reasons. So, version 2 binary files can only contain 2GB of + * information in their Protobuf Core. In version 3, the Protobuf Core was + * changed from a single message to a header message and individual + * messages for each control point. This way, the Protobuf Core could + * contain an arbitrary amount of information as long as any single point + * does not exceed 2GB. At the same time, control measure log data was + * moved into the Protobuf Core so that each measure contains its own log + * data. + * + * Version 3 binary control network files are formatted as follows: + *
    + *
  • + * pvl File Header: The Pvl Header in version 3 binary files + * is the same as the Pvl Header in version 2 binary files, except it has + * offsets to the Protobuf Header and Protobuf Core instead of the + * Protobuf Core and Protobuf Log Data. + *
  • + *
  • + * Protobuf Header: The binary component of version 3 binary + * control network files starts with a protobuf message header that + * contains general information about the network and the size of each + * control point's protobuf message. The size of each control point + * message is required to parse the Protobuf Core because protobuf + * messages are not self-delimiting. This structure is defined by + * ControlNetFileHeaderV0002.proto. + *
  • + *
  • + * Protobuf Core: Immediately after the Protobuf Header is + * the Protobuf Core which contains all of the control point and control + * measure information. This is structured as consecutive protobuf + * messages where each message contains all of the information for a + * control point and its control measures. Because protobuf messages + * are not self-delimiting, the size of each message must be known prior + * to parsing the Protobuf Core. The control point messages are defined + * by ControlPointFileEntryV0002.proto. + *
  • + *
+ * + * Version 3 also further differentiated control point types. Control + * points that had their latitude, longitude, and/or radius constrained + * were changed from Tie points to Constrained points. + * + * Version 4 + * + * This version was created when Ground and Tie control points were renamed + * to Fixed and Free respectively. Version 4 Pvl control network files are + * identical to version 3 Pvl control network files, except for the new + * control point type values. When version 4 was created, the .proto file + * that defined control point protobuf messages was modified to allow for + * the new control point type names and the old names were flagged as + * deprecated. So, version 3 and version 4 binary control network files are + * formatted exactly the same. + * + * Version 5 + * + * This version was created to allow for progressive reading and writing of + * binary control network files. Previous versions required the entire + * contents of binary control network files to be read into memory before + * the ControlNet, ControlPoint, and ControlMeasure objects could be + * created. Version 5 was created to allow binary control network files + * to be read one control point at a time. Similarly, previous versions + * required all of the information in the control network to be copied into + * protobuf structures before any of it could be written to a file. + * + * Version 5 Pvl control network files are identical to version 4 Pvl + * control network files. + * + * Version 5 binary control network files are formatted the same as version + * 4 binary control network files except for how they store the sizes of + * the control point messages in the Protobuf Core. In a version 5 binary + * control network file, each control point message is prepended by an + * unsigned, 32 bit, LSB, integer (c++ uint32_t) that contains the size of + * the message. This design was modeled after the delimited read and write + * functionality in the Java protobuf library. Additionally, the Protobuf + * Header contains the number of control points in the network instead of + * a list of all the control point message sizes. The structure of the + * Protobuf Header is defined by ControlNetFileHeaderV0005.proto. + * The structure of the protobuf messages in the Protobuf Core is defined + * by ControlPointFileEntryV0002.proto, the same as in version 4. + * + * Starting with version 5, the naming scheme for .proto files was changed + * to use the same version number as the control net file format. So, the + * new .proto file defining the Protobuf Header was named + * ControlNetFileHeaderV0005.proto instead of + * ControlNetFileHeaderV0003.proto. * * @ingroup ControlNetwork * @@ -189,7 +388,7 @@ namespace Isis { * @history 2017-12-18 Adam Goins and Kristin Berry - Added new write() method. * @history 2017-12-19 Kristin Berry - Corrected method names and general cleanup in toPvl and * write for refactor. - * @histroy 2017-12-20 Jesse Mapel - Made read and createPoint methods match new + * @history 2017-12-20 Jesse Mapel - Made read and createPoint methods match new * ControlPointV#### classes. * @history 2017-12-20 Jeannie Backer - Updated toPvl and write methods to get surface point * information from the ControlPoint. @@ -200,6 +399,10 @@ namespace Isis { * Target::GetRadii calls to speed up createPoint(). * @history 2018-01-12 Adam Goins - Added Progress during reads. * @history 2018-01-24 Jesse Mapel - Fixed c++11 build warnings. + * @history 2018-01-27 Jesse Mapel - Fixed some documentation formatting. Added a section + * describing the different file format versions. + * @history 2018-01-30 Adam Goins - Ensured point sizes are written/read as lsb by using + * EndianSwapper. */ class ControlNetVersioner { @@ -222,30 +425,72 @@ namespace Isis { Pvl toPvl(); private: - // These three methods are private for safety reasons. - // TODO write a better reason. JAM + // These three methods are private to ensure proper memory management + //! Default constructor. Intentially un-implemented. ControlNetVersioner(); + /** + * Copy constructor. Intentially un-implemented. + * + * @param other The other ControlNetVersioner to create a copy of. + */ ControlNetVersioner(const ControlNetVersioner &other); + /** + * Asssignment operator. Intentially un-implemented. + * + * @param other The other ControlNetVersione to assign from. + * + * @return @b ControlNetVersioner& A reference to this after assignment. + */ ControlNetVersioner &operator=(const ControlNetVersioner &other); // Private ControlNetHeader structs for versioning - // TODO Document these for doxygen. JAM + /** + * Versioned container for general information about a control network. + * + * @ingroup ControlNetwork + * + * @author 2017-12-27 Jesse Mapel + * + * @internal + * @history 2017-12-27 Jesse Mapel - Original Version + */ struct ControlNetHeaderV0001 { + //! The ID/Name of the control network QString networkID; + //! The NAIF name of the target body QString targetName; + //! The date and time of the control network's creation QString created; + //! The date and time of the control network's last modification QString lastModified; + //! The text description of the control network QString description; + //! The name of the user or program that last modified the control network QString userName; + /** + * The equatorial radius of the target body + * used to convert from spherical to rectangular coordinates + */ Distance equatorialRadius; + /** + * The equatorial radius of the target body + * used to convert from spherical to rectangular coordinates + */ Distance polarRadius; }; + + //! Typedef for consistent naming of containers for version 2 typedef ControlNetHeaderV0001 ControlNetHeaderV0002; + //! Typedef for consistent naming of containers for version 3 typedef ControlNetHeaderV0001 ControlNetHeaderV0003; + //! Typedef for consistent naming of containers for version 4 typedef ControlNetHeaderV0001 ControlNetHeaderV0004; + //! Typedef for consistent naming of containers for version 5 typedef ControlNetHeaderV0001 ControlNetHeaderV0005; + //! Typedef for consistent naming of containers for version 4 typedef ControlPointV0003 ControlPointV0004; + //! Typedef for consistent naming of containers for version 5 typedef ControlPointV0003 ControlPointV0005; void read(const FileName netFile, Progress *progress=NULL); diff --git a/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.truth b/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.truth index 47e2a628432a9e0ea099ab49cfd3fe0733f6f9e8..f0d2e7d37abc644e989032217714a236f7bb04a7 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.truth +++ b/isis/src/control/objs/ControlNetVersioner/ControlNetVersioner.truth @@ -2,13 +2,16 @@ Test ControlNetVersioner Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork2_PvlV0001.net... Read network... -**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork2_PvlV0001.net] failed. +Reading Control Points... +0% Processed **I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork2_PvlV0001.net] failed. **I/O ERROR** Failed to initialize control point at index [0]. **I/O ERROR** Unable to get target body radii for [] when calculating covariance matrix. Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork3_PvlV0001.net... Read network... +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed Converted directly to Pvl: Object = ControlNetwork NetworkId = Null @@ -63,6 +66,8 @@ Reading/Writing control network is consistent Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork1_PvlV0001.net... Read network... +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed Converted directly to Pvl: Object = ControlNetwork NetworkId = TestNet01 @@ -117,6 +122,8 @@ Reading/Writing control network is consistent Reading: $control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net... Read network... +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed Converted directly to Pvl: Object = ControlNetwork NetworkId = Test @@ -303,6 +310,8 @@ Read network... Reading: $control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net... Read network... +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed Write the network and re-read it... After reading and writing to a binary form does Pvl match? Reading/Writing control network is consistent @@ -310,6 +319,8 @@ Reading/Writing control network is consistent Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork4_PvlV0003.pvl... Read network... +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed Converted directly to Pvl: Object = ControlNetwork NetworkId = LUNAE_PALUS_THEMIS_DIR @@ -549,3 +560,98 @@ Conversion to Pvl stays consistent Reading/Writing control network is consistent Check conversions between the binary format and the pvl format. The conversion methods for pvl->bin and bin->pvl are correct. + +Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork5_PvlV0003.pvl... + +Read network... +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed +Write the network and re-read it... +After reading and writing to a binary form does Pvl match? +Reading/Writing control network is consistent + +Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork3_PvlV0001.net... + +Read network... +Write the network and re-read it... +After reading and writing to a binary form does Pvl match? +Reading/Writing control network is consistent + +Reading: $control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net... + +Read network... +Write the network and re-read it... +After reading and writing to a binary form does Pvl match? +Reading/Writing control network is consistent + +Reading: $control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net... + +Read network... +Write the network and re-read it... +After reading and writing to a binary form does Pvl match? +Reading/Writing control network is consistent + +Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork4_PvlV0003.pvl... + +Read network... +Write the network and re-read it... +After reading and writing to a binary form does Pvl match? +Reading/Writing control network is consistent + +Test writing from ControlNet objects + +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed +Adding Control Points to Network... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed + +Test reading version 1 protobuf network + +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed +Take all of the control points and delete them. + 1 point taken + 2 points taken + 3 points taken + 4 points taken + +Test reading version 5 protobuf network + +Reading Control Points... +0% Processed 10% Processed 20% Processed 30% Processed 40% Processed 50% Processed 60% Processed 70% Processed 80% Processed 90% Processed 100% Processed + +Test writing with invalid target + + +Test reading a random PVL file + +**I/O ERROR** Reading the control network [equirectangular.map] failed. +**I/O ERROR** Could not determine the control network file type. + +Test reading a PVL files with missing header information + +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV1.net] failed. +**I/O ERROR** Missing required header information. +**ERROR** PVL Keyword [TargetName] does not exist in [Object = ControlNetwork] in file [/usgs/cpkgs/isis3/data/control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV1.net]. +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV2.net] failed. +**I/O ERROR** Missing required header information. +**ERROR** PVL Keyword [TargetName] does not exist in [Object = ControlNetwork] in file [/usgs/cpkgs/isis3/data/control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV2.net]. +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV3.net] failed. +**I/O ERROR** Missing required header information. +**ERROR** PVL Keyword [TargetName] does not exist in [Object = ControlNetwork] in file [/usgs/cpkgs/isis3/data/control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV3.net]. +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV4.net] failed. +**I/O ERROR** Missing required header information. +**ERROR** PVL Keyword [TargetName] does not exist in [Object = ControlNetwork] in file [/usgs/cpkgs/isis3/data/control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV4.net]. +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV5.net] failed. +**I/O ERROR** Missing required header information. +**ERROR** PVL Keyword [TargetName] does not exist in [Object = ControlNetwork] in file [/usgs/cpkgs/isis3/data/control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV5.net]. + +Test reading a protobuf file with a bad version number + +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_ProtoNetwork_BadVersion.net] failed. +**I/O ERROR** The Protobuf file version [7] is not supported. + +Test reading a protobuf file with no version number + +**I/O ERROR** Reading the control network [unitTest_ControlNetVersioner_ProtoNetwork_NoVersion.net] failed. +**ERROR** PVL Keyword [StartByte] does not exist in [Object = Core]. diff --git a/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.cpp b/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.cpp index 48257e0ed23d74ff7827b178896de8daee369b5f..764952534bafa34803e3b20b0abecc4e65ccea28 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.cpp +++ b/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.cpp @@ -27,7 +27,7 @@ namespace Isis { ControlPointV0001::ControlPointV0001( QSharedPointer pointData, QSharedPointer logData) - : m_pointData(pointData), m_logData(logData) { + : m_pointData(pointData), m_logData(logData) { } @@ -40,8 +40,8 @@ namespace Isis { * lat/lon to x/y/z. */ ControlPointV0001::ControlPointV0001(PvlObject &pointObject, const QString targetName) - : m_pointData(new ControlNetFileProtoV0001_PBControlPoint), - m_logData(new ControlNetLogDataProtoV0001_Point) { + : m_pointData(new ControlNetFileProtoV0001_PBControlPoint), + m_logData(new ControlNetLogDataProtoV0001_Point) { // Clean up the Pvl control point // Anything that doesn't have a value is removed for (int cpKeyIndex = 0; cpKeyIndex < pointObject.keywords(); cpKeyIndex ++) { @@ -111,7 +111,7 @@ namespace Isis { } else if ( pointObject.hasKeyword("AprioriX") && pointObject.hasKeyword("AprioriY") - && pointObject.hasKeyword("AprioriZ")) { + && pointObject.hasKeyword("AprioriZ") ) { m_pointData->set_apriorix( toDouble(pointObject["AprioriX"][0]) ); m_pointData->set_aprioriy( toDouble(pointObject["AprioriY"][0]) ); m_pointData->set_aprioriz( toDouble(pointObject["AprioriZ"][0]) ); @@ -126,8 +126,8 @@ namespace Isis { } // Ground points were previously flagged by the Held keyword being true. - if ( (pointObject.hasKeyword("Held") && pointObject["Held"][0] == "True") || - (pointObject["PointType"][0] == "Ground") ) { + if ( (pointObject.hasKeyword("Held") && pointObject["Held"][0] == "True") + || (pointObject["PointType"][0] == "Ground") ) { m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Ground); } else if (pointObject["PointType"][0] == "Tie") { @@ -148,16 +148,19 @@ namespace Isis { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::User); } else if (source == "AverageOfMeasures") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); } else if (source == "Reference") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Reference); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::Reference); } else if (source == "Basemap") { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Basemap); } else if (source == "BundleSolution") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriXYZSource [" + source + "]"; @@ -175,16 +178,19 @@ namespace Isis { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::User); } else if (source == "AverageOfMeasures") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); } else if (source == "Reference") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Reference); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::Reference); } else if (source == "Basemap") { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Basemap); } else if (source == "BundleSolution") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriLatLonSource [" + source + "]"; @@ -202,7 +208,8 @@ namespace Isis { m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::User); } else if (source == "AverageOfMeasures") { - m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); + m_pointData->set_aprioriradiussource( + ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); } else if (source == "Ellipsoid") { m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::Ellipsoid); @@ -211,7 +218,8 @@ namespace Isis { m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::DEM); } else if (source == "BundleSolution") { - m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); + m_pointData->set_aprioriradiussource( + ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriRadiusSource, [" + source + "]"; @@ -570,7 +578,7 @@ namespace Isis { * control point data. */ QSharedPointer ControlPointV0001::pointData() { - return m_pointData; + return m_pointData; } @@ -581,7 +589,7 @@ namespace Isis { * measure log data. */ QSharedPointer ControlPointV0001::logData() { - return m_logData; + return m_logData; } @@ -594,7 +602,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 1 protobuf representation of the control point that the value + * @param[out] point The version 1 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -604,15 +612,17 @@ namespace Isis { QSharedPointer point, void (ControlNetFileProtoV0001_PBControlPoint::*setter)(bool)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); value = value.toLower(); - if (value == "true" || value == "yes") + if (value == "true" || value == "yes") { (point.data()->*setter)(true); + } } @@ -625,7 +635,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 1 protobuf representation of the control point that the value + * @param[out] point The version 1 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -635,8 +645,9 @@ namespace Isis { QSharedPointer point, void (ControlNetFileProtoV0001_PBControlPoint::*setter)(double)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } double value = toDouble(container[keyName][0]); container.deleteKeyword(keyName); @@ -653,7 +664,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 1 protobuf representation of the control point that the value + * @param[out] point The version 1 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -663,8 +674,9 @@ namespace Isis { QSharedPointer point, void (ControlNetFileProtoV0001_PBControlPoint::*setter)(const std::string&)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); @@ -691,15 +703,17 @@ namespace Isis { ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure, void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(bool)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); value = value.toLower(); - if (value == "true" || value == "yes") + if (value == "true" || value == "yes") { (measure.*setter)(true); + } } @@ -757,8 +771,9 @@ namespace Isis { void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter) (const std::string &)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; diff --git a/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.h b/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.h index ddc6d6f43ccc63fae1689c89967b1dcdd3c53004..0fe4e6e89683c364be1a73e1be617ccfa930e629 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.h +++ b/isis/src/control/objs/ControlNetVersioner/ControlPointV0001.h @@ -33,12 +33,28 @@ namespace Isis { class PvlContainer; /** - * @breif A container for the information stored in a version 1 ControlPoint. + * @brief A container for the information stored in a version 1 ControlPoint. * * A wrapper around the version 1 protobuf serialization of a ControlPoint. It allows for reading - * ControlPoints serialized as both PvlObjects and protobuf messages. In order to simplify the - * upgrade process from version 1 to version 2, the data is always stored in a protobuf message - * after being read. + * ControlPoints serialized as both PvlObjects and protobuf messages. + * + * This class is designed to be compatible with all Pvl formats created prior + * to the use of versioning. So, the PvlObject constructor has to work with + * several different formats. Hence, several different keywords are checked + * for the same value. + * + * Because this version supports several different formats, there is no + * standardized set of keywords, but all version 1 Pvl control networks + * have the same high level structure. Control points are represented by + * objects contained in the ControlNetwork object. Control measures are + * represented by groups contained in the control point objects. + * + * Once read in, the data is always stored in a protobuf message regardless + * of the source. This is done to optimize reading binary control network + * files. Because the protobuf format for version 1 control points is + * identical to the version 2 format, control points read from a version 1 + * file are automatically "converted" to version 2. This also makes the + * version 1 to 2 upgrade process as simple as passing a pointer. * * @ingroup ControlNetwork * @@ -48,6 +64,7 @@ namespace Isis { * @history 2017-12-18 Jesse Mapel - Original version. * @history 2017-12-21 Adam Goins - Changed Pvl constructor to take PvlObject. * @history 2017-12-21 Jesse Mapel - Improved documentation. + * @history 2017-01-27 Jesse Mapel - More documentation improvements. */ class ControlPointV0001 { public: @@ -59,9 +76,23 @@ namespace Isis { QSharedPointer logData(); private: - // These are intentionally not implemented + /** + * Default constructor. Intentionally un-implemented. + */ ControlPointV0001(); + /** + * Copy constructor. Intentionally un-implemented. + * + * @param other The other ControlPointV0001 to copy from. + */ ControlPointV0001(const ControlPointV0001 &other); + /** + * Assignment operator. Intentionally un-implemented. + * + * @param other The other ControlPointV0001 to assign from. + * + * @return @b ControlPointV0001& A reference to this after assignment. + */ ControlPointV0001 &operator=(const ControlPointV0001 &other); // methods for converting from Pvl to protobuf @@ -88,7 +119,8 @@ namespace Isis { void copy(PvlContainer &container, QString keyName, ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure, - void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(const std::string &)); + void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)( + const std::string &)); QSharedPointer m_pointData; /**< Protobuf container that holds information used to create a control point.*/ diff --git a/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.cpp b/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.cpp index 7d6d841c29f7c706dbfd2243acc8df883aa7c969..7ad11df692d70039ac4c57812ab1799d76e7dc4b 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.cpp +++ b/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.cpp @@ -20,9 +20,9 @@ namespace Isis { ControlPointV0002::ControlPointV0002( QSharedPointer pointData, QSharedPointer logData) - : m_pointData(pointData), m_logData(logData) { + : m_pointData(pointData), m_logData(logData) { - } + } /** @@ -31,8 +31,8 @@ namespace Isis { * @param pointObject The control point and its measures in a Pvl object. */ ControlPointV0002::ControlPointV0002(PvlObject &pointObject) - : m_pointData(new ControlNetFileProtoV0001_PBControlPoint), - m_logData(new ControlNetLogDataProtoV0001_Point) { + : m_pointData(new ControlNetFileProtoV0001_PBControlPoint), + m_logData(new ControlNetLogDataProtoV0001_Point) { // Copy over strings, doubles, and bools copy(pointObject, "PointId", @@ -93,16 +93,19 @@ namespace Isis { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::User); } else if (source == "AverageOfMeasures") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); } else if (source == "Reference") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Reference); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::Reference); } else if (source == "Basemap") { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::Basemap); } else if (source == "BundleSolution") { - m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); + m_pointData->set_apriorisurfpointsource( + ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriXYZSource [" + source + "]"; @@ -120,7 +123,8 @@ namespace Isis { m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::User); } else if (source == "AverageOfMeasures") { - m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); + m_pointData->set_aprioriradiussource( + ControlNetFileProtoV0001_PBControlPoint::AverageOfMeasures); } else if (source == "Ellipsoid") { m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::Ellipsoid); @@ -129,7 +133,8 @@ namespace Isis { m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::DEM); } else if (source == "BundleSolution") { - m_pointData->set_aprioriradiussource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); + m_pointData->set_aprioriradiussource( + ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriRadiusSource, [" + source + "]"; @@ -224,10 +229,12 @@ namespace Isis { measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::Manual); } else if (type == "registeredpixel") { - measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredPixel); + measure.set_type( + ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredPixel); } else if (type == "registeredsubpixel") { - measure.set_type(ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredSubPixel); + measure.set_type( + ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::RegisteredSubPixel); } else { throw IException(IException::Io, @@ -322,7 +329,7 @@ namespace Isis { * @param oldPoint The old version 1 control point. */ ControlPointV0002::ControlPointV0002(ControlPointV0001 &oldPoint) - : m_pointData(oldPoint.pointData()), m_logData(oldPoint.logData()) { + : m_pointData(oldPoint.pointData()), m_logData(oldPoint.logData()) { } @@ -334,7 +341,7 @@ namespace Isis { * point data. */ QSharedPointer ControlPointV0002::pointData() { - return m_pointData; + return m_pointData; } @@ -345,7 +352,7 @@ namespace Isis { * measure log data. */ QSharedPointer ControlPointV0002::logData() { - return m_logData; + return m_logData; } @@ -358,7 +365,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 1 protobuf representation of the control point that the value + * @param[out] point The version 1 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -368,15 +375,17 @@ namespace Isis { QSharedPointer point, void (ControlNetFileProtoV0001_PBControlPoint::*setter)(bool)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); value = value.toLower(); - if (value == "true" || value == "yes") + if (value == "true" || value == "yes") { (point.data()->*setter)(true); + } } @@ -389,7 +398,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 1 protobuf representation of the control point that the value + * @param[out] point The version 1 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -399,8 +408,9 @@ namespace Isis { QSharedPointer point, void (ControlNetFileProtoV0001_PBControlPoint::*setter)(double)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } double value = toDouble(container[keyName][0]); container.deleteKeyword(keyName); @@ -417,7 +427,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 1 protobuf representation of the control point that the value + * @param[out] point The version 1 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -427,8 +437,9 @@ namespace Isis { QSharedPointer point, void (ControlNetFileProtoV0001_PBControlPoint::*setter)(const std::string&)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); @@ -455,15 +466,17 @@ namespace Isis { ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure, void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(bool)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); value = value.toLower(); - if (value == "true" || value == "yes") + if (value == "true" || value == "yes") { (measure.*setter)(true); + } } @@ -486,8 +499,9 @@ namespace Isis { ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure, void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(double)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } double value = toDouble(container[keyName][0]); container.deleteKeyword(keyName); @@ -515,8 +529,9 @@ namespace Isis { void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter) (const std::string &)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); diff --git a/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.h b/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.h index 2bd6e6bd5bb97f0a99ea5babb17f06a97ab0476c..95d18e5077731d6a796993f221f98de01f5333d7 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.h +++ b/isis/src/control/objs/ControlNetVersioner/ControlPointV0002.h @@ -34,20 +34,125 @@ namespace Isis { class PvlContainer; /** - * @breif A container for the information stored in a version 2 ControlPoint. + * @brief A container for the information stored in a version 2 ControlPoint. * * A wrapper around the version 2 protobuf serialization of a ControlPoint. It allows for reading - * ControlPoints serialized as both PvlObjects and protobuf messages. In order to simplify the - * upgrade process from version 1 to version 2, the data is always stored in a protobuf message - * after being read. + * ControlPoints serialized as both PvlObjects and protobuf messages. + * + * The version 1 and 2 control points use the same internal protobuf message format. + * Thus the "upgrade" process simply copies the shared pointer to the protobuf message. + * + * Version 2 was the first version to have a standardized Pvl format. In the + * Pvl format, control points are represented by objects contained in the + * ControlNetwork object. Control measures are represented by groups + * contained in the control point objects. + * + * Valid Control Point Keywords + * + *
    + *
  • PointId: The point ID string
  • + *
  • ChooserName: The name of the application or user that last + * modified the point
  • + *
  • DateTime: The date and time of the last modification to the + * point
  • + *
  • AprioriXYZSource: What type of source the apriori ground + * point was calculated from. Options: + *
      + *
    • None
    • + *
    • User
    • + *
    • AverageOfMeasures
    • + *
    • Reference
    • + *
    • Basemap
    • + *
    • BundleSolution
    • + *
  • + *
  • AprioriXYZSourceFile: The name of the file that the apriori + * ground point was calculated from
  • + *
  • AprioriRadiusSource: What type of source the apriori point + * radius was calculated from. Options: + *
      + *
    • None
    • + *
    • User
    • + *
    • AverageOfMeasures
    • + *
    • Ellipsoid
    • + *
    • DEM
    • + *
    • BundleSolution
    • + *
  • + *
  • AprioriRadiusSourceFile: The name of the file that the + * apriori point radius was calculated from
  • + *
  • JigsawRejected: If the point was rejected by a bundle + * adjustment
  • + *
  • EditLock: If the point is locked out of editing
  • + *
  • Ignore: If the point will be ignored
  • + *
  • AprioriX: The body fixed X coordinate of the a priori + * ground point in meters
  • + *
  • AprioriY: The body fixed Y coordinate of the a priori + * ground point in meters
  • + *
  • AprioriZ: The body fixed Z coordinate of the a priori + * ground point in meters
  • + *
  • AdjustedX: The body fixed X coordinate of the adjusted + * ground point in meters
  • + *
  • AdjustedY: The body fixed Y coordinate of the adjusted + * ground point in meters
  • + *
  • AdjustedZ: The body fixed Z coordinate of the adjusted + * ground point in meters
  • + *
  • LatitudeConstrained: If the latitude of the ground point + * is constrained
  • + *
  • LongitudeConstrained: If the longitude of the ground point + * is constrained
  • + *
  • RadiusConstrained: If the radius of the ground point + * is constrained
  • + *
  • PointType: What type of point it is. Options: + *
      + *
    • Ground
    • + *
    • Tie
    • + *
  • + *
  • AprioriCovarianceMatrix: A six element vector corresponding + * to the upper triangle; elements (0,0), (0,1), (0,2), (1,1), (1,2), + * and (2,2); of the 3x3, symmetric covariance matrix for + * the rectangular, a priori ground point.
  • + *
  • AdjustedCovarianceMatrix: A six element vector corresponding + * to the upper triangle; elements (0,0), (0,1), (0,2), (1,1), (1,2), + * and (2,2); of the 3x3, symmetric covariance matrix for + * the rectangular, adjusted ground point.
  • + *
+ * + * Valid Control Measure Keywords + * + *
    + *
  • SerialNumber: The serial number of the cube the measure + * is from
  • + *
  • ChooserName: The name of the application or user who last + * modified the measure
  • + *
  • DateTime: The date and time of the last modification
  • + *
  • Diameter: If the measure was selected from a crater, this + * is the diameter of the crater in meters
  • + *
  • EditLock: If the measure is locked out of editing
  • + *
  • Ignore: If the measure will be ignored
  • + *
  • JigsawRejected: If the measure was rejected during a + * bundle adjustment
  • + *
  • AprioriSample: The a priori sample
  • + *
  • AprioriLine: The a priori line
  • + *
  • SampleSigma: The standard deviation of the sample + * measurement
  • + *
  • LineSigma: The standard deviation of the line + * measurement
  • + *
  • Sample: The adjusted sample
  • + *
  • Line: The adjusted line
  • + *
  • SampleResidual: The difference between the a priori and + * adjusted sample
  • + *
  • LineResidual: The difference between the a priori and + * adjusted line
  • + *
  • Reference: If the measure is the reference measure for + * its point
  • + *
  • MeasureType: What type of measure it is. Options: + *
      + *
    • candidate
    • + *
    • manual
    • + *
    • registeredpixel
    • + *
    • registeredsubpixel
    • + *
  • + *
* - * The version 1 and 2 control points use the same internal protobuf message, because a new - * version was not created. When version 2 was added, the version 1 protobuf message was simply - * modified to accomodate both versions. Thus the "upgrade" process simply copyies the shared - * pointer to the protobuf message. Then, ControlPointV0003 has logic to upgrade from either a - * version 1, or version 2 ControlPoint. This choice was made to reduce the amount of new code - * that needed to be written during the transition from working with entire files to working with - * individual control points in the versioner. * * @ingroup ControlNetwork * @@ -58,6 +163,7 @@ namespace Isis { * @history 2017-12-21 Jesse Mapel - Added support for measure log data. * @history 2017-12-21 Adam Goins - Changed Pvl constructor to take PvlObject. * @history 2018-01-03 Jesse Mapel - Improved documentation. + * @history 2017-01-27 Jesse Mapel - More documentation improvements. */ class ControlPointV0002 { public: @@ -70,9 +176,23 @@ namespace Isis { QSharedPointer logData(); private: - // These are intentionally not implemented + /** + * Default constructor. Intentionally un-implemented. + */ ControlPointV0002(); + /** + * Copy constructor. Intentionally un-implemented. + * + * @param other The other ControlPointV0002 to copy from. + */ ControlPointV0002(const ControlPointV0002 &other); + /** + * Assignment operator. Intentionally un-implemented. + * + * @param other The other ControlPointV0002 to assign from. + * + * @return @b ControlPointV0002& A reference to this after assignment. + */ ControlPointV0002 &operator=(const ControlPointV0002 &other); // methods for converting from Pvl to protobuf @@ -99,7 +219,8 @@ namespace Isis { void copy(PvlContainer &container, QString keyName, ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure &measure, - void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)(const std::string &)); + void (ControlNetFileProtoV0001_PBControlPoint_PBControlMeasure::*setter)( + const std::string &)); QSharedPointer m_pointData; /**< protobuf container that holds information used to create a control point.*/ diff --git a/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.cpp b/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.cpp index 7846bacb83808a29add5ac8e65da0265cf48edc4..86b3526a5f43c876b1a3bc947283ffe3a59a7394 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.cpp +++ b/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.cpp @@ -19,9 +19,9 @@ namespace Isis { * @param pointData The protobuf message from a control net file. */ ControlPointV0003::ControlPointV0003(QSharedPointer pointData) - : m_pointData(pointData) { + : m_pointData(pointData) { - } + } /** @@ -30,7 +30,7 @@ namespace Isis { * @param pointObject The control point and its measures in a Pvl object */ ControlPointV0003::ControlPointV0003(PvlObject &pointObject) - : m_pointData(new ControlPointFileEntryV0002) { + : m_pointData(new ControlPointFileEntryV0002) { // Copy over strings, doubles, and bools copy(pointObject, "PointId", @@ -75,15 +75,15 @@ namespace Isis { // In version 4, these were changed to fixed, free, and constrained respectively. // The protobuf file version was not changed, fixed and free were simply added to the // enumeration and the old names were flagged as obsolete. - if (pointObject["PointType"][0] == "Fixed" || - pointObject["PointType"][0] == "Ground") { + if (pointObject["PointType"][0] == "Fixed" + || pointObject["PointType"][0] == "Ground") { m_pointData->set_type(ControlPointFileEntryV0002::Fixed); } else if (pointObject["PointType"][0] == "Constrained") { m_pointData->set_type(ControlPointFileEntryV0002::Constrained); } - else if (pointObject["PointType"][0] == "Free" || - pointObject["PointType"][0] == "Tie") { + else if (pointObject["PointType"][0] == "Free" + || pointObject["PointType"][0] == "Tie") { m_pointData->set_type(ControlPointFileEntryV0002::Free); } else { @@ -240,7 +240,6 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } else { - ControlPointFileEntryV0002_Measure_MeasureLogData protoBufDataEntry; protoBufDataEntry.set_doubledatatype(interpreter.GetDataType()); @@ -569,7 +568,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 2 protobuf representation of the control point that the value + * @param[out] point The version 2 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -587,8 +586,9 @@ namespace Isis { container.deleteKeyword(keyName); value = value.toLower(); - if (value == "true" || value == "yes") + if (value == "true" || value == "yes") { (point.data()->*setter)(true); + } } @@ -601,7 +601,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 2 protobuf representation of the control point that the value + * @param[out] point The version 2 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -630,7 +630,7 @@ namespace Isis { * @param container The PvlContainer representation of the control point that contains the * PvlKeyword. * @param keyName The name of the keyword to be copied. - * @param point[out] The version 2 protobuf representation of the control point that the value + * @param[out] point The version 2 protobuf representation of the control point that the value * will be copied into. * @param setter The protobuf mutator method that sets the value of the field in the protobuf * representation. @@ -640,8 +640,9 @@ namespace Isis { QSharedPointer point, void (ControlPointFileEntryV0002::*setter)(const std::string&)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); @@ -668,15 +669,17 @@ namespace Isis { ControlPointFileEntryV0002_Measure &measure, void (ControlPointFileEntryV0002_Measure::*setter)(bool)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } QString value = container[keyName][0]; container.deleteKeyword(keyName); value = value.toLower(); - if (value == "true" || value == "yes") + if (value == "true" || value == "yes") { (measure.*setter)(true); + } } @@ -699,8 +702,9 @@ namespace Isis { ControlPointFileEntryV0002_Measure &measure, void (ControlPointFileEntryV0002_Measure::*setter)(double)) { - if (!container.hasKeyword(keyName)) + if (!container.hasKeyword(keyName)) { return; + } double value = toDouble(container[keyName][0]); container.deleteKeyword(keyName); diff --git a/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.h b/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.h index af417cb9152bc3a482478a9e4a86e65753bc7e70..e01ad9b747fa7476e74277e230337f75008b2d75 100644 --- a/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.h +++ b/isis/src/control/objs/ControlNetVersioner/ControlPointV0003.h @@ -33,15 +33,129 @@ namespace Isis { class PvlContainer; /** - * @breif A container for the information stored in a version 3 and 4 ControlPoint. + * @brief A container for the information stored in a version 3 and 4 ControlPoint. * * A wrapper around the version 3 and 4 protobuf serialization of a ControlPoint. It allows for * reading ControlPoints serialized as both PvlObjects and protobuf messages. It also allows * for upgrading version 2 ControlPoints to version 3 and 4 ControlPoints. * * The version 3 and 4 binary serialization of ControlPoint use the same protobuf message, so - * this class works with both versions. The differences between the version 3 and 4 Pvl - * serialization is small enough that it is handled in the PvlObject constructor. + * this class works with both versions. The difference between the version 3 and 4 Pvl + * serializations is Ground and Tie points were renamed to Fixed and Free respectively. + * This is sufficiently minor that it is handled in the pvl constructor. + * + * In the Pvl format, control points are represented by objects contained in the + * ControlNetwork object. Control measures are represented by groups + * contained in the control point objects. + * + * Valid Control Point Keywords + * + *
    + *
  • PointId: The point ID string
  • + *
  • ChooserName: The name of the application or user that last + * modified the point
  • + *
  • DateTime: The date and time of the last modification to the + * point
  • + *
  • AprioriXYZSource: What type of source the apriori ground + * point was calculated from. Options: + *
      + *
    • None
    • + *
    • User
    • + *
    • AverageOfMeasures
    • + *
    • Reference
    • + *
    • Basemap
    • + *
    • BundleSolution
    • + *
  • + *
  • AprioriXYZSourceFile: The name of the file that the apriori + * ground point was calculated from
  • + *
  • AprioriRadiusSource: What type of source the apriori point + * radius was calculated from. Options: + *
      + *
    • None
    • + *
    • User
    • + *
    • AverageOfMeasures
    • + *
    • Ellipsoid
    • + *
    • DEM
    • + *
    • BundleSolution
    • + *
  • + *
  • AprioriRadiusSourceFile: The name of the file that the + * apriori point radius was calculated from
  • + *
  • JigsawRejected: If the point was rejected by a bundle + * adjustment
  • + *
  • EditLock: If the point is locked out of editing
  • + *
  • Ignore: If the point will be ignored
  • + *
  • AprioriX: The body fixed X coordinate of the a priori + * ground point in meters
  • + *
  • AprioriY: The body fixed Y coordinate of the a priori + * ground point in meters
  • + *
  • AprioriZ: The body fixed Z coordinate of the a priori + * ground point in meters
  • + *
  • AdjustedX: The body fixed X coordinate of the adjusted + * ground point in meters
  • + *
  • AdjustedY: The body fixed Y coordinate of the adjusted + * ground point in meters
  • + *
  • AdjustedZ: The body fixed Z coordinate of the adjusted + * ground point in meters
  • + *
  • LatitudeConstrained: If the latitude of the ground point + * is constrained
  • + *
  • LongitudeConstrained: If the longitude of the ground point + * is constrained
  • + *
  • RadiusConstrained: If the radius of the ground point + * is constrained
  • + *
  • PointType: What type of point it is. Options: + *
      + *
    • Fixed
    • + *
    • Ground
    • + *
    • Constrained
    • + *
    • Free
    • + *
    • Tie
    • + *
  • + *
  • AprioriCovarianceMatrix: A six element vector corresponding + * to the upper triangle; elements (0,0), (0,1), (0,2), (1,1), (1,2), + * and (2,2); of the 3x3, symmetric covariance matrix for + * the rectangular, a priori ground point.
  • + *
  • AdjustedCovarianceMatrix: A six element vector corresponding + * to the upper triangle; elements (0,0), (0,1), (0,2), (1,1), (1,2), + * and (2,2); of the 3x3, symmetric covariance matrix for + * the rectangular, adjusted ground point.
  • + *
+ * + * Valid Control Measure Keywords + * + *
    + *
  • SerialNumber: The serial number of the cube the measure + * is from
  • + *
  • ChooserName: The name of the application or user who last + * modified the measure
  • + *
  • DateTime: The date and time of the last modification
  • + *
  • Diameter: If the measure was selected from a crater, this + * is the diameter of the crater in meters
  • + *
  • EditLock: If the measure is locked out of editing
  • + *
  • Ignore: If the measure will be ignored
  • + *
  • JigsawRejected: If the measure was rejected during a + * bundle adjustment
  • + *
  • AprioriSample: The a priori sample
  • + *
  • AprioriLine: The a priori line
  • + *
  • SampleSigma: The standard deviation of the sample + * measurement
  • + *
  • LineSigma: The standard deviation of the line + * measurement
  • + *
  • Sample: The adjusted sample
  • + *
  • Line: The adjusted line
  • + *
  • SampleResidual: The difference between the a priori and + * adjusted sample
  • + *
  • LineResidual: The difference between the a priori and + * adjusted line
  • + *
  • Reference: If the measure is the reference measure for + * its point
  • + *
  • MeasureType: What type of measure it is. Options: + *
      + *
    • candidate
    • + *
    • manual
    • + *
    • registeredpixel
    • + *
    • registeredsubpixel
    • + *
  • + *
* * @ingroup ControlNetwork * @@ -55,6 +169,7 @@ namespace Isis { * the deprecated "ToProtocolBuffer()" call from * ControlMeasureLogData. * @history 2018-01-03 Jesse Mapel - Improved documentation. + * @history 2017-01-27 Jesse Mapel - More documentation improvements. */ class ControlPointV0003 { public: @@ -65,9 +180,23 @@ namespace Isis { const ControlPointFileEntryV0002 &pointData(); private: - // These are intentionally not implemented + /** + * Default constructor. Intentionally un-implemented. + */ ControlPointV0003(); + /** + * Copy constructor. Intentionally un-implemented. + * + * @param other The other ControlPointV0003 to copy from. + */ ControlPointV0003(const ControlPointV0003 &other); + /** + * Assignment operator. Intentionally un-implemented. + * + * @param other The other ControlPointV0003 to assign from. + * + * @return @b ControlPointV0003& A reference to this after assignment. + */ ControlPointV0003 &operator=(const ControlPointV0003 &other); // methods for converting from Pvl to protobuf diff --git a/isis/src/control/objs/ControlNetVersioner/unitTest.cpp b/isis/src/control/objs/ControlNetVersioner/unitTest.cpp index afa4fd2f881c13f1fcc21f40d75f66bb7fb69cad..d5b60a8c13942d278c401e5f98d50bc1c05e890c 100644 --- a/isis/src/control/objs/ControlNetVersioner/unitTest.cpp +++ b/isis/src/control/objs/ControlNetVersioner/unitTest.cpp @@ -8,27 +8,135 @@ #include "IException.h" #include "IString.h" #include "Preference.h" +#include "Progress.h" #include "Pvl.h" using namespace std; using namespace Isis; -void TestNetwork(const QString &filename, bool printNetwork = true, bool pvlInput = false); +void TestNetwork(const QString &filename, Progress *progress, bool printNetwork = true, bool pvlInput = false); int main(int argc, char *argv[]) { Preference::Preferences(true); + Progress *testProgress = new Progress(); std::cout << "Test ControlNetVersioner"; - TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork2_PvlV0001.net"); // No target - TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork3_PvlV0001.net"); // Really odd keywords with target - TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork1_PvlV0001.net"); // Another set of odd keywords - TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net"); // Binary V1 - TestNetwork("$control/testData/unitTest_ControlNetVersioner_BadNetwork_ProtoV0001.net"); // Corrupted (based off of oldNetwork2.net) - TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net", false); // Binary V2 - TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork4_PvlV0003.pvl", true, true); // Network with rejected jigsaw points + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork2_PvlV0001.net", testProgress); // No target + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork3_PvlV0001.net", testProgress); // Really odd keywords with target + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork1_PvlV0001.net", testProgress); // Another set of odd keywords + TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net", testProgress); // Binary V1 + TestNetwork("$control/testData/unitTest_ControlNetVersioner_BadNetwork_ProtoV0001.net", testProgress); // Corrupted (based off of oldNetwork2.net) + TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net", testProgress, false); // Binary V2 + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork4_PvlV0003.pvl", testProgress, true, true); // Network with rejected jigsaw points + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork5_PvlV0003.pvl", testProgress, false, false); // Network full of weird test cases (based on PvlNetwork4) + + // Re-test each version without progress + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork3_PvlV0001.net", 0, false); + TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net", 0, false); + TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net", 0, false); + TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork4_PvlV0003.pvl", 0, false); + + std::cout << std::endl << "Test writing from ControlNet objects" << std::endl << std::endl; + ControlNet *binaryV2Net = new ControlNet("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net", + testProgress); + ControlNetVersioner *binV2Versioner = new ControlNetVersioner(binaryV2Net); + binV2Versioner->write("./binaryV2tmp.net"); + remove("./binaryV2tmp.net"); + delete binV2Versioner; + binV2Versioner = NULL; + + std::cout << std::endl << "Test reading version 1 protobuf network" << std::endl << std::endl; + ControlNetVersioner *binV1Versioner = new ControlNetVersioner(FileName("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork1_ProtoV0001.net"), testProgress); + std::cout << "Take all of the control points and delete them." << std::endl; + int pointsTaken = 0; + ControlPoint *readPoint = binV1Versioner->takeFirstPoint(); + while (readPoint != NULL) { + pointsTaken++; + std::cout << " " << pointsTaken << (pointsTaken > 1 ? " points taken" : " point taken") << std::endl; + delete readPoint; + readPoint = binV1Versioner->takeFirstPoint(); + } + delete binV1Versioner; + binV1Versioner = NULL; + + std::cout << std::endl << "Test reading version 5 protobuf network" << std::endl << std::endl; + ControlNetVersioner *binV5Versioner = new ControlNetVersioner(FileName("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork3_ProtoV0005.net"), testProgress); + delete binV5Versioner; + binV5Versioner = NULL; + + std::cout << std::endl << "Test writing with invalid target" << std::endl << std::endl; + try { + binaryV2Net->SetTarget("INVALID_TARGET_NAME"); + binV2Versioner = new ControlNetVersioner(binaryV2Net); + } + catch (IException &e) { + e.print(); + if (binV2Versioner) { + delete binV2Versioner; + binV2Versioner = NULL; + } + } + + std::cout << std::endl << "Test reading a random PVL file" << std::endl << std::endl; + try { + ControlNetVersioner invalidVersioner("$base/templates/maps/equirectangular.map"); + } + catch (IException &e) { + e.print(); + } + + std::cout << std::endl << "Test reading a PVL files with missing header information" << std::endl << std::endl; + try { + ControlNetVersioner invalidVersionerV1("$control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV1.net"); + } + catch (IException &e) { + e.print(); + } + try { + ControlNetVersioner invalidVersionerV2("$control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV2.net"); + } + catch (IException &e) { + e.print(); + } + try { + ControlNetVersioner invalidVersionerV3("$control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV3.net"); + } + catch (IException &e) { + e.print(); + } + try { + ControlNetVersioner invalidVersionerV4("$control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV4.net"); + } + catch (IException &e) { + e.print(); + } + try { + ControlNetVersioner invalidVersionerV5("$control/testData/unitTest_ControlNetVersioner_PvlNetwork_BadHeaderV5.net"); + } + catch (IException &e) { + e.print(); + } + + std::cout << std::endl << "Test reading a protobuf file with a bad version number" << std::endl << std::endl; + try { + ControlNetVersioner invalidVersioner("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork_BadVersion.net"); + } + catch (IException &e) { + e.print(); + } + + std::cout << std::endl << "Test reading a protobuf file with no version number" << std::endl << std::endl; + try { + ControlNetVersioner invalidVersioner("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork_NoVersion.net"); + } + catch (IException &e) { + e.print(); + } + + delete binaryV2Net; } -void TestNetwork(const QString &filename, bool printNetwork, bool pvlInput) { +void TestNetwork(const QString &filename, Progress *progress, bool printNetwork, bool pvlInput) { std::cout << "\nReading: " << filename << "...\n"; FileName networkFileName(filename); @@ -44,7 +152,7 @@ void TestNetwork(const QString &filename, bool printNetwork, bool pvlInput) { // The reason for the intermediate Pvl is described in // ControlNetVersioner.h. std::cout << "\nRead network..." << std::endl; - test = new ControlNetVersioner(networkFileName); + test = new ControlNetVersioner(networkFileName, progress); if(printNetwork) { std::cout << "Converted directly to Pvl:" << std::endl; diff --git a/isis/src/docsys/documents/ControlNetworks/ControlNetworks.xml b/isis/src/docsys/documents/ControlNetworks/ControlNetworks.xml new file mode 100644 index 0000000000000000000000000000000000000000..5f0cd5ac5b404725fd93cbc154e14328de4327fd --- /dev/null +++ b/isis/src/docsys/documents/ControlNetworks/ControlNetworks.xml @@ -0,0 +1,536 @@ + + + + + + + + + + + +

Introduction

+ +

Control Network

+

A Control Network in ISIS3 is a structure which holds a network of image correspondances, also known as tie points or control points, which identify common ground points across multiple images of the same body. A Control Network is made up of Control Points (the common tie point) and a Control Point has one or more Control Measures (measurements in image space of the common point in a particular image). There are two file formats for Control Networks in ISIS3 -- a binary google protocol buffer format and a human-readable pvl format. Both contain the same contents and information. This document describes the keywords present in the PVL format for convenience.

+ +

Control Network

+

This section describes the keywords associated with the main Control Network object.

+ +
+  Object = ControlNetwork
+  NetworkId    = ExampleNetwork1
+  TargetName   = Template
+  UserName     = aexample
+  Created      = 2012-01-04T12:09:57
+  LastModified = 2012-01-04T12:09:57
+  Description  = "Example PvlV0005 ControlNetwork template."
+  Version      = 5
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Keyword Required Default Description
NetworkId Yes No Default A user defined single-word identifier assigned to the control network file.
TargetName Yes "" The planetary body to which the control network file applies. This Target Name should appear in all cubes used in the control network. Possible example values are Moon, or Mars.
UserName No No Default Name of the user that created the control network file.
Created No Set automatically Initial creation date and time of control net file. Once this is set it should not be modified.
LastModified No None Date and time on which the control net file was last modified. All programs which modify the contents of this network must set this keyword.
Description No None Brief description of the control network file. This is free-form text normally supplied by the person running the application.
Version No Set to current version on output. The Version of the Control Network file. The most recent version is 5.
+ + +

Control Point

+

A control point is one or more measurements that identify the same feature or location in different images. This section contains the information describing a Control Point.

+ +
+  Object = ControlPoint
+    PointType                = "Fixed    # (Fixed, Constrained, Free)"
+    PointId                  = I00826010RDR_ex_1_ID
+    ChooserName              = aexample
+    DateTime                 = 2012-01-04T17:01:32
+    EditLock                 = True
+    Ignore                   = True
+    AprioriXYZSource         = "User # (None, User, AverageOfMeasures, Reference, Basemap, BundleSolution)"
+    AprioriXYZSourceFile     = /home/temp/xyzSource.cub
+    AprioriRadiusSource      = "User   # (AverageOfMeasures, BundleSolution, Ellipsoid, DEM)"
+    AprioriRadiusSourceFile  = /home/temp/radiusSource.cub
+
+    # AprioriLatitude = 1.1 <degrees>
+    AprioriX                 = 100 <meters>
+
+    # AprioriLongitude = 2.2 <degrees>
+    AprioriY                 = 100 <meters>
+
+    # AprioriRadius = 3.3 <meters>
+    AprioriZ                 = 100 <meters>
+    AprioriCovarianceMatrix  = (1.1, 2.2, 3.3, 4.4, 5.5, 6.6)
+    LatitudeConstrained      = True
+    LongitudeConstrained     = True
+    RadiusConstrained        = True
+
+    # AdjustedLatitude = 1.1 <degrees>
+    AdjustedX                = 100 <meters>
+
+    # AdjustedLongitude = 2.2 <degrees>
+    AdjustedY                = 100 <meters>
+
+    # AdjustedRadius = 3.3 <meters>
+    AdjustedZ                = 100 <meters>
+    AdjustedCovarianceMatrix = (1.1, 2.2, 3.3, 4.4, 5.5, 6.6)
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Keyword Required Default Description
PointType Yes No Default?
    +
  • Fixed - A Fixed point is a Control Point whose lat/lon is well established and should not be changed. Some people will refer to this as a truth (i.e., ground truth).
  • +
  • Constrained - A Constrained point is a Control Point whose lat/lon/radius is somewhat established and should not be changed.
  • +
  • Free - A Free point is a Control Point that identifies common measurements between two or more cubes. While it could have a lat/lon, it is not necessarily correct and is subject to change. This is the most common type of control point. This point type floats freely in a bundle adjustment.
  • +
+ +
PointId Yes No Default String to identify an individual Control Point. This is a required keyword for all points and must be unique within a single Control Network. This keyword is often generated automatically by applications which create Control Points.
ChooserName No No Default The name of the user who manually created a point or the name of the application which automatically created a point.
DateTime No No Default Indicates the date/time a ground Control Point's coordinate was last changed
EditLock No False Indicator to applications that edit the contents of Control Points that all information about this point (e.g. Latitude, Longitude, Radius) should not be modified. This does not include adding or removing measurements or the contents of existing measurements, as long as those measures are not locked. +
Ignore No False Flag (True/False) to indicate whether this Control Point should be Ignored. When a point is ignored, no data within the point should be used by a program unless the program is explicitly working with ignored points. +
AprioriXYZSource No None + Set to one of the values below: +
    +
  • User - The a priori coordinates for this point were entered by the user.
  • +
  • AverageOfMeasures - The a priori coordinates for this point were calculated by averaging the coordinates for all measures (e.g., Average lat/lon or x/y/z for all measures).
  • +
  • Reference - The a priori coordinates for this point were obtained from the camera associated with the Control Measure marked as "REFERENCE".
  • +
  • Basemap - The a priori coordinates for this point were obtained from either a controlled mosaic or a single projected image used for a priori coordinates.
  • +
  • BundleSolution - The a priori coordinates for this point were obtained from a previous run of jigsaw.
  • +
+
AprioriXYZSourceFile No "" A string containing the file name of the AprioriLatitude and AprioriLongitude source. This keyword will only be used if AprioriLatLonSource == Basemap. +
AprioriRadiusSource No Doesn't exist in net Set to one of the values below: +
    +
  • User - The a priori radius was hand entered by the user.
  • +
  • AverageOfMeasures - The a priori radius was calculated as the average radius for all measures.
  • +
  • Ellipsoid - The a priori radius was calculated using the Naif PCK body radii. The number of radii used depends on the IAU definition of the target body.
  • +
  • DEM - Digital Elevation Model used for a priori radius.
  • +
  • BundleSolution - Radius output from a previous run of jigsaw.
  • +
+
AprioriRadiusSourceFile No "" A string containing the file name of the AprioriRadius source. +
If AprioriiRadiusSource = Ellipsoid, this keyword will be set to the Naif PCK file. +
If AprioriRadiusSource = DEM, this keyword will be set to the file name of the DEM. +
AprioriX No False Internal storage of the '''initial''' position of the point on the target. Always stored in body fixed x,y,z coordinates. +
AprioriY No False Internal storage of the '''initial''' position of the point on the target. Always stored in body fixed x,y,z coordinates. +
AprioriZ No False Internal storage of the '''initial''' position of the point on the target. Always stored in body fixed x,y,z coordinates. +
AprioriSigmaX No None Pre-adjustment standard deviation of XXXXXXX. An indicator of accuracy that may be used in the weighting of the XXXXXX point coordinate in the bundle adjustment. May originate from a variety of sources; for example a base-map, a previous bundle adjustment, or from the assumed or estimated quality of a sensor measurement such as GPS (in the case of terrestrial mapping) or lidar. Or for other planets accuracy of the MOLA solution. Units are meters. +
AprioriSigmaY No None Pre-adjustment standard deviation of XXXXXXX. An indicator of accuracy that may be used in the weighting of the XXXXXX point coordinate in the bundle adjustment. May originate from a variety of sources; for example a base-map, a previous bundle adjustment, or from the assumed or estimated quality of a sensor measurement such as GPS (in the case of terrestrial mapping) or lidar. Or for other planets accuracy of the MOLA solution. Units are meters. +
AprioriSigmaZ No None Pre-adjustment standard deviation of XXXXXXX. An indicator of accuracy that may be used in the weighting of the XXXXXX point coordinate in the bundle adjustment. May originate from a variety of sources; for example a base-map, a previous bundle adjustment, or from the assumed or estimated quality of a sensor measurement such as GPS (in the case of terrestrial mapping) or lidar. Or for other planets accuracy of the MOLA solution. Units are meters. +
LatitudeConstrained No False Flag that indicates if the Latitude is constrained. +
LongitudeConstrained No False Flag that indicates if the longitude is constrained. +
RadiusConstrained No False Flag that indicates if the radius is constrained. +
AdjustedX No None Adjusted X coordinate of the Control Point location. Units are decimal meters. +
AdjustedY No None Adjusted Y coordinate of the Control Point location. Units are decimal meters. +
AdjustedZ No None Adjusted Z coordinate of the Control Point location. Units are decimal meters. +
+ +

Control Measure

+

A Control Measure is a measurement in image space (sample and line coordinates) of a point in one cube that has been associated with a Control Point and other overlapping image cubes. + +Each ControlMeasure group in a PVL-formatted Control Network contains all information concerning a control measurement. An example follows:

+ +
+    Group = ControlMeasure
+      SerialNumber       = Example/Measure/111.000
+      MeasureType        = "Candidate   # (Candidate, Manual, RegisteredPixel, RegisteredSubPixel)"
+      ChooserName        = aexample
+      DateTime           = 2012-01-04T17:01:32
+      EditLock           = True
+      Ignore             = True
+      Sample             = 180.0
+      Line               = 270.0
+      Diameter           = 10.0
+      AprioriSample      = 50
+      AprioriLine        = 50
+      SampleSigma        = 10 <pixels>
+      LineSigma          = 10 <pixels>
+      SampleResidual     = 10 <pixels>
+      LineResidual       = -10 <pixels>
+      JigsawRejected     = Yes
+      MinimumPixelZScore = -6.9339878963865
+      MaximumPixelZScore = 7.8509687345151
+      GoodnessOfFit      = 0.7774975693515
+      Reference          = True
+      End_Group
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Keyword Required Default Description
SerialNumber Yes No Default A serial number is a unique identifier for a cube. This value is usually comprised of a spacecraft name, instrument name, start time, and if needed, other identifying label values from the cube. Serial numbers are used within control networks in conjunction with a cube list to associate cubes and control measures. +
MeasureType No Candidate +
    +
  • Candidate - This Control Measurement is considered a candidate (i.e., the location is preliminary or not well know).
  • +
  • Manual - This Control Measurement was hand measured (eg. qnet).
  • +
  • RegisteredPixel - Automatically registered to whole pixel (eg. pointreg).
  • +
  • RegisteredSubPixel - Automatically registered to sub-pixel (eg. pointreg, qnet).
  • +
+
ChooserName No Omitted if not setIndicates the name of the user or application that last changed this Control Measure's coordinate.
DateTime No Omitted if not set Indicates the date/time the Control Measure's line/sample coordinates were last changed. +
EditLock No False Indicates that the measure is not to be edited. This includes the Ignore and Reference flag for any measure. +
Ignore No False Flag (True/False) to indicate whether this Control Measure should be Ignored. When a measurement is ignored it should not be used by a program unless the program is explicitly working with ignored measurements. +
Sample No 0.0? Sample coordinate of the Control Measure within the cube. The value of the keyword is a floating point number. +
Line No 0.0? Line coordinate of the Control Measure within the cube. The value of the keyword is a floating point number. +
Diameter No 0.0 The diameter of the crater in meters, if the control measure is associated with a crater. +
AprioriSample No None The first identified sample coordinate of the measure by any application. In this initial state the a priori keyword values are the same as line/sample keyword values. +
AprioriLine No None The first identified line coordinate of the measure by any application. In this initial state the a priori keyword values are the same as line/sample keyword values. +
SampleSigma No None +Standard deviation of sample measurement. An indicator of precision used in the weighting of measurements in the bundle adjustment (i.e. Jigsaw). May be determined from experience (e.g., manual point measurement) or perhaps estimated within an automated point measurement technique (e.g., ellipse fitting of crater edges, or through the use of an interest operator). Units are pixels. +
LineSigma No NoneStandard deviation of line measurement. An indicator of precision used in the weighting of measurements in the bundle adjustment (i.e. Jigsaw). May be determined from experience (e.g., manual point measurement) or perhaps estimated within an automated point measurement technique (e.g., ellipse fitting of crater edges, or through the use of an interest operator). Units are pixels. +
SampleResidual No None +The difference between the 'estimated' sample measurement (as determined at the end of each iteration of the bundle adjustment) and the original sample measurement. Used in the determination of outliers throughout the bundle. Measurement residuals are used upon convergence to compute the reference variance (σ02) which in turn is used to scale the inverse of the normal equations matrix for error propagation. Units are pixels. +
LineResidual No None +The difference between the ''estimated'' line measurement (as determined at the end of each iteration of the bundle adjustment) and the original sample measurement. Used in the determination of outliers throughout the bundle. Measurement residuals are used upon convergence to compute the reference variance (σ02) which in turn is used to scale the inverse of the normal equations matrix for error propagation. Units are pixels. +
JigsawRejected No False A flag indicating if this measure has been rejected by jigsaw. +
MinimumPixelZScore No None Control measures store z-scores in pairs. A pair contains the z-scores of the minimum and maximum pixels in the pattern chip generated for the given measure during point registration. Each z-score indicates how many standard deviations the given pixel value is above or below the mean DN. This is used when using area-based-matching in ISIS3. +
MaximumPixelZScore No None Control measures store z-scores in pairs. A pair contains the z-scores of the minimum and maximum pixels in the pattern chip generated for the given measure during point registration. Each z-score indicates how many standard deviations the given pixel value is above or below the mean DN. This is used when using area-based-matching in ISIS3. +
GoodnessOfFit No None This measures how well the computed fit area matches the pattern area when using applications like pointreg. +
Reference No False(?) A flag indicating if this measure is the reference measure for its parent Control Point. +
+ + + + HTML + + + index.html + +
+
+ + + technicaldoc + + + + administrator + + + + Original Version. Migrated information from internal wiki, ControlNetVersioner.h, the pvl template file, and many other header files. Actual original authors include most of the ISIS3 team. + + + + Control Networks + Control Network format and keyword definitions in ISIS 3 + + This document describes the format of and defines the keywords that are part of + Control Networks in ISIS3. + + Kristin Berry + 2018-01-26 + +