diff --git a/modules/c++/six.sidd/include/six/sidd/DerivedData.h b/modules/c++/six.sidd/include/six/sidd/DerivedData.h index 5e65b10e6..091a4e9ca 100644 --- a/modules/c++/six.sidd/include/six/sidd/DerivedData.h +++ b/modules/c++/six.sidd/include/six/sidd/DerivedData.h @@ -69,7 +69,7 @@ struct DerivedData: public Data * Contains generic and extensible targeting and geographic * region information. */ - mem::ScopedCloneablePtr geographicAndTarget; + mem::ScopedCopyablePtr geographicAndTarget; /*! * Contains the meta-data necessary for performing @@ -189,7 +189,7 @@ struct DerivedData: public Data */ virtual LatLonCorners getImageCorners() const { - return geographicAndTarget->geographicCoverage->footprint; + return geographicAndTarget->geographicCoverage.footprint; } /*! @@ -198,7 +198,7 @@ struct DerivedData: public Data */ virtual void setImageCorners(const LatLonCorners& imageCorners) { - geographicAndTarget->geographicCoverage->footprint = imageCorners; + geographicAndTarget->geographicCoverage.footprint = imageCorners; } /*! diff --git a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h index 65f2d0d64..70b0a0beb 100644 --- a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h +++ b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h @@ -19,136 +19,120 @@ * see . * */ -#ifndef __SIX_GEOGRAPHIC_AND_TARGET_H__ -#define __SIX_GEOGRAPHIC_AND_TARGET_H__ - -#include - -#include "six/Types.h" -#include "six/Init.h" -#include "six/ParameterCollection.h" - -namespace six -{ -namespace sidd -{ -/*! - * \struct TargetInformation - * \brief SIDD TargetInformation grouping - * - * Provides target specific geographic information. - */ -struct TargetInformation -{ - //! SIDD Identifier set (min occurs zero, max unbounded) - ParameterCollection identifiers; - - //! SIDD Footprint: target footprint as defined by polygonal shape - LatLonCorners footprint; - - /*! - * (Optional) SIDD TargetInformationExtension - * Generic extension. Could be used to indicate type of target, - * terrain, etc. - */ - ParameterCollection targetInformationExtensions; - - - //! Clone any sub-objects if vectors are not empty - TargetInformation* clone() const; -}; - -/*! - * \struct GeographicInformation - * \brief SIDD GeographicInfo grouping - * - * Library name differs from spec. to keep API consistent - * The GeographicInformation object gives specifics about the geo-region - * - */ -struct GeographicInformation -{ - //! SIDD CountryCode Country code (1+) - std::vector countryCodes; - - //! SIDD SecurityInfo (name differs for API consistency) - std::string securityInformation; - - /*! - * SIDD GeographicInfoExtension (name differs for API consistency) - * Country identifier for this geographic region. - */ - ParameterCollection geographicInformationExtensions; - - //! Clone this element and its children - GeographicInformation* clone() const; -}; - -//! Note that subRegion and geographicInformation are mutually exclusive! -/*! - * \struct GeographicCoverage - * \brief SIDD SubRegion and GeographicCoverage element group - * - * This object contains the information associated with some geographic - * coverage - */ -class GeographicCoverage -{ -public: - //! This identifier determines if we are doing SubRegion or nesting - RegionType regionType; - - //! SIDD GeoregionIdentifier: an ID for the georegion - ParameterCollection georegionIdentifiers; - - /*! - * The estimated ground footprint of the product (note this is required - * and is used to set the image corners - */ - LatLonCorners footprint; - - //! SIDD SubRegion info, mutually exclusive with geographicInformation - std::vector > subRegion; - - //! SIDD: GeographicInfo, mutually exclusive with SubRegion - mem::ScopedCloneablePtr geographicInformation; - - //! Constructor requires a RegionType to properly initialize - GeographicCoverage(RegionType regionType); - - //! Carefully clones the sub-regions and geo information section - GeographicCoverage* clone() const; - -}; - -/*! - * \struct GeographicAndTarget - * \brief SIDD GoegraphicAndTarget block - * - * Contains generic and extensible targeting and geographic region - * information - * - */ -class GeographicAndTarget -{ -public: - //! SIDD GeographicCoverage: Provides geo coverage information - mem::ScopedCloneablePtr geographicCoverage; - - //! (Optional, Unbounded) Provides target specific geo information - std::vector > targetInformation; - - //! Constructor, auto-initializes coverage object - GeographicAndTarget(RegionType regionType) : - geographicCoverage(new GeographicCoverage(regionType)) - { - } - - //! Clones geo coverage and any targets - GeographicAndTarget* clone() const; -}; - -} -} -#endif +#ifndef __SIX_GEOGRAPHIC_AND_TARGET_H__ +#define __SIX_GEOGRAPHIC_AND_TARGET_H__ + +#include + +#include +#include +#include +#include + +namespace six +{ +namespace sidd +{ +/*! + * \struct TargetInformation + * \brief SIDD TargetInformation grouping + * + * Provides target specific geographic information. + */ +struct TargetInformation +{ + //! SIDD Identifier set (min occurs one, max unbounded) + ParameterCollection identifiers; + + //! (Optional) SIDD Footprint: target footprint as defined by polygonal shape + mem::ScopedCopyablePtr footprint; + + /*! + * (Optional) SIDD TargetInformationExtension + * Generic extension. Could be used to indicate type of target, + * terrain, etc. + */ + ParameterCollection targetInformationExtensions; +}; + +/*! + * \struct GeographicInformation + * \brief SIDD GeographicInfo grouping + * + * Library name differs from spec. to keep API consistent + * The GeographicInformation object gives specifics about the geo-region + * + */ +struct GeographicInformation +{ + //! SIDD CountryCode Country code (1+) + std::vector countryCodes; + + //! SIDD SecurityInfo (name differs for API consistency) + std::string securityInformation; + + /*! + * SIDD GeographicInfoExtension (name differs for API consistency) + * Country identifier for this geographic region. + */ + ParameterCollection geographicInformationExtensions; +}; + +//! Note that subRegion and geographicInformation are mutually exclusive! +/*! + * \struct GeographicCoverage + * \brief SIDD SubRegion and GeographicCoverage element group + * + * This object contains the information associated with some geographic + * coverage + */ +class GeographicCoverage +{ +public: + //! Constructor requires a RegionType to properly initialize + GeographicCoverage(RegionType regionType); + + //! This identifier determines if we are doing SubRegion or nesting + RegionType regionType; + + //! SIDD GeoregionIdentifier: an ID for the georegion + ParameterCollection georegionIdentifiers; + + /*! + * The estimated ground footprint of the product (note this is required + * and is used to set the image corners + */ + LatLonCorners footprint; + + //! SIDD SubRegion info, mutually exclusive with geographicInformation + std::vector > subRegion; + + //! SIDD: GeographicInfo, mutually exclusive with SubRegion + mem::ScopedCopyablePtr geographicInformation; +}; + +/*! + * \struct GeographicAndTarget + * \brief SIDD GoegraphicAndTarget block + * + * Contains generic and extensible targeting and geographic region + * information + * + */ +class GeographicAndTarget +{ +public: + //! Constructor requires a RegionType to properly initialize + GeographicAndTarget(RegionType regionType); + + //! SIDD GeographicCoverage: Provides geo coverage information + GeographicCoverage geographicCoverage; + + //! (Optional, Unbounded) Provides target specific geo information + std::vector > targetInformation; +}; +} +} + +#endif diff --git a/modules/c++/six.sidd/source/CropUtils.cpp b/modules/c++/six.sidd/source/CropUtils.cpp index 2df7fae46..07c342473 100644 --- a/modules/c++/six.sidd/source/CropUtils.cpp +++ b/modules/c++/six.sidd/source/CropUtils.cpp @@ -226,7 +226,7 @@ void cropSIDD(const std::string& inPathname, data->measurement->pixelFootprint.col = aoiDims.col; six::LatLonCorners& corners = - data->geographicAndTarget->geographicCoverage->footprint; + data->geographicAndTarget->geographicCoverage.footprint; corners.upperLeft = pixelToLatLon(aoiOffset.row, aoiOffset.col); corners.upperRight = pixelToLatLon(aoiOffset.row, lastCol); corners.lowerRight = pixelToLatLon(lastRow, lastCol); diff --git a/modules/c++/six.sidd/source/DerivedXMLParser.cpp b/modules/c++/six.sidd/source/DerivedXMLParser.cpp index d503fa3b3..d171591a4 100644 --- a/modules/c++/six.sidd/source/DerivedXMLParser.cpp +++ b/modules/c++/six.sidd/source/DerivedXMLParser.cpp @@ -611,7 +611,7 @@ void DerivedXMLParser::parseGeographicTargetFromXML( { parseGeographicCoverageFromXML( getFirstAndOnly(geographicAndTargetXML, "GeographicCoverage"), - geographicAndTarget->geographicCoverage.get()); + &geographicAndTarget->geographicCoverage); // optional to unbounded std::vector targetInfosXML; @@ -633,7 +633,10 @@ void DerivedXMLParser::parseGeographicTargetFromXML( // optional XMLElem tmpXML = getOptional(targetInfosXML[i], "Footprint"); if (tmpXML) - common().parseFootprint(tmpXML, "Vertex", ti->footprint); + { + ti->footprint.reset(new six::LatLonCorners()); + common().parseFootprint(tmpXML, "Vertex", *ti->footprint); + } // optional common().parseParameters(targetInfosXML[i], @@ -1264,22 +1267,25 @@ XMLElem DerivedXMLParser::convertGeographicTargetToXML( convertGeographicCoverageToXML( "GeographicCoverage", - geographicAndTarget->geographicCoverage.get(), + &geographicAndTarget->geographicCoverage, geographicAndTargetXML); // optional to unbounded - for (std::vector >:: + for (std::vector >:: const_iterator it = geographicAndTarget->targetInformation.begin(); it != geographicAndTarget->targetInformation.end(); ++it) { TargetInformation* ti = (*it).get(); XMLElem tiXML = newElement("TargetInformation", geographicAndTargetXML); - // 0 to unbounded + // 1 to unbounded common().addParameters("Identifier", ti->identifiers, tiXML); // optional - createFootprint("Footprint", "Vertex", ti->footprint, tiXML); + if (ti->footprint.get()) + { + createFootprint("Footprint", "Vertex", *ti->footprint, tiXML); + } // optional to unbounded common().addParameters("TargetInformationExtension", @@ -1334,7 +1340,7 @@ XMLElem DerivedXMLParser::convertGeographicCoverageToXML( else { //loop over SubRegions - for (std::vector >:: + for (std::vector >:: const_iterator it = geoCoverage->subRegion.begin(); it != geoCoverage->subRegion.end(); ++it) { diff --git a/modules/c++/six.sidd/source/GeographicAndTarget.cpp b/modules/c++/six.sidd/source/GeographicAndTarget.cpp index 42f72499e..500e3b049 100644 --- a/modules/c++/six.sidd/source/GeographicAndTarget.cpp +++ b/modules/c++/six.sidd/source/GeographicAndTarget.cpp @@ -19,36 +19,23 @@ * see . * */ -#include "six/sidd/GeographicAndTarget.h" - -using namespace six; -using namespace six::sidd; - -TargetInformation* TargetInformation::clone() const -{ - return new TargetInformation(*this); -} - -GeographicInformation* GeographicInformation::clone() const -{ - return new GeographicInformation(*this); -} - -GeographicCoverage::GeographicCoverage(RegionType rt) : - regionType(rt) -{ - //! TODO: add one to all one or more types - if (regionType == RegionType::GEOGRAPHIC_INFO) - geographicInformation.reset(new GeographicInformation()); -} - -GeographicCoverage* GeographicCoverage::clone() const -{ - return new GeographicCoverage(*this); -} - -GeographicAndTarget* GeographicAndTarget::clone() const -{ - return new GeographicAndTarget(*this); -} +#include "six/sidd/GeographicAndTarget.h" +namespace six +{ +namespace sidd +{ +GeographicCoverage::GeographicCoverage(RegionType rt) : + regionType(rt) +{ + //! TODO: add one to all one or more types + if (regionType == RegionType::GEOGRAPHIC_INFO) + geographicInformation.reset(new GeographicInformation()); +} + +GeographicAndTarget::GeographicAndTarget(RegionType regionType) : + geographicCoverage(regionType) +{ +} +} +}