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-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  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 
117 }
118 
120  const std::vector<te::rst::BandProperty*> bandsProperties,
121  const unsigned int maxNumberOfRAMBlocks )
122  : te::rst::Raster( grid, te::common::RWAccess )
123 {
124  // Finding the global block dimensions
125 
126  std::vector< unsigned int> numbersOfBlocksX;
127  std::vector< unsigned int> numbersOfBlocksY;
128  std::vector< unsigned int> blocksSizesBytes;
129 
130  {
131  for( unsigned int bandIdx = 0 ; bandIdx < bandsProperties.size() ; ++bandIdx )
132  {
133  // Making all bands blocking equal
134  bandsProperties[ bandIdx ]->m_nblocksx = bandsProperties[ 0 ]->m_nblocksx;
135  bandsProperties[ bandIdx ]->m_nblocksy = bandsProperties[ 0 ]->m_nblocksy;
136  bandsProperties[ bandIdx ]->m_blkw = bandsProperties[ 0 ]->m_blkw;
137  bandsProperties[ bandIdx ]->m_blkh = bandsProperties[ 0 ]->m_blkh;
138  bandsProperties[ bandIdx ]->m_nblocksx = (int)std::ceil(
139  ((double)grid->getNumberOfColumns()) /
140  ((double)bandsProperties[ bandIdx ]->m_blkw) );
141  bandsProperties[ bandIdx ]->m_nblocksy = (int)std::ceil(
142  ((double)grid->getNumberOfRows()) /
143  ((double)bandsProperties[ bandIdx ]->m_blkh) );
144 
145  const unsigned int blockSizeBytes = (unsigned int)(
146  bandsProperties[ bandIdx ]->m_blkw *
147  bandsProperties[ bandIdx ]->m_blkh *
148  te::rst::GetPixelSize( bandsProperties[ bandIdx ]->m_type ) );
149 
150  numbersOfBlocksX.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksx );
151  numbersOfBlocksY.push_back( (unsigned int)bandsProperties[ bandIdx ]->m_nblocksy );
152  blocksSizesBytes.push_back( blockSizeBytes );
153  }
154  }
155 
156  if( ! m_blocksManager.initialize( maxNumberOfRAMBlocks, numbersOfBlocksX,
157  numbersOfBlocksY, blocksSizesBytes,
159  throw Exception(TE_TR("Cannot initialize the blocks menager") );
160 
161  for( unsigned int bandsIdx = 0 ; bandsIdx < bandsProperties.size() ;
162  ++bandsIdx )
163  {
164  m_bands.push_back( new te::mem::ExpansibleBand( m_blocksManager, *this,
165  *(bandsProperties[ bandsIdx ]) , bandsIdx ) );
166  delete ( bandsProperties[ bandsIdx ] );
167  }
168 
170 }
171 
173 {
174  free();
175 }
176 
177 void te::mem::ExpansibleRaster::open(const std::map<std::string, std::string>& /*rinfo*/,
179 {
180 }
181 
182 std::map<std::string, std::string> te::mem::ExpansibleRaster::getInfo() const
183 {
184  return std::map<std::string, std::string>();
185 }
186 
188 {
189  std::vector<te::rst::BandProperty*> bandsProperties;
190  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
191  {
192  bandsProperties.push_back( new te::rst::BandProperty(
193  *(m_bands[ bandsIdx ]->getProperty() ) ) );
194  }
195 
196  return new te::mem::ExpansibleRaster( new te::rst::Grid( *m_grid ), bandsProperties,
197  m_blocksManager.getMaxNumberOfRAMBlocks() );
198 }
199 
200 bool te::mem::ExpansibleRaster::addTopLines( const unsigned int number )
201 {
202  if( m_bands.empty() ) return false;
203 
204  if( number )
205  {
206  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
207  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkh) );
208 
209  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
210 
211  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
212  {
213  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
214  if( ! m_blocksManager.addTopBlocks( blockExpansionSize, bandsIdx,
215  bandAddedBlocksCoords ) )
216  return false;
217 
218  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
219  bandAddedBlocksCoords.end() );
220 
221  m_bands[ bandsIdx ]->getProperty()->m_nblocksy += blockExpansionSize;
222  }
223 
224  dummyFillBlocks( addedBlocksCoords );
225 
226  const unsigned int newLinesNumber =
227  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
228  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
229  const unsigned int newColsNumber =
230  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
231  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
232 
233  const double addedLinesNumber = (double)( blockExpansionSize *
234  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) );
235 
236  te::gm::Coord2D newULC(
237  m_grid->getExtent()->getLowerLeftX(),
238  m_grid->getExtent()->getUpperRightY() + ( addedLinesNumber *
239  m_grid->getResolutionY() ) );
240 
241  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
242  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
243  &newULC, m_grid->getSRID() ) );
244  delete( m_grid );
245  m_grid = newGridPtr;
246  }
247 
248  return true;
249 }
250 
251 bool te::mem::ExpansibleRaster::addBottomLines( const unsigned int number )
252 {
253  if( m_bands.empty() ) return false;
254 
255  if( number )
256  {
257  const unsigned int currExtraLines =
258  ( (unsigned int)( m_bands[ 0 ]->getProperty()->m_blkh *
259  m_bands[ 0 ]->getProperty()->m_nblocksy ) ) -
260  m_grid->getNumberOfRows();
261 
262  te::gm::Coord2D uLC(
263  m_grid->getExtent()->getLowerLeftX(),
264  m_grid->getExtent()->getUpperRightY() );
265 
266  if( currExtraLines < number )
267  {
268  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
269  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkh) );
270 
271  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
272 
273  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
274  {
275  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
276  if( ! m_blocksManager.addBottomBlocks( blockExpansionSize, bandsIdx,
277  bandAddedBlocksCoords ) )
278  return false;
279 
280  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
281  bandAddedBlocksCoords.end() );
282 
283  m_bands[ bandsIdx ]->getProperty()->m_nblocksy += blockExpansionSize;
284  }
285 
286  dummyFillBlocks( addedBlocksCoords );
287 
288  const unsigned int newLinesNumber =
289  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
290  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
291  const unsigned int newColsNumber =
292  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
293  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
294 
295  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
296  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
297  &uLC, m_grid->getSRID() ) );
298  delete( m_grid );
299  m_grid = newGridPtr;
300  }
301  else
302  {
303  te::rst::Grid* newGridPtr( new te::rst::Grid(
304  m_grid->getNumberOfColumns(),
305  m_grid->getNumberOfRows() + number,
306  m_grid->getResolutionX(), m_grid->getResolutionY(),
307  &uLC, m_grid->getSRID() ) );
308  delete( m_grid );
309  m_grid = newGridPtr;
310  }
311  }
312 
313  return true;
314 }
315 
316 bool te::mem::ExpansibleRaster::addLeftColumns( const unsigned int number )
317 {
318  if( m_bands.empty() ) return false;
319 
320  if( number )
321  {
322  const unsigned int oldColsNumber =
323  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
324  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
325 
326  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
327  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkw) );
328 
329  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
330 
331  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
332  {
333  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
334  if( ! m_blocksManager.addLeftBlocks( blockExpansionSize, bandsIdx,
335  bandAddedBlocksCoords ) )
336  return false;
337 
338  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
339  bandAddedBlocksCoords.end() );
340 
341  m_bands[ bandsIdx ]->getProperty()->m_nblocksx += blockExpansionSize;
342  }
343 
344  dummyFillBlocks( addedBlocksCoords );
345 
346  const unsigned int newLinesNumber =
347  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
348  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
349  const unsigned int newColsNumber =
350  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
351  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
352 
353  const double addedColsNumber = (double)( newColsNumber - oldColsNumber );
354 
355  te::gm::Coord2D newULC(
356  m_grid->getExtent()->getLowerLeftX() - ( addedColsNumber *
357  m_grid->getResolutionX() ),
358  m_grid->getExtent()->getUpperRightY() );
359 
360  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
361  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
362  &newULC, m_grid->getSRID() ) );
363  delete( m_grid );
364  m_grid = newGridPtr;
365  }
366 
367  return true;
368 }
369 
370 bool te::mem::ExpansibleRaster::addRightColumns( const unsigned int number )
371 {
372  if( m_bands.empty() ) return false;
373 
374  if( number )
375  {
376  const unsigned int currExtraCols =
377  ( (unsigned int)( m_bands[ 0 ]->getProperty()->m_blkw *
378  m_bands[ 0 ]->getProperty()->m_nblocksx ) ) -
379  m_grid->getNumberOfColumns();
380 
381  te::gm::Coord2D uLC(
382  m_grid->getExtent()->getLowerLeftX(),
383  m_grid->getExtent()->getUpperRightY() );
384 
385  if( currExtraCols < number )
386  {
387  const unsigned int blockExpansionSize = (unsigned int)std::ceil(
388  ((double)number) / ((double)m_bands[ 0 ]->getProperty()->m_blkw) );
389 
390  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
391 
392  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
393  {
394  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > bandAddedBlocksCoords;
395  if( ! m_blocksManager.addRightBlocks( blockExpansionSize, bandsIdx,
396  bandAddedBlocksCoords ) )
397  return false;
398 
399  addedBlocksCoords.insert( addedBlocksCoords.end(), bandAddedBlocksCoords.begin(),
400  bandAddedBlocksCoords.end() );
401 
402  m_bands[ bandsIdx ]->getProperty()->m_nblocksx += blockExpansionSize;
403  }
404 
405  dummyFillBlocks( addedBlocksCoords );
406 
407  const unsigned int newLinesNumber =
408  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkh) *
409  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksy );
410  const unsigned int newColsNumber =
411  ((unsigned int)m_bands[ 0 ]->getProperty()->m_blkw) *
412  ((unsigned int)m_bands[ 0 ]->getProperty()->m_nblocksx );
413 
414  te::rst::Grid* newGridPtr( new te::rst::Grid( newColsNumber,
415  newLinesNumber, m_grid->getResolutionX(), m_grid->getResolutionY(),
416  &uLC, m_grid->getSRID() ) );
417  delete( m_grid );
418  m_grid = newGridPtr;
419  }
420  else
421  {
422  te::rst::Grid* newGridPtr( new te::rst::Grid(
423  m_grid->getNumberOfColumns() + number,
424  m_grid->getNumberOfRows(),
425  m_grid->getResolutionX(), m_grid->getResolutionY(),
426  &uLC, m_grid->getSRID() ) );
427  delete( m_grid );
428  m_grid = newGridPtr;
429  }
430  }
431 
432  return true;
433 }
434 
435 bool te::mem::ExpansibleRaster::addTopBands( const unsigned int number )
436 {
437  if( m_bands.empty() ) return false;
438 
439  if( number )
440  {
441  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
442 
443  if( ! m_blocksManager.addTopBands( number, addedBlocksCoords ) )
444  return false;
445 
446  m_bands.insert( m_bands.begin(), number, 0 );
447  for( unsigned int bIdx = 0 ; bIdx < m_bands.size() ; ++bIdx )
448  {
449  if( m_bands[ bIdx ] )
450  {
451  te::mem::ExpansibleBand* oldBandPtr = m_bands[ bIdx ];
452  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
453  *( oldBandPtr->getProperty() ), bIdx );
454  delete( oldBandPtr );
455  }
456  else
457  {
458  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
459  *( m_bands[ number ]->getProperty() ), bIdx );
460  }
461  }
462 
463  dummyFillBlocks( addedBlocksCoords );
464  }
465 
466  return true;
467 }
468 
469 bool te::mem::ExpansibleRaster::addBottomBands( const unsigned int number )
470 {
471  if( m_bands.empty() ) return false;
472 
473  if( number )
474  {
475  std::vector< ExpansibleBandBlocksManager::BlockIndex3D > addedBlocksCoords;
476 
477  if( ! m_blocksManager.addBottomBands( number, addedBlocksCoords ) )
478  return false;
479 
480  unsigned int lastBandIdx = (unsigned int)m_bands.size() - 1;
481  m_bands.insert( m_bands.end(), number, 0 );
482  for( unsigned int bIdx = lastBandIdx + 1 ; bIdx < m_bands.size() ; ++bIdx )
483  {
484  m_bands[ bIdx ] = new te::mem::ExpansibleBand( m_blocksManager, *this,
485  *( m_bands[ lastBandIdx ]->getProperty() ), bIdx );
486  }
487 
488  dummyFillBlocks( addedBlocksCoords );
489  }
490 
491  return true;
492 }
493 
495 {
496  if( m_bands.size() > 0 )
497  {
498  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ; ++bandsIdx )
499  delete (m_bands[ bandsIdx ]);
500  m_bands.clear();
501  }
502 
503  m_blocksManager.free();
504 }
505 
507 {
508  for( unsigned int bandsIdx = 0 ; bandsIdx < m_bands.size() ;
509  ++bandsIdx )
510  {
511  te::mem::ExpansibleBand& band = *( m_bands[ bandsIdx ] );
512 
517  te::rst::SetBlockFunctions( &gb, &gbi, &sb, &sbi, band.getProperty()->m_type );
518 
519  const int elementsNumber = band.getProperty()->m_blkh *
520  band.getProperty()->m_blkw;
521  double* noDataValuePtr = &( band.getProperty()->m_noDataValue );
522  const unsigned int nBlocksX = band.getProperty()->m_nblocksx;
523  const unsigned int nBlocksY = band.getProperty()->m_nblocksy;
524  unsigned int blockXIdx = 0;
525  unsigned int blockYIdx = 0;
526  int eIdx = 0;
527  void* blockPtr = 0;
528 
529  for( blockXIdx = 0 ; blockXIdx < nBlocksX ; ++blockXIdx )
530  {
531  for( blockYIdx = 0 ; blockYIdx < nBlocksY ; ++blockYIdx )
532  {
533  blockPtr = m_blocksManager.getBlockPointer( bandsIdx, blockXIdx,
534  blockYIdx );
535  assert( blockPtr );
536 
537  for( eIdx = 0 ; eIdx < elementsNumber ; ++eIdx )
538  sb( eIdx, blockPtr, noDataValuePtr );
539  }
540  }
541  }
542 }
543 
545  const std::vector< ExpansibleBandBlocksManager::BlockIndex3D >& blocksCoords )
546 {
547  for( unsigned int coodsIdx = 0 ; coodsIdx < blocksCoords.size() ;
548  ++coodsIdx )
549  {
550  const ExpansibleBandBlocksManager::BlockIndex3D& block3DIdx = blocksCoords[ coodsIdx ];
551 
552  assert( block3DIdx.m_dim0Index < m_bands.size() );
553  te::mem::ExpansibleBand& band = *( m_bands[ block3DIdx.m_dim0Index ] );
554 
559 
560  te::rst::SetBlockFunctions( &gb, &gbi, &sb, &sbi, band.getProperty()->m_type );
561 
562  void* blockPtr = m_blocksManager.getBlockPointer( block3DIdx.m_dim0Index,
563  block3DIdx.m_dim2Index, block3DIdx.m_dim1Index );
564 
565  const int elementsNumber = band.getProperty()->m_blkh *
566  band.getProperty()->m_blkw;
567 
568  double* noDataValuePtr = &( band.getProperty()->m_noDataValue );
569 
570  for( int eIdx = 0 ; eIdx < elementsNumber ; ++eIdx )
571  sb( eIdx, blockPtr, noDataValuePtr );
572  }
573 }
574 
575 
576 
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:345
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:370
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:77
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...