Isis 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. | |
ControlNetVersioner (const FileName netFile, Progress *progress=NULL) | |
Construct a ControlNetVersioner from a file. | |
~ControlNetVersioner () | |
Destroy a ControlNetVersioner. | |
QString | netId () const |
Returns the ID for the network. | |
QString | targetName () const |
Returns the target for the network. | |
QString | creationDate () const |
Returns the date and time that the network was created. | |
QString | lastModificationDate () const |
Returns the date and time of the last modification to the network. | |
QString | description () const |
Returns the network's description. | |
QString | userName () const |
Returns the name of the last person or program to modify the network. | |
int | numPoints () const |
Returns the number of points that have been read in or are ready to write out. | |
ControlPoint * | takeFirstPoint () |
Returns the first point stored in the versioner's internal list. | |
void | write (FileName netFile) |
This will write a control net file object to disk. | |
Pvl | toPvl () |
Generates a Pvl file from the currently stored control points and header. | |
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. |
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.
QString Isis::ControlNetVersioner::description | ( | ) | const |
Returns the network's description.
QString Isis::ControlNetVersioner::lastModificationDate | ( | ) | const |
Returns the date and time of the last modification to the network.
QString Isis::ControlNetVersioner::netId | ( | ) | const |
int Isis::ControlNetVersioner::numPoints | ( | ) | const |
Returns the number of points that have been read in or are ready to write out.
Referenced by 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.
QString Isis::ControlNetVersioner::targetName | ( | ) | const |
Returns the target for the network.
Pvl Isis::ControlNetVersioner::toPvl | ( | ) |
Generates a Pvl file from the currently stored control points and header.
References _FILEINFO_, Isis::PvlKeyword::addComment(), 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::ControlPoint::GetAprioriRadiusSource(), Isis::ControlPoint::GetAprioriRadiusSourceFile(), Isis::ControlPoint::GetAprioriSurfacePoint(), Isis::ControlPoint::GetAprioriSurfacePointSource(), Isis::ControlPoint::GetAprioriSurfacePointSourceFile(), Isis::ControlPoint::GetChooserName(), Isis::ControlPoint::GetDateTime(), Isis::ControlPoint::GetId(), Isis::SurfacePoint::GetLatitude(), Isis::SurfacePoint::GetLatSigmaDistance(), Isis::SurfacePoint::GetLocalRadius(), Isis::SurfacePoint::GetLocalRadiusSigma(), Isis::SurfacePoint::GetLongitude(), Isis::SurfacePoint::GetLonSigmaDistance(), Isis::ControlPoint::GetMeasure(), Isis::ControlPoint::GetNumMeasures(), Isis::SurfacePoint::GetRectangularMatrix(), 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::ControlPoint::IsEditLocked(), Isis::ControlPoint::IsIgnored(), Isis::ControlPoint::IsReferenceExplicit(), 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::toString(), Isis::IException::Unknown, Isis::ControlPoint::SurfacePointSource::User, Isis::ControlPoint::RadiusSource::User, and Isis::SurfacePoint::Valid().
QString Isis::ControlNetVersioner::userName | ( | ) | const |
Returns the name of the last person or program to modify the network.
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::ControlPoint::GetNumMeasures(), Isis::IException::Io, numPoints(), and Isis::toString().