Isis 3 Developer Reference
|
Handle various control network file format versions. More...
#include <ControlNetVersioner.h>
Public Member Functions | |
ControlNetVersioner (ControlNet *net) | |
Construct a ControlNetVersioner from a control network. More... | |
ControlNetVersioner (const FileName netFile, Progress *progress=NULL) | |
Construct a ControlNetVersioner from a file. More... | |
~ControlNetVersioner () | |
Destroy a ControlNetVersioner. More... | |
QString | netId () const |
Returns the ID for the network. More... | |
QString | targetName () const |
Returns the target for the network. More... | |
QString | creationDate () const |
Returns the date and time that the network was created. More... | |
QString | lastModificationDate () const |
Returns the date and time of the last modification to the network. More... | |
QString | description () const |
Returns the network's description. More... | |
QString | userName () const |
Returns the name of the last person or program to modify the network. More... | |
int | numPoints () const |
Returns the number of points that have been read in or are ready to write out. More... | |
ControlPoint * | takeFirstPoint () |
Returns the first point stored in the versioner's internal list. More... | |
void | write (FileName netFile) |
This will write a control net file object to disk. More... | |
Pvl | toPvl () |
Generates a Pvl file from the currently stored control points and header. More... | |
Handle various control network file format versions.
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 filename. When writing a control net file or generating a Pvl network, the ControlNetVersioner is initialized from a ControlNet object.
This class exists to isolate the code dealing with control network file formats. ControlNet can then interface with this class and only has to work with the current ControlPoint object.
The read routine is as follows:
Once the ControlNet file is read into the ControlNetVersioner, the ControlPoints can be accessed through the takeFirstPoint method. This will remove the first ControlPoint stored in the ControlNetVersioner and give it to the caller. At this point, the caller is given ownership of the ControlPoint and is expected to delete it when finished. General information about the control network can be accessed directly from the ControlNetVersioner.
The protobuf file write routine is as follows:
Once the ControlNetVersioner is initialized from a file or a ControlNet, a Pvl formatted version of the control network can be created by the toPvl method. This will always output the control network in the latest Pvl format. From here, the Pvl network can be written to a file with Pvl::write(filename).
If the control network file format is changed the following changes need to be made to ControlNetVersioner and its supporting classes:
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:
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:
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:
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.
Isis::ControlNetVersioner::ControlNetVersioner | ( | ControlNet * | net | ) |
Construct a ControlNetVersioner from a control network.
This versioner can only be used to write out the control points in the control network. It is expected that the control points in the control network will not be deleted while the control net versioner persists.
net | A pointer to the network that will be written out. |
References Isis::ControlNet::CreatedDate(), Isis::ControlNet::Description(), Isis::ControlNet::GetLastModified(), Isis::ControlNet::GetNetworkId(), Isis::ControlNet::GetPoints(), Isis::ControlNet::GetTarget(), and Isis::ControlNet::GetUserName().
Isis::ControlNetVersioner::ControlNetVersioner | ( | const FileName | netFile, |
Progress * | progress = NULL |
||
) |
Construct a ControlNetVersioner from a file.
The file will be read in and converted into a header object that contains general information about the network and a list of ControlPoints.
netFile | The control network file to read in. |
progress | The progress object to track reading points. |
Isis::ControlNetVersioner::~ControlNetVersioner | ( | ) |
Destroy a ControlNetVersioner.
If the versioner owns the control points stored in it, they will also be deleted.
QString Isis::ControlNetVersioner::creationDate | ( | ) | const |
Returns the date and time that the network was created.
Referenced by Isis::ControlNet::ReadControl().
QString Isis::ControlNetVersioner::description | ( | ) | const |
Returns the network's description.
Referenced by Isis::ControlNet::ReadControl().
QString Isis::ControlNetVersioner::lastModificationDate | ( | ) | const |
Returns the date and time of the last modification to the network.
Referenced by Isis::ControlNet::ReadControl().
QString Isis::ControlNetVersioner::netId | ( | ) | const |
Returns the ID for the network.
Referenced by Isis::ControlNetDiff::compare(), and Isis::ControlNet::ReadControl().
int Isis::ControlNetVersioner::numPoints | ( | ) | const |
Returns the number of points that have been read in or are ready to write out.
Referenced by Isis::ControlNetDiff::compare(), Isis::ControlNet::ReadControl(), and write().
ControlPoint * Isis::ControlNetVersioner::takeFirstPoint | ( | ) |
Returns the first point stored in the versioner's internal list.
This method passes ownership of the point to the caller who is expected to delete it when done with it.
Referenced by Isis::ControlNet::ReadControl().
QString Isis::ControlNetVersioner::targetName | ( | ) | const |
Returns the target for the network.
Referenced by Isis::ControlNetDiff::compare(), and Isis::ControlNet::ReadControl().
Pvl Isis::ControlNetVersioner::toPvl | ( | ) |
Generates a Pvl file from the currently stored control points and header.
References _FILEINFO_, Isis::PvlKeyword::addComment(), Isis::PvlObject::addGroup(), Isis::PvlObject::addObject(), Isis::ControlPoint::SurfacePointSource::AverageOfMeasures, Isis::ControlPoint::RadiusSource::AverageOfMeasures, Isis::ControlPoint::SurfacePointSource::Basemap, Isis::ControlPoint::SurfacePointSource::BundleSolution, Isis::ControlPoint::RadiusSource::BundleSolution, Isis::ControlMeasure::Candidate, Isis::ControlPoint::Constrained, Isis::Angle::degrees(), Isis::ControlPoint::RadiusSource::DEM, Isis::ControlPoint::RadiusSource::Ellipsoid, Isis::PvlObject::findObject(), Isis::ControlPoint::Fixed, Isis::ControlPoint::GetAdjustedSurfacePoint(), Isis::ControlMeasure::GetAprioriLine(), Isis::ControlPoint::GetAprioriRadiusSource(), Isis::ControlPoint::GetAprioriRadiusSourceFile(), Isis::ControlMeasure::GetAprioriSample(), Isis::ControlPoint::GetAprioriSurfacePoint(), Isis::ControlPoint::GetAprioriSurfacePointSource(), Isis::ControlPoint::GetAprioriSurfacePointSourceFile(), Isis::ControlMeasure::GetChooserName(), Isis::ControlPoint::GetChooserName(), Isis::ControlMeasure::GetCubeSerialNumber(), Isis::ControlMeasure::GetDateTime(), Isis::ControlPoint::GetDateTime(), Isis::ControlMeasure::GetDiameter(), Isis::ControlPoint::GetId(), Isis::SurfacePoint::GetLatitude(), Isis::SurfacePoint::GetLatSigmaDistance(), Isis::ControlMeasure::GetLine(), Isis::ControlMeasure::GetLineResidual(), Isis::ControlMeasure::GetLineSigma(), Isis::SurfacePoint::GetLocalRadius(), Isis::SurfacePoint::GetLocalRadiusSigma(), Isis::ControlMeasure::GetLogDataEntries(), Isis::SurfacePoint::GetLongitude(), Isis::SurfacePoint::GetLonSigmaDistance(), Isis::ControlPoint::GetMeasure(), Isis::ControlPoint::GetNumMeasures(), Isis::SurfacePoint::GetRectangularMatrix(), Isis::ControlMeasure::GetSample(), Isis::ControlMeasure::GetSampleResidual(), Isis::ControlMeasure::GetSampleSigma(), Isis::ControlMeasure::GetType(), Isis::ControlPoint::GetType(), Isis::SurfacePoint::GetX(), Isis::SurfacePoint::GetY(), Isis::SurfacePoint::GetZ(), Isis::ControlPoint::HasAprioriRadiusSourceFile(), Isis::ControlPoint::HasAprioriSurfacePointSourceFile(), Isis::ControlPoint::HasRefMeasure(), Isis::ControlPoint::IndexOfRefMeasure(), Isis::ControlPoint::IsCoord1Constrained(), Isis::ControlPoint::IsCoord2Constrained(), Isis::ControlMeasure::IsEditLocked(), Isis::ControlPoint::IsEditLocked(), Isis::ControlMeasure::IsIgnored(), Isis::ControlPoint::IsIgnored(), Isis::ControlPoint::IsReferenceExplicit(), Isis::ControlMeasure::IsRejected(), Isis::ControlMeasure::Manual, Isis::Displacement::meters(), Isis::Distance::meters(), Isis::ControlPoint::SurfacePointSource::None, Isis::ControlPoint::RadiusSource::None, Isis::Null, Isis::ControlPoint::SurfacePointSource::Reference, Isis::ControlMeasure::RegisteredPixel, Isis::ControlMeasure::RegisteredSubPixel, Isis::ControlMeasureLogData::ToKeyword(), Isis::toString(), Isis::IException::Unknown, Isis::ControlPoint::SurfacePointSource::User, Isis::ControlPoint::RadiusSource::User, and Isis::SurfacePoint::Valid().
Referenced by Isis::ControlNetDiff::compare(), and Isis::ControlNet::Write().
QString Isis::ControlNetVersioner::userName | ( | ) | const |
Returns the name of the last person or program to modify the network.
Referenced by Isis::ControlNet::ReadControl().
void Isis::ControlNetVersioner::write | ( | FileName | netFile | ) |
This will write a control net file object to disk.
netFile | The output filename that will be written to |
References _FILEINFO_, Isis::PvlContainer::addComment(), Isis::PvlObject::addGroup(), Isis::PvlContainer::addKeyword(), Isis::PvlObject::addObject(), Isis::FileName::expanded(), Isis::ControlPoint::GetNumMeasures(), Isis::IException::Io, numPoints(), and Isis::toString().
Referenced by Isis::ControlNet::Write().