OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
MEMTiledRasterBand Class Reference

#include <ossimGdalTiledDataset.h>

Inheritance diagram for MEMTiledRasterBand:

Public Member Functions

 MEMTiledRasterBand (GDALDataset *poDS, int nBand, GByte *pabyData, GDALDataType eType, int nPixelOffset, int nLineOffset, int bAssumeOwnership)
 
virtual ~MEMTiledRasterBand ()
 
virtual CPLErr IReadBlock (int, int, void *)
 
virtual CPLErr IWriteBlock (int, int, void *)
 

Protected Attributes

MEMTiledDatasettheDataset
 
ossimImageSourceSequencertheInterface
 

Private Member Functions

void copyNulls (void *pImage, int count) const
 Copies null values to pImage. More...
 
template<class T >
void copyNulls (void *pImage, int count, T dummyTemplate) const
 Copies null values to pImage. More...
 

Friends

class MEMTiledDataset
 

Detailed Description

Definition at line 76 of file ossimGdalTiledDataset.h.

Constructor & Destructor Documentation

◆ MEMTiledRasterBand()

MEMTiledRasterBand::MEMTiledRasterBand ( GDALDataset *  poDS,
int  nBand,
GByte *  pabyData,
GDALDataType  eType,
int  nPixelOffset,
int  nLineOffset,
int  bAssumeOwnership 
)

Definition at line 41 of file ossimGdalTiledDataset.cpp.

48  :
49  MEMRasterBand(poDS,
50  nBand,
51  pabyData,
52  eType,
53  nPixelOffset,
54  nLineOffset,
55  bAssumeOwnership),
56  theDataset(NULL),
57  theInterface(NULL)
58 {
59 }
MEMTiledDataset * theDataset
ossimImageSourceSequencer * theInterface

◆ ~MEMTiledRasterBand()

MEMTiledRasterBand::~MEMTiledRasterBand ( )
virtual

Definition at line 65 of file ossimGdalTiledDataset.cpp.

67 {
68  CPLDebug( "MEM", "~MEMTiledRasterBand(%p)", this );
69  if( bOwnData )
70  {
71  CPLDebug( "MEM", "~MEMTiledRasterBand() - free raw data." );
72  VSIFree( pabyData );
73  }
74 }

Member Function Documentation

◆ copyNulls() [1/2]

void MEMTiledRasterBand::copyNulls ( void *  pImage,
int  count 
) const
private

Copies null values to pImage.

Parameters
pImageBuffer to copy to.
countpixels to null out.

Definition at line 482 of file ossimGdalTiledDataset.cpp.

References ossimRectilinearDataObject::getScalarType(), OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SCALAR_UNKNOWN, OSSIM_SINT16, OSSIM_SINT32, OSSIM_SINT8, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, MEMTiledDataset::theData, theDataset, and ossimRefPtr< T >::valid().

483 {
484  if (theDataset && pImage)
485  {
486  if (theDataset->theData.valid())
487  {
488  switch (theDataset->theData->getScalarType())
489  {
490  case OSSIM_UINT8:
491  {
492  return copyNulls(pImage, count, ossim_uint8(0));
493  }
494  case OSSIM_SINT8:
495  {
496  return copyNulls(pImage, count, ossim_sint8(0));
497  }
498 
499  case OSSIM_UINT16:
500  case OSSIM_USHORT11:
501  {
502  return copyNulls(pImage, count, ossim_uint16(0));
503  }
504  case OSSIM_SINT16:
505  {
506  return copyNulls(pImage, count, ossim_sint16(0));
507  }
508 
509  case OSSIM_UINT32:
510  {
511  return copyNulls(pImage, count, ossim_uint32(0));
512  }
513  case OSSIM_SINT32:
514  {
515  return copyNulls(pImage, count, ossim_sint32(0));
516  }
517  case OSSIM_FLOAT32:
519  {
520  return copyNulls(pImage, count, ossim_float32(0.0));
521  }
522 
524  case OSSIM_FLOAT64:
525  {
526  return copyNulls(pImage, count, ossim_float64(0.0));
527  }
529  default:
530  {
531  break;
532  }
533 
534  } // End of "switch (theDataset->theData->getScalarType())"
535 
536  } // End of "if (theDataset->theData.valid())"
537 
538  } // End of "if (theDataset && pImage)"
539 }
8 bit signed integer
64 bit floating point
16 bit unsigned integer
bool valid() const
Definition: ossimRefPtr.h:75
float ossim_float32
16 bit signed integer
signed char ossim_sint8
32 bit floating point
unsigned short ossim_uint16
32 bit unsigned integer
MEMTiledDataset * theDataset
double ossim_float64
signed short ossim_sint16
32 bit signed integer
unsigned int ossim_uint32
32 bit normalized floating point
signed int ossim_sint32
virtual ossimScalarType getScalarType() const
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
8 bit unsigned integer
unsigned char ossim_uint8
ossimRefPtr< ossimImageData > theData
void copyNulls(void *pImage, int count) const
Copies null values to pImage.

◆ copyNulls() [2/2]

template<class T >
void MEMTiledRasterBand::copyNulls ( void *  pImage,
int  count,
dummyTemplate 
) const
private

Copies null values to pImage.

Parameters
pImageBuffer to copy to.
countpixels to null out.
dummyTemplateDummy for scalar type.

Definition at line 542 of file ossimGdalTiledDataset.cpp.

References ossimImageData::getNullPix(), MEMTiledDataset::theData, and theDataset.

545 {
546  // All pointer checking performed by caller.
547 
548  T* p = static_cast<T*>(pImage);
549  T nullPix = static_cast<T>(theDataset->theData->getNullPix(0));
550 
551  for (int i = 0; i < count; ++i)
552  {
553  p[i] = nullPix;
554  }
555 }
MEMTiledDataset * theDataset
virtual const ossim_float64 * getNullPix() const
ossimRefPtr< ossimImageData > theData

◆ IReadBlock()

CPLErr MEMTiledRasterBand::IReadBlock ( int  nBlockXOff,
int  nBlockYOff,
void *  pImage 
)
virtual

Definition at line 81 of file ossimGdalTiledDataset.cpp.

85 {
86 #if 0
87  if (traceDebug())
88  {
90  << "MEMTiledRasterBand::IReadBlock DEBUG: entered..."
91  << "\nnBlockXSize: " << nBlockXSize
92  << "\nnBlockYSize: " << nBlockYSize
93  << "\nnBlockXOff: " << nBlockXSize
94  << "\nnBlockYOff: " << nBlockYSize
95 
96  << endl;
97  }
98 #endif
99 
100  if (!theDataset->theData) // Check for a valid buffer.
101  {
102  return CE_None;
103  }
104 
106 
107  ossimIpt ul(theDataset->theAreaOfInterest.ul().x + nBlockXOff*nBlockXSize,
108  theDataset->theAreaOfInterest.ul().y + nBlockYOff*nBlockYSize);
109 
110  ossimIrect requestRect(ul.x,
111  ul.y,
112  ul.x + nBlockXSize - 1,
113  ul.y + nBlockYSize - 1);
114 #if 0
115  if (traceDebug())
116  {
118  << "\nrequestRect: " << requestRect
119  << "\nbufferRect: " << bufferRect
120  << endl;
121  }
122 #endif
123 
124  if(requestRect.height() > 1)
125  {
127  << "MEMTiledRasterBand::IReadBlock WARN!"
128  << "\nOnly one scanline block reads allowed" << endl;
129  return CE_None;
130  }
131 
132  if(nBlockYOff==0)
133  {
135  }
136 
137  bool loadBuffer = false;
138 
139  if ( (requestRect.completely_within(bufferRect) == false) ||
141  {
142  loadBuffer = true;
143  }
144 
145 #if 0
146  ossim_int32 scanlineTile = ((nBlockYOff*nBlockYSize)%theDataset->theTileSize.y);
147  if (traceDebug())
148  {
150  << "\nscanlineTile: " << scanlineTile
151  << endl;
152  }
153 #endif
154 
155  if(loadBuffer)
156  {
158  theDataset->theData->setOrigin(requestRect.ul());
159  // fill the tile with one row;
161  for(ossim_uint32 i = 0; i < numberOfTiles; ++i)
162  {
163  ossimIpt tileOrigin(ul.x+theDataset->theTileSize.x*i, ul.y);
164 #if 0
165  if (traceDebug())
166  {
168  << "\ntileOrigin: " << tileOrigin << endl;
169  }
170 #endif
173  ossimIrect(tileOrigin.x,
174  tileOrigin.y,
175  tileOrigin.x + (theDataset->theTileSize.x - 1),
176  tileOrigin.y + (theDataset->theTileSize.y - 1)));
177  if(data.valid())
178  {
179  if (data->getBuf())
180  {
181  theDataset->theData->loadTile(data.get());
182  }
183  else
184  {
185  // Hmmm???
186  ossimRefPtr<ossimImageData> tempData =
187  (ossimImageData*)data->dup();
188  tempData->initialize();
189  theDataset->theData->loadTile(tempData.get());
190  }
191  }
192  }
194 
195  // Capture the buffer rectangle.
196  bufferRect = theDataset->theData->getImageRectangle();
197  }
198 
199 #if 0
200  if (traceDebug())
201  {
203  << "nBlockYOff: " << nBlockYOff
204  << "\ntheDataset->theData->getImageRectangle()"
206  << endl;
207  }
208 #endif
209 
210  // Bytes per pixel.
211  const ossim_int32 BPP = static_cast<ossim_int32>(
213 
215  {
216  copyNulls(pImage, nBlockYSize * nBlockXSize);
217  }
218  else
219  {
220  int nWordSize = GDALGetDataTypeSize( eDataType ) / 8;
221  CPLAssert( nBlockXOff == 0 );
222 
223  if( nPixelOffset == nWordSize )
224  {
225  ossim_uint32 offset = (ul.y - bufferRect.ul().y) *
226  bufferRect.width() * BPP +
227  (ul.x - bufferRect.ul().x) * BPP;
228 
229  GByte *pabyCur = ((GByte*) (theDataset->theData->getBuf(nBand-1)))
230  + offset;
231 
232  memcpy( pImage,
233  pabyCur,
234  nPixelOffset * nBlockXSize);
235  }
236  else
237  {
239  << "MEMTiledRasterBand::IReadBlock WARN!"
240  << "\nUnhandled wordsize..."
241  << endl;
242 #if 0
243  // shift to start of scanline
244  GByte *pabyCur = (GByte*) (theDataset->theData->getBuf(nBand-1))
246  theDataset->theData->getWidth()*scanlineTile);
247 
248  for( int iPixel = 0; iPixel < nBlockXSize; iPixel++ )
249  {
250  memcpy( (GByte *) pImage+ iPixel*nWordSize,
251  pabyCur + iPixel*nPixelOffset,
252  nWordSize );
253  }
254 #endif
255  }
256  }
257 
258  return CE_None;
259 }
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
virtual ossim_uint32 getWidth() const
bool valid() const
Definition: ossimRefPtr.h:75
ossimIrect theAreaOfInterest
const ossimIpt & ul() const
Definition: ossimIrect.h:274
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual void initialize()
Initialize the data buffer.
MEMTiledDataset * theDataset
virtual ossimObject * dup() const
virtual void loadTile(const void *src, const ossimIrect &src_rect, ossimInterleaveType il_type)
virtual ossimDataObjectStatus validate() const
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
ossim_uint32 width() const
Definition: ossimIrect.h:500
virtual void setOrigin(const ossimIpt &origin)
virtual ossim_uint32 getScalarSizeInBytes() const
virtual void makeBlank()
Initializes data to null pixel values.
ossim_int64 getNumberOfTilesHorizontal() const
ossimImageSourceSequencer * theInterface
ossim_int32 y
Definition: ossimIpt.h:142
virtual const void * getBuf() const
ossim_int32 x
Definition: ossimIpt.h:141
ossimRefPtr< ossimImageData > theData
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
void copyNulls(void *pImage, int count) const
Copies null values to pImage.

◆ IWriteBlock()

CPLErr MEMTiledRasterBand::IWriteBlock ( int  ,
int  ,
void *   
)
virtual

Definition at line 265 of file ossimGdalTiledDataset.cpp.

268 {
269 // int nWordSize = GDALGetDataTypeSize( eDataType );
270 // CPLAssert( nBlockXOff == 0 );
271 
272 // if( nPixelOffset*8 == nWordSize )
273 // {
274 // memcpy( pabyData+nLineOffset*nBlockYOff,
275 // pImage,
276 // nPixelOffset * nBlockXSize );
277 // }
278 // else
279 // {
280 // GByte *pabyCur = pabyData + nLineOffset*nBlockYOff;
281 
282 // for( int iPixel = 0; iPixel < nBlockXSize; iPixel++ )
283 // {
284 // memcpy( pabyCur + iPixel*nPixelOffset,
285 // ((GByte *) pImage) + iPixel*nWordSize,
286 // nWordSize );
287 // }
288 // }
289 
290  return CE_None;
291 }

Friends And Related Function Documentation

◆ MEMTiledDataset

friend class MEMTiledDataset
friend

Definition at line 80 of file ossimGdalTiledDataset.h.

Member Data Documentation

◆ theDataset

MEMTiledDataset* MEMTiledRasterBand::theDataset
protected

Definition at line 81 of file ossimGdalTiledDataset.h.

Referenced by copyNulls().

◆ theInterface

ossimImageSourceSequencer* MEMTiledRasterBand::theInterface
protected

Definition at line 82 of file ossimGdalTiledDataset.h.


The documentation for this class was generated from the following files: