diff --git a/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.cpp b/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.cpp index f6830d10cf..ab4637f7a9 100644 --- a/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.cpp +++ b/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.cpp @@ -235,7 +235,6 @@ namespace Isis { QString timeValue = stopTime.text(); PvlToXmlTranslationManager::resetElementValue(stopTime, timeValue + "Z"); } - } QDomElement obsSysNode = obsAreaNode.firstChildElement("Observing_System"); @@ -277,14 +276,12 @@ namespace Isis { // move target to just below Observing_System. QDomElement targetIdNode = obsAreaNode.firstChildElement("Target_Identification"); obsAreaNode.insertAfter(targetIdNode, obsAreaNode.firstChildElement("Observing_System")); - } else if (inputLabel->findObject("IsisCube").hasGroup("Mapping")) { translationFileName = "$base/translations/pds4ExportTargetFromMapping.trn"; PvlToXmlTranslationManager targXlator(*inputLabel, translationFileName.expanded()); targXlator.Auto(*m_domDoc); - } else { throw IException(IException::Unknown, "Unable to find a target in input cube.", _FILEINFO_); @@ -292,11 +289,72 @@ namespace Isis { } + /** + * This method reorders the existing m_domDoc to follow PDS4 standards and fixes time formatting + * if needed. + */ + void ProcessExportPds4::reorder() { + QDomElement obsAreaNode = m_domDoc->documentElement().firstChildElement("Observation_Area"); + if ( !obsAreaNode.isNull() ) { + + // fix start/stop times, if needed + QDomElement timeNode = obsAreaNode.firstChildElement("Time_Coordinates"); + if (!timeNode.isNull()) { + QDomElement startTime = timeNode.firstChildElement("start_date_time"); + if (startTime.text() == "") { + startTime.setAttribute("xsi:nil", "true"); + } + else { + QString timeValue = startTime.text(); + PvlToXmlTranslationManager::resetElementValue(startTime, timeValue + "Z"); + } + QDomElement stopTime = timeNode.firstChildElement("stop_date_time"); + if (stopTime.text() == "") { + stopTime.setAttribute("xsi:nil", "true"); + } + else { + QString timeValue = stopTime.text(); + PvlToXmlTranslationManager::resetElementValue(stopTime, timeValue + "Z"); + } + } + QDomElement investigationAreaNode = obsAreaNode.firstChildElement("Investigation_Area"); + obsAreaNode.insertAfter(investigationAreaNode, obsAreaNode.firstChildElement("Time_Coordinates")); + + QDomElement obsSystemNode = obsAreaNode.firstChildElement("Observing_System"); + obsAreaNode.insertAfter(obsSystemNode, obsAreaNode.firstChildElement("Investigation_Area")); + + QDomElement targetIdNode = obsAreaNode.firstChildElement("Target_Identification"); + obsAreaNode.insertAfter(targetIdNode, obsAreaNode.firstChildElement("Observing_System")); + + QDomElement missionAreaNode = obsAreaNode.firstChildElement("Mission_Area"); + obsAreaNode.insertAfter(missionAreaNode, obsAreaNode.firstChildElement("Target_Identification")); + + QDomElement disciplineAreaNode = obsAreaNode.firstChildElement("Discipline_Area"); + obsAreaNode.insertAfter(disciplineAreaNode, obsAreaNode.firstChildElement("Mission_Area")); + } + + QDomElement identificationAreaNode = m_domDoc->documentElement().firstChildElement("Identification_Area"); + if ( !identificationAreaNode.isNull() ) { + QDomElement aliasListNode = identificationAreaNode.firstChildElement("Alias_List"); + identificationAreaNode.insertAfter(aliasListNode, identificationAreaNode.firstChildElement("product_class")); + } + + QDomElement fileAreaObservationalNode = m_domDoc->documentElement().firstChildElement("File_Area_Observational"); + QDomElement array2DImageNode = fileAreaObservationalNode.firstChildElement("Array_2D_Image"); + if ( !array2DImageNode.isNull() ) { + QDomElement descriptionNode = array2DImageNode.firstChildElement("description"); + array2DImageNode.insertAfter(descriptionNode, array2DImageNode.firstChildElement("axis_index_order")); + } + } + /** * Allows mission specific programs to set logical_identifier * required for PDS4 labels. This value is added to the xml file * by the identificationArea() method. * + * The input value will be converted to all-lowercase if not already + * in line with PDS4 requirements. + * * The input string should be colon separated string with 6 * identifiers: * @@ -318,7 +376,7 @@ namespace Isis { * compliant labels. */ void ProcessExportPds4::setLogicalId(QString lid) { - m_lid = lid; + m_lid = lid.toLower(); } @@ -355,7 +413,7 @@ namespace Isis { } - /** + /** * Allows mission specific programs to use specified * versions of dictionaries. * diff --git a/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.h b/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.h index 5631803c23..8d4a64b247 100644 --- a/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.h +++ b/isis/src/base/objs/ProcessExportPds4/ProcessExportPds4.h @@ -118,7 +118,7 @@ namespace Isis { static void translateUnits(QDomDocument &label, QString transMapFile = "$base/translations/pds4ExportUnits.pvl"); - + void reorder(); void addSchema(QString sch, QString xsd, QString xmlns, QString xmlnsURI) ; protected: void identificationArea(); diff --git a/isis/src/tgo/apps/tgocassisrdrgen/main.cpp b/isis/src/tgo/apps/tgocassisrdrgen/main.cpp index 0619ae215b..2b56f80c84 100644 --- a/isis/src/tgo/apps/tgocassisrdrgen/main.cpp +++ b/isis/src/tgo/apps/tgocassisrdrgen/main.cpp @@ -109,6 +109,10 @@ void IsisMain() { "xmlns", "http://psa.esa.int/psa/em16/cas/v1");*/ + process.addSchema("CASSIS_1010.sch", + "CASSIS_1010.xsd", + "xmlns:cassis", + "local"); // Add geometry schema for mosaics if (label->findObject("IsisCube").hasGroup("Mosaic")) { process.addSchema("PDS4_GEOM_1B00_1610.sch", @@ -117,7 +121,6 @@ void IsisMain() { "https://pds.jpl.nasa.gov/datastandards/schema/released/geom/v1"); } - /* * Add additional pds label data here */ @@ -135,6 +138,7 @@ void IsisMain() { cubeLab.Auto(pdsLabel); ProcessExportPds4::translateUnits(pdsLabel); + process.reorder(); QString outFile = ui.GetFileName("TO");