OTB  9.0.0
Orfeo Toolbox
otbSatelliteRSR.h
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 otbSatelliteRSR_h
22 #define otbSatelliteRSR_h
23 
24 #include <vector>
25 #include <utility>
26 #include <limits>
27 
28 #include "otbSpectralResponse.h"
29 
30 namespace otb
31 {
47 template <class TPrecision = double, class TValuePrecision = double>
48 class SatelliteRSR : public itk::DataObject
49 {
50 public:
52  typedef SatelliteRSR Self;
53  typedef itk::DataObject Superclass;
54  typedef itk::SmartPointer<Self> Pointer;
55  typedef itk::SmartPointer<const Self> ConstPointer;
56 
58  itkNewMacro(Self);
59  ;
60  itkTypeMacro(SatelliteRSR, DataObject);
61  ;
63 
66  itkGetConstMacro(NbBands, unsigned int);
67  ;
68  itkSetMacro(NbBands, unsigned int);
69  ;
71 
72  itkSetMacro(SortBands, bool);
73  ;
74 
76  typedef TPrecision PrecisionType;
77  typedef TValuePrecision ValuePrecisionType;
78 
81  typedef std::vector<SpectralResponsePointerType> RSRVectorType;
83 
85  virtual bool Clear();
86 
88  virtual int Size() const;
89 
91  void Load(const std::string& filename, ValuePrecisionType coefNormalization = 1.0);
92 
94  void Load(PrecisionType lambdaMin, PrecisionType lambdaMax, PrecisionType sampling, 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 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() override{};
156 
157  bool m_SortBands;
158 
159 private:
160  SatelliteRSR(const Self&) = delete;
161  void operator=(const Self&) = delete;
162 
165 
168 
170  unsigned int m_NbBands;
171 };
172 
173 } // end namespace otb
174 
175 
176 #ifndef OTB_MANUAL_INSTANTIATION
177 #include "otbSatelliteRSR.hxx"
178 #endif
179 
180 #endif
otb::SatelliteRSR::m_NbBands
unsigned int m_NbBands
Definition: otbSatelliteRSR.h:170
otb::SatelliteRSR::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSatelliteRSR.h:55
otb::SatelliteRSR::ValuePrecisionType
TValuePrecision ValuePrecisionType
Definition: otbSatelliteRSR.h:77
otb::SpectralResponse::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSpectralResponse.h:61
otb::SatelliteRSR::operator()
ValuePrecisionType operator()(const PrecisionType &lambda, const unsigned int numBand)
Definition: otbSatelliteRSR.hxx:132
otb::SatelliteRSR::sort_band
Definition: otbSatelliteRSR.h:97
otb::SatelliteRSR::operator=
void operator=(const Self &)=delete
otb::SatelliteRSR::RSRVectorType
std::vector< SpectralResponsePointerType > RSRVectorType
Definition: otbSatelliteRSR.h:81
otb::SatelliteRSR::SpectralResponseType
SpectralResponse< TPrecision, TValuePrecision > SpectralResponseType
Definition: otbSatelliteRSR.h:79
otb::SatelliteRSR::PrecisionType
TPrecision PrecisionType
Definition: otbSatelliteRSR.h:72
otb::SatelliteRSR::Superclass
itk::DataObject Superclass
Definition: otbSatelliteRSR.h:53
otb::SatelliteRSR::SatelliteRSR
SatelliteRSR()
Definition: otbSatelliteRSR.hxx:30
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SatelliteRSR::~SatelliteRSR
~SatelliteRSR() override
Definition: otbSatelliteRSR.h:155
otb::SatelliteRSR::Size
virtual int Size() const
Definition: otbSatelliteRSR.hxx:126
otb::SatelliteRSR::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbSatelliteRSR.hxx:147
otb::SatelliteRSR::Clear
virtual bool Clear()
Definition: otbSatelliteRSR.hxx:119
otb::SatelliteRSR::VectorPairType
SpectralResponseType::VectorPairType VectorPairType
Definition: otbSatelliteRSR.h:82
otb::SatelliteRSR::Load
void Load(const std::string &filename, ValuePrecisionType coefNormalization=1.0)
Definition: otbSatelliteRSR.hxx:38
otb::SatelliteRSR::SpectralResponsePointerType
SpectralResponseType::Pointer SpectralResponsePointerType
Definition: otbSatelliteRSR.h:80
otb::SatelliteRSR::Self
SatelliteRSR Self
Definition: otbSatelliteRSR.h:52
otb::SatelliteRSR::sort_band::operator()
bool operator()(SpectralResponsePointerType a, SpectralResponsePointerType b)
Definition: otbSatelliteRSR.h:99
otb::SatelliteRSR::GetSolarIrradiance
SpectralResponseType * GetSolarIrradiance()
Definition: otbSatelliteRSR.h:142
otb::SatelliteRSR
This class represents a hierarchy of vector data.
Definition: otbSatelliteRSR.h:48
otb::SatelliteRSR::m_RSR
RSRVectorType m_RSR
Definition: otbSatelliteRSR.h:164
otb::SatelliteRSR::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSatelliteRSR.h:54
otb::SatelliteRSR::m_SortBands
bool m_SortBands
Definition: otbSatelliteRSR.h:155
otbSpectralResponse.h
otb::SpectralResponse::VectorPairType
std::vector< PairType > VectorPairType
Definition: otbSpectralResponse.h:70
otb::SatelliteRSR::GetRSR
RSRVectorType & GetRSR()
Definition: otbSatelliteRSR.h:136
otb::SpectralResponse
This class represents the spectral response of an object (or a satellite band).
Definition: otbSpectralResponse.h:55
otb::SatelliteRSR::m_SolarIrradiance
SpectralResponsePointerType m_SolarIrradiance
Definition: otbSatelliteRSR.h:167
otbSatelliteRSR.hxx