Orfeo Toolbox  4.0
otbGenericMapProjection.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbGenericMapProjection_txx
19 #define __otbGenericMapProjection_txx
20 
22 #include "otbMacro.h"
23 
24 namespace otb
25 {
26 
27 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
28  unsigned int NOutputDimensions>
30 ::GenericMapProjection() : Superclass(ParametersDimension)
31 {
32  m_MapProjection = MapProjectionAdapter::New();
33 }
34 
35 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
36  unsigned int NOutputDimensions>
39 {
40 }
41 
42 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
43  unsigned int NOutputDimensions>
47 {
48  return m_MapProjection;
49 }
50 
51 
52 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
53  unsigned int NOutputDimensions>
54 std::string
57 {
58  return m_MapProjection->GetWkt();
59 }
60 
61 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
62  unsigned int NOutputDimensions>
63 void
65 ::SetWkt(const std::string& projectionRefWkt)
66 {
67  m_MapProjection->SetWkt(projectionRefWkt);
68  this->Modified();
69 }
70 
71 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
72  unsigned int NOutputDimensions>
73 bool
76 {
77  return m_MapProjection->InstanciateProjection();
78 }
79 
80 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
81  unsigned int NOutputDimensions>
84 ::TransformPoint(const InputPointType& point) const
85 {
86  OutputPointType outputPoint;
87 
88  if (DirectionOfMapping == TransformDirection::INVERSE)
89  {
90 
91  double lon, lat, h;
92  double z = 0.0;
93  if (InputPointType::PointDimension == 3) z = point[2];
94 
95  m_MapProjection->InverseTransform(point[0], point[1], z, lon, lat, h);
96 
97  outputPoint[0] = lon;
98  outputPoint[1] = lat;
99  if (OutputPointType::PointDimension == 3) outputPoint[2] = h;
100 
101  }
102  if (DirectionOfMapping == TransformDirection::FORWARD)
103  {
104 
105  double x, y, z;
106  double h = 0.0;
107  if (InputPointType::PointDimension == 3) h = point[2];
108  m_MapProjection->ForwardTransform(point[0], point[1], h, x, y, z);
109  outputPoint[0] = x;
110  outputPoint[1] = y;
111  if (OutputPointType::PointDimension == 3) outputPoint[2] = z;
112 
113  }
114 
115  return outputPoint;
116 }
117 
118 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
119  unsigned int NOutputDimensions>
120 void
122 ::PrintMap() const
123 {
124  m_MapProjection->PrintMap();
125 }
126 
127 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
128  unsigned int NOutputDimensions>
129 bool
132 {
133  return (m_MapProjection->GetMapProjection() != NULL);
134 }
135 
136 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
137  unsigned int NOutputDimensions>
138  void
140 ::SetParameter(const std::string& key, const std::string& value)
141 {
142  m_MapProjection->SetParameter(key, value);
143 }
144 
145 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
146  unsigned int NOutputDimensions>
147 std::string
149 ::GetParameter(const std::string& key) const
150 {
151  return m_MapProjection->GetParameter(key);
152 }
153 
154 template<TransformDirection::TransformationDirection TDirectionOfMapping, class TScalarType, unsigned int NInputDimensions,
155  unsigned int NOutputDimensions>
156 void
158 ::PrintSelf(std::ostream& os, itk::Indent indent) const
159 {
160  Superclass::PrintSelf(os, indent);
161  os << indent << "ProjectionRefWkt: " << m_MapProjection->GetWkt() << std::endl;
162 }
163 
164 } // namespace otb
165 
166 #endif

Generated at Sat Mar 8 2014 15:57:04 for Orfeo Toolbox with doxygen 1.8.3.1