11#include "EllipsoidShape.h"
13#include "IException.h"
14#include "NaifStatus.h"
17#include "ShapeModelFactory.h"
18#include "SpecialPixel.h"
49 PvlGroup &kernels = lab.findGroup(
"Kernels", Pvl::Traverse);
51 PvlGroup &inst = lab.findGroup(
"Instrument", Pvl::Traverse);
53 *
m_name = inst[
"TargetName"][0];
54 QString trykey =
"NaifIkCode";
58 if (kernels.hasKeyword(
"NaifFrameCode")) {
59 trykey =
"NaifFrameCode";
62 if (
name().toUpper() ==
"SKY") {
65 int ikCode = toInt(kernels[trykey][0]);
68 if (kernels.hasKeyword(
"NaifSpkCode")) {
73 (*m_systemName).append(
"THE COSMOS");
82 SpiceChar naifBuf[40];
84 bodc2n_c((SpiceInt) *
m_systemCode,
sizeof(naifBuf), naifBuf, &found);
87 (*m_systemName).append(s.c_str());
95 if (kernels.hasKeyword(
"NaifBodyCode")) {
119 PvlGroup &inst = label.findGroup(
"Instrument", Pvl::Traverse);
120 QString targetName = inst[
"TargetName"][0];
123 PvlGroup &kernels = label.findGroup(
"Kernels", Pvl::Traverse);
125 QString trykey =
"NaifIkCode";
129 if (kernels.hasKeyword(
"NaifFrameCode")) {
130 trykey =
"NaifFrameCode";
133 if (
name().toUpper() ==
"SKY" && kernels.hasKeyword(trykey)) {
136 int ikCode = toInt(kernels[trykey][0]);
139 if (kernels.hasKeyword(
"NaifSpkCode")) {
144 (*m_systemName).append(
"THE COSMOS");
232 catch (IException &e) {
236 code =
m_spice->getInteger(
"BODY_CODE", 0);
240 else if (lab.hasObject(
"NaifKeywords")
241 && lab.findObject(
"NaifKeywords").hasKeyword(
"BODY_CODE") ) {
242 code = int(lab.findObject(
"NaifKeywords").findKeyword(
"BODY_CODE"));
248 "BODY_CODE not found for this Target.",
252 catch (IException &e2) {
256 "Unable to look up NAIF body code for this Target.",
274 bodn2c_c(
name.toLatin1().data(), &code, &found);
276 QString msg =
"Could not convert Target [" +
name +
277 "] to NAIF body code";
278 throw IException(IException::Io, msg, _FILEINFO_);
301 PvlGroup mapping = mapGroup;
306 if (mapping.hasKeyword(
"EquatorialRadius")
307 && mapping.hasKeyword(
"PolarRadius")) {
315 if (mapping.hasKeyword(
"TargetName")) {
316 target = mapping[
"TargetName"][0];
320 if (target.isEmpty()) {
321 bool hasInstrumentGroup = cubeLab.findObject(
"IsisCube").hasGroup(
"Instrument");
322 if (hasInstrumentGroup) {
323 PvlGroup inst = cubeLab.findGroup(
"Instrument", Pvl::Traverse);
324 if (inst.hasKeyword(
"TargetName")) {
325 target = inst[
"TargetName"][0];
326 mapping.addKeyword( PvlKeyword(
"TargetName", target), PvlContainer::Replace );
332 if (target.isEmpty()) {
333 throw IException(IException::Unknown,
334 "Unable to find a TargetName keyword in the given PVL.",
345 mapping.addKeyword(
radii.findKeyword(
"EquatorialRadius"), PvlContainer::Replace );
346 mapping.addKeyword(
radii.findKeyword(
"PolarRadius"), PvlContainer::Replace );
349 catch (IException &e) {
355 if (cubeLab.hasObject(
"NaifKeywords")) {
357 PvlObject naifKeywords = cubeLab.findObject(
"NaifKeywords");
363 SpiceInt bodyCode = 0;
368 catch (IException &e2) {
369 throw IException(e, IException::Unknown, e2.what(), _FILEINFO_);
371 QString radiiKeyword =
"BODY" +
toString(
int(bodyCode)) +
"_RADII";
373 if (naifKeywords.hasKeyword(radiiKeyword)) {
374 PvlKeyword
radii = naifKeywords.findKeyword(radiiKeyword);
375 mapping.addKeyword( PvlKeyword(
"EquatorialRadius",
377 PvlContainer::Replace);
378 mapping.addKeyword( PvlKeyword(
"PolarRadius",
380 PvlContainer::Replace);
384 catch (IException &e) {
386 if (naifKeywords.hasKeyword(
"BODY_FRAME_CODE")) {
388 PvlKeyword bodyFrame = naifKeywords.findKeyword(
"BODY_FRAME_CODE");
389 QString radiiKeyword =
"BODY" + bodyFrame[0] +
"_RADII";
391 if (naifKeywords.hasKeyword(radiiKeyword)) {
392 PvlKeyword
radii = naifKeywords.findKeyword(radiiKeyword);
393 mapping.addKeyword( PvlKeyword(
"EquatorialRadius",
396 PvlContainer::Replace);
397 mapping.addKeyword( PvlKeyword(
"PolarRadius",
400 PvlContainer::Replace);
409 QString msg =
"Unable to find Equatorial and Polar radii for target [" + target +
"].";
410 throw IException(e, IException::Unknown, msg, _FILEINFO_);
430 if (target.isEmpty()) {
431 throw IException(IException::Unknown,
432 "Unable to find TargetRadii. The given TargetName is empty.",
438 PvlGroup mapping(
"Mapping");
439 if (cachedResults.contains(target)) {
440 mapping = cachedResults[target];
444 SpiceInt bodyCode = 0;
448 catch (IException &e) {
449 QString msg =
"Unable to find target radii for given target ["
451 throw IException(IException::Io, msg, _FILEINFO_);
455 mapping += PvlKeyword(
"TargetName", target);
456 mapping +=
radiiGroup.findKeyword(
"EquatorialRadius");
457 mapping +=
radiiGroup.findKeyword(
"PolarRadius");
458 cachedResults[target] = mapping;
479 static bool pckLoaded =
false;
483 FileName kern(
"$base/kernels/pck/pck?????.tpc");
484 kern = kern.highestVersion();
485 QString kernName = kern.expanded();
488 SpiceQL::load(kernName.toLatin1().data());
494 SpiceDouble
radii[3];
495 bodvar_c(bodyCode,
"RADII", &n,
radii);
500 catch (IException &e) {
501 QString msg =
"Unable to find radii for target code [" +
toString(bodyCode)
502 +
"]. Target code was not found in furnished kernels.";
504 throw IException(e, IException::Unknown, msg, _FILEINFO_);
562 int Target::frameType() {
567 std::vector<Angle> Target::poleRaCoefs() {
572 std::vector<Angle> Target::poleDecCoefs() {
577 std::vector<Angle> Target::pmCoefs() {
582 std::vector<double> Target::poleRaNutPrecCoefs() {
587 std::vector<double> Target::poleDecNutPrecCoefs() {
592 std::vector<double> Target::pmNutPrecCoefs() {
597 std::vector<Angle> Target::sysNutPrecConstants() {
602 std::vector<Angle> Target::sysNutPrecCoefs() {
611 if (
m_shape->name() !=
"Ellipsoid") {
Distance measurement, usually in meters.
@ Meters
The distance is being specified in meters.
Define shapes and provide utilities for ISIS targets.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
static ShapeModel * create(Target *target, Pvl &pvl)
Construct a valid shape model from the given target and contents of kernels group.
Define shapes and provide utilities for Isis targets.
Obtain SPICE information for a spacecraft.
virtual SpiceRotation * bodyRotation() const
Accessor method for the body rotation.
FrameType getFrameType()
Accessor method to get the rotation frame type.
std::vector< Angle > poleDecCoefs()
Return the coefficients used to calculate the target body pole dec.
std::vector< Angle > sysNutPrecCoefs()
Return the coefficients used to calculate the target body system nut/prec angles.
std::vector< Angle > sysNutPrecConstants()
Return the constants used to calculate the target body system nut/prec angles.
std::vector< double > poleRaNutPrecCoefs()
Return the coefficients used to calculate the target body pole ra nut/prec coefficients.
std::vector< Angle > poleRaCoefs()
Return the coefficients used to calculate the target body pole ra.
std::vector< double > pmNutPrecCoefs()
Return the coefficients used to calculate the target body pm nut/prec coefficients.
std::vector< double > poleDecNutPrecCoefs()
Return the coefficients used to calculate the target body pole dec nut/prec coefficients.
std::vector< Angle > pmCoefs()
Return the coefficients used to calculate the target body prime meridian.
SpiceInt naifBodyCode() const
This returns the NAIF body code of the target.
SpiceInt * m_systemCode
The NaifBodyCode of the targets planetary system If the target is sky, then what should this be?
~Target()
Destroys the Target.
void init()
Initialize member variables.
Target()
Constructs an empty Target object.
QString * m_systemName
name of the planetary system of the target
void setSpice(Spice *spice)
Set the Spice pointer for the Target.
void setRadii(std::vector< Distance > radii)
Sets the radii of the body.
QString * m_name
target name
Spice * spice() const
Return the spice object.
static PvlGroup radiiGroup(QString target)
Creates a Pvl Group with keywords TargetName, EquitorialRadius, and PolarRadius.
std::vector< Distance > m_radii
target radii
void setShapeEllipsoid()
Set the shape to the ellipsoid and save the original shape.
std::vector< Distance > radii() const
Returns the radii of the body in km.
ShapeModel * m_shape
target shape model
ShapeModel * shape() const
Return the shape.
static SpiceInt lookupNaifBodyCode(QString name)
This returns the NAIF body code of the target indicated in the labels.
SpiceInt naifPlanetSystemCode() const
This returns the NAIF planet system body code of the target.
SpiceInt * m_bodyCode
The NaifBodyCode value, if it exists in the labels.
bool isSky() const
Return if our target is the sky.
QString name() const
Return target name.
Spice * m_spice
parent Spice object, needed to get pixel resolution in ShapeModels
void restoreShape()
Restores the shape to the original after setShapeEllipsoid has overridden it.
QString systemName() const
Return planet system name.
bool m_sky
flag indicating target is the sky
ShapeModel * m_originalShape
target original shape model
void setName(QString name)
Set the name for the Target.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
Namespace for the standard library.