Loading isis/src/control/objs/ControlNetVersioner/ControlPointV0001.cpp +252 −60 Original line number Diff line number Diff line Loading @@ -3,7 +3,10 @@ #include <QString> #include "ControlPointV0001.h" #include "Distance.h" #include "Pvl.h" #include "SurfacePoint.h" #include "Target.h" using namespace std; Loading @@ -25,18 +28,28 @@ namespace Isis { * Create a ControlPointV0001 object from a version 1 control point Pvl object * * @param pointObject The control point and its measures in a Pvl object * @param targetName The name of the taret used to get the body radii when converting from * lat/lon to x/y/z. */ ControlPointV0001::ControlPointV0001(const Pvl &pointObject) ControlPointV0001::ControlPointV0001(Pvl &pointObject, const QString targetName) : m_pointData(new ControlNetFileProtoV0001_PBControlPoint) { // Copy over strings, doubles, and bools // Clean up the Pvl control point // Anything that doesn't have a value is removed for (int cpKeyIndex = 0; cpKeyIndex < pointObject.keywords(); cpKeyIndex ++) { if (pointObject[cpKeyIndex][0] == "") { pointObject.deleteKeyword(cpKeyIndex); } } // Copy over POD values copy(pointObject, "PointId", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_id); copy(pointObject, "ChooserName", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_choosername); copy(pointObject, "DateTime", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_datetime); copy(pointObject, "AprioriXYZSourceFile", copy(pointObject, "AprioriLatLonSourceFile", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorisurfpointsourcefile); copy(pointObject, "AprioriRadiusSourceFile", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriradiussourcefile); Loading @@ -46,18 +59,6 @@ namespace Isis { m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_editlock); copy(pointObject, "Ignore", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_ignore); copy(pointObject, "AprioriX", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorix); copy(pointObject, "AprioriY", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriy); copy(pointObject, "AprioriZ", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriz); copy(pointObject, "AdjustedX", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedx); copy(pointObject, "AdjustedY", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedy); copy(pointObject, "AdjustedZ", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedz); copy(pointObject, "LatitudeConstrained", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_latitudeconstrained); copy(pointObject, "LongitudeConstrained", Loading @@ -65,14 +66,59 @@ namespace Isis { copy(pointObject, "RadiusConstrained", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_radiusconstrained); // Copy enumerated values // Copy over the adjusted surface point if ( pointObject.hasKeyword("Latitude") && pointObject.hasKeyword("Longitude") && pointObject.hasKeyword("Radius") ) { SurfacePoint adjustedPoint( Latitude(toDouble(pointObject["Latitude"][0]), Angle::Degrees), Longitude(toDouble(pointObject["Longitude"][0]), Angle::Degrees), Distance(toDouble(pointObject["Radius"][0]), Distance::Meters)); m_pointData->set_adjustedx( adjustedPoint.GetX().meters() ); m_pointData->set_adjustedy( adjustedPoint.GetY().meters() ); m_pointData->set_adjustedz( adjustedPoint.GetZ().meters() ); } else if ( pointObject.hasKeyword("X") && pointObject.hasKeyword("Y") && pointObject.hasKeyword("Z") ) { m_pointData->set_adjustedx( pointObject["Latitude"][0] ); m_pointData->set_adjustedy( pointObject["Longitude"][0] ); m_pointData->set_adjustedz( pointObject["Radius"][0] ); } else { QString msg = "Unable to find adjusted surface point values for the control point."; throw IException(e, IException::Io, msg, _FILEINFO_); } // copy over the apriori surface point if ( pointObject.hasKeyword("AprioriLatitude") && pointObject.hasKeyword("AprioriLongitude") && pointObject.hasKeyword("AprioriRadius") ) { SurfacePoint aprioriPoint( Latitude(toDouble(pointObject["AprioriLatitude"][0]), Angle::Degrees), Longitude(toDouble(pointObject["AprioriLongitude"][0]), Angle::Degrees), Distance(toDouble(pointObject["AprioriRadius"][0]), Distance::Meters)); m_pointData->set_apriorix( aprioriPoint.GetX().meters() ); m_pointData->set_aprioriy( aprioriPoint.GetY().meters() ); m_pointData->set_aprioriz( aprioriPoint.GetZ().meters() ); } // If the apriori values are missing, copy them from the adjusted. else if ( m_pointData->has_adjustedx() && m_pointData->has_adjustedy() && m_pointData->has_adjustedz() ) { m_pointData->set_apriorix( m_pointData->adjustedx() ); m_pointData->set_aprioriy( m_pointData->adjustedx() ); m_pointData->set_aprioriz( m_pointData->adjustedx() ); } else { QString msg = "Unable to find apriori surface point values for the control point."; throw IException(e, IException::Io, msg, _FILEINFO_); } // The control point type names were changed between version 3 and version 4. // In version 3, the types are ground, tie, and constrained // 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] == "Ground") { // Ground points were previously flagged by the Held keyword being true. if (pointObject.hasKeyword("Held") && pointObject["Held"][0] == "True") { m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Ground); } else if (pointObject["PointType"][0] == "Tie") { Loading @@ -83,8 +129,8 @@ namespace Isis { throw IException(IException::User, msg, _FILEINFO_); } if (pointObject.hasKeyword("AprioriXYZSource")) { QString source = pointObject["AprioriXYZSource"][0]; if (pointObject.hasKeyword("AprioriLatLonSource")) { QString source = pointObject["AprioriLatLonSource"][0]; if (source == "None") { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::None); Loading @@ -105,7 +151,7 @@ namespace Isis { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriXYZSource [" + source + "]"; QString msg = "Invalid AprioriLatLonSource [" + source + "]"; throw IException(IException::User, msg, _FILEINFO_); } } Loading Loading @@ -137,9 +183,33 @@ namespace Isis { } } // Copy array values if (pointObject.hasKeyword("AprioriCovarianceMatrix")) { PvlKeyword &matrix = pointObject["AprioriCovarianceMatrix"]; // Copy the covariance matrices // Sometimes they are not stored in version 1 Pvls so we compute them from a combination // of the surface point sigmas and the target radii. // We have to do this because Target::radiiGroup calls NAIF routines, // but doesn't check for errors. NaifStatus::CheckErrors(); PvlGroup radii; try { radii = Target::radiiGroup(targetName); } catch (IException &e) { try { NaifStatus::CheckErrors(); } catch (IException &) { // pass to the outer catch } QString msg = "Unable to get target body radii for [" + targetName + "] when calculating covariance matrix."; throw IException(e, IException::Io, msg, _FILEINFO_); } Distance equatorialRadius(radii["EquatorialRadius"], Distance::Meters); Distance polarRadius(radii["PolarRadius"], Distance::Meters); if ( pointObject.hasKeyword("ApostCovarianceMatrix") ) { PvlKeyword &matrix = pointObject["ApostCovarianceMatrix"]; m_pointData->add_aprioricovar(toDouble(matrix[0])); m_pointData->add_aprioricovar(toDouble(matrix[1])); Loading @@ -147,17 +217,102 @@ namespace Isis { m_pointData->add_aprioricovar(toDouble(matrix[3])); m_pointData->add_aprioricovar(toDouble(matrix[4])); m_pointData->add_aprioricovar(toDouble(matrix[5])); m_pointData->set_latitudeconstrained(true); m_pointData->set_longitudeconstrained(true); m_pointData->set_radiusconstrained(true); } else if ( pointObject.hasKeyword("AprioriSigmaLatitude") || pointObject.hasKeyword("AprioriSigmaLongitude") || pointObject.hasKeyword("AprioriSigmaRadius") ) { // There may be missing or negative apriori sigmas so default to 10,000 double sigmaLat = 10000.0; double sigmaLon = 10000.0; double sigmaRad = 10000.0; if ( pointObject.hasKeyword("AprioriSigmaLatitude") ) { if (toDouble(pointObject["AprioriSigmaLatitude"][0]) > 0 && toDouble(pointObject["AprioriSigmaLatitude"][0]) < sigmaLat) { sigmaLat = toDouble(pointObject["AprioriSigmaLatitude"][0]); } m_pointData->set_latitudeconstrained(true); } if ( pointObject.hasKeyword("AprioriSigmaLongitude") ) { if (toDouble(pointObject["AprioriSigmaLongitude"][0]) > 0 && toDouble(pointObject["AprioriSigmaLongitude"][0]) < sigmaLon) { sigmaLon = toDouble(pointObject["AprioriSigmaLongitude"][0]); } m_pointData->set_longitudeconstrained(true); } if ( pointObject.hasKeyword("AprioriSigmaRadius") ) { if (toDouble(pointObject["AprioriSigmaRadius"][0]) > 0 && toDouble(pointObject["AprioriSigmaRadius"][0]) < sigmaRad) { sigmaRad = toDouble(pointObject["AprioriSigmaRadius"][0]); } m_pointData->set_radiusconstrained(true); } SurfacePoint aprioriPoint; aprioriPoint.SetRadii(equatorialRadius, equatorialRadius, polarRadius); aprioriPoint.SetRectangular( Displacement(m_pointData->apriorix(), Displacement::Meters), Displacement(m_pointData->aprioriy(), Displacement::Meters), Displacement(m_pointData->aprioriz(), Displacement::Meters) ); aprioriPoint.SetSphericalSigmasDistance( Distance(sigmaLat, Distance::Meters), Distance(sigmaLon, Distance::Meters), Distance(sigmaRad, Distance::Meters) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 0) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 1) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 2) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(1, 1) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(1, 2) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(2, 2) ); } if ( pointObject.hasKeyword("AdjustedSigmaLatitude") || pointObject.hasKeyword("AdjustedSigmaLongitude") || pointObject.hasKeyword("AdjustedSigmaRadius") ) { // There may be missing or negative adjusted sigmas so default to 10,000 double sigmaLat = 10000.0; double sigmaLon = 10000.0; double sigmaRad = 10000.0; if ( pointObject.hasKeyword("AdjustedSigmaLatitude") ) { if (toDouble(pointObject["AdjustedSigmaLatitude"][0]) > 0 && toDouble(pointObject["AdjustedSigmaLatitude"][0]) < sigmaLat) { sigmaLat = toDouble(pointObject["AdjustedSigmaLatitude"][0]); } } if ( pointObject.hasKeyword("AdjustedSigmaLongitude") ) { if (toDouble(pointObject["AdjustedSigmaLongitude"][0]) > 0 && toDouble(pointObject["AdjustedSigmaLongitude"][0]) < sigmaLon) { sigmaLon = toDouble(pointObject["AdjustedSigmaLongitude"][0]); } } if (pointObject.hasKeyword("AdjustedCovarianceMatrix")) { PvlKeyword &matrix = pointObject["AdjustedCovarianceMatrix"]; if ( pointObject.hasKeyword("AdjustedSigmaRadius") ) { if (toDouble(pointObject["AdjustedSigmaRadius"][0]) > 0 && toDouble(pointObject["AdjustedSigmaRadius"][0]) < sigmaRad) { sigmaRad = toDouble(pointObject["AdjustedSigmaRadius"][0]); } } m_pointData->add_adjustedcovar(toDouble(matrix[0])); m_pointData->add_adjustedcovar(toDouble(matrix[1])); m_pointData->add_adjustedcovar(toDouble(matrix[2])); m_pointData->add_adjustedcovar(toDouble(matrix[3])); m_pointData->add_adjustedcovar(toDouble(matrix[4])); m_pointData->add_adjustedcovar(toDouble(matrix[5])); SurfacePoint adjustedPoint; adjustedPoint.SetRadii(equatorialRadius, equatorialRadius, polarRadius); adjustedPoint.SetRectangular( Displacement(m_pointData->adjustedx(), Displacement::Meters), Displacement(m_pointData->adjustedy(), Displacement::Meters), Displacement(m_pointData->adjustedz(), Displacement::Meters) ); adjustedPoint.SetSphericalSigmasDistance( Distance(sigmaLat, Distance::Meters), Distance(sigmaLon, Distance::Meters), Distance(sigmaRad, Distance::Meters) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 0) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 1) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 2) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(1, 1) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(1, 2) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(2, 2) ); } // Process Measures Loading Loading @@ -192,23 +347,44 @@ namespace Isis { // The sample, line, sample residual, and line residual are nested in another structure // inside the measure, so they cannot be copied with the conenience methods. if (group.hasKeyword("Sample")) { double value = toDouble(group["Sample"][0]); // The sample may not be a numeric value // in this case set it to 0 and ignore the measure double value try { value = toDouble(group["Sample"][0]); } catch (...) { value = 0; m_pointData->set_ignore(true); } measure.measurement().set_sample(value); group.deleteKeyword("Sample"); } if (group.hasKeyword("Line")) { double value = toDouble(group["Line"][0]); // The line may not be a numeric value // in this case set it to 0 and ignore the measure double value try { value = toDouble(group["Line"][0]); } catch (...) { value = 0; m_pointData->set_ignore(true); } measure.measurement().set_line(value); group.deleteKeyword("Line"); } if (group.hasKeyword("SampleResidual")) { double value = toDouble(group["SampleResidual"][0]); if (group.hasKeyword("ErrorSample")) { double value = toDouble(group["ErrorSample"][0]); measure.measurement().set_sampleresidual(value); group.deleteKeyword("ErrorSample"); } if (group.hasKeyword("LineResidual")) { double value = toDouble(group["LineResidual"][0]); if (group.hasKeyword("ErrorLine")) { double value = toDouble(group["ErrorLine"][0]); measure.measurement().set_lineresidual(value); group.deleteKeyword("ErrorLine"); } if (group.hasKeyword("Reference")) { if (group["Reference"][0].toLower() == "true") { m_pointData->set_referenceindex(groupIndex); Loading @@ -216,17 +392,23 @@ namespace Isis { group.deleteKeyword("Reference"); } // Copy the measure type if (group.hasKeyword("MeasureType")) { QString type = group["MeasureType"][0].toLower(); if (type == "candidate") { if (type == "estimated" || type == "unmeasured") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::Candidate); } else if (type == "manual") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::Manual); } else if (type == "registeredpixel") { else if (type == "automatic" || type == "validatedmanual" || type == "automaticpixel") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::RegisteredPixel); } else if (type == "registeredsubpixel") { else if (type == "validatedautomatic" || type == "automaticsubpixel") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::RegisteredSubPixel); } else { Loading @@ -235,6 +417,16 @@ namespace Isis { _FILEINFO_); } group.deleteKeyword("MeasureType"); } // Clean up the remaining keywords for (int cmKeyIndex = 0; cmKeyIndex < group.keywords(); cmKeyIndex ++) { if (group[cmKeyIndex][0] == "" || group[cmKeyIndex].name() == "ZScore" || group[cmKeyIndex].name() == "ErrorMagnitude") { group.deleteKeyword(cmKeyIndex); } } for (int key = 0; key < group.keywords(); key++) { ControlMeasureLogData interpreter(group[key]); Loading isis/src/control/objs/ControlNetVersioner/ControlPointV0001.h +2 −2 Original line number Diff line number Diff line Loading @@ -32,8 +32,8 @@ namespace Isis { class ControlPointV0001 { public: ControlPointV0001(const Pvl &pointObject); ControlPointV0001(const ControlPointV0001 &oldPoint); ControlPointV0001(Pvl &pointObject, const QString targetName); ControlPointV0001(QSharedPointer<ControlNetFileProtoV0001_PBControlPoint> pointData); QSharedPointer<ControlNetFileProtoV0001_PBControlPoint> pointData(); Loading Loading
isis/src/control/objs/ControlNetVersioner/ControlPointV0001.cpp +252 −60 Original line number Diff line number Diff line Loading @@ -3,7 +3,10 @@ #include <QString> #include "ControlPointV0001.h" #include "Distance.h" #include "Pvl.h" #include "SurfacePoint.h" #include "Target.h" using namespace std; Loading @@ -25,18 +28,28 @@ namespace Isis { * Create a ControlPointV0001 object from a version 1 control point Pvl object * * @param pointObject The control point and its measures in a Pvl object * @param targetName The name of the taret used to get the body radii when converting from * lat/lon to x/y/z. */ ControlPointV0001::ControlPointV0001(const Pvl &pointObject) ControlPointV0001::ControlPointV0001(Pvl &pointObject, const QString targetName) : m_pointData(new ControlNetFileProtoV0001_PBControlPoint) { // Copy over strings, doubles, and bools // Clean up the Pvl control point // Anything that doesn't have a value is removed for (int cpKeyIndex = 0; cpKeyIndex < pointObject.keywords(); cpKeyIndex ++) { if (pointObject[cpKeyIndex][0] == "") { pointObject.deleteKeyword(cpKeyIndex); } } // Copy over POD values copy(pointObject, "PointId", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_id); copy(pointObject, "ChooserName", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_choosername); copy(pointObject, "DateTime", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_datetime); copy(pointObject, "AprioriXYZSourceFile", copy(pointObject, "AprioriLatLonSourceFile", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorisurfpointsourcefile); copy(pointObject, "AprioriRadiusSourceFile", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriradiussourcefile); Loading @@ -46,18 +59,6 @@ namespace Isis { m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_editlock); copy(pointObject, "Ignore", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_ignore); copy(pointObject, "AprioriX", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_apriorix); copy(pointObject, "AprioriY", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriy); copy(pointObject, "AprioriZ", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_aprioriz); copy(pointObject, "AdjustedX", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedx); copy(pointObject, "AdjustedY", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedy); copy(pointObject, "AdjustedZ", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_adjustedz); copy(pointObject, "LatitudeConstrained", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_latitudeconstrained); copy(pointObject, "LongitudeConstrained", Loading @@ -65,14 +66,59 @@ namespace Isis { copy(pointObject, "RadiusConstrained", m_pointData, &ControlNetFileProtoV0001_PBControlPoint::set_radiusconstrained); // Copy enumerated values // Copy over the adjusted surface point if ( pointObject.hasKeyword("Latitude") && pointObject.hasKeyword("Longitude") && pointObject.hasKeyword("Radius") ) { SurfacePoint adjustedPoint( Latitude(toDouble(pointObject["Latitude"][0]), Angle::Degrees), Longitude(toDouble(pointObject["Longitude"][0]), Angle::Degrees), Distance(toDouble(pointObject["Radius"][0]), Distance::Meters)); m_pointData->set_adjustedx( adjustedPoint.GetX().meters() ); m_pointData->set_adjustedy( adjustedPoint.GetY().meters() ); m_pointData->set_adjustedz( adjustedPoint.GetZ().meters() ); } else if ( pointObject.hasKeyword("X") && pointObject.hasKeyword("Y") && pointObject.hasKeyword("Z") ) { m_pointData->set_adjustedx( pointObject["Latitude"][0] ); m_pointData->set_adjustedy( pointObject["Longitude"][0] ); m_pointData->set_adjustedz( pointObject["Radius"][0] ); } else { QString msg = "Unable to find adjusted surface point values for the control point."; throw IException(e, IException::Io, msg, _FILEINFO_); } // copy over the apriori surface point if ( pointObject.hasKeyword("AprioriLatitude") && pointObject.hasKeyword("AprioriLongitude") && pointObject.hasKeyword("AprioriRadius") ) { SurfacePoint aprioriPoint( Latitude(toDouble(pointObject["AprioriLatitude"][0]), Angle::Degrees), Longitude(toDouble(pointObject["AprioriLongitude"][0]), Angle::Degrees), Distance(toDouble(pointObject["AprioriRadius"][0]), Distance::Meters)); m_pointData->set_apriorix( aprioriPoint.GetX().meters() ); m_pointData->set_aprioriy( aprioriPoint.GetY().meters() ); m_pointData->set_aprioriz( aprioriPoint.GetZ().meters() ); } // If the apriori values are missing, copy them from the adjusted. else if ( m_pointData->has_adjustedx() && m_pointData->has_adjustedy() && m_pointData->has_adjustedz() ) { m_pointData->set_apriorix( m_pointData->adjustedx() ); m_pointData->set_aprioriy( m_pointData->adjustedx() ); m_pointData->set_aprioriz( m_pointData->adjustedx() ); } else { QString msg = "Unable to find apriori surface point values for the control point."; throw IException(e, IException::Io, msg, _FILEINFO_); } // The control point type names were changed between version 3 and version 4. // In version 3, the types are ground, tie, and constrained // 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] == "Ground") { // Ground points were previously flagged by the Held keyword being true. if (pointObject.hasKeyword("Held") && pointObject["Held"][0] == "True") { m_pointData->set_type(ControlNetFileProtoV0001_PBControlPoint::Ground); } else if (pointObject["PointType"][0] == "Tie") { Loading @@ -83,8 +129,8 @@ namespace Isis { throw IException(IException::User, msg, _FILEINFO_); } if (pointObject.hasKeyword("AprioriXYZSource")) { QString source = pointObject["AprioriXYZSource"][0]; if (pointObject.hasKeyword("AprioriLatLonSource")) { QString source = pointObject["AprioriLatLonSource"][0]; if (source == "None") { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::None); Loading @@ -105,7 +151,7 @@ namespace Isis { m_pointData->set_apriorisurfpointsource(ControlNetFileProtoV0001_PBControlPoint::BundleSolution); } else { QString msg = "Invalid AprioriXYZSource [" + source + "]"; QString msg = "Invalid AprioriLatLonSource [" + source + "]"; throw IException(IException::User, msg, _FILEINFO_); } } Loading Loading @@ -137,9 +183,33 @@ namespace Isis { } } // Copy array values if (pointObject.hasKeyword("AprioriCovarianceMatrix")) { PvlKeyword &matrix = pointObject["AprioriCovarianceMatrix"]; // Copy the covariance matrices // Sometimes they are not stored in version 1 Pvls so we compute them from a combination // of the surface point sigmas and the target radii. // We have to do this because Target::radiiGroup calls NAIF routines, // but doesn't check for errors. NaifStatus::CheckErrors(); PvlGroup radii; try { radii = Target::radiiGroup(targetName); } catch (IException &e) { try { NaifStatus::CheckErrors(); } catch (IException &) { // pass to the outer catch } QString msg = "Unable to get target body radii for [" + targetName + "] when calculating covariance matrix."; throw IException(e, IException::Io, msg, _FILEINFO_); } Distance equatorialRadius(radii["EquatorialRadius"], Distance::Meters); Distance polarRadius(radii["PolarRadius"], Distance::Meters); if ( pointObject.hasKeyword("ApostCovarianceMatrix") ) { PvlKeyword &matrix = pointObject["ApostCovarianceMatrix"]; m_pointData->add_aprioricovar(toDouble(matrix[0])); m_pointData->add_aprioricovar(toDouble(matrix[1])); Loading @@ -147,17 +217,102 @@ namespace Isis { m_pointData->add_aprioricovar(toDouble(matrix[3])); m_pointData->add_aprioricovar(toDouble(matrix[4])); m_pointData->add_aprioricovar(toDouble(matrix[5])); m_pointData->set_latitudeconstrained(true); m_pointData->set_longitudeconstrained(true); m_pointData->set_radiusconstrained(true); } else if ( pointObject.hasKeyword("AprioriSigmaLatitude") || pointObject.hasKeyword("AprioriSigmaLongitude") || pointObject.hasKeyword("AprioriSigmaRadius") ) { // There may be missing or negative apriori sigmas so default to 10,000 double sigmaLat = 10000.0; double sigmaLon = 10000.0; double sigmaRad = 10000.0; if ( pointObject.hasKeyword("AprioriSigmaLatitude") ) { if (toDouble(pointObject["AprioriSigmaLatitude"][0]) > 0 && toDouble(pointObject["AprioriSigmaLatitude"][0]) < sigmaLat) { sigmaLat = toDouble(pointObject["AprioriSigmaLatitude"][0]); } m_pointData->set_latitudeconstrained(true); } if ( pointObject.hasKeyword("AprioriSigmaLongitude") ) { if (toDouble(pointObject["AprioriSigmaLongitude"][0]) > 0 && toDouble(pointObject["AprioriSigmaLongitude"][0]) < sigmaLon) { sigmaLon = toDouble(pointObject["AprioriSigmaLongitude"][0]); } m_pointData->set_longitudeconstrained(true); } if ( pointObject.hasKeyword("AprioriSigmaRadius") ) { if (toDouble(pointObject["AprioriSigmaRadius"][0]) > 0 && toDouble(pointObject["AprioriSigmaRadius"][0]) < sigmaRad) { sigmaRad = toDouble(pointObject["AprioriSigmaRadius"][0]); } m_pointData->set_radiusconstrained(true); } SurfacePoint aprioriPoint; aprioriPoint.SetRadii(equatorialRadius, equatorialRadius, polarRadius); aprioriPoint.SetRectangular( Displacement(m_pointData->apriorix(), Displacement::Meters), Displacement(m_pointData->aprioriy(), Displacement::Meters), Displacement(m_pointData->aprioriz(), Displacement::Meters) ); aprioriPoint.SetSphericalSigmasDistance( Distance(sigmaLat, Distance::Meters), Distance(sigmaLon, Distance::Meters), Distance(sigmaRad, Distance::Meters) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 0) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 1) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(0, 2) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(1, 1) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(1, 2) ); m_pointData->add_aprioricovar( aprioriPoint.GetRectangularMatrix()(2, 2) ); } if ( pointObject.hasKeyword("AdjustedSigmaLatitude") || pointObject.hasKeyword("AdjustedSigmaLongitude") || pointObject.hasKeyword("AdjustedSigmaRadius") ) { // There may be missing or negative adjusted sigmas so default to 10,000 double sigmaLat = 10000.0; double sigmaLon = 10000.0; double sigmaRad = 10000.0; if ( pointObject.hasKeyword("AdjustedSigmaLatitude") ) { if (toDouble(pointObject["AdjustedSigmaLatitude"][0]) > 0 && toDouble(pointObject["AdjustedSigmaLatitude"][0]) < sigmaLat) { sigmaLat = toDouble(pointObject["AdjustedSigmaLatitude"][0]); } } if ( pointObject.hasKeyword("AdjustedSigmaLongitude") ) { if (toDouble(pointObject["AdjustedSigmaLongitude"][0]) > 0 && toDouble(pointObject["AdjustedSigmaLongitude"][0]) < sigmaLon) { sigmaLon = toDouble(pointObject["AdjustedSigmaLongitude"][0]); } } if (pointObject.hasKeyword("AdjustedCovarianceMatrix")) { PvlKeyword &matrix = pointObject["AdjustedCovarianceMatrix"]; if ( pointObject.hasKeyword("AdjustedSigmaRadius") ) { if (toDouble(pointObject["AdjustedSigmaRadius"][0]) > 0 && toDouble(pointObject["AdjustedSigmaRadius"][0]) < sigmaRad) { sigmaRad = toDouble(pointObject["AdjustedSigmaRadius"][0]); } } m_pointData->add_adjustedcovar(toDouble(matrix[0])); m_pointData->add_adjustedcovar(toDouble(matrix[1])); m_pointData->add_adjustedcovar(toDouble(matrix[2])); m_pointData->add_adjustedcovar(toDouble(matrix[3])); m_pointData->add_adjustedcovar(toDouble(matrix[4])); m_pointData->add_adjustedcovar(toDouble(matrix[5])); SurfacePoint adjustedPoint; adjustedPoint.SetRadii(equatorialRadius, equatorialRadius, polarRadius); adjustedPoint.SetRectangular( Displacement(m_pointData->adjustedx(), Displacement::Meters), Displacement(m_pointData->adjustedy(), Displacement::Meters), Displacement(m_pointData->adjustedz(), Displacement::Meters) ); adjustedPoint.SetSphericalSigmasDistance( Distance(sigmaLat, Distance::Meters), Distance(sigmaLon, Distance::Meters), Distance(sigmaRad, Distance::Meters) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 0) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 1) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(0, 2) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(1, 1) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(1, 2) ); m_pointData->add_adjustedcovar( adjustedPoint.GetRectangularMatrix()(2, 2) ); } // Process Measures Loading Loading @@ -192,23 +347,44 @@ namespace Isis { // The sample, line, sample residual, and line residual are nested in another structure // inside the measure, so they cannot be copied with the conenience methods. if (group.hasKeyword("Sample")) { double value = toDouble(group["Sample"][0]); // The sample may not be a numeric value // in this case set it to 0 and ignore the measure double value try { value = toDouble(group["Sample"][0]); } catch (...) { value = 0; m_pointData->set_ignore(true); } measure.measurement().set_sample(value); group.deleteKeyword("Sample"); } if (group.hasKeyword("Line")) { double value = toDouble(group["Line"][0]); // The line may not be a numeric value // in this case set it to 0 and ignore the measure double value try { value = toDouble(group["Line"][0]); } catch (...) { value = 0; m_pointData->set_ignore(true); } measure.measurement().set_line(value); group.deleteKeyword("Line"); } if (group.hasKeyword("SampleResidual")) { double value = toDouble(group["SampleResidual"][0]); if (group.hasKeyword("ErrorSample")) { double value = toDouble(group["ErrorSample"][0]); measure.measurement().set_sampleresidual(value); group.deleteKeyword("ErrorSample"); } if (group.hasKeyword("LineResidual")) { double value = toDouble(group["LineResidual"][0]); if (group.hasKeyword("ErrorLine")) { double value = toDouble(group["ErrorLine"][0]); measure.measurement().set_lineresidual(value); group.deleteKeyword("ErrorLine"); } if (group.hasKeyword("Reference")) { if (group["Reference"][0].toLower() == "true") { m_pointData->set_referenceindex(groupIndex); Loading @@ -216,17 +392,23 @@ namespace Isis { group.deleteKeyword("Reference"); } // Copy the measure type if (group.hasKeyword("MeasureType")) { QString type = group["MeasureType"][0].toLower(); if (type == "candidate") { if (type == "estimated" || type == "unmeasured") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::Candidate); } else if (type == "manual") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::Manual); } else if (type == "registeredpixel") { else if (type == "automatic" || type == "validatedmanual" || type == "automaticpixel") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::RegisteredPixel); } else if (type == "registeredsubpixel") { else if (type == "validatedautomatic" || type == "automaticsubpixel") { measure.set_type(ControlNetFileProtoV0001_PBControlPoint::PBControlMeasure::RegisteredSubPixel); } else { Loading @@ -235,6 +417,16 @@ namespace Isis { _FILEINFO_); } group.deleteKeyword("MeasureType"); } // Clean up the remaining keywords for (int cmKeyIndex = 0; cmKeyIndex < group.keywords(); cmKeyIndex ++) { if (group[cmKeyIndex][0] == "" || group[cmKeyIndex].name() == "ZScore" || group[cmKeyIndex].name() == "ErrorMagnitude") { group.deleteKeyword(cmKeyIndex); } } for (int key = 0; key < group.keywords(); key++) { ControlMeasureLogData interpreter(group[key]); Loading
isis/src/control/objs/ControlNetVersioner/ControlPointV0001.h +2 −2 Original line number Diff line number Diff line Loading @@ -32,8 +32,8 @@ namespace Isis { class ControlPointV0001 { public: ControlPointV0001(const Pvl &pointObject); ControlPointV0001(const ControlPointV0001 &oldPoint); ControlPointV0001(Pvl &pointObject, const QString targetName); ControlPointV0001(QSharedPointer<ControlNetFileProtoV0001_PBControlPoint> pointData); QSharedPointer<ControlNetFileProtoV0001_PBControlPoint> pointData(); Loading