61 KernelDb::KernelDb(
const unsigned int allowedKernelTypes) {
63 m_allowedKernelTypes = allowedKernelTypes;
64 m_kernelDbFiles.clear();
89 KernelDb::KernelDb(
const QString &dbName,
const unsigned int allowedKernelTypes) :
90 m_kernelData(dbName) {
169 return findLast(
"TargetAttitudeShape", lab);
190 return findLast(
"TargetPosition", lab);
211 return findAll(
"SpacecraftPointing", lab);
231 return findLast(
"SpacecraftClock", lab);
252 return findLast(
"SpacecraftPosition", lab);
314 return findLast(
"InstrumentAddendum", lab);
356 if (queues.size() > 0 && queues.at(0).size() > 0) {
357 lastKernel = queues.at(0).top();
383 int cameraVersion = -1;
393 priority_queue<Kernel> emptyKernelQueue;
394 emptyKernelQueue.push(
Kernel());
395 queues.push_back(emptyKernelQueue);
404 start = (QString) cube.
findGroup(
"Instrument")[
"StartTime"];
406 if (cube.
findGroup(
"Instrument").hasKeyword(
"StopTime")) {
407 end = ((QString) cube.
findGroup(
"Instrument")[
"StopTime"]);
410 end = ((QString) cube.
findGroup(
"Instrument")[
"StartTime"]);
417 priority_queue<Kernel> filesFound;
420 for (
int groupIndex = obj.
groups() - 1; groupIndex >= 0; groupIndex--) {
426 if (!grp.
isNamed(
"Selection"))
continue;
432 type = (QString) grp[
"Type"];
444 bool startMatches =
matches(lab, grp, start, cameraVersion);
445 bool endMatches =
matches(lab, grp, end, cameraVersion);
447 if (startMatches && endMatches) {
452 else if (startMatches) {
455 for (
int endTimeIndex = obj.
groups() - 1;
469 if (endTimeIndex == groupIndex)
continue;
470 if (!endTimeGrp.
isNamed(
"Selection"))
continue;
473 grp[
"Type"] != endTimeGrp[
"Type"])
continue;
474 if (!
matches(lab, endTimeGrp, end, cameraVersion))
continue;
477 bool betterMatch =
false;
480 bool endTimesMatch =
true;
483 for (
int keyIndex = 0;
484 !betterMatch && keyIndex < grp.
keywords();
488 if (!key.
isNamed(
"Time"))
continue;
490 iTime timeRangeStart((QString)key[0]);
491 iTime timeRangeEnd((QString)key[1]);
493 bool thisEndMatches =
matches(lab, endTimeGrp,
494 timeRangeEnd, cameraVersion);
495 endTimesMatch = endTimesMatch && thisEndMatches;
497 if (
matches(lab, endTimeGrp, start, cameraVersion)
498 &&
matches(lab, endTimeGrp, end, cameraVersion)) {
506 if (!betterMatch && endTimesMatch) {
510 while (endMatchFiles.size()) {
511 startMatchFiles.push_back(endMatchFiles[endMatchFiles.size() - 1]);
512 endMatchFiles.pop_back();
519 else if (betterMatch) {
527 queues.push_back(filesFound);
531 if (queues.size() == 0) {
532 priority_queue<Kernel> emptyKernelQueue;
533 emptyKernelQueue.push(
Kernel());
534 queues.push_back(emptyKernelQueue);
584 iTime timeToMatch,
int cameraVersion) {
595 bool matchKeywords =
true;
600 for (
int keyword = 0; keyword < grp.
keywords(); keyword++) {
605 iTime kernelStart = (QString) key[0];
606 iTime kernelEnd = (QString) key[1];
610 if ((kernelStart <= timeToMatch) && (kernelEnd >= timeToMatch)) {
614 else if (key.
isNamed(
"Match")) {
616 QString matchGroup = key[0];
617 QString matchKey = key[1];
618 QString matchValue = key[2];
620 QString cubeValue = cube.
findGroup(matchGroup)[matchKey];
621 cubeValue = cubeValue.simplified().trimmed().toUpper();
622 matchValue = matchValue.simplified().trimmed().toUpper();
625 if (cubeValue.compare(matchValue) != 0) {
626 matchKeywords =
false;
631 matchKeywords =
false;
634 else if (key.
isNamed(
"CameraVersion")) {
636 for (
int camVersionKeyIndex = 0;
637 camVersionKeyIndex < key.
size();
638 camVersionKeyIndex++) {
640 bool versionMatch =
false;
641 IString val = key[camVersionKeyIndex];
644 while ((commaTok = val.
Token(
",")).ToQt().length() > 0) {
645 if (commaTok.find(
'-') != string::npos) {
650 direction = (start <= end) ? 1 : -1;
652 for (
int version = start;
653 version != end + direction;
654 version += direction) {
655 if (version == cameraVersion) {
662 if (commaTok.
ToInteger() == cameraVersion) {
669 matchKeywords =
false;
674 matchKeywords =
false;
679 return matchKeywords && matchTime;
722 PvlGroup &dataDir = Preference::Preferences().findGroup(
"DataDirectory");
723 QString baseDir = dataDir[
"Base"];
726 QString missionDir = dataDir[mission];
731 FileName tasDbPath(missionDir +
"/kernels/pck");
739 FileName tpDbPath(missionDir +
"/kernels/tspk");
792 QString directory,
const Pvl &lab) {
794 FileName configFile = directory +
"/kernels.????.conf";
795 bool noConfigFile =
false;
804 FileName kernelDb(directory +
"/kernels.????.db");
809 bool foundMatch =
false;
811 for (
int groupIndex = 0; groupIndex < inst.
groups(); groupIndex++) {
819 for (
int keyIndex = 0; keyIndex < grp.
keywords(); keyIndex++) {
822 QString dir = dataDir[keyword[0]];
823 FileName kernelDb( dir +
"/" + keyword[1]);
859 QString msg =
"Unable to read kernel database file [" 890 for (
int i = 0; i < grp.
keywords(); i++) {
892 if (kfile.
name() !=
"File")
continue;
897 if (kfile.
size() == 2) {
898 QString pref = kfile[0];
899 QString version = kfile[1];
900 FileName filename(
"$" + pref +
"/" + version);
906 else if (kfile.
size() == 1) {
913 QString msg =
"Invalid File keyword value in [Group = ";
914 msg += grp.
name() +
"] in database file [";
PvlObject & object(const int index)
Return the object at the specified index.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
Kernel dem(Pvl &lab)
This method finds the highest version of all Digital Terrain Models (DEMs) found that match the crite...
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Kernel targetPosition(Pvl &lab)
This method finds the highest version of all Target Position kernels (tspk) identified by the databas...
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Kernel findLast(const QString &entry, Pvl &lab)
Finds the highest priority Kernel object for the given entry based on the allowed Kernel types...
File name manipulation and expansion.
Parse and return pieces of a time string.
int objects() const
Returns the number of objects.
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...
KernelDb(const unsigned int allowedKernelTypes)
Constructs a new KernelDb object with a given integer value representing the Kernel::Type enumeration...
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
static int CameraVersion(Cube &cube)
This looks up the current camera model version from the cube.
~KernelDb()
Destructs KernelDb object.
Namespace for the standard library.
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.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
QList< FileName > m_kernelDbFiles
List of the kernel database file names that were read in when the loadSystemDb() method is called...
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
QString originalPath() const
Returns the path of the original file name.
int ToInteger() const
Returns the object string as an integer.
bool isNamed(QString name) const
Determines whether two PvlKeywords have the same name or not.
Pvl m_kernelData
Pvl containing the information in the kernel database(s) that is read in from the constructor and whe...
Kernel spacecraftPosition(Pvl &lab)
This method finds the highest version of all Spacecraft Position kernels (spk) identified by the data...
QString m_filename
The name of the kernel database file.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
QString name() const
Returns the container name.
This class stores Kernel information, including Type and kernel file names.
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 Type typeEnum(const QString &type)
Converts the given string to a character as follows.
int size() const
Returns the number of values stored in this keyword.
QStringList files(PvlGroup &grp)
This method retrieves the values of all of the "File" keywords in the given PvlGroup.
IString Token(const IString &separator)
Returns the first token in the IString.
Kernel spacecraftClock(Pvl &lab)
This method finds the highest version of all Spacecraft Clock kernels (sclk) identified by the databa...
Contains multiple PvlContainers.
Kernel frame(Pvl &lab)
This method finds the highest version of all Frame kernels (fk) identified by the database and the al...
#define _FILEINFO_
Macro for the filename and line number.
A single keyword-value pair.
A type of error that cannot be classified as any of the other error types.
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 ...
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Container for cube-like labels.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
PvlGroup & group(const int index)
Return the group at the specified index.
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name...
QString name() const
Returns the keyword name.
Kernel leapSecond(Pvl &lab)
This method finds the top priority of all Leap Second kernels (lsk) identified by the database and th...
Adds specific functionality to C++ strings.
QList< FileName > kernelDbFiles()
Accessor method to retrieve the list of kernel database files that were read in when loadSystemDb() i...
Namespace for ISIS/Bullet specific routines.
unsigned int m_allowedKernelTypes
This integer value represents which Kernel::Types are allowed.
void readKernelDbFiles()
This method is called by loadSystemDb() to read kernel database file list compiled by loadKernelDbFil...
int groups() const
Returns the number of groups contained.
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...
Kernel instrument(Pvl &lab)
This method finds the last Instrument kernel found that matches the (ik) criteria in the database and...
Contains Pvl Groups and Pvl Objects.
void read(const QString &file)
Loads PVL information from a stream.
bool fileExists() const
Returns true if the file exists; false otherwise.
bool isVersioned() const
Checks to see if a file name is versioned by date or numerically.
Kernel targetAttitudeShape(Pvl &lab)
This method finds the highest version of all Target Attitude Shape kernels (pck) identified by the da...
Kernel instrumentAddendum(Pvl &lab)
This method finds the highest version of all Instrument Addendum kernels (iak) identified by the data...