Commit a085f2d6 authored by Kristin's avatar Kristin Committed by Summer Stapleton
Browse files

Updates to tgocassisrdrgen and ProcessExportPds4 to add content to exported CaSSIS Label. (#2858)

* Add 32-bit ISIS Special Pixel Constants to ProcessExportPds4

* Add ability to set title and version id in exported PDS4 produce in tgocassisrdrgen and ProcessExportPds4 API

* Fix bug that occurs when exporting mosaics with Archive groups and fixed min/max lat/lon to east/west bounding box positive east flip bug

* Added docs.

* Update schema to most recent versions and comment-out schema that isn't used (temporarily) in tgocassisrdrgen.
parent 22016b7e
Loading
Loading
Loading
Loading
+88 −19
Original line number Diff line number Diff line
@@ -47,6 +47,9 @@ namespace Isis {
  ProcessExportPds4::ProcessExportPds4() {

    m_lid = "";
    m_versionId = "";
    m_title = "";

    m_imageType = StandardImage;

    qSetGlobalQHashSeed(1031); // hash seed to force consistent output
@@ -61,10 +64,10 @@ namespace Isis {
    m_domDoc->appendChild(xmlHeader);

    // base pds4 schema location
    m_schemaLocation = "http://pds.nasa.gov/pds4/pds/v1 http://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1800.xsd"; 
    m_schemaLocation = "http://pds.nasa.gov/pds4/pds/v1 http://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1B00.xsd"; 

    QString xmlModel;
    xmlModel += "href=\"http://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1800.sch\" ";
    xmlModel += "href=\"http://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1B00.sch\" ";
    xmlModel += "schematypens=\"http://purl.oclc.org/dsdl/schematron\"";
    QDomProcessingInstruction header =
        m_domDoc->createProcessingInstruction("xml-model", xmlModel);
@@ -319,6 +322,39 @@ namespace Isis {
  }


  /**
   * Allows mission specific programs to set version_id
   * required for PDS4 labels. This value is added to the xml file 
   * by the identificationArea() method. 
   *  
   * The input string should be colon separated string with 6 
   * identifiers: 
   *  
   * @author 2019-03-01 Kristin Berry
   * 
   * @param versiondId The version_id value required for PDS4 
   *            compliant labels.
   */
   void ProcessExportPds4::setVersionId(QString versionId) {
    m_versionId = versionId;
  }


  /**
   * Allows mission specific programs to set the title
   * required for PDS4 labels. This value is added to the xml file 
   * by the identificationArea() method. 
   *  
   * @author 2019-03-01 Kristin Berry
   * 
   * @param title The title value required for PDS4 
   *            compliant labels.
   */
   void ProcessExportPds4::setTitle(QString title) {
    m_title = title;
  }


  /**
   * Allows mission specific programs to use specified 
   * versions of dictionaries. 
@@ -366,6 +402,16 @@ namespace Isis {
    QDomElement lidElement = identificationElement.firstChildElement("logical_identifier");
    PvlToXmlTranslationManager::resetElementValue(lidElement, m_lid);

    if (m_versionId != "") {
      QDomElement versionElement = identificationElement.firstChildElement("version_id"); 
      PvlToXmlTranslationManager::resetElementValue(versionElement, m_versionId);
    }

    if (m_title != "") {
      QDomElement titleElement = identificationElement.firstChildElement("title"); 
      PvlToXmlTranslationManager::resetElementValue(titleElement, m_title);
    }

    // Get export history and add <Modification_History> element.
    // These regular expressions match the pipe followed by the date from
    // the Application::Version() return value.
@@ -386,18 +432,17 @@ namespace Isis {
   * the PDS4 labels. 
   */
  void ProcessExportPds4::displaySettings() {
    // Add header info
    addSchema("PDS4_DISP_1B00.sch", 
              "PDS4_DISP_1B00.xsd",
              "xmlns:disp", 
              "http://pds.nasa.gov/pds4/disp/v1"); 

    Pvl *inputLabel = InputCubes[0]->label(); 
    FileName translationFileName;
    translationFileName = "$base/translations/pds4ExportDisplaySettings.trn";
    PvlToXmlTranslationManager xlator(*inputLabel, translationFileName.expanded());
    xlator.Auto(*m_domDoc);

    // Add header info
    addSchema("PDS4_DISP_1700.sch", 
              "PDS4_DISP_1700.xsd",
              "xmlns:disp", 
              "http://pds.nasa.gov/pds4/disp/v1"); 
  }

  
@@ -409,8 +454,8 @@ namespace Isis {
    Pvl *inputLabel = InputCubes[0]->label(); 
    if ( !inputLabel->findObject("IsisCube").hasGroup("BandBin") ) return;
    // Add header info
    addSchema("PDS4_IMG_1900.sch", 
              "PDS4_IMG_1900.xsd",
    addSchema("PDS4_IMG_1A10_1510.sch", 
              "PDS4_IMG_1A10_1510.xsd",
              "xmlns:img", 
              "http://pds.nasa.gov/pds4/img/v1"); 
    
@@ -754,6 +799,33 @@ namespace Isis {
                                                    toString(base));
        elementArrayElement.appendChild(offsetElement);
      }

      // Add the Special_Constants class to define ISIS special pixel values: 

      // Assume 32-bit/Real for CaSSIS
      QDomElement specialConstantElement = m_domDoc->createElement("Special_Constants");
      arrayImageElement.insertAfter(specialConstantElement,
                                    arrayImageElement.lastChildElement("Axis_Array"));

      QDomElement nullElement = m_domDoc->createElement("missing_constant");
      PvlToXmlTranslationManager::setElementValue(nullElement, QString::number(NULL8, 'g', 18)); //toString(NULL8));
      specialConstantElement.appendChild(nullElement);

      QDomElement highInstrumentSatElement = m_domDoc->createElement("high_instrument_saturation");
      PvlToXmlTranslationManager::setElementValue(highInstrumentSatElement, QString::number(HIGH_INSTR_SAT8, 'g', 18));
      specialConstantElement.appendChild(highInstrumentSatElement);

      QDomElement highRepresentationSatElement = m_domDoc->createElement("high_representation_saturation");
      PvlToXmlTranslationManager::setElementValue(highRepresentationSatElement, QString::number(HIGH_REPR_SAT8, 'g', 18));
      specialConstantElement.appendChild(highRepresentationSatElement);

      QDomElement lowInstrumentSatElement = m_domDoc->createElement("low_instrument_saturation");
      PvlToXmlTranslationManager::setElementValue(lowInstrumentSatElement, QString::number(LOW_INSTR_SAT8, 'g', 18));
      specialConstantElement.appendChild(lowInstrumentSatElement);

      QDomElement lowRepresentationSatElement = m_domDoc->createElement("low_representation_saturation");
      PvlToXmlTranslationManager::setElementValue(lowRepresentationSatElement, QString::number(LOW_REPR_SAT8, 'g', 18));
      specialConstantElement.appendChild(lowRepresentationSatElement);
    }
  }

@@ -904,8 +976,8 @@ namespace Isis {
        !(inputLabel->findObject("IsisCube").hasGroup("Mapping"))) return;
    PvlGroup &inputMapping = inputLabel->findGroup("Mapping", Pvl::Traverse);

    addSchema("PDS4_CART_1700.sch", 
              "PDS4_CART_1700.xsd",
    addSchema("PDS4_CART_1900.sch", 
              "PDS4_CART_1900.xsd",
              "xmlns:cart", 
              "http://pds.nasa.gov/pds4/cart/v1"); 

@@ -984,7 +1056,6 @@ namespace Isis {
              << "Observation_Area" 
              << "Discipline_Area"
              << "cart:Cartography" 
              << "cart:Map_Projection" 
              << "cart:Spatial_Domain"
              << "cart:Bounding_Coordinates";
      QDomElement boundingCoordElement = getElement(xmlPath, baseElement);
@@ -999,8 +1070,6 @@ namespace Isis {
        PvlToXmlTranslationManager::resetElementValue(westElement, toString(minLon), "deg");
      }
    }


  }


+7 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@ namespace Isis {
   *                           attributes to elements. Matches pds validate tool specifations.
   *   @history 2018-06-12 Kristin Berry - Added schema associated with the img class when it is
   *                           used.
   *   @history 2019-03-01 Kristin Berry - Added ability to set version_id and title, added
   *                           Special_Constants to define ISIS special pixel values, fixed east/west
   *                           bounding coordinates swap bug. Fixes git issue #2635.
   */

  class ProcessExportPds4: public Isis::ProcessExport {
@@ -108,6 +111,8 @@ namespace Isis {
      QDomElement getElement(QStringList xmlPath, QDomElement parent=QDomElement());
      void addHistory(QString description, QString date = "tbd", QString version = "1.0");
      void setLogicalId(QString lid);
      void setVersionId(QString versionId);
      void setTitle(QString title);
      void setSchemaLocation(QString schema);
      void setImageType(ImageType imageType);

@@ -131,6 +136,8 @@ namespace Isis {
      QDomDocument *m_domDoc;               //!< XML label.
      QString m_schemaLocation;             //!< QString with all schema locations required.
      QString m_lid;                        //!< QString with specified logical identifier.
      QString m_versionId;                  //!< QString with specified version id.
      QString m_title;                      //!< QString with specified title. 
      ImageType m_imageType;                //!< Type of image data to be written.

  };
+20 −10
Original line number Diff line number Diff line
@@ -71,14 +71,14 @@ void IsisMain() {
    // Get the observationId from the Archive Group, or the Mosaic group, if the input is a mosaic
    QString observationId;

    if(label->findObject("IsisCube").hasGroup("Archive")){
      PvlGroup archiveGroup = label->findObject("IsisCube").findGroup("Archive");
      observationId = archiveGroup.findKeyword("ObservationId")[0];
    }
    else if (label->findObject("IsisCube").hasGroup("Mosaic")) {
    if (label->findObject("IsisCube").hasGroup("Mosaic")) {
      PvlGroup mosaicGroup = label->findObject("IsisCube").findGroup("Mosaic");
      observationId = mosaicGroup.findKeyword("ObservationId")[0];
    }
    else if(label->findObject("IsisCube").hasGroup("Archive")){
      PvlGroup archiveGroup = label->findObject("IsisCube").findGroup("Archive");
      observationId = archiveGroup.findKeyword("ObservationId")[0];
    }
    productId.setValue(observationId);
  }

@@ -86,10 +86,20 @@ void IsisMain() {
  logicalId += productId[0];
  process.setLogicalId(logicalId);

  // Set Title
  if ( ui.WasEntered("TITLE") ) {
    process.setTitle( ui.GetString("TITLE") );
  }

  // Set Version ID
  if ( ui.WasEntered("VERSIONID") ) {
    process.setVersionId( ui.GetString("VERSIONID") );
  }

  // std PDS4 label
  process.StandardPds4Label();

  process.addSchema("PDS4_PSA_1000.sch", 
/*  process.addSchema("PDS4_PSA_1000.sch", 
                    "PDS4_PSA_1000.xsd",
                    "xmlns:psa", 
                    "http://psa.esa.int/psa/v1");
@@ -97,12 +107,12 @@ void IsisMain() {
  process.addSchema("PDS4_PSA_EM16_CAS_1000.sch", 
                    "PDS4_PSA_EM16_CAS_1000.xsd",
                    "xmlns",
                    "http://psa.esa.int/psa/em16/cas/v1");
                    "http://psa.esa.int/psa/em16/cas/v1");*/

  // Add geometry schema for mosaics
  if (label->findObject("IsisCube").hasGroup("Mosaic")) {
    process.addSchema("PDS4_GEOM_1900_1510.sch", 
                      "PDS4_GEOM_1900_1510.xsd",
    process.addSchema("PDS4_GEOM_1B00_1610.sch", 
                      "PDS4_GEOM_1B00_1610.xsd",
                      "xmlns:geom",
                      "https://pds.jpl.nasa.gov/datastandards/schema/released/geom/v1");
  }
+24 −0
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@
    <change name="Kristin Berry" date="2018-06-12">
      Updated to use the tgoCassisExportMosaic.trn translation file when the input cube is a mosaic.
    </change>
    <change name="Kristin Berry" date="2019-03-01">
      Added TITLE and VERSIONID optional parameters to specify these values in the exported PDS4 label. 
      Fixed bug that disabled reading of mosaics with Archive groups. 
    </change>
  </history>

  <category>
@@ -89,6 +93,26 @@
          Update the default Product ID value. This value will be the last section of the PDS4 logical_identifier value.
        </description>
      </parameter>
      <parameter name="TITLE">
        <type>string</type>
        <internalDefault>None</internalDefault>
        <brief>
          Product ID value
        </brief>
        <description>
          Update the default Title value. 
        </description>
      </parameter>
      <parameter name="VERSIONID">
        <type>string</type>
        <internalDefault>None</internalDefault>
        <brief>
          Product ID value
        </brief>
        <description>
          Update the default Version ID value. 
        </description>
      </parameter>
    </group>

  </groups>