All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ExpansibleRaster.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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  const double freeVMem = ( ((double)maxMemPercentUsed) / 100.0 ) *
99  std::min( totalPhysMem, ( totalVMem - usedVMem ) );
100  const unsigned int maxNumberOfBlocks = (unsigned int)
101  std::max( 1.0, std::ceil( freeVMem / ((double)maxBlockSizeBytes) ) );
102 
103  if( ! m_blocksManager.initialize( maxNumberOfBlocks, numbersOfBlocksX,
104  numbersOfBlocksY, blocksSizesBytes,
106  throw Exception(TE_TR("Cannot initialize the blocks menager") );
107 
108  for( unsigned int bandsIdx = 0 ; bandsIdx < bandsProperties.size() ;
109  ++bandsIdx )
110  {
111  m_bands.push_back( new te::mem::ExpansibleBand( m_blocksManager, *this,
112  *(bandsProperties[ bandsIdx ]) , bandsIdx ) );
113  delete ( bandsProperties[ bandsIdx ] );
114  }
115 }
116 
118  const std::vector<te::rst::BandProperty*> bandsProperties,
119  const unsigned int maxNumberOfRAMBlocks )
120  : te::rst::Raster( grid, te::common::RWAccess )
121 {
122  // Finding the global block dimensions
123 
124  std::vector< unsigned int> numbersOfBlocksX;
125  std::vector< unsigned int> numbersOfBlocksY;
126  std::vector< unsigned int> blocksSizesBytes;
127 
128  {
129  for( unsigned int bandIdx = 0 ; bandIdx < bandsProperties.size() ; ++bandIdx )
130  {
131  // Making all bands blocking equal
132  bandsProperties[ bandIdx ]->m_nblocksx = bandsProperties[ 0 ]->m_nblocksx;
133  bandsProperties[ bandIdx ]->m_nblocksy = bandsProperties[ 0 ]->m_nblocksy;
134  bandsProperties[ bandIdx ]->m_blkw = bandsProperties[ 0 ]->m_blkw;
135  bandsProperties[ bandIdx ]->m_blkh = bandsProperties[ 0 ]->m_blkh;
136  bandsProperties[ bandIdx ]->m_nblocksx = (int)std::ceil(
137  ((double)grid->getNumberOfColumns()) /
138  ((double)bandsProperties[ bandIdx ]->m_blkw) );
139  bandsProperties[ bandIdx ]->m_nblocksy = (int)std::ceil(
140  ((double)grid->getNumberOfRows()) /
141  ((double)bandsProperties[ bandIdx ]->m_blkh) );
142 
143  const unsigned int blockSizeBytes = (unsigned int)(
144  bandsProperties[ bandIdx ]->m_blkw *
145  bandsProperties[ bandIdx ]->m_blkh *
146  te::rst::GetPixelSize( bandsProperties[ bandIdx ]->m_type ) );
147 
148  numbersOfBlocksX.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksx );
149  numbersOfBlocksY.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksy );
150  blocksSizesBytes.push_back( blockSizeBytes );
151  }
152  }
153 
154  if( ! m_blocksManager.initialize( maxNumberOfRAMBlocks, numbersOfBlocksX,
155  numbersOfBlocksY, blocksSizesBytes,
157  throw Exception(TE_TR("Cannot initialize the blocks menager") );
158 
159  for( unsigned int bandsIdx = 0 ; bandsIdx < bandsProperties.size() ;
160  ++bandsIdx )
161  {
162  m_bands.push_back( new te::mem::ExpansibleBand( m_blocksManager, *this,
163  *(bandsProperties[ bandsIdx ]) , bandsIdx ) );
164  delete ( bandsProperties[ bandsIdx ] );
165  }
166 }
167 
169 {
170  free();
171 }
172 
173 void te::mem::ExpansibleRaster::open(const std::map<std::string, std::string>& /*rinfo*/,
175 {
176 }
177 
178 std::map<std::string, std::string> te::mem::ExpansibleRaster::getInfo() const
179 {
180  return std::map<std::string, std::string>();
181 }
182 
184 {
185  std::vector<te::rst::BandProperty*> bandsProperties;
186  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
187  {
188  bandsProperties.push_back( new te::rst::BandProperty(
189  *(m_bands[ bandsIdx ]->getProperty() ) ) );
190  }
191 
192  return new te::mem::ExpansibleRaster( new te::rst::Grid( *m_grid ), bandsProperties,
193  m_blocksManager.getMaxNumberOfRAMBlocks() );
194 }
195 
196 bool te::mem::ExpansibleRaster::addTopLines( const unsigned int number )
197 {
198  if( m_bands.empty() ) return false;
199 
200  if( number )
201  {
202  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
203  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkh) );
204 
205  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
206 
207  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
208  {
209  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
210  if( ! m_blocksManager.addTopBlocks( blockExpansionSize, bandsIdx,
211  bandAddedBlocksCoords ) )
212  return false;
213 
214  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
215  bandAddedBlocksCoords.end() );
216 
217  m_bands[ bandsIdx ]->getProperty()->m_nblocksy += blockExpansionSize;
218  }
219 
220  dummyFillBlocks( addedBlocksCoords );
221 
222  const unsigned int newLinesNumber =
223  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
224  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
225  const unsigned int newColsNumber =
226  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
227  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
228 
229  const double addedLinesNumber = (double)( blockExpansionSize *
230  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) );
231 
232  te::gm::Coord2D newULC(
233  m_grid->getExtent()->getLowerLeftX(),
234  m_grid->getExtent()->getUpperRightY() + ( addedLinesNumber *
235  m_grid->getResolutionY() ) );
236 
237  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
238  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
239  &newULC, m_grid->getSRID() ) );
240  delete( m_grid );
241  m_grid = newGridPtr;
242  }
243 
244  return true;
245 }
246 
247 bool te::mem::ExpansibleRaster::addBottomLines( const unsigned int number )
248 {
249  if( m_bands.empty() ) return false;
250 
251  if( number )
252  {
253  const unsigned int currExtraLines =
254  ( (unsigned int)( m_bands[ 0 ]->getProperty()->m_blkh *
255  m_bands[ 0 ]->getProperty()->m_nblocksy ) ) -
256  m_grid->getNumberOfRows();
257 
258  te::gm::Coord2D uLC(
259  m_grid->getExtent()->getLowerLeftX(),
260  m_grid->getExtent()->getUpperRightY() );
261 
262  if( currExtraLines < number )
263  {
264  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
265  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkh) );
266 
267  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
268 
269  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
270  {
271  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
272  if( ! m_blocksManager.addBottomBlocks( blockExpansionSize, bandsIdx,
273  bandAddedBlocksCoords ) )
274  return false;
275 
276  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
277  bandAddedBlocksCoords.end() );
278 
279  m_bands[ bandsIdx ]->getProperty()->m_nblocksy += blockExpansionSize;
280  }
281 
282  dummyFillBlocks( addedBlocksCoords );
283 
284  const unsigned int newLinesNumber =
285  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
286  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
287  const unsigned int newColsNumber =
288  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
289  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
290 
291  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
292  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
293  &uLC, m_grid->getSRID() ) );
294  delete( m_grid );
295  m_grid = newGridPtr;
296  }
297  else
298  {
299  te::rst::Grid* newGridPtr( new te::rst::Grid(
300  m_grid->getNumberOfColumns(),
301  m_grid->getNumberOfRows() + number,
302  m_grid->getResolutionX(), m_grid->getResolutionY(),
303  &uLC, m_grid->getSRID() ) );
304  delete( m_grid );
305  m_grid = newGridPtr;
306  }
307  }
308 
309  return true;
310 }
311 
312 bool te::mem::ExpansibleRaster::addLeftColumns( const unsigned int number )
313 {
314  if( m_bands.empty() ) return false;
315 
316  if( number )
317  {
318  const unsigned int oldColsNumber =
319  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
320  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
321 
322  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
323  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkw) );
324 
325  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
326 
327  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
328  {
329  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
330  if( ! m_blocksManager.addLeftBlocks( blockExpansionSize, bandsIdx,
331  bandAddedBlocksCoords ) )
332  return false;
333 
334  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
335  bandAddedBlocksCoords.end() );
336 
337  m_bands[ bandsIdx ]->getProperty()->m_nblocksx += blockExpansionSize;
338  }
339 
340  dummyFillBlocks( addedBlocksCoords );
341 
342  const unsigned int newLinesNumber =
343  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
344  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
345  const unsigned int newColsNumber =
346  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
347  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
348 
349  const double addedColsNumber = (double)( newColsNumber - oldColsNumber );
350 
351  te::gm::Coord2D newULC(
352  m_grid->getExtent()->getLowerLeftX() - ( addedColsNumber *
353  m_grid->getResolutionX() ),
354  m_grid->getExtent()->getUpperRightY() );
355 
356  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
357  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
358  &newULC, m_grid->getSRID() ) );
359  delete( m_grid );
360  m_grid = newGridPtr;
361  }
362 
363  return true;
364 }
365 
366 bool te::mem::ExpansibleRaster::addRightColumns( const unsigned int number )
367 {
368  if( m_bands.empty() ) return false;
369 
370  if( number )
371  {
372  const unsigned int currExtraCols =
373  ( (unsigned int)( m_bands[ 0 ]->getProperty()->m_blkw *
374  m_bands[ 0 ]->getProperty()->m_nblocksx ) ) -
375  m_grid->getNumberOfColumns();
376 
377  te::gm::Coord2D uLC(
378  m_grid->getExtent()->getLowerLeftX(),
379  m_grid->getExtent()->getUpperRightY() );
380 
381  if( currExtraCols < number )
382  {
383  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
384  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkw) );
385 
386  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
387 
388  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
389  {
390  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
391  if( ! m_blocksManager.addRightBlocks( blockExpansionSize, bandsIdx,
392  bandAddedBlocksCoords ) )
393  return false;
394 
395  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
396  bandAddedBlocksCoords.end() );
397 
398  m_bands[ bandsIdx ]->getProperty()->m_nblocksx += blockExpansionSize;
399  }
400 
401  dummyFillBlocks( addedBlocksCoords );
402 
403  const unsigned int newLinesNumber =
404  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
405  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
406  const unsigned int newColsNumber =
407  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
408  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
409 
410  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
411  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
412  &uLC, m_grid->getSRID() ) );
413  delete( m_grid );
414  m_grid = newGridPtr;
415  }
416  else
417  {
418  te::rst::Grid* newGridPtr( new te::rst::Grid(
419  m_grid->getNumberOfColumns() + number,
420  m_grid->getNumberOfRows(),
421  m_grid->getResolutionX(), m_grid->getResolutionY(),
422  &uLC, m_grid->getSRID() ) );
423  delete( m_grid );
424  m_grid = newGridPtr;
425  }
426  }
427 
428  return true;
429 }
430 
431 bool te::mem::ExpansibleRaster::addTopBands( const unsigned int number )
432 {
433  if( m_bands.empty() ) return false;
434 
435  if( number )
436  {
437  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
438 
439  if( ! m_blocksManager.addTopBands( number, addedBlocksCoords ) )
440  return false;
441 
442  m_bands.insert( m_bands.begin(), number, 0 );
443  for( unsigned int bIdx = 0 ; bIdx < m_bands.size() ; ++bIdx )
444  {
445  if( m_bands[ bIdx ] )
446  {
447  te::mem::ExpansibleBand* oldBandPtr = m_bands[ bIdx ];
448  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
449  *( oldBandPtr->getProperty() ), bIdx );
450  delete( oldBandPtr );
451  }
452  else
453  {
454  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
455  *( m_bands[ number ]->getProperty() ), bIdx );
456  }
457  }
458 
459  dummyFillBlocks( addedBlocksCoords );
460  }
461 
462  return true;
463 }
464 
465 bool te::mem::ExpansibleRaster::addBottomBands( const unsigned int number )
466 {
467  if( m_bands.empty() ) return false;
468 
469  if( number )
470  {
471  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
472 
473  if( ! m_blocksManager.addBottomBands( number, addedBlocksCoords ) )
474  return false;
475 
476  unsigned int lastBandIdx = (unsigned int)m_bands.size() - 1;
477  m_bands.insert( m_bands.end(), number, 0 );
478  for( unsigned int bIdx = lastBandIdx + 1 ; bIdx < m_bands.size() ; ++bIdx )
479  {
480  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
481  *( m_bands[ lastBandIdx ]->getProperty() ), bIdx );
482  }
483 
484  dummyFillBlocks( addedBlocksCoords );
485  }
486 
487  return true;
488 }
489 
491 {
492  if( m_bands.size() > 0 )
493  {
494  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
495  delete (m_bands[ bandsIdx ]);
496  m_bands.clear();
497  }
498 
499  m_blocksManager.free();
500 }
501 
503 {
504  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ;
505  ++bandsIdx )
506  {
507  te::mem::ExpansibleBand& band = *( m_bands[ bandsIdx ] );
508 
513  te::rst::SetBlockFunctions( &gb, &gbi, &sb, &sbi, band.getProperty()->m_type );
514 
515  const int elementsNumber = band.getProperty()->m_blkh *
516  band.getProperty()->m_blkw;
517  double* noDataValuePtr = &( band.getProperty()->m_noDataValue );
518  const unsigned int nBlocksX = band.getProperty()->m_nblocksx;
519  const unsigned int nBlocksY = band.getProperty()->m_nblocksy;
520  unsigned int blockXIdx = 0;
521  unsigned int blockYIdx = 0;
522  int eIdx = 0;
523  void* blockPtr = 0;
524 
525  for( blockXIdx = 0 ; blockXIdx < nBlocksX ; ++blockXIdx )
526  {
527  for( blockYIdx = 0 ; blockYIdx < nBlocksY ; ++blockYIdx )
528  {
529  blockPtr = m_blocksManager.getBlockPointer( bandsIdx, blockXIdx,
530  blockYIdx );
531  assert( blockPtr );
532 
533  for( eIdx = 0 ; eIdx < elementsNumber ; ++eIdx )
534  sb( eIdx, blockPtr, noDataValuePtr );
535  }
536  }
537  }
538 }
539 
541  const std::vector< ExpansibleBandBlocksManager::BlockIndex3D >& blocksCoords )
542 {
543  for( unsigned int coodsIdx = 0 ; coodsIdx < blocksCoords.size() ;
544  ++coodsIdx )
545  {
546  const ExpansibleBandBlocksManager::BlockIndex3D& block3DIdx = blocksCoords[ coodsIdx ];
547 
548  assert( block3DIdx.m_dim0Index < m_bands.size() );
549  te::mem::ExpansibleBand& band = *( m_bands[ block3DIdx.m_dim0Index ] );
550 
555 
556  te::rst::SetBlockFunctions( &gb, &gbi, &sb, &sbi, band.getProperty()->m_type );
557 
558  void* blockPtr = m_blocksManager.getBlockPointer( block3DIdx.m_dim0Index,
559  block3DIdx.m_dim2Index, block3DIdx.m_dim1Index );
560 
561  const int elementsNumber = band.getProperty()->m_blkh *
562  band.getProperty()->m_blkw;
563 
564  double* noDataValuePtr = &( band.getProperty()->m_noDataValue );
565 
566  for( int eIdx = 0 ; eIdx < elementsNumber ; ++eIdx )
567  sb( eIdx, blockPtr, noDataValuePtr );
568  }
569 }
570 
571 
572 
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
unsigned int getNumberOfRows() const
Returns the grid number of rows.
Definition: Grid.cpp:209
bool addTopLines(const unsigned int number)
New lines will be added at the top of the raster (before the first line).
std::vector< ExpansibleBand * > m_bands
Internal raster bands.
A raster class for memory.
Definition: Raster.h:44
A raster band description.
Definition: BandProperty.h:61
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
void dummyFillBlocks(const std::vector< ExpansibleBandBlocksManager::BlockIndex3D > &blocksCoords)
Fill the required blocks with dummy values.
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
void dummyFillAllBlocks()
Fill all blocks with dummy values.
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.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
int m_type
The data type of the elements in the band.
Definition: BandProperty.h:133
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
Definition: BandProperty.h:136
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:347
An exception class for the TerraLib In-Memory Data Access driver.
ExpansibleBandBlocksManager m_blocksManager
Internal blocks manager.
void open(const std::map< std::string, std::string > &rinfo, te::common::AccessPolicy p=te::common::RAccess)
Opens a raster.
AccessPolicy
Supported data access policies (can be used as bitfield).
Definition: Enums.h:40
void free()
Free all allocated internal resources and go back to the initial state.
TECOMMONEXPORT unsigned long int GetUsedVirtualMemory()
Returns the amount of used virtual memory (bytes) for the current process (physical + swapped)...
bool addRightColumns(const unsigned int number)
New columns will be added at the right of the raster (after the last column).
std::map< std::string, std::string > getInfo() const
It returns additional information about the raster.
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:428
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
void(* SetBufferValueFPtr)(int index, void *buffer, const double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:40
bool addBottomBands(const unsigned int number)
New bands will be added at the bottom of the raster (after de the last band).
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
Definition: Grid.cpp:193
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
TERASTEREXPORT int GetPixelSize(int datatype)
Returns the byte size of a given datatype.
Definition: Utils.cpp:80
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
te::dt::AbstractData * clone() const
It returns a clone of this object.
Expansible raster band.
TECOMMONEXPORT unsigned long int GetTotalPhysicalMemory()
Returns the amount of total physical memory (bytes).
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
void(* GetBufferValueFPtr)(int index, void *buffer, double *value)
The type of function used to extract data from a buffer.
Definition: BlockUtils.h:37
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
bool addLeftColumns(const unsigned int number)
New columns will be added at the left of the raster (before the first column).
bool addTopBands(const unsigned int number)
New bands will be added at the top of the raster (before the first band).
#define TLINTERNAL_EXPANSIBLERASTER_MAXDISKFILESSIZE
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
TECOMMONEXPORT unsigned long int GetTotalVirtualMemory()
Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physic...