DEIMOS
Earth Observation Mission CFI Software
Usage Guide for Object Oriented Software
ESA

WORKING EARTH OBSERVATION FILES

Introduction

While the FileHandling CFI library provides methods for reading and writting generic XML files, the DataHandling library contains classes to handle the files for the Earth Observation missions. The Earth Observation missions work with a set of files with data for the mission planning activities. These files have a predefined format common for all missions. The supported files are:

The file format and versions available for these files can be found in the DataHandling SUM for the C-library. Schemas and example files can also be found in the installation package.

The following sub-sections describe the operations that can be performed with the Earth Observation Files, that is, reading, writing and validating the files.


Classes for the Earth Observation Files

All the previous files have an associated class. These classes inherit from its parent abstract class EEFile. All the classes contain a set of public attributes that can be easily accessed to:

The classes allows the following methods:

Exceptions: The IERS Bulletin B file (class IersFile), the DEM files (class DemFile) and the TLE files (class TleFile) are external to the CFI and are not in XML format. They only contain methods for reading its data.


Reading Earth Observation Files

The calling sequence for reading a file is the following:

The user should be aware that:

See Example


Writting Earth Observation Files

Create a new Earth Observation File

The calling sequence for writing a file from scratch is the following:

Note that also it is possible to create the object with the filename:
   OsfFile myOsf("./cfi_files/my_osf");
or
   OsfFile myOsf;
   myOsf.fileName = "./cfi_files/my_osf";
In this case, it is not neccessary the filename in the write method:
   myOsf.write(fhr, osfList);

Modify an existing Earth Observation File

The calling sequence to modify an existing file is the following:

Setting the schema in an XML Earth Explorer File

The schema name and version can be written in an XML file in the following ways:

See Example


Validation of Earth Observation Files

The Earth Observation files in XML can be checked to verify that they are well formed. This validation process checks the format of a file with respect to its XSD schema. (The schemas are delivered within the CFI installation package (see [GEN_SUM]))

The calling sequence to validate a file is the following:

See Example


Example

// ------------------------------------------------------------------------
//
//                           C++ Example Program.
//                           HANDLING EARTH OBSERVATION FILES
//
// ------------------------------------------------------------------------

// Non-EOCFI include files
#include <string>
#include <vector>
#include <iostream>

// EOCFI includes
#include "EEFile.h"
#include "OsfFile.h"
#include "FixedHeader.h" 
#include "CfiError.h"
#include "DataHandlingData.h"


// Namespaces
using namespace EECFI;
using namespace std;

// Main program
int main (int argc, char *argv[])
{
  //-------------------------------------------------
  //-------------------------------------------------

  try
  {

    OsfFile myOsf;
    OsfFile copyOsf("./copy_of_osf.xml");

    //-------------------------------
    // Reading an Orbit Scenario File
    //-------------------------------

    myOsf.fileName = "./osf.xml";
    myOsf.read();

    // From now on, the data of the file can be accessed with the public 
    // attributes of the object.
    // For example, print the Absolute_Orbit number of the 2nd Orbit_Change:
    cout << "2nd. Absolute Orbit =" << myOsf.osfRec[2].absOrbit << endl;

    // Important: the Fixed header is not read with read()
    myOsf.readHeader();

    //----------------------------------
    // Writing a new Orbit Scenario File
    //----------------------------------

    copyOsf.write(*myOsf.fixedHeader, myOsf.osfRec);

    //------------------------------------
    // Modify the last Orbit Scenario File
    //------------------------------------

    // Change values in the object. For example:
    // add a comment to the "Notes" in the fixed header 
    // and the Absolute_Orbit in the first Orbit_Change

    myOsf.fixedHeader->fileClass="OPER";
    myOsf.osfRec[0].absOrbit = 250;

    copyOsf.write(*(myOsf.fixedHeader), myOsf.osfRec);

    //------------------------------------
    // Validate the file
    //------------------------------------
    long validStatus;
    string schema  = "./files/schemas/EO_OPER_MPL_SWTREF_0200.XSD";
    string logfile = "validation_log.txt";

    validStatus = myOsf.validate(schema, logfile);

    cout << "Validation Status for " << myOsf.fileName << (validStatus? "OK" : "FAIL") << endl;

  }//end try

  catch (CfiError cfiError)
  {
    //If an exception is thrown, there have been errors during execution
    vector<string> errorMessages;
    
    // Get error messages
    cfiError.getMsg(errorMessages);

    // Pring Error messages
    for (long i = 0; i < errorMessages.size(); i++)
    {
      cout << errorMessages[i] << endl;
    }
  }

  return 0;

}

Generated on Mon Dec 11 2023 13:28:37 for by  doxygen 1.7.1