All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExpansibleRaster.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008-2013 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/memory/ExpansibleRaster.cpp
22 
23  \brief A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add lines/columns/bands.
24 */
25 
26 // TerraLib
27 #include "../common/Translator.h"
28 #include "../common/PlatformUtils.h"
29 #include "../geometry/Envelope.h"
30 #include "../raster/Utils.h"
31 #include "../raster/BlockUtils.h"
32 #include "Exception.h"
33 #include "ExpansibleRaster.h"
34 
35 
36 #ifndef TLINTERNAL_EXPANSIBLERASTER_MAXDISKFILESSIZE
37  #define TLINTERNAL_EXPANSIBLERASTER_MAXDISKFILESSIZE 2147483648ul
38 #endif
39 
41 {
42 }
43 
45 : te::rst::Raster( rhs )
46 {
47 }
48 
50 : te::rst::Raster( grid, p )
51 {
52 }
53 
54 te::mem::ExpansibleRaster::ExpansibleRaster( const unsigned char maxMemPercentUsed,
55  te::rst::Grid* grid,
56  const std::vector<te::rst::BandProperty*> bandsProperties )
57  : te::rst::Raster( grid, te::common::RWAccess )
58 {
59  // Finding the global block dimensions
60 
61  unsigned int maxBlockSizeBytes = 0;
62  std::vector< unsigned int> numbersOfBlocksX;
63  std::vector< unsigned int> numbersOfBlocksY;
64  std::vector< unsigned int> blocksSizesBytes;
65 
66  {
67  for( unsigned int bandIdx = 0 ; bandIdx < bandsProperties.size() ; ++bandIdx )
68  {
69  // Making all bands blocking equal
70  bandsProperties[ bandIdx ]->m_nblocksx = bandsProperties[ 0 ]->m_nblocksx;
71  bandsProperties[ bandIdx ]->m_nblocksy = bandsProperties[ 0 ]->m_nblocksy;
72  bandsProperties[ bandIdx ]->m_blkw = bandsProperties[ 0 ]->m_blkw;
73  bandsProperties[ bandIdx ]->m_blkh = bandsProperties[ 0 ]->m_blkh;
74  bandsProperties[ bandIdx ]->m_nblocksx = (int)std::ceil(
75  ((double)grid->getNumberOfColumns()) /
76  ((double)bandsProperties[ bandIdx ]->m_blkw) );
77  bandsProperties[ bandIdx ]->m_nblocksy = (int)std::ceil(
78  ((double)grid->getNumberOfRows()) /
79  ((double)bandsProperties[ bandIdx ]->m_blkh) );
80 
81  const unsigned int blockSizeBytes = (unsigned int)(
82  bandsProperties[ bandIdx ]->m_blkw *
83  bandsProperties[ bandIdx ]->m_blkh *
84  te::rst::GetPixelSize( bandsProperties[ bandIdx ]->m_type ) );
85 
86  if( maxBlockSizeBytes < blockSizeBytes )
87  maxBlockSizeBytes = blockSizeBytes;
88 
89  numbersOfBlocksX.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksx );
90  numbersOfBlocksY.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksy );
91  blocksSizesBytes.push_back( blockSizeBytes );
92  }
93  }
94 
95  const double totalPhysMem = (double)te::common::GetTotalPhysicalMemory();
96  const double usedVMem = (double)te::common::GetUsedVirtualMemory();
97  const double totalVMem = ( (double)te::common::GetTotalVirtualMemory() ) /
98  2.0;
99  const double freeVMem = ( ((double)maxMemPercentUsed) / 100.0 ) *
100  std::min( totalPhysMem, ( ( totalVMem <= usedVMem ) ? 0.0 : ( totalVMem - usedVMem ) ) );
101  const unsigned int maxNumberOfBlocks = (unsigned int)
102  std::max( 1.0, std::ceil( freeVMem / ((double)maxBlockSizeBytes) ) );
103 
104  if( ! m_blocksManager.initialize( maxNumberOfBlocks, numbersOfBlocksX,
105  numbersOfBlocksY, blocksSizesBytes,
107  throw Exception(TR_MEMORY("Cannot initialize the blocks menager") );
108 
109  for( unsigned int bandsIdx = 0 ; bandsIdx < bandsProperties.size() ;
110  ++bandsIdx )
111  {
112  m_bands.push_back( new te::mem::ExpansibleBand( m_blocksManager, *this,
113  *(bandsProperties[ bandsIdx ]) , bandsIdx ) );
114  delete ( bandsProperties[ bandsIdx ] );
115  }
116 
118 }
119 
121  const std::vector<te::rst::BandProperty*> bandsProperties,
122  const unsigned int maxNumberOfRAMBlocks )
123  : te::rst::Raster( grid, te::common::RWAccess )
124 {
125  // Finding the global block dimensions
126 
127  std::vector< unsigned int> numbersOfBlocksX;
128  std::vector< unsigned int> numbersOfBlocksY;
129  std::vector< unsigned int> blocksSizesBytes;
130 
131  {
132  for( unsigned int bandIdx = 0 ; bandIdx < bandsProperties.size() ; ++bandIdx )
133  {
134  // Making all bands blocking equal
135  bandsProperties[ bandIdx ]->m_nblocksx = bandsProperties[ 0 ]->m_nblocksx;
136  bandsProperties[ bandIdx ]->m_nblocksy = bandsProperties[ 0 ]->m_nblocksy;
137  bandsProperties[ bandIdx ]->m_blkw = bandsProperties[ 0 ]->m_blkw;
138  bandsProperties[ bandIdx ]->m_blkh = bandsProperties[ 0 ]->m_blkh;
139  bandsProperties[ bandIdx ]->m_nblocksx = (int)std::ceil(
140  ((double)grid->getNumberOfColumns()) /
141  ((double)bandsProperties[ bandIdx ]->m_blkw) );
142  bandsProperties[ bandIdx ]->m_nblocksy = (int)std::ceil(
143  ((double)grid->getNumberOfRows()) /
144  ((double)bandsProperties[ bandIdx ]->m_blkh) );
145 
146  const unsigned int blockSizeBytes = (unsigned int)(
147  bandsProperties[ bandIdx ]->m_blkw *
148  bandsProperties[ bandIdx ]->m_blkh *
149  te::rst::GetPixelSize( bandsProperties[ bandIdx ]->m_type ) );
150 
151  numbersOfBlocksX.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksx );
152  numbersOfBlocksY.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksy );
153  blocksSizesBytes.push_back( blockSizeBytes );
154  }
155  }
156 
157  if( ! m_blocksManager.initialize( maxNumberOfRAMBlocks, numbersOfBlocksX,
158  numbersOfBlocksY, blocksSizesBytes,
160  throw Exception(TR_MEMORY("Cannot initialize the blocks menager") );
161 
162  for( unsigned int bandsIdx = 0 ; bandsIdx < bandsProperties.size() ;
163  ++bandsIdx )
164  {
165  m_bands.push_back( new te::mem::ExpansibleBand( m_blocksManager, *this,
166  *(bandsProperties[ bandsIdx ]) , bandsIdx ) );
167  delete ( bandsProperties[ bandsIdx ] );
168  }
169 
171 }
172 
174 {
175  free();
176 }
177 
178 void te::mem::ExpansibleRaster::open(const std::map<std::string, std::string>& /*rinfo*/,
180 {
181 }
182 
183 std::map<std::string, std::string> te::mem::ExpansibleRaster::getInfo() const
184 {
185  return std::map<std::string, std::string>();
186 };
187 
189 {
190  std::vector<te::rst::BandProperty*> bandsProperties;
191  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
192  {
193  bandsProperties.push_back( new te::rst::BandProperty(
194  *(m_bands[ bandsIdx ]->getProperty() ) ) );
195  }
196 
197  return new te::mem::ExpansibleRaster( new te::rst::Grid( *m_grid ), bandsProperties,
198  m_blocksManager.getMaxNumberOfRAMBlocks() );
199 }
200 
201 bool te::mem::ExpansibleRaster::addTopLines( const unsigned int number )
202 {
203  if( m_bands.empty() ) return false;
204 
205  if( number )
206  {
207  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
208  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkh) );
209 
210  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
211 
212  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
213  {
214  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
215  if( ! m_blocksManager.addTopBlocks( blockExpansionSize, bandsIdx,
216  bandAddedBlocksCoords ) )
217  return false;
218 
219  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
220  bandAddedBlocksCoords.end() );
221 
222  m_bands[ bandsIdx ]->getProperty()->m_nblocksy += blockExpansionSize;
223  }
224 
225  dummyFillBlocks( addedBlocksCoords );
226 
227  const unsigned int newLinesNumber =
228  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
229  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
230  const unsigned int newColsNumber =
231  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
232  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
233 
234  const double addedLinesNumber = (double)( blockExpansionSize *
235  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) );
236 
237  te::gm::Coord2D newULC(
238  m_grid->getExtent()->getLowerLeftX(),
239  m_grid->getExtent()->getUpperRightY() + ( addedLinesNumber *
240  m_grid->getResolutionY() ) );
241 
242  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
243  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
244  &newULC, m_grid->getSRID() ) );
245  delete( m_grid );
246  m_grid = newGridPtr;
247  }
248 
249  return true;
250 }
251 
252 bool te::mem::ExpansibleRaster::addBottomLines( const unsigned int number )
253 {
254  if( m_bands.empty() ) return false;
255 
256  if( number )
257  {
258  const unsigned int currExtraLines =
259  ( (unsigned int)( m_bands[ 0 ]->getProperty()->m_blkh *
260  m_bands[ 0 ]->getProperty()->m_nblocksy ) ) -
261  m_grid->getNumberOfRows();
262 
263  te::gm::Coord2D uLC(
264  m_grid->getExtent()->getLowerLeftX(),
265  m_grid->getExtent()->getUpperRightY() );
266 
267  if( currExtraLines < number )
268  {
269  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
270  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkh) );
271 
272  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
273 
274  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
275  {
276  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
277  if( ! m_blocksManager.addBottomBlocks( blockExpansionSize, bandsIdx,
278  bandAddedBlocksCoords ) )
279  return false;
280 
281  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
282  bandAddedBlocksCoords.end() );
283 
284  m_bands[ bandsIdx ]->getProperty()->m_nblocksy += blockExpansionSize;
285  }
286 
287  dummyFillBlocks( addedBlocksCoords );
288 
289  const unsigned int newLinesNumber =
290  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
291  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
292  const unsigned int newColsNumber =
293  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
294  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
295 
296  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
297  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
298  &uLC, m_grid->getSRID() ) );
299  delete( m_grid );
300  m_grid = newGridPtr;
301  }
302  else
303  {
304  te::rst::Grid* newGridPtr( new te::rst::Grid(
305  m_grid->getNumberOfColumns(),
306  m_grid->getNumberOfRows() + number,
307  m_grid->getResolutionX(), m_grid->getResolutionY(),
308  &uLC, m_grid->getSRID() ) );
309  delete( m_grid );
310  m_grid = newGridPtr;
311  }
312  }
313 
314  return true;
315 }
316 
317 bool te::mem::ExpansibleRaster::addLeftColumns( const unsigned int number )
318 {
319  if( m_bands.empty() ) return false;
320 
321  if( number )
322  {
323  const unsigned int oldColsNumber =
324  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
325  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
326 
327  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
328  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkw) );
329 
330  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
331 
332  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
333  {
334  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
335  if( ! m_blocksManager.addLeftBlocks( blockExpansionSize, bandsIdx,
336  bandAddedBlocksCoords ) )
337  return false;
338 
339  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
340  bandAddedBlocksCoords.end() );
341 
342  m_bands[ bandsIdx ]->getProperty()->m_nblocksx += blockExpansionSize;
343  }
344 
345  dummyFillBlocks( addedBlocksCoords );
346 
347  const unsigned int newLinesNumber =
348  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
349  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
350  const unsigned int newColsNumber =
351  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
352  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
353 
354  const double addedColsNumber = (double)( newColsNumber - oldColsNumber );
355 
356  te::gm::Coord2D newULC(
357  m_grid->getExtent()->getLowerLeftX() - ( addedColsNumber *
358  m_grid->getResolutionX() ),
359  m_grid->getExtent()->getUpperRightY() );
360 
361  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
362  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
363  &newULC, m_grid->getSRID() ) );
364  delete( m_grid );
365  m_grid = newGridPtr;
366  }
367 
368  return true;
369 }
370 
371 bool te::mem::ExpansibleRaster::addRightColumns( const unsigned int number )
372 {
373  if( m_bands.empty() ) return false;
374 
375  if( number )
376  {
377  const unsigned int currExtraCols =
378  ( (unsigned int)( m_bands[ 0 ]->getProperty()->m_blkw *
379  m_bands[ 0 ]->getProperty()->m_nblocksx ) ) -
380  m_grid->getNumberOfColumns();
381 
382  te::gm::Coord2D uLC(
383  m_grid->getExtent()->getLowerLeftX(),
384  m_grid->getExtent()->getUpperRightY() );
385 
386  if( currExtraCols < number )
387  {
388  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
389  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkw) );
390 
391  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
392 
393  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
394  {
395  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
396  if( ! m_blocksManager.addRightBlocks( blockExpansionSize, bandsIdx,
397  bandAddedBlocksCoords ) )
398  return false;
399 
400  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
401  bandAddedBlocksCoords.end() );
402 
403  m_bands[ bandsIdx ]->getProperty()->m_nblocksx += blockExpansionSize;
404  }
405 
406  dummyFillBlocks( addedBlocksCoords );
407 
408  const unsigned int newLinesNumber =
409  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
410  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
411  const unsigned int newColsNumber =
412  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
413  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
414 
415  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
416  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
417  &uLC, m_grid->getSRID() ) );
418  delete( m_grid );
419  m_grid = newGridPtr;
420  }
421  else
422  {
423  te::rst::Grid* newGridPtr( new te::rst::Grid(
424  m_grid->getNumberOfColumns() + number,
425  m_grid->getNumberOfRows(),
426  m_grid->getResolutionX(), m_grid->getResolutionY(),
427  &uLC, m_grid->getSRID() ) );
428  delete( m_grid );
429  m_grid = newGridPtr;
430  }
431  }
432 
433  return true;
434 }
435 
436 bool te::mem::ExpansibleRaster::addTopBands( const unsigned int number )
437 {
438  if( m_bands.empty() ) return false;
439 
440  if( number )
441  {
442  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
443 
444  if( ! m_blocksManager.addTopBands( number, addedBlocksCoords ) )
445  return false;
446 
447  m_bands.insert( m_bands.begin(), number, 0 );
448  for( unsigned int bIdx = 0 ; bIdx < m_bands.size() ; ++bIdx )
449  {
450  if( m_bands[ bIdx ] )
451  {
452  te::mem::ExpansibleBand* oldBandPtr = m_bands[ bIdx ];
453  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
454  *( oldBandPtr->getProperty() ), bIdx );
455  delete( oldBandPtr );
456  }
457  else
458  {
459  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
460  *( m_bands[ number ]->getProperty() ), bIdx );
461  }
462  }
463 
464  dummyFillBlocks( addedBlocksCoords );
465  }
466 
467  return true;
468 }
469 
470 bool te::mem::ExpansibleRaster::addBottomBands( const unsigned int number )
471 {
472  if( m_bands.empty() ) return false;
473 
474  if( number )
475  {
476  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
477 
478  if( ! m_blocksManager.addBottomBands( number, addedBlocksCoords ) )
479  return false;
480 
481  unsigned int lastBandIdx = (unsigned int)m_bands.size() - 1;
482  m_bands.insert( m_bands.end(), number, 0 );
483  for( unsigned int bIdx = lastBandIdx + 1 ; bIdx < m_bands.size() ; ++bIdx )
484  {
485  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
486  *( m_bands[ lastBandIdx ]->getProperty() ), bIdx );
487  }
488 
489  dummyFillBlocks( addedBlocksCoords );
490  }
491 
492  return true;
493 }
494 
496 {
497  if( m_bands.size() > 0 )
498  {
499  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
500  delete (m_bands[ bandsIdx ]);
501  m_bands.clear();
502  }
503 
504  m_blocksManager.free();
505 }
506 
508 {
509  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ;
510  ++bandsIdx )
511  {
512  te::mem::ExpansibleBand& band = *( m_bands[ bandsIdx ] );
513 
518  te::rst::SetBlockFunctions( &gb, &gbi, &sb, &sbi, band.getProperty()->m_type );
519 
520  const int elementsNumber = band.getProperty()->m_blkh *
521  band.getProperty()->m_blkw;
522  double* noDataValuePtr = &( band.getProperty()->m_noDataValue );
523  const unsigned int nBlocksX = band.getProperty()->m_nblocksx;
524  const unsigned int nBlocksY = band.getProperty()->m_nblocksy;
525  unsigned int blockXIdx = 0;
526  unsigned int blockYIdx = 0;
527  int eIdx = 0;
528  void* blockPtr = 0;
529 
530  for( blockXIdx = 0 ; blockXIdx < nBlocksX ; ++blockXIdx )
531  {
532  for( blockYIdx = 0 ; blockYIdx < nBlocksY ; ++blockYIdx )
533  {
534  blockPtr = m_blocksManager.getBlockPointer( bandsIdx, blockXIdx,
535  blockYIdx );
536  assert( blockPtr );
537 
538  for( eIdx = 0 ; eIdx < elementsNumber ; ++eIdx )
539  sb( eIdx, blockPtr, noDataValuePtr );
540  }
541  }
542  }
543 }
544 
546  const std::vector< ExpansibleBandBlocksManager::BlockIndex3D >& blocksCoords )
547 {
548  for( unsigned int coodsIdx = 0 ; coodsIdx < blocksCoords.size() ;
549  ++coodsIdx )
550  {
551  const ExpansibleBandBlocksManager::BlockIndex3D& block3DIdx = blocksCoords[ coodsIdx ];
552 
553  assert( block3DIdx.m_dim0Index < m_bands.size() );
554  te::mem::ExpansibleBand& band = *( m_bands[ block3DIdx.m_dim0Index ] );
555 
560 
561  te::rst::SetBlockFunctions( &gb, &gbi, &sb, &sbi, band.getProperty()->m_type );
562 
563  void* blockPtr = m_blocksManager.getBlockPointer( block3DIdx.m_dim0Index,
564  block3DIdx.m_dim2Index, block3DIdx.m_dim1Index );
565 
566  const int elementsNumber = band.getProperty()->m_blkh *
567  band.getProperty()->m_blkw;
568 
569  double* noDataValuePtr = &( band.getProperty()->m_noDataValue );
570 
571  for( int eIdx = 0 ; eIdx < elementsNumber ; ++eIdx )
572  sb( eIdx, blockPtr, noDataValuePtr );
573  }
574 }
575 
576 
577 
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
void dummyFillAllBlocks()
Fill all blocks with dummy values.
te::dt::AbstractData * clone() const
It returns a clone of this object.
void dummyFillBlocks(const std::vector< ExpansibleBandBlocksManager::BlockIndex3D > &blocksCoords)
Fill the required blocks with dummy values.
TERASTEREXPORT int GetPixelSize(int datatype)
Returns the byte size of a given datatype.
Definition: Utils.cpp:77
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
std::vector< ExpansibleBand * > m_bands
Internal raster bands.
bool initialize(const unsigned int maxNumberRAMBlocks, const std::vector< unsigned int > &numbersOfBlocksX, const std::vector< unsigned int > &numbersOfBlocksY, const std::vector< unsigned int > &blocksSizesBytes, const unsigned long int maxDiskFilesSize)
Initialize this instance to an initial state.
Expansible raster band.
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
#define TR_MEMORY(message)
Definition: Config.h:82
#define TLINTERNAL_EXPANSIBLERASTER_MAXDISKFILESSIZE
An exception class for the TerraLib In-Memory Data Access driver.
bool addTopBands(const unsigned int number)
New bands will be added at the top of the raster (before the first band).
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
void(* SetBufferValueFPtr)(int index, void *buffer, const double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:40
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
unsigned int getNumberOfRows() const
Returns the grid number of rows.
Definition: Grid.cpp:215
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
A raster class for memory.
Definition: Raster.h:44
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
int m_type
The data type of the elements in the band.
Definition: BandProperty.h:133
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
TERASTEREXPORT void SetBlockFunctions(GetBufferValueFPtr *gb, GetBufferValueFPtr *gbi, SetBufferValueFPtr *sb, SetBufferValueFPtr *sbi, int type)
Sets the pointers to functions that helps to extract a double or complex value from a specific buffer...
Definition: BlockUtils.cpp:295
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
bool addRightColumns(const unsigned int number)
New columns will be added at the right of the raster (after the last column).
void free()
Free all allocated internal resources and go back to the initial state.
unsigned long int GetTotalPhysicalMemory()
Returns the amount of total physical memory (bytes).
bool addBottomLines(const unsigned int number)
New lines will be added at the bottom of the raster (after de the last line).
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
A raster band description.
Definition: BandProperty.h:61
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits&lt;double&gt;::max().
Definition: BandProperty.h:136
bool addBottomBands(const unsigned int number)
New bands will be added at the bottom of the raster (after de the last band).
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:370
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
Definition: Grid.cpp:205
unsigned long int GetUsedVirtualMemory()
Returns the amount of used virtual memory (bytes) for the current process (physical + swapped)...
unsigned long int GetTotalVirtualMemory()
Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physic...
bool addLeftColumns(const unsigned int number)
New columns will be added at the left of the raster (before the first column).
ExpansibleBandBlocksManager m_blocksManager
Internal blocks manager.
bool addTopLines(const unsigned int number)
New lines will be added at the top of the raster (before the first line).