1 //----------------------------------------------------------------------------
2 //
3 // License:  MIT
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author:  David Burken
8 //
9 // Description: Class declaration for ossimWavelength.
10 // See class description below.
11 //
12 //----------------------------------------------------------------------------
13 // $Id$
14 
15 #ifndef ossimWavelength_HEADER
16 #define ossimWavelength_HEADER 1
17 
18 #include <ossim/base/ossimConstants.h>
19 #include <iostream>
20 #include <map>
21 #include <vector>
22 
23 
24 class ossimEnviHeader;
25 
26 /**
27  * @class ossimWavelenght class.
28  *
29  * Simple container class encapsulating a std::map of wavelengths(key) and associated
30  * bands(value), with convenience methods.  Wavelengths values are 64 bit
31  * floating point in nanometers. Bands are zero based
32  * 32 bit unsigned integers.
33  */
34 class OSSIM_DLL ossimWavelength
35 {
36 public:
37 
38    typedef std::map< ossim_float64, ossim_uint32 > WavelengthMap;
39 
40    /** @brief default constructor */
41    ossimWavelength();
42 
43    /** @brief copy constructor */
44    ossimWavelength( const ossimWavelength& obj );
45 
46    /** @brief assignment operator= */
47    const ossimWavelength& operator=( const ossimWavelength& rhs );
48 
49    /** @brief virtual destructor */
50    ~ossimWavelength();
51 
52    const ossimWavelength::WavelengthMap& getMap() const;
53 
54    ossimWavelength::WavelengthMap& getMap();
55 
56    /**
57     * @brief Initializes map from ENVI header class.
58     *
59     * This will clear any existing map, look for the keywords
60     * "wavelength units" and "wavelength".
61     *
62     * @param header to initialize from.
63     * @return true on success, false on error.
64     */
65    bool initialize( const ossimEnviHeader& hdr );
66 
67    /**
68     * @brief Finds iterator closest to wavelength.
69     * @param requestedWavelength Requested wavelength in nanometers.
70     * @param thresholdFromCenter in nanometers.
71     * @return WavelengthMap::const_iterator if not found will return.
72     */
73    WavelengthMap::const_iterator findClosestIterator(
74       const ossim_float64& requestedWavelength,
75       const ossim_float64& thresholdFromCenter  ) const;
76 
77    /**
78     * @brief Finds index closest to wavelength.
79     * @param requestedWavelength Requested wavelength in nanometers.
80     * @param thresholdFromCenter in nanometers.
81     * @return Closest zero based index to wavelength or -1 if not found.
82     */
83    ossim_int32 findClosestIndex(
84       const ossim_float64& requestedWavelength,
85       const ossim_float64& thresholdFromCenter  ) const;
86 
87    /**
88     * @brief Gets rgb bands if "wavelength" keyword is present.
89     * @param bands Initialized by this with zero base rbg band
90     * indexes.
91     * @return true on success, false if bands not found.
92     */
93    bool getRgbBands( std::vector<ossim_uint32>& bands ) const;
94 
95    /** @return WavelengthMap::const_iterator of underlying map. */
96    WavelengthMap::const_iterator end() const;
97 
98    /** @return WavelengthMap::iterator of underlying map. */
99    WavelengthMap::iterator end();
100 
101 private:
102 
103    WavelengthMap m_map;
104 };
105 
106 #endif /* End of "#ifndef ossimWavelength_HEADER" */
107