OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimImageSource.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: Garrett Potts
8 //
9 //*************************************************************************
10 // $Id: ossimImageSource.cpp 23100 2015-01-26 19:43:08Z okramer $
11 
15 
17  "ossimImageSource" ,
19 
21  :ossimSource(owner, 0,0,false,false)
22 {
23 }
24 
26  ossim_uint32 inputListSize,
27  ossim_uint32 outputListSize,
28  bool inputListIsFixedFlag,
29  bool outputListIsFixedFlag)
30  :
31  ossimSource(owner, inputListSize, outputListSize,
32  inputListIsFixedFlag, outputListIsFixedFlag)
33 {
34 }
35 
37 {
38 }
39 
41  ossim_uint32 resLevel)
42 {
43  ossimIrect tileRect(origin.x,
44  origin.y,
45  origin.x + getTileWidth() - 1,
46  origin.y + getTileHeight() - 1);
47 
48  return getTile(tileRect, resLevel);
49 }
50 
52  ossim_uint32 resLevel)
53 {
55  getInput(0));
56  if(inter)
57  {
58  return inter->getTile(rect, resLevel);
59  }
60  return NULL;
61 }
62 
63 
65 {
66  // This is the default implementation that is not thread-friendly as it uses the object's tile
67  // then simply assigns its buffer to the provided tile. Eventually, all image sources should
68  // override this method.
69  bool status = true;
70  if (result)
71  {
72  ossimIrect tileRect = result->getImageRectangle();
73  ossimRefPtr<ossimImageData> id = getTile(tileRect, resLevel);
74  if (id.valid())
75  {
76  *result = *(id.get());
77  result->loadTile(id.get()); // Deep copy
78  }
79  else
80  {
81  status = false;
82  }
83  }
84 
85  return status;
86 }
87 
89  ossimDpt& result)const
90 {
92  getInput(0));
93  if(inter)
94  {
95  inter->getDecimationFactor(resLevel, result);
96  }
97 }
98 
99 void ossimImageSource::getDecimationFactors(std::vector<ossimDpt>& decimations)const
100 {
102  getInput(0));
103  if(inter)
104  {
105  inter->getDecimationFactors(decimations);
106  }
107 }
108 
110 {
112  getInput(0));
113  if(inter)
114  {
115  return inter->getNumberOfDecimationLevels();
116  }
117  return 0;
118 }
119 
121 {
123  getInput(0));
124  if(inter)
125  {
126  return inter->getOutputScalarType();
127  }
128 
129  return OSSIM_SCALAR_UNKNOWN;
130 }
131 
133 {
135  getInput(0));
136  if(inter)
137  {
138  return inter->getTileWidth();
139  }
140  ossimIpt tileSize;
141  ossim::defaultTileSize(tileSize);
142 
143  return tileSize.x;
144 }
145 
147 {
149  if(inter)
150  {
151  return inter->getTileHeight();
152  }
153 
154  ossimIpt tileSize;
155  ossim::defaultTileSize(tileSize);
156 
157  return tileSize.y;
158 }
159 
161 {
163  if(inter)
164  {
165  return inter->getBoundingRect(resLevel);
166  }
167  ossimIrect rect;
168  rect.makeNan();
169  return rect;
170 }
171 
173 {
174  rect = getBoundingRect( resLevel );
175 }
176 
178  const char* prefix)const
179 {
180  return ossimSource::saveState(kwl, prefix);
181 }
182 
184  const char* prefix)
185 {
186  return ossimSource::loadState(kwl, prefix);
187 }
188 
189 //*****************************************************************************
190 // METHOD: ossimImageSource::getValidImageVertices()
191 //*****************************************************************************
192 void ossimImageSource::getValidImageVertices(std::vector<ossimIpt>& validVertices,
193  ossimVertexOrdering ordering,
194  ossim_uint32 resLevel)const
195 {
197  getInput(0));
198  if(inter)
199  {
200  return inter->getValidImageVertices(validVertices,
201  ordering,
202  resLevel);
203  }
204  ossimIrect boundingRect = getBoundingRect(resLevel);
205  validVertices.clear();
206 
207  if(ordering == OSSIM_CLOCKWISE_ORDER)
208  {
209  validVertices.push_back(boundingRect.ul());
210  validVertices.push_back(boundingRect.ur());
211  validVertices.push_back(boundingRect.lr());
212  validVertices.push_back(boundingRect.ll());
213  }
214  else
215  {
216  validVertices.push_back(boundingRect.ul());
217  validVertices.push_back(boundingRect.ll());
218  validVertices.push_back(boundingRect.lr());
219  validVertices.push_back(boundingRect.ur());
220  }
221 }
222 
224 {
226  getInput(0));
227  if(inter)
228  {
229  return inter->getNullPixelValue(band);
230  }
231 
233 }
234 
236 {
238  getInput(0));
239  if(inter)
240  {
241  return inter->getMinPixelValue(band);
242  }
244 }
245 
247 {
249  getInput(0));
250  if(inter)
251  {
252  return inter->getMaxPixelValue(band);
253  }
254 
256 }
257 
258 //**************************************************************************************************
259 // Default implementation returns the image geometry object associated with the first input source
260 // (if any) connected to this source, or NULL.
261 //**************************************************************************************************
263 {
265  if ( getInput(0) )
266  {
268  if( inter )
269  {
270  result = inter->getImageGeometry();
271  }
272  }
273  return result;
274 }
275 
276 //**************************************************************************************************
278 //**************************************************************************************************
280 {
282  if (inter)
283  {
284  inter->setImageGeometry(geom);
285  }
286 }
287 
289 {
291  if (inter)
292  {
293  inter->saveImageGeometry();
294  }
295 }
296 
297 void ossimImageSource::saveImageGeometry(const ossimFilename& geometry_file) const
298 {
300  if (inter)
301  {
302  inter->saveImageGeometry(geometry_file);
303  }
304 }
305 
306 void ossimImageSource::getOutputBandList(std::vector<ossim_uint32>& bandList) const
307 {
308  const ossim_uint32 INPUT_BANDS = getNumberOfInputBands();
309  if ( INPUT_BANDS )
310  {
311  bandList.resize( INPUT_BANDS );
312  for ( ossim_uint32 band = 0; band < INPUT_BANDS; ++band )
313  {
314  bandList[band] = band;
315  }
316  }
317  else
318  {
319  bandList.clear();
320  }
321 }
322 
324 {
325  return getNumberOfInputBands();
326 }
327 
329 {
331 
332  ossimString tempName = name;
333  if(result.valid())
334  {
335  if(tempName.downcase() == ossimKeywordNames::ENABLED_KW)
336  {
337  result->clearChangeType();
338 
339  // we will at least say its a radiometric change
340  //
341  result->setFullRefreshBit();
342  }
343  }
344 
345  return result;
346 }
347 
349 {
350  ossimSource::setProperty(property);
351 }
352 
353 void ossimImageSource::getPropertyNames(std::vector<ossimString>& propertyNames)const
354 {
355  ossimSource::getPropertyNames(propertyNames);
356 }
357 
359 {
360  bool result = false;
362  if (inter)
363  {
364  result = inter->isIndexedData();
365  }
366  return result;
367 }
368 
369 // Protected to hide from use...
371  :ossimSource()
372 {}
373 
374 // Protected to hide from use...
376 {
377  return *this;
378 }
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
This will return the bounding rect of the source.
virtual bool isIndexedData() const
virtual void setProperty(ossimRefPtr< ossimProperty > property)
Represents serializable keyword/value map.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Definition: ossimSource.cpp:55
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Definition: ossimSource.cpp:66
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
const ossimImageSource & operator=(const ossimImageSource &)
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
OSSIM_DLL void defaultTileSize(ossimIpt &tileSize)
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossim_uint32 getNumberOfDecimationLevels() const
Will return the number of resolution levels.
const ossimIpt & ll() const
Definition: ossimIrect.h:277
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
virtual ossim_uint32 getTileWidth() const
Returns the default processing tile width.
void setFullRefreshBit()
ossimConnectableObject * getInput(ossim_uint32 index=0)
returns the object at the specified index.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
virtual void setImageGeometry(const ossimImageGeometry *geom)
Default implementation sets geometry of the first input to the geometry specified.
OSSIM_DLL double defaultMin(ossimScalarType scalarType)
Definition: ossimCommon.cpp:73
virtual void getOutputBandList(std::vector< ossim_uint32 > &bandList) const
Initializes bandList.
void clearChangeType()
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
virtual void saveImageGeometry() const
Default method to call input&#39;s saveImageGeometry.
ossimVertexOrdering
OSSIM_DLL double defaultNull(ossimScalarType scalarType)
virtual void getValidImageVertices(std::vector< ossimIpt > &validVertices, ossimVertexOrdering ordering=OSSIM_CLOCKWISE_ORDER, ossim_uint32 resLevel=0) const
ordering specifies how the vertices should be arranged.
unsigned int ossim_uint32
ossimImageSource(ossimObject *owner=0)
#define PTR_CAST(T, p)
Definition: ossimRtti.h:321
virtual ossimIrect getImageRectangle() const
const ossimIpt & lr() const
Definition: ossimIrect.h:276
RTTI_DEF1(ossimImageSource, "ossimImageSource", ossimSource) ossimImageSource
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
static const char * ENABLED_KW
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
const ossimIpt & ur() const
Definition: ossimIrect.h:275
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
ossimScalarType
return status
OSSIM_DLL double defaultMax(ossimScalarType scalarType)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
ossim_int32 y
Definition: ossimIpt.h:142
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
void makeNan()
Definition: ossimIrect.h:329
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
ossim_int32 x
Definition: ossimIpt.h:141
virtual ~ossimImageSource()
virtual ossim_uint32 getNumberOfInputBands() const =0
virtual void getDecimationFactor(ossim_uint32 resLevel, ossimDpt &result) const
Will return the decimation factor for the given resolution level.
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
virtual void getDecimationFactors(std::vector< ossimDpt > &decimations) const
Will return an array of all decimations for each resolution level.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)