27 #include <terralib_buildconfig.h> 30 #include "../Config.h" 36 #include <boost/test/unit_test.hpp> 37 #include <boost/shared_ptr.hpp> 38 #include <boost/thread.hpp> 45 std::vector< te::rst::BandProperty * > bandsProps;
46 for(
unsigned int bandsPropsIdx = 0 ; bandsPropsIdx < nBands ; ++bandsPropsIdx )
54 std::map< std::string, std::string >(), 0, 0 ) );
61 for( band = 0 ; band < nBands ; ++
band )
65 rasterPointer->setValue( col, line, pixelValue, band );
72 std::unique_ptr< te::rst::SynchronizedRaster > syncRasterPtr(
75 const unsigned int nBands = syncRasterPtr->getNumberOfBands();
76 const unsigned int nLines = syncRasterPtr->getNumberOfRows();
77 const unsigned int nCols = syncRasterPtr->getNumberOfColumns();
78 unsigned int band = 0;
79 unsigned int line = 0;
81 double pixelValue = 0;
83 for( band = 0 ; band < nBands ; ++
band )
85 boost::this_thread::sleep( boost::posix_time::milliseconds(100) );
91 syncRasterPtr->getValue( col, line, pixelValue, band );
92 syncRasterPtr->setValue( col, line, pixelValue + 10.0, band );
102 const unsigned int nBands = 10;
103 const unsigned int nLines = 10;
104 const unsigned int nCols = 10;
106 boost::shared_ptr< te::rst::Raster > inputRasterPointer;
112 std::unique_ptr< te::rst::RasterSynchronizer > syncPtr(
114 std::unique_ptr< te::rst::SynchronizedRaster > syncRasterPtr(
117 unsigned int band = 0;
118 unsigned int line = 0;
119 unsigned int col = 0;
120 double pixelValue = 0;
122 for( band = 0 ; band < nBands ; ++
band )
126 for( col = 0 ; col <
nCols ; ++
col )
128 syncRasterPtr->getValue( col, line, pixelValue, band );
129 syncRasterPtr->setValue( col, line, pixelValue + 10.0, band );
134 syncRasterPtr.reset();
141 unsigned int band = 0;
142 unsigned int line = 0;
143 unsigned int col = 0;
144 double pixelValue = 0;
145 double readPixelValue = 0;
147 for( band = 0 ; band < nBands ; ++
band )
149 for( col = 0 ; col <
nCols ; ++
col )
151 inputRasterPointer->getValue( col, line, readPixelValue, band );
152 BOOST_CHECK_CLOSE( pixelValue + 10.0, readPixelValue, 0.0000001 );
162 const unsigned int nBands = 10;
163 const unsigned int nLines = 100;
164 const unsigned int nCols = 100;
166 boost::shared_ptr< te::rst::Raster > inputRasterPointer;
172 std::unique_ptr< te::rst::RasterSynchronizer > syncPtr(
175 boost::thread_group threads;
177 for(
unsigned int threadIdx = 0 ; threadIdx < nBands ;
180 threads.add_thread(
new boost::thread(
threadEntry, syncPtr.get() ) );
191 unsigned int band = 0;
192 unsigned int line = 0;
193 unsigned int col = 0;
194 double pixelValue = 0;
195 double readPixelValue = 0;
197 for( band = 0 ; band < nBands ; ++
band )
199 for( col = 0 ; col <
nCols ; ++
col )
201 inputRasterPointer->getValue( col, line, readPixelValue, band );
202 BOOST_CHECK_CLOSE( pixelValue + 100.0, readPixelValue, 0.0000001 );
208 BOOST_AUTO_TEST_SUITE_END()
An adapter class to allow concurrent access to raster data by multiple threads.
A raster band description.
An access synchronizer to be used in SynchronizedRaster raster instances.
void CreateTestRaster(unsigned int nBands, unsigned int nLines, unsigned int nCols, boost::shared_ptr< te::rst::Raster > &rasterPointer, bool zero)
BOOST_AUTO_TEST_CASE(singleThread_test)
unsigned int unsigned int nCols
unsigned int unsigned int boost::shared_ptr< te::rst::Raster > & rasterPointer
void threadEntry(te::rst::RasterSynchronizer *syncPtr)
static Raster * make()
It creates and returns an empty raster with default raster driver.
BOOST_AUTO_TEST_SUITE(synchronizedRaster_tests) void CreateTestRaster(unsigned int nBands
A rectified grid is the spatial support for raster data.