OTB  10.0.0
Orfeo Toolbox
otbSensorTransformFactory.hxx
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 #ifndef otbSensorTransformFactory_hxx
21 #define otbSensorTransformFactory_hxx
22 
23 #include "otbImageMetadata.h"
25 #include "otbTransform.h"
26 #include "otbTransformFactories.h"
27 #include <functional>
28 
29 namespace otb
30 {
31 
32 template <class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
35 {
36  // Instantiate the factories
37  std::vector<
38  std::function<
40  TransformDirection direction)
41  >
42  > factories;
43  factories.push_back(TransformFactories::RPCForwardTransformFactory<TScalarType, NInputDimensions, NOutputDimensions>);
44  factories.push_back(TransformFactories::RPCInverseTransformFactory<TScalarType, NInputDimensions, NOutputDimensions>);
45  factories.push_back(TransformFactories::SARForwardTransformFactory<TScalarType, NInputDimensions, NOutputDimensions>);
46  factories.push_back(TransformFactories::SARInverseTransformFactory<TScalarType, NInputDimensions, NOutputDimensions>);
47  factories.push_back(TransformFactories::Spot5ForwardTransformFactory<TScalarType, NInputDimensions, NOutputDimensions>);
48  factories.push_back(TransformFactories::Spot5InverseTransformFactory<TScalarType, NInputDimensions, NOutputDimensions>);
49 
51  for (auto& transformFactory : factories)
52  {
53  transformPointer = transformFactory(imd, direction);
54  if (transformPointer)
55  {
56  if (transformPointer->IsValidSensorModel() && transformPointer->getDirection() == direction)
57  {
58  return transformPointer;
59  }
60  }
61  }
62  // if no object has been found, we have to warn the user
63  otbLogMacro(Warning, << "The SensorTransform factory could not find a compatible Sensor Transform");
64  return nullptr;
65 }
66 
67 } // end namespace otb
68 
69 #endif
Generic class containing image metadata used in OTB.
TransformDirection getDirection() const
virtual bool IsValidSensorModel() const =0
itk::SmartPointer< Self > Pointer
otb::SensorTransformBase< TScalarType, NInputDimensions, NOutputDimensions >::Pointer CreateTransform(const ImageMetadata &imd, TransformDirection d) const
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
TransformDirection
Definition: otbTransform.h:30
#define otbLogMacro(level, msg)
Definition: otbMacro.h:104