Commit e28c46ae authored by Luc Hermitte's avatar Luc Hermitte

STYLE: OTB-151/GeometriesProjectionFilter

parent f5926603
......@@ -57,20 +57,20 @@ otb::ogr::Layer & getRef(otb::ogr::Layer & layer)
/*=======================[ Setting and construction ]========================*/
/*===========================================================================*/
otb::GeometriesSet::GeometriesSet()
: m_geometriesSet(otb::ogr::DataSource::New())
: m_GeometriesSet(otb::ogr::DataSource::New())
, m_ImageReference(*this)
{
}
otb::GeometriesSet::GeometriesSet(ogr::DataSource::Pointer datasource)
: m_geometriesSet(datasource)
: m_GeometriesSet(datasource)
, m_ImageReference(*this)
{
assert(datasource && "unexpected nil datasource");
}
otb::GeometriesSet::GeometriesSet(ogr::Layer layer)
: m_geometriesSet(layer)
: m_GeometriesSet(layer)
, m_ImageReference(*this)
{
}
......@@ -99,13 +99,13 @@ otb::GeometriesSet::~GeometriesSet()
void otb::GeometriesSet::Set(ogr::Layer layer)
{
assert(layer && "unexpected nil layer");
m_geometriesSet = layer;
m_GeometriesSet = layer;
}
void otb::GeometriesSet::Set(ogr::DataSource::Pointer datasource)
{
assert(datasource && "unexpected nil datasource");
m_geometriesSet = datasource;
m_GeometriesSet = datasource;
}
/*===========================================================================*/
......
......@@ -83,28 +83,28 @@ public:
typename Visitor::result_type
apply(Visitor const& visitor)
{
return boost::apply_visitor(visitor, m_geometriesSet);
return boost::apply_visitor(visitor, m_GeometriesSet);
}
template <typename Visitor>
typename Visitor::result_type
apply(Visitor const& visitor) const
{
return boost::apply_visitor(visitor, m_geometriesSet);
return boost::apply_visitor(visitor, m_GeometriesSet);
}
template <typename Visitor>
typename Visitor::result_type
apply(Visitor const& visitor, Self & visitable)
{
return boost::apply_visitor(visitor, m_geometriesSet, visitable.m_geometriesSet);
return boost::apply_visitor(visitor, m_GeometriesSet, visitable.m_GeometriesSet);
}
template <typename Visitor>
typename Visitor::result_type
apply(Visitor const& visitor, Self /*const*/& visitable) const
{
return boost::apply_visitor(visitor, m_geometriesSet, visitable.m_geometriesSet);
return boost::apply_visitor(visitor, m_GeometriesSet, visitable.m_GeometriesSet);
}
//@}
......@@ -152,7 +152,7 @@ protected:
void PrintSelf(std::ostream& os, itk::Indent indent) const;
private:
typedef boost::variant<ogr::DataSource::Pointer, ogr::Layer> AnyGeometriesSetType;
AnyGeometriesSetType m_geometriesSet;
AnyGeometriesSetType m_GeometriesSet;
ImageReference m_ImageReference;
};
......
......@@ -41,7 +41,6 @@ struct ProcessVisitor : boost::static_visitor<>
: m_filter(filter) {}
void operator()(otb::ogr::Layer const& source, otb::ogr::Layer & destination) const
{
// std::cout << "G2GF: Process Visitor: L -> L ("<< source.GetName()<<")...\n";
m_filter.DoProcessLayer(source, destination);
}
......@@ -49,7 +48,6 @@ struct ProcessVisitor : boost::static_visitor<>
{
assert(source && "can't filter a nil datasource");
assert(destination && "can't filter to a nil datasource");
// std::cout << "G2GF: Process Visitor: DS("<<source->ogr().GetName()<<") -> DS("<<destination->ogr().GetName()<<") ...\n";
for (otb::ogr::DataSource::const_iterator b = source->begin(), e = source->end()
; b != e
; ++b
......@@ -57,33 +55,28 @@ struct ProcessVisitor : boost::static_visitor<>
{
otb::ogr::Layer const& sourceLayer = *b;
assert(sourceLayer && "unexpected nil source layer");
// std::cout << "source layer name:" << sourceLayer.GetName() << "\n";
otb::ogr::Layer destLayer = destination->CreateLayer(
sourceLayer.GetName(),
m_filter.DoDefineNewLayerSpatialReference(sourceLayer),
m_filter.DoDefineNewLayerGeometryType(sourceLayer),
otb::ogr::StringListConverter(m_filter.DoDefineNewLayerOptions(sourceLayer)).to_ogr()
);
// std::cout << "layer created!\n";
m_filter.DoProcessLayer(sourceLayer, destLayer);
}
}
void operator()(otb::ogr::Layer & inout) const
{
// std::cout << "G2GF: Process Visitor: L -> L ("<< source.GetName()<<")...\n";
m_filter.DoProcessLayer(inout, inout);
}
void operator()(otb::ogr::DataSource::Pointer inout) const
{
assert(inout && "can't filter a nil datasource");
// std::cout << "G2GF: Process Visitor: DS("<<source->ogr().GetName()<<") -> DS("<<destination->ogr().GetName()<<") ...\n";
for (otb::ogr::DataSource::iterator b = inout->begin(), e = inout->end(); b != e; ++b)
{
otb::ogr::Layer layer = *b;
assert(layer && "unexpected nil source layer");
// std::cout << "source layer name:" << sourceLayer.GetName() << "\n";
m_filter.DoProcessLayer(layer, layer);
}
}
......@@ -128,7 +121,6 @@ otb::GeometriesToGeometriesFilter::GetInput(void )
/*virtual*/ void otb::GeometriesToGeometriesFilter::Process(
InputGeometriesType const& source, OutputGeometriesType & destination)
{
// std::cout << "G2GF: Processing ...\n";
// si layer, appelle virt process layer
// si DS, loop et appelle virt process layer
source.apply(ProcessVisitor(*this), destination);
......@@ -137,7 +129,6 @@ otb::GeometriesToGeometriesFilter::GetInput(void )
/*virtual*/ void otb::GeometriesToGeometriesFilter::Process(
OutputGeometriesType & inout)
{
// std::cout << "G2GF: Processing ...\n";
// si layer, appelle virt process layer
// si DS, loop et appelle virt process layer
inout.apply(ProcessVisitor(*this));
......@@ -159,7 +150,6 @@ void otb::GeometriesToGeometriesFilter::GenerateOutputInformation(void )
/*virtual*/
void otb::GeometriesToGeometriesFilter::GenerateData(void )
{
// std::cout << "G2GF::GenerateData\n";
this->DoAllocateOutputs();
this->DoFinalizeInitialisation();
......
......@@ -193,7 +193,6 @@ struct TransformationFunctorDispatcher<TransformationFunctor, OGRGeometry>
void operator()(ogr::Layer const& in, ogr::Layer & out) const
{
// std::cout << "Converting layer " << in.GetName() << " -> " << out.GetName() << "\n";
OGRFeatureDefn & defn = out.GetLayerDefn();
for (ogr::Layer::const_iterator b = in.begin(), e = in.end(); b != e; ++b)
{
......@@ -208,7 +207,6 @@ struct TransformationFunctorDispatcher<TransformationFunctor, OGRGeometry>
void operator()(ogr::Layer & inout) const
{
// std::cout << "Converting layer " << inout.GetName() << "\n";
OGRFeatureDefn & defn = inout.GetLayerDefn();
// NB: We can't iterate with begin()/end() as SetFeature may invalidate the
// iterators depending of the underlying drivers
......@@ -270,7 +268,6 @@ protected:
virtual void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const
{
// std::cout << "DG2GF::DoProcessLayer: L("<<source.GetName()<<") -> L("<<destination.GetName()<<") ...\n";
if (source != destination)
{
m_TransformationFunctor(source, destination); // if TransformedElementType == layer
......
......@@ -21,9 +21,8 @@
/*===========================================================================*/
/*===========================================================================*/
/*==============================[ other stuff ]==============================*/
/*==================[ DefaultGeometriesToGeometriesFilter ]==================*/
/*===========================================================================*/
template <class TransformationFunctor>
inline
otb::DefaultGeometriesToGeometriesFilter<TransformationFunctor>::DefaultGeometriesToGeometriesFilter()
......
......@@ -42,7 +42,7 @@ public:
itkTypeMacro(ImageReference, void);
bool GetDebug() const
{
return m_holder.GetDebug();
return m_Holder.GetDebug();
}
//@}
/**\name Template-parameters typedefs */
......@@ -57,7 +57,7 @@ public:
* \post <tt>m_Origin = {0,0}</tt>
*/
ImageReference(itk::Object const& holder)
: m_holder(holder)
: m_Holder(holder)
{
m_Spacing.Fill(1);
m_Origin.Fill(0);
......@@ -67,13 +67,13 @@ public:
* \post <tt>m_Origin = origin</tt>
*/
ImageReference(SpacingType const& spacing, OriginType const& origin, itk::Object const& holder)
: m_holder(holder) , m_Spacing(spacing), m_Origin(origin)
: m_Holder(holder) , m_Spacing(spacing), m_Origin(origin)
{
}
void Modified() const
{
m_holder.Modified();
m_Holder.Modified();
}
/**\name Origin property
......@@ -155,7 +155,7 @@ public:
}
private:
itk::Object const& m_holder;
itk::Object const& m_Holder;
SpacingType m_Spacing;
OriginType m_Origin;
};
......
......@@ -29,17 +29,14 @@ namespace ogr
{
template <typename Tin, typename Tout>
struct propagate_const
{
typedef Tout type;
};
{ typedef Tout type; };
template <typename Tin, typename Tout>
struct propagate_const<Tin const, Tout>
{
typedef typename boost::add_const<Tout>::type type;
};
{ typedef typename boost::add_const<Tout>::type type; };
#define TRY_APPLY(TYPE, geometry, functor) \
if (typename propagate_const<TGeometry, TYPE>::type * dc = dynamic_cast<typename propagate_const<TGeometry, TYPE>::type*>(geometry))\
if (typename propagate_const<TGeometry, TYPE>::type * dc \
= dynamic_cast<typename propagate_const<TGeometry, TYPE>::type*>(geometry))\
{\
return functor(dc); \
}
......
......@@ -89,7 +89,7 @@ int main (int argc, char **argv)
}
try
{
const bool workingInplace = argc==2;
const bool workingInplace = argc == 2;
const bool outputIsStdout = !workingInplace && !strcmp(argv[2], "-");
const std::string inputFile = argv[1];
......
......@@ -60,7 +60,7 @@ int main (int argc, char **argv)
}
try
{
const bool workingInplace = argc==2;
const bool workingInplace = argc == 2;
const bool outputIsStdout = !workingInplace && !strcmp(argv[2], "-");
const std::string inputFile = argv[1];
......
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