28 #include "../Config.h" 33 #include <boost/shared_ptr.hpp> 42 unsigned int band = 0;
43 unsigned int line = 0;
47 for( band = 0 ; band < nBands ; ++
band )
51 raster.
setValue( col, line, pixelValue, band );
61 unsigned int band = 0;
62 unsigned int line = 0;
65 for( band = 0 ; band < nBands ; ++
band )
72 raster.
setValue( col, line, noDataValue, band );
82 unsigned int band = 0;
83 unsigned int line = 0;
88 for( band = 0 ; band < nBands ; ++
band )
92 raster.
getValue( col, line, readValue, band );
94 CPPUNIT_ASSERT( readValue == pixelValue );
101 const unsigned int& requiredBand,
102 const unsigned int& requiredCol,
const unsigned int& requiredLine,
108 unsigned int band = 0;
109 unsigned int line = 0;
110 unsigned int col = 0;
111 double readValue = 0;
112 bool elementFound =
false;
114 for( band = 0 ; band < nBands ; ++
band )
116 for( col = 0 ; col <
nCols ; ++
col )
118 raster.
getValue( col, line, readValue, band );
120 if( readValue == targetValue )
122 CPPUNIT_ASSERT( ! elementFound );
125 CPPUNIT_ASSERT( band == requiredBand );
126 CPPUNIT_ASSERT( line == requiredLine );
127 CPPUNIT_ASSERT( col == requiredCol );
131 CPPUNIT_ASSERT( elementFound );
136 std::vector< te::rst::BandProperty * > bandsProps;
138 bandsProps[ 0 ]->m_blkw = 5;
139 bandsProps[ 0 ]->m_blkh = 10;
140 bandsProps[ 0 ]->m_nblocksx = 2;
141 bandsProps[ 0 ]->m_nblocksy = 1;
143 bandsProps[ 1 ]->m_blkw = 10;
144 bandsProps[ 1 ]->m_blkh = 10;
145 bandsProps[ 1 ]->m_nblocksx = 1;
146 bandsProps[ 1 ]->m_nblocksy = 1;
148 bandsProps[ 2 ]->m_blkw = 10;
149 bandsProps[ 2 ]->m_blkh = 5;
150 bandsProps[ 2 ]->m_nblocksx = 1;
151 bandsProps[ 2 ]->m_nblocksy = 2;
162 std::vector< te::rst::BandProperty * > bandsProps;
164 bandsProps[ 0 ]->m_noDataValue = 0;
165 bandsProps[ 0 ]->m_blkw = 5;
166 bandsProps[ 0 ]->m_blkh = 10;
167 bandsProps[ 0 ]->m_nblocksx = 2;
168 bandsProps[ 0 ]->m_nblocksy = 1;
170 bandsProps[ 1 ]->m_noDataValue = 0;
171 bandsProps[ 1 ]->m_blkw = 5;
172 bandsProps[ 1 ]->m_blkh = 10;
173 bandsProps[ 1 ]->m_nblocksx = 2;
174 bandsProps[ 1 ]->m_nblocksy = 1;
176 bandsProps[ 2 ]->m_noDataValue = 0;
177 bandsProps[ 2 ]->m_blkw = 5;
178 bandsProps[ 2 ]->m_blkh = 10;
179 bandsProps[ 2 ]->m_nblocksx = 2;
180 bandsProps[ 2 ]->m_nblocksy = 1;
187 double readValue = 0;
195 rasterInstance.
getValue( 5, 5, readValue, 1 );
196 CPPUNIT_ASSERT( readValue == 0.0 );
198 rasterInstance.
setValue( 5, 5, 1, 1 );
199 rasterInstance.
getValue( 5, 5, readValue, 1 );
200 CPPUNIT_ASSERT( readValue == 1.0 );
220 std::vector< te::rst::BandProperty * > bandsProps;
222 bandsProps[ 0 ]->m_noDataValue = 0;
223 bandsProps[ 0 ]->m_blkw = 5;
224 bandsProps[ 0 ]->m_blkh = 10;
225 bandsProps[ 0 ]->m_nblocksx = 2;
226 bandsProps[ 0 ]->m_nblocksy = 1;
228 bandsProps[ 1 ]->m_noDataValue = 0;
229 bandsProps[ 1 ]->m_blkw = 5;
230 bandsProps[ 1 ]->m_blkh = 10;
231 bandsProps[ 1 ]->m_nblocksx = 2;
232 bandsProps[ 1 ]->m_nblocksy = 1;
234 bandsProps[ 2 ]->m_noDataValue = 0;
235 bandsProps[ 2 ]->m_blkw = 5;
236 bandsProps[ 2 ]->m_blkh = 10;
237 bandsProps[ 2 ]->m_nblocksx = 2;
238 bandsProps[ 2 ]->m_nblocksy = 1;
245 double readValue = 0;
253 rasterInstance.
getValue( 5, 5, readValue, 1 );
254 CPPUNIT_ASSERT( readValue == 0.0 );
256 rasterInstance.
setValue( 5, 5, 1, 1 );
272 rasterInstance.
getValue( 5, 19, readValue, 1 );
273 CPPUNIT_ASSERT( readValue == 0.0 );
275 rasterInstance.
setValue( 5, 19, 1, 1 );
277 rasterInstance.
getValue( 5, 19, readValue, 1 );
278 CPPUNIT_ASSERT( readValue == 1.0 );
294 std::vector< te::rst::BandProperty * > bandsProps;
296 bandsProps[ 0 ]->m_noDataValue = 0;
297 bandsProps[ 0 ]->m_blkw = 5;
298 bandsProps[ 0 ]->m_blkh = 10;
299 bandsProps[ 0 ]->m_nblocksx = 2;
300 bandsProps[ 0 ]->m_nblocksy = 1;
302 bandsProps[ 1 ]->m_noDataValue = 0;
303 bandsProps[ 1 ]->m_blkw = 5;
304 bandsProps[ 1 ]->m_blkh = 10;
305 bandsProps[ 1 ]->m_nblocksx = 2;
306 bandsProps[ 1 ]->m_nblocksy = 1;
308 bandsProps[ 2 ]->m_noDataValue = 0;
309 bandsProps[ 2 ]->m_blkw = 5;
310 bandsProps[ 2 ]->m_blkh = 10;
311 bandsProps[ 2 ]->m_nblocksx = 2;
312 bandsProps[ 2 ]->m_nblocksy = 1;
319 double readValue = 0;
327 rasterInstance.
getValue( 5, 5, readValue, 1 );
328 CPPUNIT_ASSERT( readValue == 0.0 );
330 rasterInstance.
setValue( 5, 5, 1, 1 );
352 std::vector< te::rst::BandProperty * > bandsProps;
354 bandsProps[ 0 ]->m_noDataValue = 0;
355 bandsProps[ 0 ]->m_blkw = 5;
356 bandsProps[ 0 ]->m_blkh = 10;
357 bandsProps[ 0 ]->m_nblocksx = 2;
358 bandsProps[ 0 ]->m_nblocksy = 1;
360 bandsProps[ 1 ]->m_noDataValue = 0;
361 bandsProps[ 1 ]->m_blkw = 5;
362 bandsProps[ 1 ]->m_blkh = 10;
363 bandsProps[ 1 ]->m_nblocksx = 2;
364 bandsProps[ 1 ]->m_nblocksy = 1;
366 bandsProps[ 2 ]->m_noDataValue = 0;
367 bandsProps[ 2 ]->m_blkw = 5;
368 bandsProps[ 2 ]->m_blkh = 10;
369 bandsProps[ 2 ]->m_nblocksx = 2;
370 bandsProps[ 2 ]->m_nblocksy = 1;
377 double readValue = 0;
385 rasterInstance.
getValue( 5, 5, readValue, 1 );
386 CPPUNIT_ASSERT( readValue == 0.0 );
388 rasterInstance.
setValue( 5, 5, 1, 1 );
404 rasterInstance.
getValue( 14, 5, readValue, 1 );
405 CPPUNIT_ASSERT( readValue == 0.0 );
407 rasterInstance.
setValue( 14, 5, 1, 1 );
408 rasterInstance.
getValue( 14, 5, readValue, 1 );
409 CPPUNIT_ASSERT( readValue == 1.0 );
425 std::vector< te::rst::BandProperty * > bandsProps;
427 bandsProps[ 0 ]->m_noDataValue = 0;
428 bandsProps[ 0 ]->m_blkw = 5;
429 bandsProps[ 0 ]->m_blkh = 10;
430 bandsProps[ 0 ]->m_nblocksx = 2;
431 bandsProps[ 0 ]->m_nblocksy = 1;
433 bandsProps[ 1 ]->m_noDataValue = 0;
434 bandsProps[ 1 ]->m_blkw = 5;
435 bandsProps[ 1 ]->m_blkh = 10;
436 bandsProps[ 1 ]->m_nblocksx = 2;
437 bandsProps[ 1 ]->m_nblocksy = 1;
439 bandsProps[ 2 ]->m_noDataValue = 0;
440 bandsProps[ 2 ]->m_blkw = 5;
441 bandsProps[ 2 ]->m_blkh = 10;
442 bandsProps[ 2 ]->m_nblocksx = 2;
443 bandsProps[ 2 ]->m_nblocksy = 1;
450 double readValue = 0;
454 rasterInstance.
getValue( 5, 5, readValue, 1 );
455 CPPUNIT_ASSERT( readValue == 0.0 );
457 rasterInstance.
setValue( 5, 5, 1, 1 );
475 std::vector< te::rst::BandProperty * > bandsProps;
477 bandsProps[ 0 ]->m_noDataValue = 0;
478 bandsProps[ 0 ]->m_blkw = 5;
479 bandsProps[ 0 ]->m_blkh = 10;
480 bandsProps[ 0 ]->m_nblocksx = 2;
481 bandsProps[ 0 ]->m_nblocksy = 1;
483 bandsProps[ 1 ]->m_noDataValue = 0;
484 bandsProps[ 1 ]->m_blkw = 5;
485 bandsProps[ 1 ]->m_blkh = 10;
486 bandsProps[ 1 ]->m_nblocksx = 2;
487 bandsProps[ 1 ]->m_nblocksy = 1;
489 bandsProps[ 2 ]->m_noDataValue = 0;
490 bandsProps[ 2 ]->m_blkw = 5;
491 bandsProps[ 2 ]->m_blkh = 10;
492 bandsProps[ 2 ]->m_nblocksx = 2;
493 bandsProps[ 2 ]->m_nblocksy = 1;
500 double readValue = 0;
504 rasterInstance.
getValue( 5, 5, readValue, 1 );
505 CPPUNIT_ASSERT( readValue == 0.0 );
507 rasterInstance.
setValue( 5, 5, 1, 1 );
519 rasterInstance.
getValue( 5, 5, readValue, 5 );
520 CPPUNIT_ASSERT( readValue == 0.0 );
522 rasterInstance.
setValue( 5, 5, 1, 5 );
523 rasterInstance.
getValue( 5, 5, readValue, 5 );
524 CPPUNIT_ASSERT( readValue == 1.0 );
532 std::vector< te::rst::BandProperty * > bandsProps;
534 bandsProps[ 0 ]->m_blkw = 100;
535 bandsProps[ 0 ]->m_blkh = 1;
536 bandsProps[ 0 ]->m_nblocksx = 1;
537 bandsProps[ 0 ]->m_nblocksy = 100;
539 bandsProps[ 1 ]->m_blkw = 100;
540 bandsProps[ 1 ]->m_blkh = 1;
541 bandsProps[ 1 ]->m_nblocksx = 1;
542 bandsProps[ 1 ]->m_nblocksy = 100;
544 bandsProps[ 2 ]->m_blkw = 100;
545 bandsProps[ 2 ]->m_blkh = 1;
546 bandsProps[ 2 ]->m_nblocksx = 1;
547 bandsProps[ 2 ]->m_nblocksy = 100;
557 std::unique_ptr< te::rst::Raster > level0Ptr( rasterInstance.
getMultiResLevel( 0 ) );
558 CPPUNIT_ASSERT( level0Ptr.get() != 0 );
559 CPPUNIT_ASSERT( level0Ptr->getNumberOfBands() == 3 );
560 CPPUNIT_ASSERT( level0Ptr->getNumberOfRows() == 100 );
561 CPPUNIT_ASSERT( level0Ptr->getNumberOfColumns() == 100 );
563 std::unique_ptr< te::rst::Raster > level1Ptr( rasterInstance.
getMultiResLevel( 1 ) );
564 CPPUNIT_ASSERT( level1Ptr.get() != 0 );
565 CPPUNIT_ASSERT( level1Ptr->getNumberOfBands() == 3 );
566 CPPUNIT_ASSERT( level1Ptr->getNumberOfRows() == 50 );
567 CPPUNIT_ASSERT( level1Ptr->getNumberOfColumns() == 50 );
569 std::unique_ptr< te::rst::Raster > level2Ptr( rasterInstance.
getMultiResLevel( 2 ) );
570 CPPUNIT_ASSERT( level2Ptr.get() != 0 );
571 CPPUNIT_ASSERT( level2Ptr->getNumberOfBands() == 3 );
572 CPPUNIT_ASSERT( level2Ptr->getNumberOfRows() == 25 );
573 CPPUNIT_ASSERT( level2Ptr->getNumberOfColumns() == 25 );
578 std::vector< te::rst::BandProperty * > bandsProps;
580 bandsProps[ 0 ]->m_blkw = 5;
581 bandsProps[ 0 ]->m_blkh = 10;
582 bandsProps[ 0 ]->m_nblocksx = 2;
583 bandsProps[ 0 ]->m_nblocksy = 1;
585 bandsProps[ 1 ]->m_blkw = 10;
586 bandsProps[ 1 ]->m_blkh = 10;
587 bandsProps[ 1 ]->m_nblocksx = 1;
588 bandsProps[ 1 ]->m_nblocksy = 1;
590 bandsProps[ 2 ]->m_blkw = 10;
591 bandsProps[ 2 ]->m_blkh = 5;
592 bandsProps[ 2 ]->m_nblocksx = 1;
593 bandsProps[ 2 ]->m_nblocksy = 2;
599 std::unique_ptr< te::mem::ExpansibleRaster > clonePtr(
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell.
bool addTopLines(const unsigned int number)
New lines will be added at the top of the raster (before the first line).
Near neighborhood interpolation method.
void assertUniqueElement(const double &targetValue, const unsigned int &requiredBand, const unsigned int &requiredCol, const unsigned int &requiredLine, const te::rst::Raster &raster)
bool createMultiResolution(const unsigned int levels, const te::rst::InterpolationMethod interpMethod)
Create a sub-sampled multi-resolution pyramid.
A raster band description.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
A test suit for the Expansible Raster Class.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max().
std::size_t getNumberOfBands() const
Returns the number of bands (dimension of cells attribute values) in the raster.
void addRightColumnsTest()
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
unsigned int unsigned int nCols
void multiResolutionTest()
An abstract class for raster data strucutures.
bool addRightColumns(const unsigned int number)
New columns will be added at the right of the raster (after the last column).
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
void fillWithNoDataValues(te::rst::Raster &raster)
BandProperty * getProperty()
Returns the band property.
bool addBottomBands(const unsigned int number)
New bands will be added at the bottom of the raster (after de the last band).
void testValues(te::rst::Raster &raster)
te::rst::Raster * getMultiResLevel(const unsigned int level) const
Returns the required level of a multi-resolution pyramid or NULL if that level does not exists...
bool addBottomLines(const unsigned int number)
New lines will be added at the bottom of the raster (after de the last line).
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Grid * getGrid()
It returns the raster grid.
unsigned int getMultiResLevelsCount() const
Returns the current number of multi-resolution pyramid levels.
void writeValues(te::rst::Raster &raster)
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
void addLeftColumnsTest()
A test suit for the Cached Raster class interface.
void addBottomBandsTest()
CPPUNIT_TEST_SUITE_REGISTRATION(TsExpansibleRaster)
A raster (stored in memory and eventually swapped to disk) where it is possible to dynamically add li...
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
te::dt::AbstractData * clone() const
It returns a clone of this object.
A rectified grid is the spatial support for raster data.
This file contains include headers for the Data Access module of TerraLib.
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).
void addBottomLinesTest()