OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimAOD.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2002 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Kathy Minear
9 //
10 // Description:
11 //
12 // Class to compute Aerosol Optical Depth (AOD) for with atmospheric
13 // correction.
14 //
15 //
16 //*************************************************************************
17 // $Id: ossimAOD.cpp 17206 2010-04-25 23:20:40Z dburken $
18 
19 #include <math.h>
20 #include <ossim/imaging/ossimAOD.h>
21 #include <ossim/base/ossimTrace.h>
24 
25 
27 
28 static ossimTrace traceDebug("ossimAOD:debug");
29 
31  :
32  ossimImageSourceFilter (owner), // base class
33  theTile (NULL)
34 {
35  //***
36  // Set the base class "theEnableFlag" to off since no adjustments have been
37  // made yet.
38  //***
39  disableSource();
40 
41  // Construction not complete.
42 }
43 
45  :
46  ossimImageSourceFilter (NULL, inputSource), // base class
47  theTile (NULL)
48 {
49  //***
50  // Set the base class "theEnableFlag" to off since no adjustments have been
51  // made yet.
52  //***
53  disableSource();
54 
55  if (inputSource == NULL)
56  {
58  cerr << "ossimAOD::ossimAOD ERROR:"
59  << "\nNull input source passed to constructor!" << endl;
60  return;
61  }
62 
63  initialize();
64 }
65 
66 
68  ossimImageSource* inputSource)
69  :
70  ossimImageSourceFilter (owner, inputSource), // base class
71  theTile (NULL)
72 {
73  //***
74  // Set the base class "theEnableFlag" to off since no adjustments have been
75  // made yet.
76  //***
77  disableSource();
78 
79  if (inputSource == NULL)
80  {
82  cerr << "ossimAOD::ossimAOD ERROR:"
83  << "\nNull input source passed to constructor!" << endl;
84  return;
85  }
86 
87  initialize();
88 }
89 
91 {
92 }
93 
95  ossim_uint32 resLevel)
96 {
97  if (!theInputConnection)
98  {
100  }
101 
102  // Fetch tile from pointer from the input source.
104  resLevel);
105 
106 
107  if (!inputTile.valid()) // Just in case...
108  {
110  << "ossimAOD::getTile ERROR:"
111  << "\nReceived null pointer to tile from input source!"
112  << "\nReturning blank tile."
113  << endl;
114  return inputTile;
115  }
116 
117  ossimDataObjectStatus tile_status = inputTile->getDataObjectStatus();
118 
119  if ( !theEnableFlag ||
120  (tile_status == OSSIM_NULL) ||
121  (tile_status == OSSIM_EMPTY) )
122  {
123  return inputTile;
124  }
125 
126  if (!theTile.valid())
127  {
128  allocate();
129  if (!theTile.valid())
130  {
131  return inputTile;
132  }
133  }
134 
135  ossim_uint32 w = tile_rect.width();
136  ossim_uint32 h = tile_rect.height();
137  ossim_uint32 tw = theTile->getWidth();
139  // ossim_uint32 bands = theTile->getNumberOfBands();
140 
141  // Set the origin of the output tile.
142  theTile->setOrigin(tile_rect.ul());
143 
144  if(w*h != tw*th)
145  {
146  theTile->setWidthHeight(w, h);
147  theTile->initialize();
148  }
149  return theTile;
150 }
151 
153 {
155 }
156 
158 {
160  {
163  theTile->initialize();
164  setInitializedFlag(true);
166  }
167  else
168  {
169  setInitializedFlag(false);
170  setErrorStatus();
171  cerr << "ossimAOD::initialize ERROR:"
172  << "\nCannot call method when input connection is NULL!"
173  << endl;
174  };
175 
176  verifyEnabled();
177 }
178 
179 bool ossimAOD::loadState(const ossimKeywordlist& /* kwl */, const char* /* prefix */)
180 {
181  static const char MODULE[] = "ossimAOD::loadState()";
182 
183  if (traceDebug()) CLOG << "entering..." << endl;
184 
185  if (!theTile)
186  {
187  cerr << MODULE << " ERROR:"
188  << "Not initialized..." << endl;
189  return false;
190  }
191 
192  if (traceDebug())
193  {
194  CLOG << "DEBUG:"
195  << *this
196  << "\nreturning..."
197  << endl;
198  }
199 
200  return true;
201 }
202 
203 
205 {
206  // Check all the pointers...
207  if ( !theInputConnection || !theTile )
208  {
209  disableSource();
210  return;
211  }
212 
213  enableSource();
214 }
215 
217 {
218  os << "ossimAOD:"
219  << "\ntheEnableFlag: " << (theEnableFlag?"enabled":"disabled")
220  << endl;
221 
222  return os;
223 }
224 
226 {
227  return hr.print(os);
228 }
229 
231 {
232 }
233 
235 {
236  return ossimString("Aerosol Optical Depth");
237 }
virtual ossim_uint32 getWidth() const
#define CLOG
Definition: ossimTrace.h:23
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Definition: ossimAOD.cpp:179
virtual ~ossimAOD()
Definition: ossimAOD.cpp:90
virtual void setWidthHeight(ossim_uint32 w, ossim_uint32 h)
Represents serializable keyword/value map.
bool theEnableFlag
Definition: ossimSource.h:62
bool valid() const
Definition: ossimRefPtr.h:75
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual void disableSource()
Definition: ossimSource.cpp:89
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossim_uint32 getHeight() const
virtual void setInitializedFlag(bool flag)
virtual void initialize()
Initialize the data buffer.
static ossimImageDataFactory * instance()
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
Definition: ossimAOD.cpp:94
ossimImageSource * theInputConnection
unsigned int ossim_uint32
ostream & operator<<(ostream &os, const ossimAOD &hr)
Definition: ossimAOD.cpp:225
virtual void enableSource()
Definition: ossimSource.cpp:84
void allocate()
Definition: ossimAOD.cpp:157
virtual ossimRefPtr< ossimImageData > create(ossimSource *owner, ossimScalarType scalar, ossim_uint32 bands=1) const
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimRefPtr< ossimImageData > theTile
Definition: ossimAOD.h:60
void verifyEnabled()
Definition: ossimAOD.cpp:204
virtual ossimString getShortName() const
Definition: ossimAOD.cpp:234
virtual void setOrigin(const ossimIpt &origin)
virtual ostream & print(ostream &os) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
Definition: ossimAOD.cpp:216
static void writeTemplate(ostream &os)
Definition: ossimAOD.cpp:230
virtual void initialize()
Definition: ossimAOD.cpp:152
#define RTTI_DEF1(cls, name, b1)
Definition: ossimRtti.h:485
ossimDataObjectStatus
Definitions for data object status.
ossimAOD(ossimObject *owner=NULL)
Definition: ossimAOD.cpp:30
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)