OTB  9.0.0
Orfeo Toolbox
otbTileMapTransform.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 
21 #ifndef otbTileMapTransform_hxx
22 #define otbTileMapTransform_hxx
23 
24 #include "otbTileMapTransform.h"
25 #include "otbMacro.h"
26 #include "otbMath.h"
27 
28 namespace otb
29 {
30 
31 template <TransformDirection TTransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
33 {
34 }
35 
36 template <TransformDirection TTransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
38 {
39 }
40 
41 template <TransformDirection TTransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
44 {
45  OutputPointType outputPoint;
46 
47  if (DirectionOfMapping == TransformDirection::INVERSE)
48  {
49  outputPoint[0] = static_cast<double>(point[0]) / (1 << m_Depth) / 256 * 360.0 - 180.0;
50  double y = static_cast<double>(point[1]) / (1 << m_Depth) / 256;
51  double ex = exp(4 * CONST_PI * (y - 0.5));
52  outputPoint[1] = -180.0 / CONST_PI * asin((ex - 1) / (ex + 1));
53  }
54 
55  if (DirectionOfMapping == TransformDirection::FORWARD)
56  {
57  double x = (180.0 + point[0]) / 360.0;
58  double y = -point[1] * CONST_PI / 180; // convert to radians
59  y = 0.5 * log((1 + sin(y)) / (1 - sin(y)));
60  y *= 1.0 / (2 * CONST_PI); // scale factor from radians to normalized
61  y += 0.5; // and make y range from 0 - 1
62 
63  outputPoint[0] = floor(x * pow(2., static_cast<double>(m_Depth)) * 256);
64  outputPoint[1] = floor(y * pow(2., static_cast<double>(m_Depth)) * 256);
65  }
66  return outputPoint;
67 }
68 
69 template <TransformDirection TTransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
71 {
72 }
73 
74 template <TransformDirection TTransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
76 {
77  this->SetDepth(level);
78 }
79 
80 template <TransformDirection TTransformDirection, class TScalarType, unsigned int NInputDimensions, unsigned int NOutputDimensions>
82 {
83  return this->GetDepth();
84 }
85 
86 } // namespace otb
87 
88 #endif
otb::TileMapTransform::GetLevel
unsigned int GetLevel() const
Definition: otbTileMapTransform.hxx:81
otb::CONST_PI
constexpr double CONST_PI
Definition: otbMath.h:49
otb::TileMapTransform::OutputPointType
itk::Point< ScalarType, NOutputDimensions > OutputPointType
Definition: otbTileMapTransform.h:52
otb::TileMapTransform::~TileMapTransform
~TileMapTransform() override
Definition: otbTileMapTransform.hxx:37
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbMacro.h
otb::TileMapTransform::InputPointType
itk::Point< ScalarType, NInputDimensions > InputPointType
Definition: otbTileMapTransform.h:51
otb::Transform
Class to overload method passed to virtual pure in ITK V4.
Definition: otbTransform.h:39
otbTileMapTransform.h
otb::TransformDirection::INVERSE
@ INVERSE
otb::TileMapTransform::SetLevel
void SetLevel(unsigned int level)
Definition: otbTileMapTransform.hxx:75
otb::TransformDirection::FORWARD
@ FORWARD
otb::TileMapTransform::PrintMap
virtual void PrintMap() const
Definition: otbTileMapTransform.hxx:70
otb::TileMapTransform::TransformPoint
OutputPointType TransformPoint(const InputPointType &point) const override
Definition: otbTileMapTransform.hxx:43
otb::TileMapTransform::TileMapTransform
TileMapTransform()
Definition: otbTileMapTransform.hxx:32