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

TargetInformation\Footprint field should be optional #7

Merged
merged 3 commits into from
Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions modules/c++/six.sidd/include/six/sidd/DerivedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct DerivedData: public Data
* Contains generic and extensible targeting and geographic
* region information.
*/
mem::ScopedCloneablePtr<GeographicAndTarget> geographicAndTarget;
mem::ScopedCopyablePtr<GeographicAndTarget> geographicAndTarget;

/*!
* Contains the meta-data necessary for performing
Expand Down Expand Up @@ -189,7 +189,7 @@ struct DerivedData: public Data
*/
virtual LatLonCorners getImageCorners() const
{
return geographicAndTarget->geographicCoverage->footprint;
return geographicAndTarget->geographicCoverage.footprint;
}

/*!
Expand All @@ -198,7 +198,7 @@ struct DerivedData: public Data
*/
virtual void setImageCorners(const LatLonCorners& imageCorners)
{
geographicAndTarget->geographicCoverage->footprint = imageCorners;
geographicAndTarget->geographicCoverage.footprint = imageCorners;
}

/*!
Expand Down
248 changes: 116 additions & 132 deletions modules/c++/six.sidd/include/six/sidd/GeographicAndTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,136 +19,120 @@
* see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __SIX_GEOGRAPHIC_AND_TARGET_H__
#define __SIX_GEOGRAPHIC_AND_TARGET_H__

#include <memory>

#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<std::string> 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<mem::ScopedCloneablePtr<GeographicCoverage> > subRegion;

//! SIDD: GeographicInfo, mutually exclusive with SubRegion
mem::ScopedCloneablePtr<GeographicInformation> 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> geographicCoverage;

//! (Optional, Unbounded) Provides target specific geo information
std::vector<mem::ScopedCloneablePtr<TargetInformation> > 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 <memory>

#include <mem/ScopedCopyablePtr.h>
#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 one, max unbounded)
ParameterCollection identifiers;

//! (Optional) SIDD Footprint: target footprint as defined by polygonal shape
mem::ScopedCopyablePtr<LatLonCorners> 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<std::string> 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<mem::ScopedCopyablePtr<GeographicCoverage> > subRegion;

//! SIDD: GeographicInfo, mutually exclusive with SubRegion
mem::ScopedCopyablePtr<GeographicInformation> 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<mem::ScopedCopyablePtr<TargetInformation> > targetInformation;
};
}
}

#endif

2 changes: 1 addition & 1 deletion modules/c++/six.sidd/source/CropUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 13 additions & 7 deletions modules/c++/six.sidd/source/DerivedXMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ void DerivedXMLParser::parseGeographicTargetFromXML(
{
parseGeographicCoverageFromXML(
getFirstAndOnly(geographicAndTargetXML, "GeographicCoverage"),
geographicAndTarget->geographicCoverage.get());
&geographicAndTarget->geographicCoverage);

// optional to unbounded
std::vector<XMLElem> targetInfosXML;
Expand All @@ -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],
Expand Down Expand Up @@ -1264,22 +1267,25 @@ XMLElem DerivedXMLParser::convertGeographicTargetToXML(

convertGeographicCoverageToXML(
"GeographicCoverage",
geographicAndTarget->geographicCoverage.get(),
&geographicAndTarget->geographicCoverage,
geographicAndTargetXML);

// optional to unbounded
for (std::vector<mem::ScopedCloneablePtr<TargetInformation> >::
for (std::vector<mem::ScopedCopyablePtr<TargetInformation> >::
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",
Expand Down Expand Up @@ -1334,7 +1340,7 @@ XMLElem DerivedXMLParser::convertGeographicCoverageToXML(
else
{
//loop over SubRegions
for (std::vector<mem::ScopedCloneablePtr<GeographicCoverage> >::
for (std::vector<mem::ScopedCopyablePtr<GeographicCoverage> >::
const_iterator it = geoCoverage->subRegion.begin();
it != geoCoverage->subRegion.end(); ++it)
{
Expand Down
Loading