11#include "EllipsoidShape.h"
13#include "IException.h"
14#include "NaifStatus.h"
17#include "ShapeModelFactory.h"
18#include "SpecialPixel.h"
53 *
m_name = inst[
"TargetName"][0];
54 QString trykey =
"NaifIkCode";
59 trykey =
"NaifFrameCode";
62 if (
name().toUpper() ==
"SKY") {
65 int ikCode =
toInt(kernels[trykey][0]);
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());
120 QString targetName = inst[
"TargetName"][0];
125 QString trykey =
"NaifIkCode";
130 trykey =
"NaifFrameCode";
136 int ikCode =
toInt(kernels[trykey][0]);
144 (*m_systemName).append(
"THE COSMOS");
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.",
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";
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) {
324 if (inst.hasKeyword(
"TargetName")) {
325 target = inst[
"TargetName"][0];
326 mapping.addKeyword(
PvlKeyword(
"TargetName", target), PvlContainer::Replace );
332 if (target.isEmpty()) {
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 );
355 if (cubeLab.hasObject(
"NaifKeywords")) {
363 SpiceInt bodyCode = 0;
371 QString radiiKeyword =
"BODY" +
toString(
int(bodyCode)) +
"_RADII";
373 if (naifKeywords.hasKeyword(radiiKeyword)) {
375 mapping.addKeyword(
PvlKeyword(
"EquatorialRadius",
377 PvlContainer::Replace);
380 PvlContainer::Replace);
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)) {
393 mapping.addKeyword(
PvlKeyword(
"EquatorialRadius",
396 PvlContainer::Replace);
400 PvlContainer::Replace);
409 QString msg =
"Unable to find Equatorial and Polar radii for target [" + target +
"].";
430 if (target.isEmpty()) {
432 "Unable to find TargetRadii. The given TargetName is empty.",
436 static QMap<QString, PvlGroup> cachedResults;
439 if (cachedResults.contains(target)) {
440 mapping = cachedResults[target];
444 SpiceInt bodyCode = 0;
449 QString msg =
"Unable to find target radii for given 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 furnsh_c(kernName.toLatin1().data());
494 SpiceDouble
radii[3];
495 bodvar_c(bodyCode,
"RADII", &n,
radii);
501 QString msg =
"Unable to find radii for target code [" +
toString(bodyCode)
502 +
"]. Target code was not found in furnished kernels.";
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() {
Distance measurement, usually in meters.
@ Meters
The distance is being specified in meters.
Define shapes and provide utilities for ISIS targets.
File name manipulation and expansion.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ Io
A type of error that occurred when performing an actual I/O operation.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
Contains Pvl Groups and Pvl Objects.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
@ Traverse
Search child objects.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
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.
QString name() const
Gets the shape name.
Obtain SPICE information for a spacecraft.
virtual SpiceRotation * bodyRotation() const
Accessor method for the body rotation.
SpiceInt getInteger(const QString &key, int index=0)
This returns a value from the NAIF text pool.
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.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
int toInt(const QString &string)
Global function to convert from a string to an integer.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Namespace for the standard library.