OTB  10.0.0
Orfeo Toolbox
otbGeometriesProjectionFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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 
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
This is the class to handle generic remote sensing transform.
itk::SmartPointer< Self > Pointer
void DoFinalizeInitialization() override
internal::ReprojectTransformationFunctor TransformationFunctorType
TransformationFunctorType::InternalTransformType InternalTransformType
TransformationFunctorDispatcherType m_TransformationFunctor
TransformationFunctorDispatcher< TransformationFunctorType, TransformedElementType, FieldCopyTransformation > TransformationFunctorDispatcherType
Superclass::OutputGeometriesType OutputGeometriesType
OGRSpatialReference * DoDefineNewLayerSpatialReference(ogr::Layer const &source) const override
itk::SmartPointer< const Self > ConstPointer
void SetOutputImageMetadata(const ImageMetadata *imd)
void DoProcessLayer(ogr::Layer const &source, ogr::Layer &destination) const override
const ImageMetadata * GetOutputImageMetadata() const
TransformationFunctorType::TransformedElementType TransformedElementType
void SetInputImageMetadata(const ImageMetadata *imd)
Superclass::InputGeometriesType InputGeometriesType
ogr::ImageReference< double > ImageReference
TransformationFunctorType::InternalTransformPointerType InternalTransformPointerType
const ImageMetadata * GetInputImageMetadata() const
void DoDefineNewLayerFields(ogr::Layer const &source, ogr::Layer &dest) const override
void GenerateOutputInformation(void) override
Generic class containing image metadata used in OTB.
Layer of geometric objects.
boost::interprocess::unique_ptr< OGRGeometry, internal::GeometryDeleter > UniqueGeometryPtr
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
ogr::UniqueGeometryPtr operator()(TGeometry const *in) const
ByCopy(ReprojectTransformationFunctor const &reprojector)
InPlace(ReprojectTransformationFunctor const &reprojector)
otb::GenericRSTransform< double, 2, 2 > InternalTransformType
void apply_inplace(OGRGeometry *inout) const
void do_transform(OGRGeometryCollection &g) const
ogr::UniqueGeometryPtr operator()(OGRGeometry const *in) const
void do_transform(OGRLineString &g) const