57 m_bodyCode =
new SpiceInt;
58 m_systemCode =
new SpiceInt;
68 *m_name = inst[
"TargetName"][0];
69 QString trykey =
"NaifIkCode";
71 m_systemName =
new QString;
74 trykey =
"NaifFrameCode";
77 if (name().toUpper() ==
"SKY") {
78 m_radii[0] = m_radii[1] = m_radii[2] =
Distance(1000.0, Distance::Meters);
80 int ikCode =
toInt(kernels[trykey][0]);
81 *m_bodyCode = ikCode / 1000;
84 *m_bodyCode = (int) kernels[
"NaifSpkCode"];
88 (*m_systemName).append(
"THE COSMOS");
92 *m_bodyCode = lookupNaifBodyCode(lab);
95 *m_systemCode = (*m_bodyCode/100)*100 + 99;
97 SpiceChar naifBuf[40];
99 bodc2n_c((SpiceInt) *m_systemCode,
sizeof(naifBuf), naifBuf, &found);
101 (*m_systemName).append(s.c_str());
110 *m_bodyCode = (int) kernels[
"NaifBodyCode"];
112 m_shape = ShapeModelFactory::create(
this, lab);
142 void Target::init() {
144 m_originalShape = NULL;
153 NaifStatus::CheckErrors();
167 if (m_radii.size() != 0) {
171 delete m_originalShape;
172 m_originalShape = NULL;
180 bool Target::isSky()
const {
191 SpiceInt Target::lookupNaifBodyCode(
Pvl &lab)
const {
194 code = lookupNaifBodyCode(*m_name);
200 code = m_spice->getInteger(
"BODY_FRAME_CODE", 0);
204 && lab.
findObject(
"NaifKeywords").hasKeyword(
"BODY_FRAME_CODE") ) {
205 code = int(lab.
findObject(
"NaifKeywords").findKeyword(
"BODY_FRAME_CODE"));
211 "BODY_FRAME_CODE not found for this Target.",
219 "Unable to look up NAIF body code for this Target.",
232 SpiceInt Target::lookupNaifBodyCode(QString name) {
234 NaifStatus::CheckErrors();
237 bodn2c_c(name.toLatin1().data(), &code, &found);
239 QString msg =
"Could not convert Target [" + name +
240 "] to NAIF body code";
243 NaifStatus::CheckErrors();
278 target = mapping[
"TargetName"][0];
282 if (target.isEmpty()) {
283 bool hasInstrumentGroup = cubeLab.
findObject(
"IsisCube").hasGroup(
"Instrument");
284 if (hasInstrumentGroup) {
287 target = inst[
"TargetName"][0];
294 if (target.isEmpty()) {
296 "Unable to find a TargetName keyword in the given PVL.",
303 PvlGroup radii = Target::radiiGroup(target);
320 if (naifKeywords.
hasKeyword(
"BODY_FRAME_CODE")) {
323 QString radiiKeyword =
"BODY"
332 PvlContainer::Replace);
336 PvlContainer::Replace);
340 PvlGroup radiiGroup = Target::radiiGroup(
toInt(bodyFrame[0]));
353 QString msg =
"Unable to find Equatorial and Polar radii for target [" + target +
"].";
374 if (target.isEmpty()) {
376 "Unable to find TargetRadii. The given TargetName is empty.",
383 if (cachedResults.contains(target)) {
384 mapping = cachedResults[target];
388 SpiceInt bodyFrame = 0;
390 bodyFrame = lookupNaifBodyCode(target);
393 QString msg =
"Unable to find target radii for given target ["
398 PvlGroup radiiGroup = Target::radiiGroup(
int(bodyFrame));
400 mapping += radiiGroup.
findKeyword(
"EquatorialRadius");
402 cachedResults[target] = mapping;
423 static bool pckLoaded =
false;
425 FileName kern(
"$base/kernels/pck/pck?????.tpc");
426 kern = kern.highestVersion();
427 QString kernName = kern.expanded();
430 furnsh_c(kernName.toLatin1().data());
436 SpiceDouble radii[3];
437 bodvar_c(bodyFrameCode,
"RADII", &n, radii);
440 NaifStatus::CheckErrors();
443 QString msg =
"Unable to find radii for target code [" +
toString(bodyFrameCode)
444 +
"]. Target code was not found in furnished kernels.";
464 SpiceInt Target::naifBodyCode()
const {
477 SpiceInt Target::naifPlanetSystemCode()
const {
478 return *m_systemCode;
483 QString Target::name()
const {
489 QString Target::systemName()
const {
490 return *m_systemName;
499 std::vector<Distance> Target::radii()
const {
504 int Target::frameType() {
505 return spice()->bodyRotation()->getFrameType();
509 std::vector<Angle> Target::poleRaCoefs() {
510 return spice()->bodyRotation()->poleRaCoefs();
514 std::vector<Angle> Target::poleDecCoefs() {
515 return spice()->bodyRotation()->poleDecCoefs();
519 std::vector<Angle> Target::pmCoefs() {
520 return spice()->bodyRotation()->pmCoefs();
524 std::vector<double> Target::poleRaNutPrecCoefs() {
525 return spice()->bodyRotation()->poleRaNutPrecCoefs();
529 std::vector<double> Target::poleDecNutPrecCoefs() {
530 return spice()->bodyRotation()->poleDecNutPrecCoefs();
534 std::vector<double> Target::pmNutPrecCoefs() {
535 return spice()->bodyRotation()->pmNutPrecCoefs();
539 std::vector<Angle> Target::sysNutPrecConstants() {
540 return spice()->bodyRotation()->sysNutPrecConstants();
544 std::vector<Angle> Target::sysNutPrecCoefs() {
545 return spice()->bodyRotation()->sysNutPrecCoefs();
552 void Target::restoreShape() {
553 if (m_shape->name() !=
"Ellipsoid") {
558 else if (m_originalShape == NULL) {
562 m_shape = m_originalShape;
563 m_originalShape = NULL;
570 void Target::setShapeEllipsoid() {
572 m_originalShape = m_shape;
582 void Target::setRadii(std::vector<Distance> radii) {
583 m_radii[0] = radii[0];
584 m_radii[1] = radii[1];
585 m_radii[2] = radii[2];
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
File name manipulation and expansion.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
int toInt(const QString &string)
Global function to convert from a string to an integer.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Define shapes and provide utilities for Isis3 targets.
Distance measurement, usually in meters.
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
A single keyword-value pair.
Container for cube-like labels.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Define shapes and provide utilities for Isis3 targets.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
Obtain SPICE information for a spacecraft.
Contains Pvl Groups and Pvl Objects.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.