OTB  6.1.0
Orfeo Toolbox
otbSatelliteRSR.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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 otbSatelliteRSR_h
22 #define otbSatelliteRSR_h
23 
24 #include <vector>
25 #include <utility>
26 #include <fstream>
27 #include <limits>
28 
29 #include "otbSpectralResponse.h"
30 
31 namespace otb
32 {
48 template<class TPrecision = double, class TValuePrecision = double>
50 {
51 public:
53  typedef SatelliteRSR Self;
57 
59  itkNewMacro(Self)
60 ; itkTypeMacro(SatelliteRSR, DataObject)
61 ;
63 
66  itkGetConstMacro(NbBands, unsigned int)
67 ; itkSetMacro(NbBands, unsigned int)
68 ;
70 
71  itkSetMacro(SortBands, bool)
72 ;
73 
75  typedef TPrecision PrecisionType;
76  typedef TValuePrecision ValuePrecisionType;
77 
80  typedef std::vector<SpectralResponsePointerType> RSRVectorType;
82 
84  virtual bool Clear();
85 
87  virtual int Size() const;
88 
90  void Load(const std::string & filename, ValuePrecisionType coefNormalization = 1.0);
91 
93  void Load(PrecisionType lambdaMin, PrecisionType lambdaMax, PrecisionType sampling,
94  ValuePrecisionType coefNormalization = 1.0);
95 
97  struct sort_band
98  {
100  {
101  PrecisionType aFirstNotNull;
102  PrecisionType bFirstNotNull;
104 
105  typename VectorPairType::const_iterator it = a->GetResponse().begin();
106 
107  while ((*it).second == 0)
108  {
109  ++it;
110  }
111  aFirstNotNull = (*it).first;
112 
113  typename VectorPairType::const_iterator it2 = b->GetResponse().begin();
114 
115  while ((*it2).second == 0)
116  {
117  ++it2;
118  }
119  bFirstNotNull = (*it2).first;
120 
121  return aFirstNotNull < bFirstNotNull;
122  }
123  };
124 
130  inline ValuePrecisionType operator()(const PrecisionType & lambda, const unsigned int numBand);
131 
133  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
134 
137  {
138  return m_RSR;
139  }
140 
143  {
144  return m_SolarIrradiance;
145  }
146 
147 protected:
149  SatelliteRSR();
150 
152  //SatelliteRSR( const std::string & filename );
153 
155  ~SatelliteRSR() ITK_OVERRIDE
156  {
157  }
158 ;
159 
160  bool m_SortBands;
161 
162 private:
163  SatelliteRSR(const Self&); //purposely not implemented
164  void operator=(const Self&); //purposely not implemented
165 
168 
171 
173  unsigned int m_NbBands;
174 };
175 
176 }// end namespace otb
177 
178 
179 #ifndef OTB_MANUAL_INSTANTIATION
180 #include "otbSatelliteRSR.txx"
181 #endif
182 
183 #endif
184 
std::vector< PairType > VectorPairType
std::vector< SpectralResponsePointerType > RSRVectorType
itk::SmartPointer< Self > Pointer
~SatelliteRSR() ITK_OVERRIDE
This class represents a hierarchy of vector data.
SpectralResponseType * GetSolarIrradiance()
RSRVectorType & GetRSR()
SpectralResponseType::Pointer SpectralResponsePointerType
SpectralResponseType::VectorPairType VectorPairType
itk::DataObject Superclass
SpectralResponsePointerType m_SolarIrradiance
TPrecision PrecisionType
bool operator()(SpectralResponsePointerType a, SpectralResponsePointerType b)
SpectralResponse< TPrecision, TValuePrecision > SpectralResponseType
unsigned int m_NbBands
TValuePrecision ValuePrecisionType
virtual bool Clear()
itk::SmartPointer< const Self > ConstPointer
void Load(const std::string &filename, ValuePrecisionType coefNormalization=1.0)
void operator=(const Self &)
This class represents the spectral response of an object (or a satellite band).
RSRVectorType m_RSR
SatelliteRSR Self
ValuePrecisionType operator()(const PrecisionType &lambda, const unsigned int numBand)
virtual int Size() const
void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE