OTB  6.7.0
Orfeo Toolbox
otbGeometriesProjectionFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbGeometriesProjectionFilter_h
22 #define otbGeometriesProjectionFilter_h
23 
25 #include "otbOGRGeometryWrapper.h"
26 #include "otbImageReference.h"
27 #include "itkTransform.h"
28 #include "otbGenericRSTransform.h"
29 
30 #include "OTBProjectionExport.h"
31 #include <string>
32 
33 class OGRCoordinateTransformation;
34 
35 namespace otb
36 {
37 
38 namespace internal
39 {
50 struct OTBProjection_EXPORT ReprojectTransformationFunctor
51  {
52  typedef OGRGeometry TransformedElementType;
53 
58  struct ByCopy
59  {
60  ByCopy(ReprojectTransformationFunctor const& reprojector) : m_Reprojector(reprojector){}
61  template <typename TGeometry>
62  ogr::UniqueGeometryPtr operator()(TGeometry const* in) const;
63  private:
65  };
67 
72  struct InPlace
73  {
74  InPlace(ReprojectTransformationFunctor const& reprojector) : m_Reprojector(reprojector){}
75  template <typename TGeometry>
76  void operator()(TGeometry * inout) const;
77  private:
79  };
81 
82 
83  ogr::UniqueGeometryPtr operator()(OGRGeometry const* in) const;
84  void apply_inplace (OGRGeometry * inout) const;
85 
93  void SetOnePointTransformation(InternalTransformPointerType transform);
94 private:
95 
101  void do_transform(OGRPoint & g) const;
102  // void do_transform(OGRLinearRing & g) const;
103 
109  void do_transform(OGRLineString & g) const;
110  // void do_transform(OGRCurve & g) const;
111 
117  void do_transform(OGRPolygon & g) const;
118 #if 0
119  void do_transform(OGRSurface & g) const;
120  void do_transform(OGRMultiLineString & g) const;
121  void do_transform(OGRMultiPoint & g) const;
122  void do_transform(OGRMultiPolygon & g) const;
123 #endif
124 
130  void do_transform(OGRGeometryCollection & g) const;
131 
135  };
136 } // internal namespace
137 
138 
166 class OTBProjection_EXPORT GeometriesProjectionFilter : public GeometriesToGeometriesFilter
167 {
168 public:
169 
177 
180 
182  itkNewMacro(Self);
183 
187 
190  typedef Superclass::InputGeometriesType InputGeometriesType;
191  // typedef Superclass::InputGeometriesPointer InputGeometriesPointer;
192  typedef Superclass::OutputGeometriesType OutputGeometriesType;
193  // typedef Superclass::OutputGeometriesPointer OutputGeometriesPointer;
195 
197 
198 private:
207  OGRSpatialReference* DoDefineNewLayerSpatialReference(ogr::Layer const& source) const override;
208 
220  void DoProcessLayer(ogr::Layer const& source, ogr::Layer & destination) const override;
221 
227  void DoFinalizeInitialization() override;
228 
237  void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer & dest) const override;
238 
239 protected:
242 
244  ~GeometriesProjectionFilter() override;
245 
249  void GenerateOutputInformation(void) override;
250 
251 public:
254  void SetInputSpacing(ImageReference::SpacingType const& spacing);
255  void SetOutputSpacing(ImageReference::SpacingType const& spacing);
256  void SetInputOrigin(ImageReference::OriginType const& origin);
257  void SetOutputOrigin(ImageReference::OriginType const& origin);
259 
262  itkGetMacro(InputKeywordList, ImageKeywordlist);
263  void SetInputKeywordList(const ImageKeywordlist& kwl);
265 
266  itkGetMacro(OutputKeywordList, ImageKeywordlist);
267  void SetOutputKeywordList(const ImageKeywordlist& kwl);
269 
276  itkSetStringMacro(OutputProjectionRef);
277  itkGetStringMacro(OutputProjectionRef);
279 
280 
281 private:
288 
291 
296 
299 
305 
306  std::string m_OutputProjectionRef; // in WKT format!
309 };
310 } // end namespace otb
311 
312 #ifndef OTB_MANUAL_INSTANTIATION
314 #endif
315 
316 #endif // otbGeometriesProjectionFilter_h
Superclass::InputGeometriesType InputGeometriesType
ByCopy(ReprojectTransformationFunctor const &reprojector)
Storage and conversion for OSSIM metadata.
Layer of geometric objets.
itk::SmartPointer< const Self > ConstPointer
internal::ReprojectTransformationFunctor TransformationFunctorType
Superclass::OutputGeometriesType OutputGeometriesType
TransformationFunctorDispatcherType m_TransformationFunctor
TransformationFunctorType::InternalTransformType InternalTransformType
boost::interprocess::unique_ptr< OGRGeometry, internal::GeometryDeleter > UniqueGeometryPtr
TransformationFunctorDispatcher< TransformationFunctorType, TransformedElementType, FieldCopyTransformation > TransformationFunctorDispatcherType
TransformationFunctorType::InternalTransformPointerType InternalTransformPointerType
This is the class to handle generic remote sensing transform.
TransformationFunctorType::TransformedElementType TransformedElementType
ogr::ImageReference< double > ImageReference
InPlace(ReprojectTransformationFunctor const &reprojector)
otb::GenericRSTransform< double, 2, 2 > InternalTransformType