14#include "CameraFactory.h"
16#include "IException.h"
20#include "Preference.h"
21#include "Preference.h"
23#include "PvlKeyword.h"
156 return findLast(
"TargetAttitudeShape", lab);
177 return findLast(
"TargetPosition", lab);
198 return findAll(
"SpacecraftPointing", lab);
218 return findLast(
"SpacecraftClock", lab);
239 return findLast(
"SpacecraftPosition", lab);
301 return findLast(
"InstrumentAddendum", lab);
343 if (queues.size() > 0 && queues.at(0).size() > 0) {
344 lastKernel = queues.at(0).top();
370 int cameraVersion = -1;
380 priority_queue<Kernel> emptyKernelQueue;
381 emptyKernelQueue.push(
Kernel());
382 queues.push_back(emptyKernelQueue);
391 start = (QString) cube.
findGroup(
"Instrument")[
"StartTime"];
393 if (cube.
findGroup(
"Instrument").hasKeyword(
"StopTime")) {
394 end = ((QString) cube.
findGroup(
"Instrument")[
"StopTime"]);
397 end = ((QString) cube.
findGroup(
"Instrument")[
"StartTime"]);
404 priority_queue<Kernel> filesFound;
407 for (
int groupIndex = obj.
groups() - 1; groupIndex >= 0; groupIndex--) {
413 if (!grp.
isNamed(
"Selection"))
continue;
419 type = (QString) grp[
"Type"];
432 bool startMatches =
matches(lab, grp, start, cameraVersion);
433 bool endMatches =
matches(lab, grp, end, cameraVersion);
435 if (startMatches && endMatches) {
440 else if (startMatches) {
443 for (
int endTimeIndex = obj.
groups() - 1;
457 if (endTimeIndex == groupIndex)
continue;
458 if (!endTimeGrp.
isNamed(
"Selection"))
continue;
461 grp[
"Type"] != endTimeGrp[
"Type"])
continue;
462 if (!
matches(lab, endTimeGrp, end, cameraVersion))
continue;
465 bool betterMatch =
false;
468 bool endTimesMatch =
true;
471 for (
int keyIndex = 0;
472 !betterMatch && keyIndex < grp.
keywords();
476 if (!key.
isNamed(
"Time"))
continue;
478 iTime timeRangeStart((QString)key[0]);
479 iTime timeRangeEnd((QString)key[1]);
481 bool thisEndMatches =
matches(lab, endTimeGrp,
482 timeRangeEnd, cameraVersion);
483 endTimesMatch = endTimesMatch && thisEndMatches;
485 if (
matches(lab, endTimeGrp, start, cameraVersion)
486 &&
matches(lab, endTimeGrp, end, cameraVersion)) {
494 if (!betterMatch && endTimesMatch) {
498 while (endMatchFiles.size()) {
499 startMatchFiles.push_back(endMatchFiles[endMatchFiles.size() - 1]);
500 endMatchFiles.pop_back();
507 else if (betterMatch) {
515 queues.push_back(filesFound);
519 if (queues.size() == 0) {
520 priority_queue<Kernel> emptyKernelQueue;
521 emptyKernelQueue.push(
Kernel());
522 queues.push_back(emptyKernelQueue);
572 iTime timeToMatch,
int cameraVersion) {
583 bool matchKeywords =
true;
584 double startOffset = 0;
585 double endOffset = 0;
589 startOffset = (double) grp[
"StartOffset"] + 0.001;
592 endOffset = (double) grp[
"EndOffset"] + 0.001;
601 for (
int keyword = 0; keyword < grp.
keywords(); keyword++) {
607 iTime kernelStart = (QString) key[0];
608 iTime kernelEnd = (QString) key[1];
612 if ((kernelStart - startOffset <= timeToMatch) && (kernelEnd + endOffset >= timeToMatch)) {
619 QString instId = (QString) inst.
findKeyword(
"InstrumentId");
626 else if (key.
isNamed(
"Match")) {
628 QString matchGroup = key[0];
629 QString matchKey = key[1];
630 QString matchValue = key[2];
632 QString cubeValue = cube.
findGroup(matchGroup)[matchKey];
633 cubeValue = cubeValue.simplified().trimmed().toUpper();
634 matchValue = matchValue.simplified().trimmed().toUpper();
637 if (cubeValue.compare(matchValue) != 0) {
638 matchKeywords =
false;
643 matchKeywords =
false;
646 else if (key.
isNamed(
"CameraVersion")) {
648 for (
int camVersionKeyIndex = 0;
649 camVersionKeyIndex < key.
size();
650 camVersionKeyIndex++) {
652 bool versionMatch =
false;
653 IString val = key[camVersionKeyIndex];
656 while ((commaTok = val.
Token(
",")).ToQt().length() > 0) {
657 if (commaTok.find(
'-') != string::npos) {
662 direction = (start <= end) ? 1 : -1;
664 for (
int version = start;
665 version != end + direction;
666 version += direction) {
667 if (version == cameraVersion) {
674 if (commaTok.
ToInteger() == cameraVersion) {
681 matchKeywords =
false;
686 matchKeywords =
false;
691 return matchKeywords && matchTime;
734 PvlGroup &dataDir = Preference::Preferences().findGroup(
"DataDirectory");
735 QString baseDir = dataDir[
"Base"];
738 QString missionDir = dataDir[mission];
752 FileName tpDbPath(missionDir +
"/kernels/tspk");
805 QString directory,
const Pvl &lab) {
807 FileName configFile = directory +
"/kernels.????.conf";
808 bool noConfigFile =
false;
817 FileName kernelDb(directory +
"/kernels.????.db");
822 bool foundMatch =
false;
824 for (
int groupIndex = 0; groupIndex < inst.
groups(); groupIndex++) {
832 for (
int keyIndex = 0; keyIndex < grp.
keywords(); keyIndex++) {
835 QString dir = dataDir[keyword[0]];
836 FileName kernelDb( dir +
"/" + keyword[1]);
872 QString msg =
"Unable to read kernel database file ["
903 for (
int i = 0; i < grp.
keywords(); i++) {
905 if (kfile.
name() !=
"File")
continue;
910 if (kfile.
size() == 2) {
911 QString pref = kfile[0];
912 QString version = kfile[1];
913 FileName filename(
"$" + pref +
"/" + version);
919 else if (kfile.
size() == 1) {
926 QString msg =
"Invalid File keyword value in [Group = ";
927 msg += grp.
name() +
"] in database file [";
static int CameraVersion(Cube &cube)
This looks up the current camera model version from the cube.
File name manipulation and expansion.
bool fileExists() const
Returns true if the file exists; false otherwise.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name.
QString originalPath() const
Returns the path of the original file name.
bool isVersioned() const
Checks to see if a file name is versioned by date or numerically.
@ Unknown
A type of error that cannot be classified as any of the other error types.
Adds specific functionality to C++ strings.
int ToInteger() const
Returns the object string as an integer.
IString Token(const IString &separator)
Returns the first token in the IString.
Kernel instrumentAddendum(Pvl &lab)
This method finds the highest version of all Instrument Addendum kernels (iak) identified by the data...
QStringList files(PvlGroup &grp)
This method retrieves the values of all of the "File" keywords in the given PvlGroup.
Kernel spacecraftClock(Pvl &lab)
This method finds the highest version of all Spacecraft Clock kernels (sclk) identified by the databa...
Kernel targetAttitudeShape(Pvl &lab)
This method finds the highest version of all Target Attitude Shape kernels (pck) identified by the da...
void loadKernelDbFiles(PvlGroup &dataDir, QString directory, const Pvl &lab)
This method is called by loadSystemDb() to create a list of all appropriate kernel database files to ...
QList< FileName > m_kernelDbFiles
List of the kernel database file names that were read in when the loadSystemDb() method is called.
Kernel instrument(Pvl &lab)
This method finds the last Instrument kernel found that matches the (ik) criteria in the database and...
~KernelDb()
Destructs KernelDb object.
void loadSystemDb(const QString &mission, const Pvl &lab)
Loads the appropriate kernel database files with the defined BASE and MISSION info for each type of k...
static bool matches(const Pvl &lab, PvlGroup &kernelDbGrp, iTime timeToMatch, int cameraVersion)
This static method determines whether the given cube label matches the given criteria.
Kernel targetPosition(Pvl &lab)
This method finds the highest version of all Target Position kernels (tspk) identified by the databas...
Kernel findLast(const QString &entry, Pvl &lab)
Finds the highest priority Kernel object for the given entry based on the allowed Kernel types.
Pvl m_kernelData
Pvl containing the information in the kernel database(s) that is read in from the constructor and whe...
QList< std::priority_queue< Kernel > > findAll(const QString &entry, Pvl &lab)
Finds all of the Kernel objects for the given entry value based on the allowed Kernel types.
QString m_filename
The name of the kernel database file.
Kernel spacecraftPosition(Pvl &lab)
This method finds the highest version of all Spacecraft Position kernels (spk) identified by the data...
unsigned int m_allowedKernelTypes
This integer value represents which Kernel::Types are allowed.
Kernel frame(Pvl &lab)
This method finds the highest version of all Frame kernels (fk) identified by the database and the al...
QList< std::priority_queue< Kernel > > spacecraftPointing(Pvl &lab)
This method finds a list of the highest versions of all Spacecraft Pointing kernels (ck) identified b...
QList< FileName > kernelDbFiles()
Accessor method to retrieve the list of kernel database files that were read in when loadSystemDb() i...
Kernel dem(Pvl &lab)
This method finds the highest version of all Digital Terrain Models (DEMs) found that match the crite...
Kernel leapSecond(Pvl &lab)
This method finds the top priority of all Leap Second kernels (lsk) identified by the database and th...
void readKernelDbFiles()
This method is called by loadSystemDb() to read kernel database file list compiled by loadKernelDbFil...
KernelDb(const unsigned int allowedKernelTypes)
Constructs a new KernelDb object with a given integer value representing the Kernel::Type enumeration...
This class stores Kernel information, including Type and kernel file names.
static Type typeEnum(const QString &type)
Converts the given string to a character as follows.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
QString name() const
Returns the container name.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Contains multiple PvlContainers.
Container for cube-like labels.
A single keyword-value pair.
QString name() const
Returns the keyword name.
int size() const
Returns the number of values stored in this keyword.
bool isNamed(QString name) const
Determines whether two PvlKeywords have the same name or not.
Contains Pvl Groups and Pvl Objects.
PvlGroup & group(const int index)
Return the group at the specified index.
int groups() const
Returns the number of groups contained.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
@ Traverse
Search child objects.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Parse and return pieces of a time string.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Namespace for the standard library.