Commit c1af14fa authored by Kris Becker's avatar Kris Becker
Browse files

Corrected issues with Apollo dataset; user comments are now added to kernel...

Corrected issues with Apollo dataset; user comments are now added to kernel comment section rather than replacing them; Added OVERLAP parameter to provide control over start/end time conflicts; support both type 9 ad 13 SPK kernels. Fixes #739.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@5769 41f8697f-d340-4b68-9986-7bafba869bb8
parent a654212b
Loading
Loading
Loading
Loading
+10 −52
Original line number Diff line number Diff line
@@ -42,25 +42,20 @@ namespace Isis {
 * @author 2011-04-01 Kris Becker 
 * @internal 
 * @history 2011-04-11 Kris Becker Completed documentation 
 * @history 2013-12-19 Kris Becker Simplified by removing user comment file 
 *                                 handling.  See SpkKernelWriter. 
 */
template <class K>
  class Commentor {
    public:
      /** Constructor w/initialization  */
      Commentor() { init(); }
      /** Constructor w/caller provided file containing comments */
      Commentor(const QString &comfile) {
        init();
        if ( !comfile.isEmpty() ) {
          loadCommentFile(comfile);
        }
      }

      /** Destructor  */
      virtual ~Commentor() { }
       
      /** Returns full size of current comments internalized  */
      int size() const { return (_comComment.size() + _comSetComments.size()); }
      int size() const { return (m_comComment.size() + m_comSetComments.size()); }

      /**
       * @brief operator() method to collect comments from each segment
@@ -72,71 +67,34 @@ template <class K>
       * @param K Segment where specific comments are retreived
       */
      void operator()(const K &source)  {
         _comSetComments.append(source.getComment());
         return;
      }

      /** 
       * @brief Loads general comments from a given file 
       *
       * @internal
       * @history Debbie A. Cook - Added spkwriter signature keyword to user's
       *                           comment
       */
      void loadCommentFile(const QString &comFile) {
        _comComment = readCommentFile(comFile);
        // The following line was added to ensure that a
        // user's entered comment file includes the
        // keyword indicating an spkwriter-created kernel.
        _comComment += "  (ID:USGS_SPK_ABCORR=NONE)\n";
        _comFile = comFile;
         m_comSetComments.append(source.getComment());
         return;
      }

      /** Allows user to set comment header string */
      void setCommentHeader(const QString &comment) {
        _comComment = comment;
        m_comComment = comment;
        return;
      }

      /** Returns the current contents of the collected comments */
      QString comments() const { 
        return (_comComment + _comSetComments);
        return (m_comComment + m_comSetComments);
      }

      /** Clear out all comments collected for starting over */
      void Clear() {
        _comSetComments.clear();
        m_comSetComments.clear();
        return;
      }

    private:
      QString _comFile;
      QString _comComment;
      QString _comSetComments;

      /**
       * @brief Read comments from a file
       *  
       * This method reads a text file containing comments that will be written 
       * to the SPICE kernel written. 
       *                          
       * @return QString Returns contents of of comment file
       */
      QString readCommentFile(const QString comfile) {
        TextFile t(comfile);
        QString comment;
        QString cline;
        while ( t.GetLine(cline, false) ) {
          cline.push_back('\n');
          comment += cline;
        }
        return (comment);
      }
      QString m_comComment;
      QString m_comSetComments;

      /** Initialize setting all content to empty strings */
      void init() {
        _comFile = _comComment = _comSetComments = "";
        m_comComment = m_comSetComments = "";
      }
  };

+4 −4
Original line number Diff line number Diff line
@@ -118,8 +118,8 @@ class KernelWriter {

    /** Accumulate comment from K object and individed set */
    QString getComment(const K &kernels, const QString &comfile) {
      Commentor<SegmentType> commentor(comfile);
      if (comfile.isEmpty()) { commentor.setCommentHeader(k_header()); }
      Commentor<SegmentType> commentor;
      commentor.setCommentHeader(k_header(comfile));
      kernels.Accept(commentor);
      return (commentor.comments());
    }
@@ -129,14 +129,14 @@ class KernelWriter {
    virtual int k_open(const QString &kfile, const int &comsize = 512) = 0;
    virtual void k_write(const SpiceInt &handle, const K &kernels) = 0;
    virtual void k_close(SpiceInt &handle) = 0;
    virtual QString k_header() const = 0;
    virtual QString k_header(const QString &comfile = "") const = 0;

  private:
    SpiceInt    _handle;    ///< SPICE file handle


    /**
     * @brief WRite comments to output NAIF SPICE kernel.
     * @brief Write comments to output NAIF SPICE kernel.
     *
     * @return bool Returns success if so.
     */
+17 −8
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@
#include <functional>
#include <algorithm>

#include <QtGlobal>

#include "IString.h"
#include "IException.h"
#include "SpiceSegment.h"
@@ -93,7 +95,7 @@ template <typename K>
      virtual ~SpiceKernel() { }
  
      /** Returns the number of segments */
      int size() const { return (_segments.size()); }
      int size() const { return (m_segments.size()); }

      /**
       * Const iterator into list
@@ -101,7 +103,7 @@ template <typename K>
       * @return ConstSegmentIter Returns a const iterator to the list
       */
      ConstSegmentIter begin() const {
        return _segments.begin();
        return m_segments.begin();
      }

      /**
@@ -110,7 +112,7 @@ template <typename K>
       * @return ConstSegmentIter  Returns the const end of the list
       */
      ConstSegmentIter end() const {
        return _segments.end();
        return m_segments.end();
      }

      /**
@@ -119,7 +121,7 @@ template <typename K>
       * @return SegmentIter Returns an iterator on the collection
       */
      SegmentIter begin() {
        return _segments.begin();
        return m_segments.begin();
      }

      /**
@@ -129,7 +131,14 @@ template <typename K>
       *         of the iteration loop
       */
      SegmentIter end() {
        return _segments.end();
        return m_segments.end();
      }

      /** Return const reference to segment at index */
      const K &at(int index) const {
        Q_ASSERT(index >= 0);
        Q_ASSERT(index < size());
        return (m_segments[index]);
      }

      /**
@@ -141,8 +150,8 @@ template <typename K>
       * @param segment New segment to add to list
       */
      void add(const K &segment) {
        _segments.push_back(segment);
        std::stable_sort(_segments.begin(), _segments.end());
        m_segments.push_back(segment);
        std::stable_sort(m_segments.begin(), m_segments.end());
      }

      /**
@@ -186,7 +195,7 @@ template <typename K>


    private:
      SegmentList  _segments;  ///< List of arbitrary segments
      SegmentList  m_segments;  ///< List of arbitrary segments
  };


+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ void SpiceSegment::setId(const QString &name) {
}



/**
 * @brief Provide on-demand loading of a kernel type in the NAIF pool
 *
+23 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ namespace Isis {
   *                                 kernel as needing special light time and
   *                                 stellar aberration correction in spiceinit
   */
  QString SpkKernelWriter::k_header() const {
  QString SpkKernelWriter::k_header(const QString &comfile) const {
    ostringstream comment;
    comment << "\
 ****************************************************************************\n\
@@ -121,6 +121,28 @@ namespace Isis {
\n\
        The contents of this kernel are summarized below.\n\
\n\
User Comments\n\
-----------------------------------------------------------------------\n\
\n";

    // Now write any user comments provided
   if ( !comfile.isEmpty() ) {

     // Write user comment header
     TextFile txt(comfile);
     QString cline;
     while ( txt.GetLineNoFilter(cline )) {
       comment << cline << "\n";
     }
   }
   else {
     // None provided
     comment << "\
      NONE\n";
   }

   //  Finish comments for segement data
   comment << "\
 \n\
 Segment (by file) Summary\n\
 -----------------------------------------------------------------------\n\
Loading