Commit bdbe2b99 authored by Luc Hermitte's avatar Luc Hermitte

DOC: OTB-151/GeometriesProjectionFilter -- doxygen groups + set-way to change image references

parent 75b5aa68
......@@ -179,8 +179,8 @@ void otb::ReprojectTransformationFunctor::apply_inplace(OGRGeometry * inout) con
/*===========================================================================*/
otb::GeometriesProjectionFilter::GeometriesProjectionFilter()
: InputImageReference(*this)
, OutputImageReference(*this)
: m_InputImageReference(*this)
, m_OutputImageReference(*this)
{
}
......@@ -215,10 +215,10 @@ void otb::GeometriesProjectionFilter::DoFinalizeInitialisation()
m_Transform->SetGeoidFile(m_GeoidFile);
m_Transform->SetAverageElevation(k_averageElevation);
m_Transform->SetInputSpacing(InputImageReference.GetSpacing());
m_Transform->SetInputOrigin(InputImageReference.GetOrigin());
m_Transform->SetOutputSpacing(OutputImageReference.GetSpacing());
m_Transform->SetOutputOrigin(OutputImageReference.GetOrigin());
m_Transform->SetInputSpacing(m_InputImageReference.GetSpacing());
m_Transform->SetInputOrigin(m_InputImageReference.GetOrigin());
m_Transform->SetOutputSpacing(m_OutputImageReference.GetSpacing());
m_Transform->SetOutputOrigin(m_OutputImageReference.GetOrigin());
// As the InputProjectionRef can't be known yet, InstanciateTransform() will
// be called from DoProcessLayer
......@@ -233,7 +233,7 @@ void otb::GeometriesProjectionFilter::DoFinalizeInitialisation()
// InputGeometriesType::ConstPointer input = this->GetInput();
OutputGeometriesType::Pointer output = this->GetOutput();
output->SetImageReference(OutputImageReference);
output->SetImageReference(m_OutputImageReference);
}
/*virtual*/
......
......@@ -29,10 +29,25 @@ class OGRCoordinateTransformation;
namespace otb
{
/**\ingroup Projection GeometriesFilters
* Internal functor used to reproject a \c OGRGeometry.
*
* \internal
* As \c OGRGeometry isn't open to new functions through a \em Visitor design
* pattern, this class use a nasty hack: it try to downcast to any possible
* subtype of \c OGRGeometry.
*
* \since OTB v 3.14.0
* \todo Move into an \c internal namespace.
*/
struct ReprojectTransformationFunctor
{
typedef OGRGeometry TransformedElementType;
/**\ingroup Projection GeometriesFilters
* Internal functor used to reproject a \c OGRGeometry: \em By-Copy transformation policy.
* \since OTB v 3.14.0
*/
struct ByCopy
{
ByCopy(ReprojectTransformationFunctor const& reprojector) : m_Reprojector(reprojector){}
......@@ -42,6 +57,10 @@ struct ReprojectTransformationFunctor
ReprojectTransformationFunctor const& m_Reprojector;
};
/**\ingroup Projection GeometriesFilters
* Internal functor used to reproject a \c OGRGeometry: \em In-Place transformation policy.
* \since OTB v 3.14.0
*/
struct InPlace
{
InPlace(ReprojectTransformationFunctor const& reprojector) : m_Reprojector(reprojector){}
......@@ -80,6 +99,28 @@ private:
};
/**\ingroup Projection GeometriesFilters
* \class GeometriesProjectionFilter
* Projection filter for OGR geometries sets.
* \since OTB v 3.14.0
*
* \param[in] InputGeometriesSet
* \param[in] InputKeywordList if the \em InputGeometriesSet doesn't have a
* projection reference (i.e. a \c OGRSpatialReference), this filter will use
* the \em InputKeywordList to describe the positionning of the geometries set.
*
* \param[in,out] OutputGeometriesSet This set of geometries needs to be given to
* the filter (in order to set the exact output file/OGR driver). However the
* filter is in charge of filling the geometries set.
* \param[in] OutputProjectionRef wkt description of the \c OGRSpatialReference
* to project the \em InputGeometriesSet into.
* \param[in] OutputKeywordList if no \em OutputProjectionRef is set, the
* projection will be done according to the \em OutputKeywordList.
*
* \note Unlike \c VectorDataProjectionFilter, we have to explicitly set which
* to use between projection reference or keyword list. There is no \em
* MetaDataDictionary property.
*/
class ITK_EXPORT GeometriesProjectionFilter : public GeometriesToGeometriesFilter
{
public:
......@@ -106,11 +147,8 @@ public:
// typedef Superclass::InputGeometriesPointer InputGeometriesPointer;
typedef Superclass::OutputGeometriesType OutputGeometriesType;
// typedef Superclass::OutputGeometriesPointer OutputGeometriesPointer;
//@}
typedef ogr::ImageReference<double> ImageReference;
/**\name Class typedefs */
//@{
typedef ogr::ImageReference<double> ImageReference;
//@}
private:
......@@ -128,9 +166,25 @@ protected:
virtual void GenerateOutputInformation(void);
public:
ImageReference InputImageReference;
ImageReference OutputImageReference;
/**\name Image Reference (origin, spacing) */
//@{
void SetInputSpacing(ImageReference::SpacingType const& spacing)
{
m_InputImageReference.SetSpacing(spacing);
}
void SetOutputSpacing(ImageReference::SpacingType const& spacing)
{
m_OutputImageReference.SetSpacing(spacing);
}
void SetInputOrigin(ImageReference::OriginType const& origin)
{
m_InputImageReference.SetOrigin(origin);
}
void SetOutputOrigin(ImageReference::OriginType const& origin)
{
m_OutputImageReference.SetOrigin(origin);
}
//@}
/**\name Keywords lists accessors and mutators */
//@{
itkGetMacro(InputKeywordList, ImageKeywordlist);
......@@ -176,6 +230,12 @@ private:
InternalTransformPointerType m_Transform;
//@}
/**\name Image Reference (origin, spacing) */
//@{
ImageReference m_InputImageReference;
ImageReference m_OutputImageReference;
//@}
std::string m_OutputProjectionRef; // in WKT format!
ImageKeywordlist m_InputKeywordList;
ImageKeywordlist m_OutputKeywordList;
......
......@@ -139,13 +139,6 @@ otb::GeometriesToGeometriesFilter::GetInput(void )
void otb::GeometriesToGeometriesFilter::GenerateOutputInformation(void )
{
Superclass::GenerateOutputInformation();
#if 0
// Apply only with data sources
OutputGeometriesType::Pointer output = this->GetOutput();
InputGeometriesType::Pointer input = this->GetInput();
output->SetMetaDataDictionary(input->GetMetaDataDictionary());
#endif
}
/*virtual*/
......
......@@ -120,6 +120,11 @@ private:
*/
virtual std::vector<std::string> DoDefineNewLayerOptions(ogr::Layer const& source) const;
/**
* Hook used to define the fields of the new layer.
* \param[in] source source \c Layer -- for reference
* \param[in,out] dest destination \c Layer
*/
virtual void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const = 0;
/** Hook used to conclude the initialization phase.
......@@ -134,16 +139,32 @@ private:
friend struct ::ProcessVisitor;
};
/**\ingroup GeometriesFilters
* Helper class to operate an exact copy of the fields from a source layer.
* \since OTB v 3.14.0
*/
struct FieldCopyTransformation
{
OGRFeatureDefn & getDefinition(ogr::Layer & outLayer) const
{
return outLayer.GetLayerDefn();
}
/**
* In-place transformation: does nothing.
* \param[in] inoutFeature \c Feature to change.
* \throw Nothing
*/
void fieldsTransform(ogr::Feature const& inoutFeature) const
{
// default => do nothing for in-place transformation
}
/**
* By-Copy transformation: copies all fields.
* \param[in] inFeature input \c Feature
* \param[in,out] outFeature output \c Feature
*
* \throw itk::ExceptionObject if the fields cannot be copied.
*/
void fieldsTransform(ogr::Feature const& inFeature, ogr::Feature & outFeature) const
{
// default => copy all fields for copy transformation
......@@ -154,6 +175,12 @@ struct FieldCopyTransformation
}
}
/**
* Defines the fields in the destination layer.
* \param[in] source source \c Layer
* \param[in,out] dest destination \c Layer
* \throw itk::ExceptionObject in case the operation can't succeed.
*/
void DefineFields(ogr::Layer const& source, ogr::Layer & dest) const
{
OGRFeatureDefn & inDefinition = source.GetLayerDefn();
......
......@@ -27,12 +27,20 @@ namespace otb
{
namespace ogr
{
/**\ingroup boost
* \brief propagation of const-qualifier.
* \note This type traits is likelly to appear in boost at some point in time.
* \note As a consequence, it follows C++ standard and boost naming policy.
* \since OTB v 3.14.0
* @{
*/
template <typename Tin, typename Tout>
struct propagate_const
{ typedef Tout type; };
template <typename Tin, typename Tout>
struct propagate_const<Tin const, Tout>
{ typedef typename boost::add_const<Tout>::type type; };
/** @} */
#define TRY_APPLY(TYPE, geometry, functor) \
if (typename propagate_const<TGeometry, TYPE>::type * dc \
......@@ -42,6 +50,22 @@ if (typename propagate_const<TGeometry, TYPE>::type * dc \
}
/**\ingroup gGeometry
* External polymorphic call of functions on \c OGRGeometry.
* This helper function tries to polymorphically dispatch the call of a function
* on the right \c OGRGeometry subtype.
* \internal
* In a perfect world, \c OGRGeometry would have provided a visitor to extend
* the number of functions to polymorphically %apply on them. As this isn't the
* case, \c apply executes many downcasts until it finds the right subtype.
*
* \tparam TResult type of the result
* \tparam TGeometry matched an \c OGRGeometry that may or may not be const
* qualified.
* \tparam TFunctor functor to apply on the geometry.
* \todo Support a list of types to check
* \since OTB v 3.14.0
*/
template <typename TResult, class TGeometry, typename TFunctor>
TResult apply(TGeometry * geometry, TFunctor functor)
{
......
......@@ -58,6 +58,7 @@ namespace boost {
*
* \sa http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3350.html about
* \c contiguous_iterator_tag.
* \since OTB v 3.14.0
* @{
*/
template <typename Range> struct is_contiguous
......
......@@ -130,8 +130,8 @@ int main(int argc, char* argv[])
// Software Guide : BeginCodeSnippet
filter->SetOutputKeywordList(imageReader->GetOutput()->GetImageKeywordlist()); // nec qd capteur
filter->OutputImageReference.SetOrigin(imageReader->GetOutput()->GetOrigin()); // nec qd capteur
filter->OutputImageReference.SetSpacing(imageReader->GetOutput()->GetSpacing()); // nec qd capteur
filter->SetOutputOrigin(imageReader->GetOutput()->GetOrigin()); // nec qd capteur
filter->SetOutputSpacing(imageReader->GetOutput()->GetSpacing()); // nec qd capteur
filter->SetOutputProjectionRef( imageReader->GetOutput()->GetProjectionRef()); // ~ wkt
// Software Guide : EndCodeSnippet
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment