OTB  9.0.0
Orfeo Toolbox
otbSensorTransformFactory.hxx
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 #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 
49  for (auto& transformFactory : factories)
50  {
51  transformPointer = transformFactory(imd, direction);
52  if (transformPointer)
53  {
54  if (transformPointer->IsValidSensorModel() && transformPointer->getDirection() == direction)
55  {
56  return transformPointer;
57  }
58  }
59  }
60  // if no object has been found, we have to warn the user
61  otbLogMacro(Warning, << "The SensorTransform factory could not find a compatible Sensor Transform");
62  return nullptr;
63 }
64 
65 } // end namespace otb
66 
67 #endif
otb::TransformDirection
TransformDirection
Definition: otbTransform.h:30
otbLogMacro
#define otbLogMacro(level, msg)
Definition: otbMacro.h:52
otb::SensorTransformBase::getDirection
TransformDirection getDirection() const
Definition: otbSensorTransformBase.h:82
otbTransform.h
otb::SensorTransformBase::IsValidSensorModel
virtual bool IsValidSensorModel() const =0
otb::SensorTransformFactory::CreateTransform
otb::SensorTransformBase< TScalarType, NInputDimensions, NOutputDimensions >::Pointer CreateTransform(const ImageMetadata &imd, TransformDirection d) const
Definition: otbSensorTransformFactory.hxx:34
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbSensorTransformFactory.h
otb::SensorTransformBase::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSensorTransformBase.h:56
otbTransformFactories.h
otb::ImageMetadata
Generic class containing image metadata used in OTB.
Definition: otbImageMetadata.h:270
otbImageMetadata.h