Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPHD1.0.1 #294

Merged
merged 10 commits into from
Dec 9, 2019
Merged
1,163 changes: 1,163 additions & 0 deletions six/modules/c++/cphd/conf/schema/CPHD_schema_V1.0.1_2018_05_21.xsd

Large diffs are not rendered by default.

145 changes: 46 additions & 99 deletions six/modules/c++/cphd/include/cphd/CPHDXMLControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,10 @@

#include <memory>

#include <mem/SharedPtr.h>
#include <logging/Logger.h>
#include <xml/lite/Element.h>
#include <xml/lite/Document.h>
#include <six/XMLParser.h>
#include <six/SICommonXMLParser10x.h>
#include <cphd/SceneCoordinates.h>
#include <cphd/Data.h>
#include <cphd/Global.h>
#include <cphd/Metadata.h>
#include <cphd/PVP.h>
#include <cphd/ReferenceGeometry.h>
#include <cphd/CPHDXMLParser.h>
#include <cphd/Types.h>

namespace cphd
Expand All @@ -45,24 +37,31 @@ namespace cphd
* \class CPHDXMLControl
*
* \brief This class converts a Metadata object into a CPHD XML
* Document Object Model (DOM).
* Document Object Model (DOM) and vice-versa.
*/
class CPHDXMLControl : public six::XMLParser
class CPHDXMLControl
{
public:
/*!
* \func CPHDXMLControl
*
* \brief Default constructor
*
* \param log provide logger object
* \param ownLog flag indicates if log should be deleted
*/
CPHDXMLControl();
CPHDXMLControl(logging::Logger* log = nullptr, bool ownLog = false);

/*!
* \func CPHDXMLControl
//! Destructor
virtual ~CPHDXMLControl();

/*
* \func setLogger
* \brief Handles setting logger based on log provided and ownLog flag
*
* \brief Constructor with custom log option
* \param log provide logger object
* \param ownLog flag indicates if log should be deleted
*/
CPHDXMLControl(logging::Logger* log, bool ownLog);
void setLogger(logging::Logger* log, bool ownLog = false);

/*!
* \func toXMLString
Expand All @@ -71,7 +70,7 @@ class CPHDXMLControl : public six::XMLParser
* Calls toXML
* \return XML String
*/
std::string toXMLString(
virtual std::string toXMLString(
JonathanMeans marked this conversation as resolved.
Show resolved Hide resolved
const Metadata& metadata,
const std::vector<std::string>& schemaPaths = std::vector<std::string>(),
bool prettyPrint = false);
Expand All @@ -85,7 +84,7 @@ class CPHDXMLControl : public six::XMLParser
* \param schemaPaths Vector of XML Schema for validation
* \return pointer to xml Document object
*/
std::unique_ptr<xml::lite::Document> toXML(
virtual std::unique_ptr<xml::lite::Document> toXML(
const Metadata& metadata,
const std::vector<std::string>& schemaPaths = std::vector<std::string>());

Expand All @@ -99,7 +98,7 @@ class CPHDXMLControl : public six::XMLParser
*
* \return pointer to metadata object
*/
std::unique_ptr<Metadata> fromXML(
virtual std::unique_ptr<Metadata> fromXML(
const std::string& xmlString,
const std::vector<std::string>& schemaPaths = std::vector<std::string>());

Expand All @@ -113,92 +112,40 @@ class CPHDXMLControl : public six::XMLParser
*
* \return pointer to metadata object
*/
std::unique_ptr<Metadata> fromXML(
virtual std::unique_ptr<Metadata> fromXML(
const xml::lite::Document* doc,
const std::vector<std::string>& schemaPaths = std::vector<std::string>());

private:
typedef xml::lite::Element* XMLElem;
protected:
logging::Logger *mLog;
bool mOwnLog;

private:
static const char CPHD10_URI[];

//! Returns the default URI
std::string getDefaultURI() const;

//! Returns the URI to use with SI Common types
std::string getSICommonURI() const;

//! Write to XML object
XMLElem toXML(const CollectionInformation& obj, XMLElem parent);
XMLElem toXML(const Global& obj, XMLElem parent);
XMLElem toXML(const SceneCoordinates& obj, XMLElem parent);
XMLElem toXML(const Data& obj, XMLElem parent);
XMLElem toXML(const Channel& obj, XMLElem parent);
XMLElem toXML(const Pvp& obj, XMLElem parent);
XMLElem toXML(const SupportArray& obj, XMLElem parent);
XMLElem toXML(const Dwell& obj, XMLElem parent);
XMLElem toXML(const ReferenceGeometry& obj, XMLElem parent);
XMLElem toXML(const Antenna& obj, XMLElem parent);
XMLElem toXML(const TxRcv& obj, XMLElem parent);
XMLElem toXML(const ErrorParameters& obj, XMLElem parent);
XMLElem toXML(const ProductInfo& obj, XMLElem parent);
XMLElem toXML(const GeoInfo& obj, XMLElem parent);
XMLElem toXML(const MatchInformation& obj, XMLElem parent);

//! Read from XML object
void fromXML(const XMLElem collectionIDXML, CollectionInformation& collectionID);
void fromXML(const XMLElem globalXML, Global& global);
void fromXML(const XMLElem sceneCoordsXML, SceneCoordinates& scene);
void fromXML(const XMLElem dataXML, Data& data);
void fromXML(const XMLElem channelXML, Channel& channel);
void fromXML(const XMLElem pvpXML, Pvp& pvp);
void fromXML(const XMLElem DwellXML, Dwell& dwell);
void fromXML(const XMLElem refGeoXML, ReferenceGeometry& refGeo);
void fromXML(const XMLElem supportArrayXML, SupportArray& supportArray);
void fromXML(const XMLElem antennaXML, Antenna& antenna);
void fromXML(const XMLElem txRcvXML, TxRcv& txRcv);
void fromXML(const XMLElem errParamXML, ErrorParameters& errParam);
void fromXML(const XMLElem productInfoXML, ProductInfo& productInfo);
void fromXML(const XMLElem geoInfoXML, GeoInfo& geoInfo);
void fromXML(const XMLElem matchInfoXML, MatchInformation& matchInfo);


//! Create helper functions
XMLElem createLatLonFootprint(const std::string& name,
const std::string& cornerName,
const cphd::LatLonCorners& corners,
XMLElem parent) const;
XMLElem createPVPType(const std::string& name,
const PVPType& p,
XMLElem parent) const;
XMLElem createAPVPType(const std::string& name,
const APVPType& p,
XMLElem parent) const;

XMLElem createErrorParamPlatform(const std::string& name,
const ErrorParameters::Bistatic::Platform p,
XMLElem parent) const;
/*!
* This function takes in a Metadata object and converts
* it to a new-allocated XML DOM.
*
* \param data A Metadata object
* \return An XML DOM
*/
virtual std::unique_ptr<xml::lite::Document> toXMLImpl(const Metadata& metadata);

//! Parse helper functions
void parseAreaType(const XMLElem areaXML, AreaType& area) const;
void parseLineSample(const XMLElem lsXML, LineSample& ls) const;
void parseIAExtent(const XMLElem extentXML, ImageAreaXExtent& extent) const;
void parseIAExtent(const XMLElem extentXML, ImageAreaYExtent& extent) const;
void parseChannelParameters(const XMLElem paramXML,
ChannelParameter& param) const;
void parsePVPType(Pvp& p, const XMLElem paramXML, PVPType& param) const;
void parsePVPType(Pvp& p, const XMLElem paramXML) const;
void parsePlatformParams(const XMLElem platXML, Bistatic::PlatformParams& plat) const;
void parseCommon(const XMLElem imgTypeXML, ImagingType* imgType) const;
void parsePosVelErr(const XMLElem posVelErrXML, six::PosVelError& posVelErr) const;
void parsePlatform(const XMLElem platXML, ErrorParameters::Bistatic::Platform& plat) const;
void parseSupportArrayParameter(const XMLElem paramXML, SupportArrayParameter& param,
bool additionalFlag) const;
void parseTxRcvParameter(const XMLElem paramXML, ParameterType& param) const;
/*!
* Function takes a DOM Document* node and creates a new-allocated
* ComplexData* populated by the DOM.
*
* \param doc An XML document pointer
* \return A Metadata object
*/
virtual std::unique_ptr<Metadata> fromXMLImpl(const xml::lite::Document* doc);

private:
six::SICommonXMLParser10x mCommon;
/*
* \Function creates a new parser to parse XML or document
*
* \param uri A string specifying CPHD uri
*/
std::unique_ptr<CPHDXMLParser>
getParser(const std::string& uri) const;
};
}

Expand Down
170 changes: 170 additions & 0 deletions six/modules/c++/cphd/include/cphd/CPHDXMLParser.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/* =========================================================================
* This file is part of cphd-c++
* =========================================================================
*
* (C) Copyright 2004 - 2019, MDA Information Systems LLC
*
* cphd-c++ is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; If not,
* see <http://www.gnu.org/licenses/>.
*
*/

#ifndef __CPHD_CPHD_XML_PARSER_H__
#define __CPHD_CPHD_XML_PARSER_H__

#include <memory>

#include <mem/SharedPtr.h>
#include <logging/Logger.h>
#include <xml/lite/Element.h>
#include <xml/lite/Document.h>
#include <six/XMLParser.h>
#include <six/SICommonXMLParser10x.h>
#include <cphd/SceneCoordinates.h>
#include <cphd/Data.h>
#include <cphd/Global.h>
#include <cphd/Metadata.h>
#include <cphd/PVP.h>
#include <cphd/ReferenceGeometry.h>
#include <cphd/Types.h>

namespace cphd
{
/*!
* \class CPHDXMLParser
*
* \brief This class converts a Metadata object into a CPHD XML
* Document Object Model (DOM) and vise-versa.
*/
class CPHDXMLParser : public six::XMLParser
{
public:
/*!
* \func CPHDXMLParser
* \brief Constructor
*
* \param uri CPHD file uri string
* \param addClassAttributes flag indicates whether to add as attribute
* \param log provide logger object
* \param ownLog flag indicates if log should be deleted
*/
CPHDXMLParser(const std::string& uri,
bool addClassAttributes,
logging::Logger* log = nullptr,
bool ownLog = false);

/*!
* \func toXML
*
* \brief Convert metadata to XML document object
*
* \param metadata Valid CPHD metadata object
* \param schemaPaths Vector of XML Schema for validation
* \return pointer to xml Document object
*/
std::unique_ptr<xml::lite::Document> toXML(
const Metadata& metadata);

/*!
* \func fromXML
*
* \brief Parse XML document to Metadata object
*
* \param doc XML document object of CPHD
* \param schemaPaths Vector of XML Schema for validation
*
* \return pointer to metadata object
*/
std::unique_ptr<Metadata> fromXML(
const xml::lite::Document* doc);

private:
typedef xml::lite::Element* XMLElem;

private:

//! Write to XML object
XMLElem toXML(const CollectionInformation& obj, XMLElem parent);
XMLElem toXML(const Global& obj, XMLElem parent);
XMLElem toXML(const SceneCoordinates& obj, XMLElem parent);
XMLElem toXML(const Data& obj, XMLElem parent);
XMLElem toXML(const Channel& obj, XMLElem parent);
XMLElem toXML(const Pvp& obj, XMLElem parent);
XMLElem toXML(const SupportArray& obj, XMLElem parent);
XMLElem toXML(const Dwell& obj, XMLElem parent);
XMLElem toXML(const ReferenceGeometry& obj, XMLElem parent);
XMLElem toXML(const Antenna& obj, XMLElem parent);
XMLElem toXML(const TxRcv& obj, XMLElem parent);
XMLElem toXML(const ErrorParameters& obj, XMLElem parent);
XMLElem toXML(const ProductInfo& obj, XMLElem parent);
XMLElem toXML(const GeoInfo& obj, XMLElem parent);
XMLElem toXML(const MatchInformation& obj, XMLElem parent);

//! Read from XML object
void fromXML(const XMLElem collectionIDXML, CollectionInformation& collectionID);
void fromXML(const XMLElem globalXML, Global& global);
void fromXML(const XMLElem sceneCoordsXML, SceneCoordinates& scene);
void fromXML(const XMLElem dataXML, Data& data);
void fromXML(const XMLElem channelXML, Channel& channel);
void fromXML(const XMLElem pvpXML, Pvp& pvp);
void fromXML(const XMLElem DwellXML, Dwell& dwell);
void fromXML(const XMLElem refGeoXML, ReferenceGeometry& refGeo);
void fromXML(const XMLElem supportArrayXML, SupportArray& supportArray);
void fromXML(const XMLElem antennaXML, Antenna& antenna);
void fromXML(const XMLElem txRcvXML, TxRcv& txRcv);
void fromXML(const XMLElem errParamXML, ErrorParameters& errParam);
void fromXML(const XMLElem productInfoXML, ProductInfo& productInfo);
void fromXML(const XMLElem geoInfoXML, GeoInfo& geoInfo);
void fromXML(const XMLElem matchInfoXML, MatchInformation& matchInfo);


//! Create helper functions
XMLElem createLatLonFootprint(const std::string& name,
const std::string& cornerName,
const cphd::LatLonCorners& corners,
XMLElem parent) const;
XMLElem createPVPType(const std::string& name,
const PVPType& p,
XMLElem parent) const;
XMLElem createAPVPType(const std::string& name,
const APVPType& p,
XMLElem parent) const;

XMLElem createErrorParamPlatform(const std::string& name,
const ErrorParameters::Bistatic::Platform p,
XMLElem parent) const;

//! Parse helper functions
void parseAreaType(const XMLElem areaXML, AreaType& area) const;
void parseLineSample(const XMLElem lsXML, LineSample& ls) const;
void parseIAExtent(const XMLElem extentXML, ImageAreaXExtent& extent) const;
void parseIAExtent(const XMLElem extentXML, ImageAreaYExtent& extent) const;
void parseChannelParameters(const XMLElem paramXML,
ChannelParameter& param) const;
void parsePVPType(Pvp& p, const XMLElem paramXML, PVPType& param) const;
void parsePVPType(Pvp& p, const XMLElem paramXML) const;
void parsePlatformParams(const XMLElem platXML, Bistatic::PlatformParams& plat) const;
void parseCommon(const XMLElem imgTypeXML, ImagingType* imgType) const;
void parsePosVelErr(const XMLElem posVelErrXML, six::PosVelError& posVelErr) const;
void parsePlatform(const XMLElem platXML, ErrorParameters::Bistatic::Platform& plat) const;
void parseSupportArrayParameter(const XMLElem paramXML, SupportArrayParameter& param,
bool additionalFlag) const;
void parseTxRcvParameter(const XMLElem paramXML, ParameterType& param) const;

private:
six::SICommonXMLParser10x mCommon;
};
}

#endif
6 changes: 6 additions & 0 deletions six/modules/c++/cphd/include/cphd/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ struct Metadata : MetadataBase
size_t getCompressedSignalSize(size_t channel) const override;
bool isCompressed() const override;

std::string getUri() const;
vkrishna1997 marked this conversation as resolved.
Show resolved Hide resolved
void setUri(const std::string& version);

//! CollectionInfo block. Contains the general collection information
//! CPHD can use the SICD Collection Information block directly
Expand Down Expand Up @@ -136,6 +138,10 @@ struct Metadata : MetadataBase
{
return !((*this) == other);
}

private:
//! Stores file URI
std::string mUri;
};

//! Ostream operator
Expand Down
Loading