From fd53520dfac9d6db42f8674d2069bf3d3ba8202a Mon Sep 17 00:00:00 2001 From: acpaquette Date: Mon, 22 Jan 2024 12:53:45 -0700 Subject: [PATCH] Allows CSMCamera to pickup naif target radii --- isis/src/base/objs/CSMCamera/CSMCamera.cpp | 17 +++++++++++------ isis/src/base/objs/Target/Target.cpp | 12 ++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/isis/src/base/objs/CSMCamera/CSMCamera.cpp b/isis/src/base/objs/CSMCamera/CSMCamera.cpp index 85af2e3927..cf704933e0 100644 --- a/isis/src/base/objs/CSMCamera/CSMCamera.cpp +++ b/isis/src/base/objs/CSMCamera/CSMCamera.cpp @@ -771,18 +771,23 @@ void sanitize(std::string &input); /** * Set the Target object for the camera model. + * + * If no radii can be found in the label from the naif keywords + * use the radii from the csm model * * @param label The label containing information to create the Target from */ void CSMCamera::setTarget(Pvl label) { Target *target = new Target(label); - // get radii from CSM - csm::Ellipsoid targetEllipsoid = csm::SettableEllipsoid::getEllipsoid(m_model); - std::vector radii = {Distance(targetEllipsoid.getSemiMajorRadius(), Distance::Meters), - Distance(targetEllipsoid.getSemiMajorRadius(), Distance::Meters), - Distance(targetEllipsoid.getSemiMinorRadius(), Distance::Meters)}; - target->setRadii(radii); + if (target->radii().size() == 0) { + // get radii from CSM + csm::Ellipsoid targetEllipsoid = csm::SettableEllipsoid::getEllipsoid(m_model); + std::vector radii = {Distance(targetEllipsoid.getSemiMajorRadius(), Distance::Meters), + Distance(targetEllipsoid.getSemiMajorRadius(), Distance::Meters), + Distance(targetEllipsoid.getSemiMinorRadius(), Distance::Meters)}; + target->setRadii(radii); + } // Target needs to be able to access the camera to do things like // compute resolution diff --git a/isis/src/base/objs/Target/Target.cpp b/isis/src/base/objs/Target/Target.cpp index 32689d99d1..18c24bd6d0 100644 --- a/isis/src/base/objs/Target/Target.cpp +++ b/isis/src/base/objs/Target/Target.cpp @@ -143,6 +143,18 @@ namespace Isis { *m_systemCode = -1; (*m_systemName).append("THE COSMOS"); } + + if (label.hasObject("NaifKeywords")) { + PvlObject naifKeywords = label.findObject("NaifKeywords"); + QString m_bodyCode = naifKeywords["BODY_CODE"]; + PvlKeyword radiiKey = naifKeywords.findKeyword("BODY" + m_bodyCode + "_RADII"); + std::vector radii(3, Distance()); + radii[0] = Distance(radiiKey[0].toDouble(), Distance::Kilometers); + radii[1] = Distance(radiiKey[1].toDouble(), Distance::Kilometers); + radii[2] = Distance(radiiKey[2].toDouble(), Distance::Kilometers); + + setRadii(radii); + } m_shape = ShapeModelFactory::create(this, label); }