OTB  9.0.0
Orfeo Toolbox
otbGeometriesProjectionFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 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 #include "otbImageMetadata.h"
30 
31 #include "OTBProjectionExport.h"
32 #include <string>
33 
34 class OGRCoordinateTransformation;
35 
36 namespace otb
37 {
38 
39 namespace internal
40 {
51 struct OTBProjection_EXPORT ReprojectTransformationFunctor
52 {
53  typedef OGRGeometry TransformedElementType;
54 
59  struct ByCopy
60  {
61  ByCopy(ReprojectTransformationFunctor const& reprojector) : m_Reprojector(reprojector)
62  {
63  }
64  template <typename TGeometry>
65  ogr::UniqueGeometryPtr operator()(TGeometry const* in) const;
66 
67  private:
69  };
70 
75  struct InPlace
76  {
77  InPlace(ReprojectTransformationFunctor const& reprojector) : m_Reprojector(reprojector)
78  {
79  }
80  template <typename TGeometry>
81  void operator()(TGeometry* inout) const;
82 
83  private:
85  };
86 
87 
88  ogr::UniqueGeometryPtr operator()(OGRGeometry const* in) const;
89  void apply_inplace(OGRGeometry* inout) const;
90 
98  void SetOnePointTransformation(InternalTransformPointerType transform);
99 
100 private:
106  void do_transform(OGRPoint& g) const;
107  // void do_transform(OGRLinearRing & g) const;
108 
114  void do_transform(OGRLineString& g) const;
115  // void do_transform(OGRCurve & g) const;
116 
122  void do_transform(OGRPolygon& g) const;
123 #if 0
124  void do_transform(OGRSurface & g) const;
125  void do_transform(OGRMultiLineString & g) const;
126  void do_transform(OGRMultiPoint & g) const;
127  void do_transform(OGRMultiPolygon & g) const;
128 #endif
129 
135  void do_transform(OGRGeometryCollection& g) const;
136 
140 };
141 } // internal namespace
142 
143 
170 class OTBProjection_EXPORT GeometriesProjectionFilter : public GeometriesToGeometriesFilter
171 {
172 public:
173 
178  typedef itk::SmartPointer<Self> Pointer;
179  typedef itk::SmartPointer<const Self> ConstPointer;
181 
184 
186  itkNewMacro(Self);
187 
191 
194  typedef Superclass::InputGeometriesType InputGeometriesType;
195  // typedef Superclass::InputGeometriesPointer InputGeometriesPointer;
196  typedef Superclass::OutputGeometriesType OutputGeometriesType;
197  // typedef Superclass::OutputGeometriesPointer OutputGeometriesPointer;
199 
201 
202 private:
211  OGRSpatialReference* DoDefineNewLayerSpatialReference(ogr::Layer const& source) const override;
212 
224  void DoProcessLayer(ogr::Layer const& source, ogr::Layer& destination) const override;
225 
231  void DoFinalizeInitialization() override;
232 
241  void DoDefineNewLayerFields(ogr::Layer const& source, ogr::Layer& dest) const override;
242 
243 protected:
246 
248  ~GeometriesProjectionFilter() override;
249 
253  void GenerateOutputInformation(void) override;
254 
255 public:
258  void SetInputSpacing(ImageReference::SpacingType const& spacing);
259  void SetOutputSpacing(ImageReference::SpacingType const& spacing);
260  void SetInputOrigin(ImageReference::OriginType const& origin);
261  void SetOutputOrigin(ImageReference::OriginType const& origin);
263 
264 
268  {
269  return m_InputImageMetadata;
270  }
271 
273  {
274  m_InputImageMetadata = imd;
275  this->Modified();
276  }
277 
279  {
280  return m_OutputImageMetadata;
281  }
283  {
284  m_OutputImageMetadata = imd;
285  this->Modified();
286  }
288 
295  itkSetStringMacro(OutputProjectionRef);
296  itkGetStringMacro(OutputProjectionRef);
298 
299 
300 private:
306 
309 
314 
317 
323 
324  std::string m_OutputProjectionRef; // in WKT format!
325  const ImageMetadata* m_InputImageMetadata = nullptr;
326  const ImageMetadata* m_OutputImageMetadata = nullptr;
327 };
328 } // end namespace otb
329 
330 #ifndef OTB_MANUAL_INSTANTIATION
332 #endif
333 
334 #endif // otbGeometriesProjectionFilter_h
otb::GeometriesSource
Definition: otbGeometriesSource.h:72
otb::GeometriesProjectionFilter::GetInputImageMetadata
const ImageMetadata * GetInputImageMetadata() const
Definition: otbGeometriesProjectionFilter.h:267
otb::GenericRSTransform::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbGenericRSTransform.h:66
otb::GeometriesProjectionFilter::SetInputImageMetadata
void SetInputImageMetadata(const ImageMetadata *imd)
Definition: otbGeometriesProjectionFilter.h:272
otb::GeometriesProjectionFilter::SetOutputImageMetadata
void SetOutputImageMetadata(const ImageMetadata *imd)
Definition: otbGeometriesProjectionFilter.h:282
otb::internal::ReprojectTransformationFunctor
Definition: otbGeometriesProjectionFilter.h:51
otb::internal::ReprojectTransformationFunctor::ByCopy::ByCopy
ByCopy(ReprojectTransformationFunctor const &reprojector)
Definition: otbGeometriesProjectionFilter.h:61
otbImageReference.h
otb::GeometriesProjectionFilter::ImageReference
ogr::ImageReference< double > ImageReference
Definition: otbGeometriesProjectionFilter.h:198
otb::GeometriesProjectionFilter::TransformedElementType
TransformationFunctorType::TransformedElementType TransformedElementType
Definition: otbGeometriesProjectionFilter.h:304
otb::internal::ReprojectTransformationFunctor::TransformedElementType
OGRGeometry TransformedElementType
Definition: otbGeometriesProjectionFilter.h:53
otb::GeometriesProjectionFilter::m_TransformationFunctor
TransformationFunctorDispatcherType m_TransformationFunctor
Definition: otbGeometriesProjectionFilter.h:307
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::internal::ReprojectTransformationFunctor::InPlace::InPlace
InPlace(ReprojectTransformationFunctor const &reprojector)
Definition: otbGeometriesProjectionFilter.h:77
otbOGRGeometryWrapper.h
otb::GeometriesProjectionFilter::m_Transform
InternalTransformPointerType m_Transform
Definition: otbGeometriesProjectionFilter.h:315
otb::ogr::UniqueGeometryPtr
boost::interprocess::unique_ptr< OGRGeometry, internal::GeometryDeleter > UniqueGeometryPtr
Definition: otbOGRGeometryWrapper.h:109
otb::GeometriesProjectionFilter
Definition: otbGeometriesProjectionFilter.h:170
otb::GeometriesProjectionFilter::OutputGeometriesType
Superclass::OutputGeometriesType OutputGeometriesType
Definition: otbGeometriesProjectionFilter.h:196
otb::TransformationFunctorDispatcher< TransformationFunctorType, TransformedElementType, FieldCopyTransformation >
otb::GeometriesProjectionFilter::m_OutputProjectionRef
std::string m_OutputProjectionRef
Definition: otbGeometriesProjectionFilter.h:324
otb::GeometriesProjectionFilter::TransformationFunctorDispatcherType
TransformationFunctorDispatcher< TransformationFunctorType, TransformedElementType, FieldCopyTransformation > TransformationFunctorDispatcherType
Definition: otbGeometriesProjectionFilter.h:305
otb::internal::ReprojectTransformationFunctor::InternalTransformPointerType
InternalTransformType::Pointer InternalTransformPointerType
Definition: otbGeometriesProjectionFilter.h:92
otb::GenericRSTransform
This is the class to handle generic remote sensing transform.
Definition: otbGenericRSTransform.h:57
otb::GeometriesProjectionFilter::InternalTransformPointerType
TransformationFunctorType::InternalTransformPointerType InternalTransformPointerType
Definition: otbGeometriesProjectionFilter.h:313
otb::ogr::ImageReference< double >
otbGeometriesToGeometriesFilter.h
otb::GeometriesProjectionFilter::Superclass
GeometriesToGeometriesFilter Superclass
Definition: otbGeometriesProjectionFilter.h:177
otb::GeometriesProjectionFilter::InternalTransformType
TransformationFunctorType::InternalTransformType InternalTransformType
Definition: otbGeometriesProjectionFilter.h:312
otb::GeometriesProjectionFilter::GetOutputImageMetadata
const ImageMetadata * GetOutputImageMetadata() const
Definition: otbGeometriesProjectionFilter.h:278
otb::GeometriesProjectionFilter::InputGeometriesType
Superclass::InputGeometriesType InputGeometriesType
Definition: otbGeometriesProjectionFilter.h:194
otb::GeometriesProjectionFilter::m_InputImageReference
ImageReference m_InputImageReference
Definition: otbGeometriesProjectionFilter.h:320
otb::internal::ReprojectTransformationFunctor::InternalTransformType
otb::GenericRSTransform< double, 2, 2 > InternalTransformType
Definition: otbGeometriesProjectionFilter.h:91
otb::GeometriesToGeometriesFilter
Definition: otbGeometriesToGeometriesFilter.h:58
otbGenericRSTransform.h
otbGeometriesProjectionFilter.hxx
otb::GeometriesProjectionFilter::Self
GeometriesProjectionFilter Self
Definition: otbGeometriesProjectionFilter.h:176
otb::internal::ReprojectTransformationFunctor::ByCopy
Definition: otbGeometriesProjectionFilter.h:59
otb::ImageMetadata
Generic class containing image metadata used in OTB.
Definition: otbImageMetadata.h:270
otb::internal::ReprojectTransformationFunctor::InPlace::m_Reprojector
ReprojectTransformationFunctor const & m_Reprojector
Definition: otbGeometriesProjectionFilter.h:84
otb::ogr::Layer
Layer of geometric objects.
Definition: otbOGRLayerWrapper.h:80
otb::internal::ReprojectTransformationFunctor::m_Transform
InternalTransformPointerType m_Transform
Definition: otbGeometriesProjectionFilter.h:139
otb::GeometriesProjectionFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbGeometriesProjectionFilter.h:178
otbImageMetadata.h
otb::GeometriesProjectionFilter::m_OutputImageReference
ImageReference m_OutputImageReference
Definition: otbGeometriesProjectionFilter.h:321
otb::internal::ReprojectTransformationFunctor::InPlace
Definition: otbGeometriesProjectionFilter.h:75
otb::GeometriesProjectionFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbGeometriesProjectionFilter.h:179
otb::GeometriesProjectionFilter::TransformationFunctorType
internal::ReprojectTransformationFunctor TransformationFunctorType
Definition: otbGeometriesProjectionFilter.h:303
otb::internal::ReprojectTransformationFunctor::ByCopy::m_Reprojector
ReprojectTransformationFunctor const & m_Reprojector
Definition: otbGeometriesProjectionFilter.h:68