18 #ifndef __otbOGRGeometriesVisitor_h
19 #define __otbOGRGeometriesVisitor_h
21 #include <boost/mpl/assert.hpp>
22 #include <boost/type_traits/is_same.hpp>
23 #include <boost/type_traits/remove_const.hpp>
24 #include "ogr_geometry.h"
37 template <
typename Tin,
typename Tout>
40 template <
typename Tin,
typename Tout>
42 {
typedef typename boost::add_const<Tout>::type
type; };
45 #define TRY_APPLY(TYPE, geometry, functor) \
46 if (typename propagate_const<TGeometry, TYPE>::type * dc \
47 = dynamic_cast<typename propagate_const<TGeometry, TYPE>::type*>(geometry))\
69 template <
typename TResult,
class TGeometry,
typename TFunctor>
70 TResult
apply(TGeometry * geometry, TFunctor functor)
72 BOOST_MPL_ASSERT((boost::is_same<OGRGeometry,
typename boost::remove_const<TGeometry>::type >));
74 else TRY_APPLY(OGRLinearRing, geometry, functor)
75 else TRY_APPLY(OGRLineString, geometry, functor)
77 else TRY_APPLY(OGRPolygon, geometry, functor)
79 else TRY_APPLY(OGRMultiLineString, geometry, functor)
80 else TRY_APPLY(OGRMultiPoint, geometry, functor)
81 else TRY_APPLY(OGRMultiPolygon, geometry, functor)
82 else TRY_APPLY(OGRGeometryCollection, geometry, functor)
92 #ifndef OTB_MANUAL_INSTANTIATION
96 #endif // __otbOGRGeometriesVisitor_h