From 510cf52b6d472a8ac39915b2ee6d1cd49e75b2d1 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 a58b6ff98a..23ebb38b50 100644 --- a/isis/src/base/objs/CSMCamera/CSMCamera.cpp +++ b/isis/src/base/objs/CSMCamera/CSMCamera.cpp @@ -651,18 +651,23 @@ namespace Isis { /** * 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 ab8eb2d0c3..37910d6f5a 100644 --- a/isis/src/base/objs/Target/Target.cpp +++ b/isis/src/base/objs/Target/Target.cpp @@ -119,6 +119,18 @@ namespace Isis { QString targetName = inst["TargetName"][0]; setName(targetName); + 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); }