From 066313469d9801709d87f04191ca395d3bc32394 Mon Sep 17 00:00:00 2001 From: Adam Sylvester Date: Tue, 11 Aug 2015 12:57:23 -0400 Subject: [PATCH 1/3] GeographicAndTarget\TargetInformation\Footprint is optional but the previous implementation was always adding it in when writing. Made this a pointer to represent optional. --- .../include/six/sidd/GeographicAndTarget.h | 15 ++++++++------- modules/c++/six.sidd/source/DerivedXMLParser.cpp | 12 +++++++++--- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h index 65f2d0d64..8a5235088 100644 --- a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h +++ b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h @@ -23,10 +23,11 @@ #define __SIX_GEOGRAPHIC_AND_TARGET_H__ #include - -#include "six/Types.h" -#include "six/Init.h" -#include "six/ParameterCollection.h" + +#include +#include +#include +#include namespace six { @@ -40,11 +41,11 @@ namespace sidd */ struct TargetInformation { - //! SIDD Identifier set (min occurs zero, max unbounded) + //! SIDD Identifier set (min occurs one, max unbounded) ParameterCollection identifiers; - //! SIDD Footprint: target footprint as defined by polygonal shape - LatLonCorners footprint; + //! (Optional) SIDD Footprint: target footprint as defined by polygonal shape + mem::ScopedCopyablePtr footprint; /*! * (Optional) SIDD TargetInformationExtension diff --git a/modules/c++/six.sidd/source/DerivedXMLParser.cpp b/modules/c++/six.sidd/source/DerivedXMLParser.cpp index d503fa3b3..562f2ce60 100644 --- a/modules/c++/six.sidd/source/DerivedXMLParser.cpp +++ b/modules/c++/six.sidd/source/DerivedXMLParser.cpp @@ -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], @@ -1275,11 +1278,14 @@ XMLElem DerivedXMLParser::convertGeographicTargetToXML( 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", From 39551c076f6d4cad8cf57f25ba5be38293b2bb91 Mon Sep 17 00:00:00 2001 From: Adam Sylvester Date: Tue, 11 Aug 2015 13:33:13 -0400 Subject: [PATCH 2/3] Replacing clone() methods with compiler-generated copy constructors where possible --- .../six.sidd/include/six/sidd/DerivedData.h | 6 +-- .../include/six/sidd/GeographicAndTarget.h | 45 ++++++------------- modules/c++/six.sidd/source/CropUtils.cpp | 2 +- .../c++/six.sidd/source/DerivedXMLParser.cpp | 8 ++-- .../six.sidd/source/GeographicAndTarget.cpp | 33 +++++--------- 5 files changed, 32 insertions(+), 62 deletions(-) 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 8a5235088..865d3690e 100644 --- a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h +++ b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h @@ -53,10 +53,6 @@ struct TargetInformation * terrain, etc. */ ParameterCollection targetInformationExtensions; - - - //! Clone any sub-objects if vectors are not empty - TargetInformation* clone() const; }; /*! @@ -80,9 +76,6 @@ struct GeographicInformation * 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! @@ -95,7 +88,10 @@ struct GeographicInformation */ class GeographicCoverage { -public: +public: + //! Constructor requires a RegionType to properly initialize + GeographicCoverage(RegionType regionType); + //! This identifier determines if we are doing SubRegion or nesting RegionType regionType; @@ -109,17 +105,10 @@ class GeographicCoverage LatLonCorners footprint; //! SIDD SubRegion info, mutually exclusive with geographicInformation - std::vector > subRegion; + 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; - + mem::ScopedCopyablePtr geographicInformation; }; /*! @@ -132,24 +121,18 @@ class GeographicCoverage */ class GeographicAndTarget { -public: +public: + //! Constructor requires a RegionType to properly initialize + GeographicAndTarget(RegionType regionType); + //! SIDD GeographicCoverage: Provides geo coverage information - mem::ScopedCloneablePtr geographicCoverage; + GeographicCoverage 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; + 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 562f2ce60..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; @@ -1267,11 +1267,11 @@ 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) { @@ -1340,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..4ae41aebc 100644 --- a/modules/c++/six.sidd/source/GeographicAndTarget.cpp +++ b/modules/c++/six.sidd/source/GeographicAndTarget.cpp @@ -21,34 +21,21 @@ */ #include "six/sidd/GeographicAndTarget.h" -using namespace six; -using namespace six::sidd; - -TargetInformation* TargetInformation::clone() const -{ - return new TargetInformation(*this); -} - -GeographicInformation* GeographicInformation::clone() const +namespace six +{ +namespace sidd { - 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); -} +} +GeographicAndTarget::GeographicAndTarget(RegionType regionType) : + geographicCoverage(regionType) +{ +} +} +} From 901bd7b604ae7bbf5e7c8a049411548ad62759d3 Mon Sep 17 00:00:00 2001 From: Adam Sylvester Date: Tue, 11 Aug 2015 13:34:35 -0400 Subject: [PATCH 3/3] Fixing line endings --- .../include/six/sidd/GeographicAndTarget.h | 216 +++++++++--------- .../six.sidd/source/GeographicAndTarget.cpp | 20 +- 2 files changed, 118 insertions(+), 118 deletions(-) diff --git a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h index 865d3690e..70b0a0beb 100644 --- a/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h +++ b/modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h @@ -19,120 +19,120 @@ * see . * */ -#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 -{ +#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 -{ + + //! 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; -}; -} + //! SIDD GeographicCoverage: Provides geo coverage information + GeographicCoverage geographicCoverage; + + //! (Optional, Unbounded) Provides target specific geo information + std::vector > targetInformation; +}; +} } - -#endif + +#endif diff --git a/modules/c++/six.sidd/source/GeographicAndTarget.cpp b/modules/c++/six.sidd/source/GeographicAndTarget.cpp index 4ae41aebc..500e3b049 100644 --- a/modules/c++/six.sidd/source/GeographicAndTarget.cpp +++ b/modules/c++/six.sidd/source/GeographicAndTarget.cpp @@ -19,18 +19,18 @@ * see . * */ -#include "six/sidd/GeographicAndTarget.h" - +#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()); +{ +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) : @@ -38,4 +38,4 @@ GeographicAndTarget::GeographicAndTarget(RegionType regionType) : { } } -} +}