All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Blender.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/rp/Blender.cpp
22  \brief Blended pixel value calculation for two overlaped rasters.
23 */
24 
25 #include "Blender.h"
26 
27 #include "Macros.h"
28 #include "../geometry/LinearRing.h"
29 #include "../geometry/MultiPoint.h"
30 #include "../geometry/MultiLineString.h"
31 #include "../geometry/Point.h"
32 #include "../geometry/CurvePolygon.h"
33 #include "../geometry/Envelope.h"
34 #include "../geometry/Enums.h"
35 #include "../raster/Raster.h"
36 #include "../raster/Grid.h"
37 #include "../raster/Band.h"
38 #include "../raster/BandProperty.h"
39 #include "../raster/Utils.h"
40 #include "../raster/SynchronizedRaster.h"
41 #include "../common/PlatformUtils.h"
42 #include "../common/progress/TaskProgress.h"
43 
44 #include <boost/thread.hpp>
45 #include <boost/graph/graph_concepts.hpp>
46 #include <boost/scoped_ptr.hpp>
47 
48 #include <complex>
49 #include <limits>
50 #include <algorithm>
51 #include <memory>
52 
53 // Get the perpendicular distance from a point P(pX,pY) from a line defined
54 // by the points A(lineAX,lineAY) and B(lineBX,lineBY)
55 // Requires two previously declared variables aux1 and aux2
56 #define getPerpendicularDistance( pX, pY, lineAX, lineAY, lineBX, lineBY, aux1, aux2, perpDist ) \
57  aux1 = lineAX - lineBX; \
58  aux2 = lineAY - lineBY; \
59  if( aux1 == 0.0 ) \
60  { \
61  perpDist = std::abs( pX - lineAX ); \
62  } \
63  else if( aux2 == 0.0 ) \
64  { \
65  perpDist = std::abs( pY - lineAY ); \
66  } \
67  else \
68  { \
69  perpDist = \
70  std::abs( \
71  ( aux2 * pX ) - ( aux1 * pY ) + ( lineAX * lineBY ) - ( lineBX * lineAY ) \
72  ) \
73  / \
74  std::sqrt( ( aux1 * aux1 ) + ( aux2 * aux2 ) ); \
75  }
76 
77 namespace te
78 {
79  namespace rp
80  {
82  : m_returnValuePtr( 0 ), m_abortValuePtr( 0 ), m_sync1Ptr( 0 ), m_sync2Ptr( 0 ),
83  m_raster1BlocksInfosPtr( 0 ), m_mutexPtr( 0 ), m_blockProcessedSignalMutexPtr( 0 ),
84  m_blockProcessedSignalPtr( 0 ), m_runningThreadsCounterPtr( 0 ),
85  m_blendMethod( te::rp::Blender::InvalidBlendMethod ),
86  m_interpMethod2( te::rst::NearestNeighbor ),
87  m_noDataValue( 0.0 ), m_forceRaster1NoDataValue( false ),
88  m_forceRaster2NoDataValue( false ),
89  m_maxRasterCachedBlocks( 0 ), m_useProgress( false )
90  {
91  }
92 
94  const BlendIntoRaster1ThreadParams& rhs )
95  {
96  operator=( rhs );
97  }
98 
100  {
101  }
102 
104  const BlendIntoRaster1ThreadParams& rhs )
105  {
106  m_returnValuePtr = rhs.m_returnValuePtr;
107  m_abortValuePtr = rhs.m_abortValuePtr;
108  m_sync1Ptr = rhs.m_sync1Ptr;
109  m_sync2Ptr = rhs.m_sync2Ptr;
110  m_raster1BlocksInfosPtr = rhs.m_raster1BlocksInfosPtr;
111  m_mutexPtr = rhs.m_mutexPtr;
112  m_blockProcessedSignalMutexPtr = rhs.m_blockProcessedSignalMutexPtr;
113  m_blockProcessedSignalPtr = rhs.m_blockProcessedSignalPtr;
114  m_runningThreadsCounterPtr = rhs.m_runningThreadsCounterPtr;
119  m_noDataValue = rhs.m_noDataValue;
122  m_maxRasterCachedBlocks = rhs.m_maxRasterCachedBlocks;
127  m_useProgress = rhs.m_useProgress;
128 
129  if( rhs.m_r1ValidDataDelimiterPtr.get() )
130  {
132  }
133  else
134  {
136  }
137 
138  if( rhs.m_r2ValidDataDelimiterPtr.get() )
139  {
141  }
142  else
143  {
145  }
146 
147  if( rhs.m_geomTransformationPtr.get() )
148  {
149  m_geomTransformationPtr.reset( rhs.m_geomTransformationPtr->clone() );
150  }
151  else
152  {
153  m_geomTransformationPtr.reset();
154  }
155 
156  return *this;
157  }
158 
159  // ----------------------------------------------------------------------
161  {
162  initState();
163  }
164 
166  {
167  clear();
168  }
169 
171  const std::vector< unsigned int >& raster1Bands,
172  const te::rst::Raster& raster2,
173  const std::vector< unsigned int >& raster2Bands,
174  const BlendMethod& blendMethod,
175  const te::rst::Interpolator::Method& interpMethod1,
176  const te::rst::Interpolator::Method& interpMethod2,
177  const double& noDataValue,
178  const bool forceRaster1NoDataValue,
179  const bool forceRaster2NoDataValue,
180  const std::vector< double >& pixelOffsets1,
181  const std::vector< double >& pixelScales1,
182  const std::vector< double >& pixelOffsets2,
183  const std::vector< double >& pixelScales2,
184  te::gm::MultiPolygon const * const r1ValidDataDelimiterPtr,
185  te::gm::MultiPolygon const * const r2ValidDataDelimiterPtr,
186  const te::gm::GeometricTransformation& geomTransformation,
187  const unsigned int threadsNumber,
188  const bool enableProgressInterface )
189  {
192  "Invalid raster 1" );
195  "Invalid raster 2" );
196  TERP_TRUE_OR_RETURN_FALSE( raster1Bands.size() > 0,
197  "Invalid raster bands vector" );
198  TERP_TRUE_OR_RETURN_FALSE( raster1Bands.size() ==
199  raster2Bands.size(), "Invalid raster bands vector" );
200  TERP_TRUE_OR_RETURN_FALSE( pixelOffsets1.size() ==
201  raster1Bands.size(), "Invalid pixel offsets" );
202  TERP_TRUE_OR_RETURN_FALSE( pixelScales1.size() ==
203  raster1Bands.size(), "Invalid pixel scales" );
204  TERP_TRUE_OR_RETURN_FALSE( pixelOffsets2.size() ==
205  raster2Bands.size(), "Invalid pixel offsets" );
206  TERP_TRUE_OR_RETURN_FALSE( pixelScales2.size() ==
207  raster2Bands.size(), "Invalid pixel scales" );
208  TERP_TRUE_OR_RETURN_FALSE( ( r1ValidDataDelimiterPtr ?
209  ( r1ValidDataDelimiterPtr->getNumGeometries() > 0 ) : true ),
210  "Invalid polygon 1" )
211  TERP_TRUE_OR_RETURN_FALSE( ( r2ValidDataDelimiterPtr ?
212  ( r2ValidDataDelimiterPtr->getNumGeometries() > 0 ) : true ),
213  "Invalid polygon 2" )
214  TERP_TRUE_OR_RETURN_FALSE( geomTransformation.isValid(),
215  "Invalid transformation" );
216 
217  clear();
218 
219  // defining the input rasters
220 
221  m_raster1Ptr = &raster1;
222  m_raster2Ptr = &raster2;
223 
224  // Generating the valid data area points
225 
226  if( r1ValidDataDelimiterPtr )
227  {
228  m_r1ValidDataDelimiterPtr.reset( (te::gm::MultiPolygon*)r1ValidDataDelimiterPtr->clone() );
229  }
230  if( r2ValidDataDelimiterPtr )
231  {
232  m_r2ValidDataDelimiterPtr.reset( (te::gm::MultiPolygon*)r2ValidDataDelimiterPtr->clone() );
233  }
234 
235  // indexed under raster 1 lines/cols
236  std::auto_ptr< te::gm::MultiPolygon > indexedDelimiter1Ptr(
238 
239  if( r1ValidDataDelimiterPtr )
240  {
241  const te::rst::Grid& grid = (*raster1.getGrid());
242 
243  const std::size_t nGeoms = r1ValidDataDelimiterPtr->getNumGeometries();
244 
245  for( std::size_t geomIdx = 0 ; geomIdx < nGeoms ; ++geomIdx )
246  {
247  te::gm::Polygon const* geomPtr = dynamic_cast< te::gm::Polygon* >(
248  r1ValidDataDelimiterPtr->getGeometryN( geomIdx ) );
249  TERP_DEBUG_TRUE_OR_THROW( geomPtr, "Invalid geometry pointer" );
250 
251  const std::size_t nRings = geomPtr->getNumRings();
252 
253  te::gm::Polygon* outPolPtr = new te::gm::Polygon( 0, te::gm::PolygonType, 0, 0 );
254 
255  for( std::size_t ringIdx = 0 ; ringIdx < nRings ; ++ringIdx )
256  {
257  te::gm::LinearRing const* inRingPtr = dynamic_cast< te::gm::LinearRing const* >(
258  geomPtr->getRingN( ringIdx ) );
259  assert( inRingPtr );
260 
261  const std::size_t nPoints = inRingPtr->getNPoints();
262  te::gm::Coord2D const * inCoordsPtr = inRingPtr->getCoordinates();
263  te::gm::Coord2D auxCoord;
264 
265  te::gm::LinearRing* outRingPtr = new te::gm::LinearRing( nPoints,
266  te::gm::LineStringType, 0, 0 );
267 
268  for( std::size_t pIdx = 0 ; pIdx < nPoints ; ++pIdx )
269  {
270  grid.geoToGrid( inCoordsPtr[ pIdx ].x, inCoordsPtr[ pIdx ].y,
271  auxCoord.x, auxCoord.y );
272  outRingPtr->setPoint( pIdx, auxCoord.x, auxCoord.y );
273  }
274 
275  outPolPtr->add( outRingPtr );
276 
277  }
278 
279  indexedDelimiter1Ptr->add( outPolPtr );
280  }
281  }
282  else
283  {
284  te::gm::LinearRing* outRingPtr = new te::gm::LinearRing( 5,
285  te::gm::LineStringType, 0, 0 );
286 
287  outRingPtr->setPoint( 0,
288  -0.5,
289  -0.5 );
290  outRingPtr->setPoint( 1,
291  ((double)raster1.getNumberOfColumns()) - 0.5,
292  -0.5 );
293  outRingPtr->setPoint( 2,
294  ((double)raster1.getNumberOfColumns()) - 0.5,
295  ((double)raster1.getNumberOfRows()) - 0.5 );
296  outRingPtr->setPoint( 3,
297  -0.5,
298  ((double)raster1.getNumberOfRows()) - 0.5 );
299  outRingPtr->setPoint( 4,
300  -0.5,
301  -0.5 );
302 
303  te::gm::Polygon* outPolPtr = new te::gm::Polygon( 0, te::gm::PolygonType, 0, 0 );
304 
305  outPolPtr->add( outRingPtr );
306 
307  indexedDelimiter1Ptr->add( outPolPtr );
308  }
309 
310  // indexed under raster 1 lines/cols
311  std::auto_ptr< te::gm::MultiPolygon > indexedDelimiter2Ptr(
313 
314  if( r2ValidDataDelimiterPtr )
315  {
316  const te::rst::Grid& grid = (*raster2.getGrid());
317 
318  const std::size_t nGeoms = r2ValidDataDelimiterPtr->getNumGeometries();
319 
320  for( std::size_t geomIdx = 0 ; geomIdx < nGeoms ; ++geomIdx )
321  {
322  te::gm::Polygon const* geomPtr = dynamic_cast< te::gm::Polygon* >(
323  r2ValidDataDelimiterPtr->getGeometryN( geomIdx ) );
324  TERP_DEBUG_TRUE_OR_THROW( geomPtr, "Invalid geometry pointer" );
325 
326  const std::size_t nRings = geomPtr->getNumRings();
327 
328  te::gm::Polygon* outPolPtr = new te::gm::Polygon( 0, te::gm::PolygonType, 0, 0 );
329 
330  for( std::size_t ringIdx = 0 ; ringIdx < nRings ; ++ringIdx )
331  {
332  te::gm::LinearRing const* inRingPtr = dynamic_cast< te::gm::LinearRing const* >(
333  geomPtr->getRingN( ringIdx ) );
334  assert( inRingPtr );
335 
336  const std::size_t nPoints = inRingPtr->getNPoints();
337  te::gm::Coord2D const * inCoordsPtr = inRingPtr->getCoordinates();
338  te::gm::Coord2D auxCoord;
339  te::gm::Coord2D auxCoord2;
340 
341  te::gm::LinearRing* outRingPtr = new te::gm::LinearRing( nPoints,
342  te::gm::LineStringType, 0, 0 );
343 
344  for( std::size_t pIdx = 0 ; pIdx < nPoints ; ++pIdx )
345  {
346  grid.geoToGrid( inCoordsPtr[ pIdx ].x, inCoordsPtr[ pIdx ].y,
347  auxCoord.x, auxCoord.y );
348  geomTransformation.inverseMap( auxCoord.x, auxCoord.y, auxCoord2.x, auxCoord2.y );
349  outRingPtr->setPoint( pIdx, auxCoord2.x, auxCoord2.y );
350  }
351 
352  outPolPtr->add( outRingPtr );
353  }
354 
355  indexedDelimiter2Ptr->add( outPolPtr );
356  }
357  }
358  else
359  {
360  te::gm::LinearRing* outRingPtr = new te::gm::LinearRing( 5,
361  te::gm::LineStringType, 0, 0 );
362 
363  te::gm::Coord2D auxCoord;
364 
365  geomTransformation.inverseMap(
366  -0.5,
367  -0.5,
368  auxCoord.x, auxCoord.y );
369  outRingPtr->setPoint( 0, auxCoord.x, auxCoord.y );
370  outRingPtr->setPoint( 4, auxCoord.x, auxCoord.y );
371 
372  geomTransformation.inverseMap(
373  ((double)raster2.getNumberOfColumns()) - 0.5,
374  -0.5,
375  auxCoord.x, auxCoord.y );
376  outRingPtr->setPoint( 1, auxCoord.x, auxCoord.y );
377 
378  geomTransformation.inverseMap(
379  ((double)raster2.getNumberOfColumns()) - 0.5,
380  ((double)raster2.getNumberOfRows()) - 0.5,
381  auxCoord.x, auxCoord.y );
382  outRingPtr->setPoint( 2, auxCoord.x, auxCoord.y );
383 
384  geomTransformation.inverseMap(
385  -0.5,
386  ((double)raster2.getNumberOfRows()) - 0.5,
387  auxCoord.x, auxCoord.y );
388  outRingPtr->setPoint( 3, auxCoord.x, auxCoord.y );
389 
390  te::gm::Polygon* outPolPtr = new te::gm::Polygon( 0, te::gm::PolygonType, 0, 0 );
391 
392  outPolPtr->add( outRingPtr );
393 
394  indexedDelimiter2Ptr->add( outPolPtr );
395  }
396 
397  // Calculating the intersection (raster 1 lines/cols)
398 
399  m_intersectionPtr.reset( indexedDelimiter2Ptr->intersection(
400  indexedDelimiter1Ptr.get() ) );
401 
402  // Initializing the intersection tile indexer
403 
404  if( m_intersectionPtr.get() )
405  {
407  m_intersectionTileIndexers ), "Intersection tile indexers creation error" );
408  }
409 
410  // Extracting the intersection segments points
411 
412  if( m_intersectionPtr.get() )
413  {
414  std::size_t ringIdx = 0;
415  std::auto_ptr< te::gm::Geometry > ringIntersectionPtr;
416  std::size_t nPols = 0;
417  std::size_t polIdx = 0;
418 
419  nPols = indexedDelimiter2Ptr->getNumGeometries();
420  for( polIdx = 0 ; polIdx < nPols ; ++polIdx )
421  {
422  te::gm::Polygon const* polPtr = dynamic_cast< te::gm::Polygon* >(
423  indexedDelimiter2Ptr->getGeometryN( polIdx ) );
424  TERP_DEBUG_TRUE_OR_THROW( polPtr, "Invalid geometry pointer" );
425 
426  for( ringIdx = 0 ; ringIdx < polPtr->getNumRings() ;
427  ++ringIdx )
428  {
429  ringIntersectionPtr.reset( indexedDelimiter1Ptr->intersection(
430  polPtr->getRingN( ringIdx ) ) );
431 
432  if( ringIntersectionPtr.get() != 0 )
433  {
434  TERP_TRUE_OR_THROW( getSegments( ringIntersectionPtr.get(),
435  m_r2IntersectionSegmentsPoints ), "Error getting intersection segments" );
436  }
437  }
438  }
439 
440  nPols = indexedDelimiter1Ptr->getNumGeometries();
441  for( polIdx = 0 ; polIdx < nPols ; ++polIdx )
442  {
443  te::gm::Polygon const* polPtr = dynamic_cast< te::gm::Polygon* >(
444  indexedDelimiter1Ptr->getGeometryN( polIdx ) );
445  TERP_DEBUG_TRUE_OR_THROW( polPtr, "Invalid geometry pointer" );
446 
447  for( ringIdx = 0 ; ringIdx < polPtr->getNumRings() ;
448  ++ringIdx )
449  {
450  ringIntersectionPtr.reset( indexedDelimiter2Ptr->intersection(
451  polPtr->getRingN( ringIdx ) ) );
452 
453  if( ringIntersectionPtr.get() != 0 )
454  {
455  TERP_TRUE_OR_THROW( getSegments( ringIntersectionPtr.get(),
456  m_r1IntersectionSegmentsPoints ), "Error getting intersection segments" );
457  }
458  }
459  }
460 
461 /* std::cout << std::endl;
462  for( unsigned int idx = 0 ; idx < m_r1IntersectionSegmentsPoints.size() ; ++idx )
463  {
464  std::cout << std::endl << "m_r1IntersectionSegmentsPoints[" << idx << "]="
465  << m_r1IntersectionSegmentsPoints[ idx ].first.x
466  << " " << m_r1IntersectionSegmentsPoints[ idx ].first.y
467  << " " << m_r1IntersectionSegmentsPoints[ idx ].second.x
468  << " " << m_r1IntersectionSegmentsPoints[ idx ].second.y;
469  }
470  for( unsigned int idx = 0 ; idx < m_r2IntersectionSegmentsPoints.size() ; ++idx )
471  {
472  std::cout << std::endl << "m_r2IntersectionSegmentsPoints[" << idx << "]="
473  << m_r2IntersectionSegmentsPoints[ idx ].first.x
474  << " " << m_r2IntersectionSegmentsPoints[ idx ].first.y
475  << " " << m_r2IntersectionSegmentsPoints[ idx ].second.x
476  << " " << m_r2IntersectionSegmentsPoints[ idx ].second.y;
477  }
478  std::cout << std::endl; */
479 
482  }
483 
484  // defining the blending method
485 
486  switch( blendMethod )
487  {
488  case NoBlendMethod :
489  {
491  break;
492  }
494  {
495  if( ( m_intersectionPtr.get() != 0 ) &&
498  {
500  }
501  else
502  {
504  }
505  break;
506  }
507  case SumMethod :
508  {
509  if( ( m_intersectionPtr.get() != 0 ) &&
512  {
514  }
515  else
516  {
518  }
519  break;
520  }
521  default :
522  {
523  TERP_LOG_AND_THROW( "Invalid blend method" );
524  break;
525  }
526  }
527 
528  // Defining the blending function pointers
529 
531 
532  // defining the geometric transformation
533 
534  m_geomTransformationPtr = geomTransformation.clone();
535 
536  // defining the interpolators
537 
538  if( forceRaster1NoDataValue )
539  {
540  std::vector< std::complex<double> > noDataValues1( raster1.getNumberOfBands(),
541  std::complex<double>( noDataValue, 0.0 ) );
542  m_interp1Ptr.reset( new te::rst::Interpolator( &raster1, interpMethod1,
543  noDataValues1 ) );
544  }
545  else
546  {
547  m_interp1Ptr.reset( new te::rst::Interpolator( &raster1, interpMethod1 ) );
548  }
549 
550  if( forceRaster2NoDataValue )
551  {
552  std::vector< std::complex<double> > noDataValues2( raster2.getNumberOfBands(),
553  std::complex<double>( noDataValue, 0.0 ) );
554  m_interp2Ptr.reset( new te::rst::Interpolator( &raster2, interpMethod2,
555  noDataValues2 ) );
556  }
557  else
558  {
559  m_interp2Ptr.reset( new te::rst::Interpolator( &raster2, interpMethod2 ) );
560  }
561 
562  m_interpMethod1 = interpMethod1;
563  m_interpMethod2 = interpMethod2;
564 
565  // defining dummy values
566 
567  m_forceRaster1NoDataValue = forceRaster1NoDataValue;
568  m_forceRaster2NoDataValue = forceRaster2NoDataValue;
569 
570  for( std::vector< unsigned int >::size_type rasterBandsIdx = 0 ;
571  rasterBandsIdx < raster1Bands.size() ; ++rasterBandsIdx )
572  {
573  TERP_TRUE_OR_RETURN_FALSE( raster1Bands[ rasterBandsIdx ] <
574  raster1.getNumberOfBands(), "Invalid band" );
575  TERP_TRUE_OR_RETURN_FALSE( raster2Bands[ rasterBandsIdx ] <
576  raster2.getNumberOfBands(), "Invalid band" );
577 
578  if( forceRaster1NoDataValue )
579  {
580  m_raster1NoDataValues.push_back( noDataValue );
581  }
582  else
583  {
584  m_raster1NoDataValues.push_back( raster1.getBand( raster1Bands[
585  rasterBandsIdx ] )->getProperty()->m_noDataValue );
586  }
587 
588  if( forceRaster2NoDataValue )
589  {
590  m_raster2NoDataValues.push_back( noDataValue );
591  }
592  else
593  {
594  m_raster2NoDataValues.push_back( raster2.getBand( raster2Bands[
595  rasterBandsIdx ] )->getProperty()->m_noDataValue );
596  }
597  }
598 
599  m_outputNoDataValue = noDataValue;
600 
601  // defining raster bands
602 
603  m_raster1Bands = raster1Bands;
604  m_raster2Bands = raster2Bands;
605 
606  // defining pixel offsets
607 
608  m_pixelOffsets1 = pixelOffsets1;
609  m_pixelScales1 = pixelScales1;
610 
611  m_pixelOffsets2 = pixelOffsets2;
612  m_pixelScales2 = pixelScales2;
613 
614  // threads
615 
616  if( threadsNumber == 0 )
617  {
619  }
620  else
621  {
622  m_threadsNumber = threadsNumber;
623  }
624 
625  // progress interface
626 
627  m_enableProgressInterface = enableProgressInterface;
628 
629  return true;
630  }
631 
633  {
637  m_threadsNumber = 0;
639  m_blendFuncPtr = 0;
640  m_raster1Ptr = 0;
641  m_raster2Ptr = 0;
648  }
649 
651  {
654  m_intersectionPtr.reset();
658  m_interp1Ptr.reset();
659  m_interp2Ptr.reset();
660  m_raster1Bands.clear();
661  m_raster2Bands.clear();
662  m_pixelOffsets1.clear();
663  m_pixelScales1.clear();
664  m_pixelOffsets2.clear();
665  m_pixelScales2.clear();
666  m_raster1NoDataValues.clear();
667  m_raster2NoDataValues.clear();
669 
670  initState();
671  }
672 
674  {
675  switch( blendMethod )
676  {
677  case NoBlendMethod :
678  {
680  break;
681  }
683  {
685  break;
686  }
687  case SumMethod :
688  {
690  break;
691  }
692  default :
693  {
694  TERP_LOG_AND_THROW( "Invalid blend method" );
695  break;
696  }
697  }
698  }
699 
700  void Blender::noBlendMethodImp( const double& line, const double& col,
701  double* const values )
702  {
703  // Finding the point over the second raster
704 
707 
708  // Blending values
709 
712  {
713  m_interp1Ptr->getValue( col, line, m_noBlendMethodImp_cValue,
716 
717  if( m_noBlendMethodImp_Value == m_raster1NoDataValues[ m_noBlendMethodImp_BandIdx ] )
718  {
721  m_raster2Bands[ m_noBlendMethodImp_BandIdx ] );
723 
724  if( m_noBlendMethodImp_Value == m_raster2NoDataValues[ m_noBlendMethodImp_BandIdx ] )
725  {
727  }
728  else
729  {
730 
733 
735  }
736  }
737  else
738  {
739 
742 
744  }
745  }
746  }
747 
748  void Blender::euclideanDistanceMethodImp( const double& line, const double& col,
749  double* const values )
750  {
751  TERP_DEBUG_TRUE_OR_THROW( m_intersectionPtr.get(), "Invalid intersection pointer" );
752  TERP_DEBUG_TRUE_OR_THROW( m_r1IntersectionSegmentsPointsSize > 1, "Invalid intersection points" );
753  TERP_DEBUG_TRUE_OR_THROW( m_r2IntersectionSegmentsPointsSize > 1, "Invalid intersection points" );
754 
755  // Checking if it is inside the intersection
756 
759 
764  {
768  {
770  break;
771  }
772  }
773 
774  // Blending if the point is inside the intersection
775 
777  {
778  // Finding distances to both rasters valid area delimiters
779 
780  m_euclideanDistanceMethodImp_dist1 = std::numeric_limits<double>::max();
784  {
785 
787  col,
788  line,
790  m_r1IntersectionSegmentsPoints[ m_euclideanDistanceMethodImp_vecIdx ].first.y,
791  m_r1IntersectionSegmentsPoints[ m_euclideanDistanceMethodImp_vecIdx ].second.x,
792  m_r1IntersectionSegmentsPoints[ m_euclideanDistanceMethodImp_vecIdx ].second.y,
796 
798  {
800  }
801  }
802 
803  m_euclideanDistanceMethodImp_dist2 = std::numeric_limits<double>::max();
807  {
808 
810  col,
811  line,
813  m_r2IntersectionSegmentsPoints[ m_euclideanDistanceMethodImp_vecIdx ].first.y,
814  m_r2IntersectionSegmentsPoints[ m_euclideanDistanceMethodImp_vecIdx ].second.x,
815  m_r2IntersectionSegmentsPoints[ m_euclideanDistanceMethodImp_vecIdx ].second.y,
819 
821  {
823  }
824  }
825 
826  // Finding the point over the second raster
827 
830 
831  // Blending values
832 
835  {
836  m_interp1Ptr->getValue( col, line, m_euclideanDistanceMethodImp_cValue1,
840  m_raster2Bands[ m_euclideanDistanceMethodImp_BandIdx ] );
841 
843  {
845  {
847  }
848  else
849  {
851  (
853  *
855  )
856  +
857  m_pixelOffsets2[ m_euclideanDistanceMethodImp_BandIdx ];
858  }
859  }
860  else
861  {
863  {
865  (
867  *
869 
870  )
871  +
872  m_pixelOffsets1[ m_euclideanDistanceMethodImp_BandIdx ];
873  }
874  else
875  {
877  {
879  (
881  *
883  )
884  +
885  m_pixelOffsets1[ m_euclideanDistanceMethodImp_BandIdx ];
886  }
887  else if( m_euclideanDistanceMethodImp_dist1 == 0.0 )
888  {
890  (
892  *
894 
895  )
896  +
897  m_pixelOffsets2[ m_euclideanDistanceMethodImp_BandIdx ];
898  }
899  else
900  {
902  (
903  (
904  (
905  (
907  *
909 
910  )
911  +
912  m_pixelOffsets1[ m_euclideanDistanceMethodImp_BandIdx ]
913  )
914  *
916  )
917  +
918  (
919  (
920  (
922  *
924  )
925  +
926  m_pixelOffsets2[ m_euclideanDistanceMethodImp_BandIdx ]
927  )
928  *
930  )
931  )
932  /
933  (
935  +
937  );
938  }
939  }
940  }
941  }
942  }
943  else
944  {
945  noBlendMethodImp( line, col, values );
946  }
947  }
948 
949  void Blender::sumMethodImp( const double& line, const double& col,
950  double* const values )
951  {
952  TERP_DEBUG_TRUE_OR_THROW( m_intersectionPtr.get(), "Invalid intersection pointer" );
953  TERP_DEBUG_TRUE_OR_THROW( m_r1IntersectionSegmentsPointsSize > 1, "Invalid intersection points" );
954  TERP_DEBUG_TRUE_OR_THROW( m_r2IntersectionSegmentsPointsSize > 1, "Invalid intersection points" );
955 
956  // Checking if it is inside the intersection
957 
960 
965  {
969  {
971  break;
972  }
973  }
974 
975  // Blending if the point is inside the intersection
976 
978  {
979  // Finding the point over the second raster
980 
983 
984  // Blending values
985 
988  {
989  m_interp1Ptr->getValue( col, line, m_sumMethodImp_cValue1,
993  m_raster2Bands[ m_sumMethodImp_BandIdx ] );
994 
996  {
998  {
1000  }
1001  else
1002  {
1003  values[ m_sumMethodImp_BandIdx ] =
1004  (
1005  m_sumMethodImp_cValue2.real()
1006  *
1008  )
1009  +
1010  m_pixelOffsets2[ m_sumMethodImp_BandIdx ];
1011  }
1012  }
1013  else
1014  {
1016  {
1017  values[ m_sumMethodImp_BandIdx ] =
1018  (
1019  m_sumMethodImp_cValue1.real()
1020 
1021  *
1023  )
1024  +
1025  m_pixelOffsets1[ m_sumMethodImp_BandIdx ];
1026  }
1027  else
1028  {
1029  values[ m_sumMethodImp_BandIdx ] =
1030  (
1031  (
1032  m_sumMethodImp_cValue1.real()
1033  *
1035  )
1036  +
1037  m_pixelOffsets1[ m_sumMethodImp_BandIdx ]
1038  )
1039  +
1040  (
1041  (
1042  m_sumMethodImp_cValue2.real()
1043  *
1045  )
1046  +
1047  m_pixelOffsets2[ m_sumMethodImp_BandIdx ]
1048  );
1049  }
1050  }
1051  }
1052  }
1053  else
1054  {
1055  noBlendMethodImp( line, col, values );
1056  }
1057  }
1058 
1059 
1061  {
1063  te::common::WAccess, "Invalid output raster access policy" );
1064 
1065  // Locating raster2 over the raster1
1066 
1067  unsigned int firstOutputRasterCol = 0;
1068  unsigned int lastOutputRasterRow = 0;
1069  unsigned int lastOutputRasterCol = 0;
1070  unsigned int firstOutputRasterRow = 0;
1071 
1072  {
1073  const double raster2LastRowIdx =
1074  (double)( m_raster2Ptr->getNumberOfRows() - 1 );
1075  const double raster2LastColIdx =
1076  (double)( m_raster2Ptr->getNumberOfColumns() - 1 );
1077  double raster2LLColOverRaster1 = 0;
1078  double raster2LLRowOverRaster1 = 0;
1079  double raster2LRColOverRaster1 = 0;
1080  double raster2LRRowOverRaster1 = 0;
1081  double raster2URColOverRaster1 = 0;
1082  double raster2URRowOverRaster1 = 0;
1083  double raster2ULColOverRaster1 = 0;
1084  double raster2ULRowOverRaster1 = 0;
1085 
1087  0.0,
1088  raster2LastRowIdx,
1089  raster2LLColOverRaster1,
1090  raster2LLRowOverRaster1);
1092  raster2LastColIdx,
1093  raster2LastRowIdx,
1094  raster2LRColOverRaster1,
1095  raster2LRRowOverRaster1);
1097  raster2LastColIdx,
1098  0.0,
1099  raster2URColOverRaster1,
1100  raster2URRowOverRaster1);
1102  0.0,
1103  0.0,
1104  raster2ULColOverRaster1,
1105  raster2ULRowOverRaster1);
1106 
1107  firstOutputRasterCol = (unsigned int)
1108  std::max( 0.0,
1109  std::min( (double)( m_raster1Ptr->getNumberOfColumns() - 1 ),
1110  std::floor(
1111  std::min( raster2LLColOverRaster1,
1112  std::min( raster2LRColOverRaster1,
1113  std::min( raster2URColOverRaster1,
1114  raster2ULColOverRaster1
1115  )
1116  )
1117  )
1118  )
1119  )
1120  );
1121 
1122  lastOutputRasterRow = (unsigned int)
1123  std::max( 0.0,
1124  std::min( (double)( m_raster1Ptr->getNumberOfRows() - 1 ),
1125  std::ceil(
1126  std::max( raster2LLRowOverRaster1,
1127  std::max( raster2LRRowOverRaster1,
1128  std::max( raster2URRowOverRaster1,
1129  raster2ULRowOverRaster1
1130  )
1131  )
1132  )
1133  )
1134  )
1135  );
1136 
1137  lastOutputRasterCol = (unsigned int)
1138  std::max( 0.0,
1139  std::min( (double)( m_raster1Ptr->getNumberOfColumns() - 1 ),
1140  std::ceil(
1141  std::max( raster2LLColOverRaster1,
1142  std::max( raster2LRColOverRaster1,
1143  std::max( raster2URColOverRaster1,
1144  raster2ULColOverRaster1
1145  )
1146  )
1147  )
1148  )
1149  )
1150  );
1151 
1152  firstOutputRasterRow = (unsigned int)
1153  std::max( 0.0,
1154  std::min( (double)( m_raster1Ptr->getNumberOfRows() - 1 ),
1155  std::floor(
1156  std::min( raster2LLRowOverRaster1,
1157  std::min( raster2LRRowOverRaster1,
1158  std::min( raster2URRowOverRaster1,
1159  raster2ULRowOverRaster1
1160  )
1161  )
1162  )
1163  )
1164  )
1165  );
1166 
1167  assert( firstOutputRasterCol >= 0 );
1168  assert( firstOutputRasterCol <=
1169  ( m_raster1Ptr->getNumberOfColumns() - 1 ) );
1170  assert( lastOutputRasterRow >= 0 );
1171  assert( lastOutputRasterRow <=
1172  ( m_raster1Ptr->getNumberOfRows() - 1 ) );
1173  assert( lastOutputRasterCol >= 0 );
1174  assert( lastOutputRasterCol <=
1175  ( m_raster1Ptr->getNumberOfColumns() - 1 ) );
1176  assert( firstOutputRasterRow >= 0 );
1177  assert( firstOutputRasterRow <=
1178  ( m_raster1Ptr->getNumberOfRows() - 1 ) );
1179  }
1180 
1181  // Discovering the raster 1 blocks we need to process
1182 
1183  std::vector< RasterBlockInfo > raster1BlocksInfos;
1184  bool allRaster1BandsWithSameBlocking = true;
1185 
1186  {
1187  const te::rst::Band& firstBand = *( m_raster1Ptr->getBand(
1188  m_raster1Bands[ 0 ] ) );
1189 
1190  for( unsigned int raster1BandsIdx = 0 ; raster1BandsIdx <
1191  m_raster1Bands.size() ; ++raster1BandsIdx )
1192  {
1193  const te::rst::Band& band = *( m_raster1Ptr->getBand(
1194  m_raster1Bands[ raster1BandsIdx ] ) );
1195 
1196  if(
1197  ( band.getProperty()->m_blkh != firstBand.getProperty()->m_blkh )
1198  ||
1199  ( band.getProperty()->m_blkw != firstBand.getProperty()->m_blkw )
1200  ||
1201  ( band.getProperty()->m_nblocksx != firstBand.getProperty()->m_nblocksx )
1202  ||
1203  ( band.getProperty()->m_nblocksy != firstBand.getProperty()->m_nblocksy )
1204  )
1205  {
1206  allRaster1BandsWithSameBlocking = false;
1207  break;
1208  }
1209  }
1210 
1211  unsigned int firstBlockX = firstOutputRasterCol /
1212  firstBand.getProperty()->m_blkw;
1213  unsigned int lastBlockX = lastOutputRasterCol /
1214  firstBand.getProperty()->m_blkw;
1215  unsigned int firstBlockY = firstOutputRasterRow /
1216  firstBand.getProperty()->m_blkh;
1217  unsigned int lastBlockY = lastOutputRasterRow /
1218  firstBand.getProperty()->m_blkh;
1219 
1220  for( unsigned int blkY = firstBlockY ; blkY <= lastBlockY ; ++blkY )
1221  {
1222  for( unsigned int blkX = firstBlockX ; blkX <= lastBlockX ; ++blkX )
1223  {
1224  raster1BlocksInfos.push_back( RasterBlockInfo() );
1225 
1226  RasterBlockInfo& rBInfo = raster1BlocksInfos.back();
1227 
1228  rBInfo.m_wasProcessed = false;
1229  rBInfo.m_blkX = blkX;
1230  rBInfo.m_blkY = blkY;
1231  rBInfo.m_blkTotalPixelsNumber = firstBand.getProperty()->m_blkh *
1232  firstBand.getProperty()->m_blkw;
1233 
1234  rBInfo.m_firstRasterRow2Process = blkY * firstBand.getProperty()->m_blkh;
1235  rBInfo.m_firstRasterRow2Process = std::max( firstOutputRasterRow,
1236  rBInfo.m_firstRasterRow2Process );
1237  rBInfo.m_firstRasterRow2Process = std::min( lastOutputRasterRow,
1238  rBInfo.m_firstRasterRow2Process );
1239 
1240  rBInfo.m_rasterRows2ProcessBound = ( blkY + 1 ) * firstBand.getProperty()->m_blkh;
1241  rBInfo.m_rasterRows2ProcessBound = std::max( firstOutputRasterRow,
1242  rBInfo.m_rasterRows2ProcessBound );
1243  rBInfo.m_rasterRows2ProcessBound = std::min( lastOutputRasterRow,
1244  rBInfo.m_rasterRows2ProcessBound );
1245 
1246  rBInfo.m_firstRasterCol2Process = blkX * firstBand.getProperty()->m_blkw;
1247  rBInfo.m_firstRasterCol2Process = std::max( firstOutputRasterCol,
1248  rBInfo.m_firstRasterCol2Process );
1249  rBInfo.m_firstRasterCol2Process = std::min( lastOutputRasterCol,
1250  rBInfo.m_firstRasterCol2Process );
1251 
1252  rBInfo.m_rasterCols2ProcessBound = ( blkX + 1 ) * firstBand.getProperty()->m_blkw;
1253  rBInfo.m_rasterCols2ProcessBound = std::max( firstOutputRasterCol,
1254  rBInfo.m_rasterCols2ProcessBound );
1255  rBInfo.m_rasterCols2ProcessBound = std::min( lastOutputRasterCol,
1256  rBInfo.m_rasterCols2ProcessBound );
1257  }
1258  }
1259  }
1260 
1261  // blending
1262 
1263  bool returnValue = true;
1264 
1265  {
1266  // Guessing memory resources
1267 
1268  const double totalPhysMem = (double)te::common::GetTotalPhysicalMemory();
1269  const double usedVMem = (double)te::common::GetUsedVirtualMemory();
1270  const double totalVMem = ( (double)te::common::GetTotalVirtualMemory() );
1271  const double maxVMem2Use = 0.75 * MIN( totalPhysMem, ( totalVMem - usedVMem ) );
1272 
1273  // Creating thread exec params
1274 
1275  bool abortValue = false;
1276  boost::mutex mutex;
1279  boost::mutex blockProcessedSignalMutex;
1280  boost::condition_variable blockProcessedSignal;
1281  unsigned int runningThreadsCounter = 0;
1282 
1283  BlendIntoRaster1ThreadParams auxThreadParams;
1284  auxThreadParams.m_returnValuePtr = &returnValue;
1285  auxThreadParams.m_abortValuePtr = &abortValue;
1286  auxThreadParams.m_sync1Ptr = &sync1;
1287  auxThreadParams.m_sync2Ptr = &sync2;
1288  auxThreadParams.m_raster1BlocksInfosPtr = &raster1BlocksInfos;
1289  auxThreadParams.m_mutexPtr = &mutex;
1290  auxThreadParams.m_blockProcessedSignalMutexPtr = &blockProcessedSignalMutex;
1291  auxThreadParams.m_blockProcessedSignalPtr = &blockProcessedSignal;
1292  auxThreadParams.m_runningThreadsCounterPtr = &runningThreadsCounter;
1293  auxThreadParams.m_raster1Bands = m_raster1Bands;
1294  auxThreadParams.m_raster2Bands = m_raster2Bands;
1295  auxThreadParams.m_blendMethod = m_blendMethod;
1296  auxThreadParams.m_interpMethod2 = m_interpMethod2;
1297  auxThreadParams.m_noDataValue = m_outputNoDataValue;
1300  auxThreadParams.m_pixelOffsets1 = m_pixelOffsets1;
1301  auxThreadParams.m_pixelScales1 = m_pixelScales1;
1302  auxThreadParams.m_pixelOffsets2 = m_pixelOffsets2;
1303  auxThreadParams.m_pixelScales2 = m_pixelScales2;
1304 
1305  std::vector< BlendIntoRaster1ThreadParams > allThreadsParams( m_threadsNumber,
1306  auxThreadParams );
1307 
1308  // creating threads
1309 
1310  if( ( m_threadsNumber == 1 ) || (!allRaster1BandsWithSameBlocking) )
1311  {
1312  runningThreadsCounter = 1;
1313  if( m_r1ValidDataDelimiterPtr.get() )
1314  {
1315  allThreadsParams[ 0 ].m_r1ValidDataDelimiterPtr.reset(
1317  }
1318  if( m_r2ValidDataDelimiterPtr.get() )
1319  {
1320  allThreadsParams[ 0 ].m_r2ValidDataDelimiterPtr.reset(
1322  }
1323  allThreadsParams[ 0 ].m_geomTransformationPtr.reset(
1325  allThreadsParams[ 0 ].m_maxRasterCachedBlocks = std::max( 1u,
1326  ((unsigned int)maxVMem2Use)
1327  / ((unsigned int)m_raster2Ptr->getBand( m_raster1Bands[ 0 ] )->getBlockSize() ) );
1328  allThreadsParams[ 0 ].m_useProgress = m_enableProgressInterface;
1329 
1330  blendIntoRaster1Thread( &( allThreadsParams[ 0 ] ) );
1331  }
1332  else
1333  {
1334  boost::thread_group threads;
1335  runningThreadsCounter = m_threadsNumber;
1336 
1337  for( unsigned int threadIdx = 0 ; threadIdx < m_threadsNumber ;
1338  ++threadIdx )
1339  {
1340  if( m_r1ValidDataDelimiterPtr.get() )
1341  {
1342  allThreadsParams[ threadIdx ].m_r1ValidDataDelimiterPtr.reset(
1344  }
1345  if( m_r2ValidDataDelimiterPtr.get() )
1346  {
1347  allThreadsParams[ threadIdx ].m_r2ValidDataDelimiterPtr.reset(
1349  }
1350  allThreadsParams[ threadIdx ].m_geomTransformationPtr.reset(
1352 
1353  allThreadsParams[ 0 ].m_maxRasterCachedBlocks = std::max( 1u,
1354  ((unsigned int)maxVMem2Use)
1355  /
1356  (
1357  ((unsigned int)m_raster2Ptr->getBand( m_raster1Bands[ 0 ] )->getBlockSize() )
1358  *
1359  m_threadsNumber
1360  ) );
1361 
1362  allThreadsParams[ threadIdx ].m_useProgress = false;
1363 
1364  threads.add_thread( new boost::thread( blendIntoRaster1Thread,
1365  &( allThreadsParams[ threadIdx ] ) ) );
1366  };
1367 
1368  // progress stuff
1369 
1370  std::auto_ptr< te::common::TaskProgress > progressPtr;
1372  {
1373  progressPtr.reset( new te::common::TaskProgress );
1374  progressPtr->setTotalSteps( raster1BlocksInfos.size() );
1375  progressPtr->setMessage( "Blending" );
1376 
1377  while( (!abortValue) && (runningThreadsCounter > 0 ) )
1378  {
1379  if( progressPtr->isActive() )
1380  {
1381  boost::unique_lock<boost::mutex> lock( blockProcessedSignalMutex );
1382  blockProcessedSignal.timed_wait( lock,
1383  boost::posix_time::seconds( 1 ) );
1384 
1385  int processedBlocksNmb = 0;
1386  for( unsigned int raster1BlocksInfosIdx = 0 ; raster1BlocksInfosIdx <
1387  raster1BlocksInfos.size() ; ++raster1BlocksInfosIdx )
1388  {
1389  if( raster1BlocksInfos[ raster1BlocksInfosIdx ].m_wasProcessed )
1390  {
1391  ++processedBlocksNmb;
1392  }
1393  }
1394 
1395  if( processedBlocksNmb != progressPtr->getCurrentStep() )
1396  {
1397  progressPtr->pulse();
1398  }
1399  }
1400  else
1401  {
1402  mutex.lock();
1403  abortValue = true;
1404  mutex.unlock();
1405  }
1406  }
1407  }
1408 
1409  // Joining threads
1410 
1411  threads.join_all();
1412  }
1413  }
1414 
1415  return returnValue;
1416  }
1417 
1419  {
1420  // Instantiating the local rasters instance
1421 
1422  te::rst::SynchronizedRaster raster1( paramsPtr->m_raster1Bands.size(),
1423  *( paramsPtr->m_sync1Ptr ) );
1425  *( paramsPtr->m_sync2Ptr ) );
1426 
1427  // Guessing the output raster channels ranges
1428 
1429  const std::vector< unsigned int >& raster1Bands =
1430  paramsPtr->m_raster1Bands;
1431  const unsigned int raster1BandsSize = raster1Bands.size();
1432 
1433  std::vector< double > raster1BandsRangeMin( raster1BandsSize, 0 );
1434  std::vector< double > raster1BandsRangeMax( raster1BandsSize, 0 );
1435 
1436  {
1437  for( unsigned int raster1BandsIdx = 0 ; raster1BandsIdx <
1438  raster1BandsSize ; ++raster1BandsIdx )
1439  {
1440  unsigned int bandIdx = raster1Bands[ raster1BandsIdx ];
1441 
1442  te::rst::GetDataTypeRanges( raster1.getBand( bandIdx )->getProperty()->m_type,
1443  raster1BandsRangeMin[ raster1BandsIdx ],
1444  raster1BandsRangeMax[ raster1BandsIdx ]);
1445  }
1446  }
1447 
1448  // instantiating the thread local blender instance
1449 
1450  paramsPtr->m_mutexPtr->lock();
1451  const unsigned int raster1BlocksInfosSize = paramsPtr->m_raster1BlocksInfosPtr->size();
1452  paramsPtr->m_mutexPtr->unlock();
1453 
1454  Blender blender;
1455 
1456  if( ! blender.initialize(
1457  raster1,
1458  paramsPtr->m_raster1Bands,
1459  raster2,
1460  paramsPtr->m_raster2Bands,
1461  paramsPtr->m_blendMethod,
1463  paramsPtr->m_interpMethod2,
1464  paramsPtr->m_noDataValue,
1465  paramsPtr->m_forceRaster1NoDataValue,
1466  paramsPtr->m_forceRaster2NoDataValue,
1467  paramsPtr->m_pixelOffsets1,
1468  paramsPtr->m_pixelScales1,
1469  paramsPtr->m_pixelOffsets2,
1470  paramsPtr->m_pixelScales2,
1471  paramsPtr->m_r1ValidDataDelimiterPtr.get(),
1472  paramsPtr->m_r2ValidDataDelimiterPtr.get(),
1473  *( paramsPtr->m_geomTransformationPtr ),
1474  1,
1475  false ) )
1476  {
1477  paramsPtr->m_mutexPtr->lock();
1478  *(paramsPtr->m_abortValuePtr) = true;
1479  *(paramsPtr->m_returnValuePtr) = false;
1480  --( *(paramsPtr->m_runningThreadsCounterPtr) );
1481  paramsPtr->m_mutexPtr->unlock();
1482  return;
1483  }
1484 
1485  // progress stuff
1486 
1487  std::auto_ptr< te::common::TaskProgress > progressPtr;
1488 
1489  if( paramsPtr->m_useProgress )
1490  {
1491  progressPtr.reset( new te::common::TaskProgress );
1492  progressPtr->setTotalSteps( raster1BlocksInfosSize );
1493  progressPtr->setMessage( "Blending" );
1494  }
1495 
1496  // loocking for the next raster block to blend
1497 
1498  boost::scoped_array< double > blendedValuesHandler( new double[ raster1BandsSize ] );
1499  double* blendedValuesHandlerPtr = blendedValuesHandler.get();
1500 
1501  const double noDataValue = paramsPtr->m_noDataValue;
1502 
1503  for( unsigned int raster1BlocksInfosIdx = 0 ; raster1BlocksInfosIdx <
1504  raster1BlocksInfosSize ; ++raster1BlocksInfosIdx )
1505  {
1506  paramsPtr->m_mutexPtr->lock();
1507 
1508  if( paramsPtr->m_raster1BlocksInfosPtr->operator[]( raster1BlocksInfosIdx ).m_wasProcessed )
1509  {
1510  paramsPtr->m_mutexPtr->unlock();
1511  }
1512  else
1513  {
1514  RasterBlockInfo& rBInfo = paramsPtr->m_raster1BlocksInfosPtr->operator[](
1515  raster1BlocksInfosIdx );
1516  rBInfo.m_wasProcessed = true;
1517  paramsPtr->m_mutexPtr->unlock();
1518 
1519  //blending block data
1520 
1521  unsigned int raster1Row = 0;
1522  unsigned int raster1Col = 0;
1523  unsigned int raster1BandsIdx = 0;
1524 
1525  for( raster1Row = rBInfo.m_firstRasterRow2Process ; raster1Row < rBInfo.m_rasterRows2ProcessBound ;
1526  ++raster1Row )
1527  {
1528  for( raster1Col = rBInfo.m_firstRasterCol2Process ; raster1Col < rBInfo.m_rasterCols2ProcessBound ;
1529  ++raster1Col )
1530  {
1531  blender.getBlendedValues( (double)raster1Row, (double)raster1Col,
1532  blendedValuesHandlerPtr );
1533 
1534  for( raster1BandsIdx = 0 ; raster1BandsIdx < raster1BandsSize ; ++raster1BandsIdx )
1535  {
1536  double& blendedValue = blendedValuesHandlerPtr[ raster1BandsIdx ];
1537 
1538  if( blendedValue != noDataValue )
1539  {
1540  blendedValue = std::max( blendedValue ,
1541  raster1BandsRangeMin[ raster1BandsIdx ] );
1542  blendedValue = std::min( blendedValue ,
1543  raster1BandsRangeMax[ raster1BandsIdx ] );
1544 
1545  raster1.setValue( raster1Col, raster1Row, blendedValue,
1546  raster1Bands[ raster1BandsIdx ] );
1547  }
1548  }
1549  }
1550  }
1551 
1552  // progress stuff
1553 
1554  if( paramsPtr->m_useProgress )
1555  {
1556  if( progressPtr->isActive() )
1557  {
1558  progressPtr->pulse();
1559  }
1560  else
1561  {
1562  paramsPtr->m_mutexPtr->lock();
1563  *(paramsPtr->m_abortValuePtr) = true;
1564  *(paramsPtr->m_returnValuePtr) = false;
1565  --( *(paramsPtr->m_runningThreadsCounterPtr) );
1566  paramsPtr->m_mutexPtr->unlock();
1567  return;
1568  }
1569  }
1570  else
1571  {
1572  // notifying the main thread with the block processed signal
1573 
1574  boost::lock_guard<boost::mutex> blockProcessedSignalLockGuard(
1575  *( paramsPtr->m_blockProcessedSignalMutexPtr) );
1576 
1577  paramsPtr->m_blockProcessedSignalPtr->notify_one();
1578  }
1579  }
1580 
1581  // do we must continue processing ?
1582 
1583  if( *(paramsPtr->m_abortValuePtr) )
1584  {
1585  break;
1586  }
1587  }
1588 
1589  paramsPtr->m_mutexPtr->lock();
1590  --( *(paramsPtr->m_runningThreadsCounterPtr) );
1591  paramsPtr->m_mutexPtr->unlock();
1592  }
1593 
1594  bool Blender::getSegments( te::gm::Geometry const * const geometryPtr,
1595  std::vector< std::pair< te::gm::Coord2D, te::gm::Coord2D > >& segments ) const
1596  {
1597  if( dynamic_cast< te::gm::LineString const * >( geometryPtr ) )
1598  {
1599  te::gm::LineString const* castGeomPtr =
1600  dynamic_cast< te::gm::LineString const * >( geometryPtr );
1601 
1602  std::size_t nPoints = castGeomPtr->size();
1603  te::gm::Coord2D const* coodsPtr = castGeomPtr->getCoordinates();
1604 
1605  for( std::size_t pIdx = 1 ; pIdx < nPoints ; ++pIdx )
1606  {
1607  segments.push_back( std::pair< te::gm::Coord2D, te::gm::Coord2D >(
1608  coodsPtr[ pIdx - 1 ], coodsPtr[ pIdx ] ) );
1609  }
1610  }
1611  else if( dynamic_cast< te::gm::CurvePolygon const * >( geometryPtr ) )
1612  {
1613  te::gm::CurvePolygon const * castGeomPtr =
1614  dynamic_cast< te::gm::CurvePolygon const * >( geometryPtr );
1615 
1616  std::size_t numGeoms = castGeomPtr->getNumRings();
1617 
1618  for( std::size_t gIdx = 0 ; gIdx < numGeoms ; ++gIdx )
1619  {
1620  if( ! ( getSegments( castGeomPtr->getRingN( gIdx ), segments ) ) )
1621  {
1622  return false;
1623  }
1624  }
1625  }
1626  else if( dynamic_cast< te::gm::GeometryCollection const * >( geometryPtr ) )
1627  {
1628  te::gm::GeometryCollection const * castGeomPtr =
1629  dynamic_cast< te::gm::GeometryCollection const * >( geometryPtr );
1630 
1631  std::size_t numGeoms = castGeomPtr->getNumGeometries();
1632 
1633  for( std::size_t gIdx = 0 ; gIdx < numGeoms ; ++gIdx )
1634  {
1635  if( ! ( getSegments( castGeomPtr->getGeometryN( gIdx ), segments ) ) )
1636  {
1637  return false;
1638  }
1639  }
1640  }
1641 
1642  return true;
1643  }
1644 
1645  bool Blender::getTileIndexers( te::gm::Geometry const * const geometryPtr,
1646  boost::ptr_vector< te::rst::TileIndexer >& tileIndexers ) const
1647  {
1648  if( dynamic_cast< te::gm::Polygon const * >( geometryPtr ) )
1649  {
1650  te::gm::Polygon const * castGeomPtr =
1651  dynamic_cast< te::gm::Polygon const * >( geometryPtr );
1652 
1653  tileIndexers.push_back( new te::rst::TileIndexer( *castGeomPtr, 1.0 ) );
1654  }
1655  else if( dynamic_cast< te::gm::GeometryCollection const * >( geometryPtr ) )
1656  {
1657  te::gm::GeometryCollection const * castGeomPtr =
1658  dynamic_cast< te::gm::GeometryCollection const * >( geometryPtr );
1659 
1660  std::size_t numGeoms = castGeomPtr->getNumGeometries();
1661 
1662  for( std::size_t gIdx = 0 ; gIdx < numGeoms ; ++gIdx )
1663  {
1664  if( ! ( getTileIndexers( castGeomPtr->getGeometryN( gIdx ), tileIndexers ) ) )
1665  {
1666  return false;
1667  }
1668  }
1669  }
1670 
1671  return true;
1672  }
1673 
1674  } // end namespace rp
1675 } // end namespace te
1676 
double m_euclideanDistanceMethodImp_aux1
Definition: Blender.h:267
te::rst::Interpolator::Method m_interpMethod1
The interpolation method to use when reading raster 1 data.
Definition: Blender.h:230
std::vector< std::pair< te::gm::Coord2D, te::gm::Coord2D > > m_r2IntersectionSegmentsPoints
A sub-set of the intersection polygon wich is part of raster 2 valid data polygon ( raster 1 indexed ...
Definition: Blender.h:227
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
Definition: CurvePolygon.h:153
void initState()
Reset the instance to its initial default state.
Definition: Blender.cpp:632
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
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.
Definition: Raster.cpp:233
void add(Curve *ring)
It adds the ring to the curve polygon.
Definition: CurvePolygon.h:267
void push_back(Curve *ring)
It adds the curve to the curve polygon.
Definition: CurvePolygon.h:279
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
Near neighborhood interpolation method.
Definition: Enums.h:95
static void blendIntoRaster1Thread(BlendIntoRaster1ThreadParams *paramsPtr)
Thread entry for the method blendIntoRaster1.
Definition: Blender.cpp:1418
Polygon tile indexing class for optmized geometrical relational tests.
Definition: TileIndexer.h:54
An adapter class to allow concurrent access to raster data by multiple threads.
double y
y-coordinate.
Definition: Coord2D.h:114
unsigned long int m_maxRasterCachedBlocks
The maximum number of raster cache blocks.
Definition: Blender.h:202
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
Definition: Utils.cpp:334
bool * m_abortValuePtr
A pointer to the abort execution value.
Definition: Blender.h:180
std::vector< unsigned int > m_raster2Bands
Input raster 2 band indexes to use.
Definition: Blender.h:236
double m_euclideanDistanceMethodImp_Point2Col
Definition: Blender.h:259
std::vector< RasterBlockInfo > * m_raster1BlocksInfosPtr
blocks to process.
Definition: Blender.h:183
The parameters passed to blendIntoRaster1Thread method.
Definition: Blender.h:175
bool m_useProgress
If enabled each thread will use its own progress interface, if false only a signal will be emitted on...
Definition: Blender.h:203
boost::condition_variable * m_blockProcessedSignalPtr
Signal used to update the main process progress update.
Definition: Blender.h:186
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
Definition: LineString.h:456
double m_euclideanDistanceMethodImp_currDist
Definition: Blender.h:263
double x
x-coordinate.
Definition: Coord2D.h:113
std::vector< double > m_pixelScales1
The values scale to be applied to raster 1 pixel values before the blended value calcule (one element...
Definition: Blender.h:196
Blended pixel value calculation for two overlaped rasters.
Definition: Blender.h:58
double m_sumMethodImp_Point2Col
Definition: Blender.h:275
std::auto_ptr< te::gm::MultiPolygon > m_r2ValidDataDelimiterPtr
A pointer to a geometry (raster 2 world/projected coords) delimiting the raster region with valid dat...
Definition: Blender.h:200
std::vector< double > m_pixelOffsets1
The values offset to be applied to raster 1 pixel values before the blended value calcule (one elemen...
Definition: Blender.h:195
std::vector< double > m_pixelScales2
The values scale to be applied to raster 2 pixel values before the blended value calcule (one element...
Definition: Blender.h:240
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
double m_sumMethodImp_Point2Line
Definition: Blender.h:274
std::complex< double > m_sumMethodImp_cValue2
Definition: Blender.h:277
te::rst::Raster const * m_raster2Ptr
Input raster 2.
Definition: Blender.h:221
double m_outputNoDataValue
The output raster no-data value.
Definition: Blender.h:232
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
Definition: Interpolator.h:55
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
Blended pixel value calculation for two overlaped rasters.
boost::mutex * m_mutexPtr
mutex pointer.
Definition: Blender.h:184
std::vector< double > m_raster2NoDataValues
Raster 2 no-data values (on value per band).
Definition: Blender.h:242
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
#define MIN(a, b)
Macro that returns min between two values.
std::auto_ptr< te::gm::Geometry > m_intersectionPtr
The Intersection geometry ( raster 1 indexed coods).
Definition: Blender.h:224
std::vector< unsigned int > m_raster2Bands
Input raster 2 band indexes to use (this vector has the same size as raster1Bands).
Definition: Blender.h:189
bool * m_returnValuePtr
A pointer to the threadreturn value.
Definition: Blender.h:179
void clear()
Clear all internal allocated resources.
Definition: Blender.cpp:650
unsigned int * m_runningThreadsCounterPtr
a pointer to the running threads counter.
Definition: Blender.h:187
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
An access synchronizer to be used in SynchronizedRaster raster instances.
2D Geometric transformation base class.
te::rst::RasterSynchronizer * m_sync2Ptr
Raster 1 syncronizer pointer.
Definition: Blender.h:182
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
std::size_t m_r1IntersectionSegmentsPointsSize
Size of m_r1IntersectionSegmentsPoints;.
Definition: Blender.h:226
std::complex< double > m_sumMethodImp_cValue1
Definition: Blender.h:276
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
double m_euclideanDistanceMethodImp_dist2
Definition: Blender.h:265
No blending performed.
Definition: Blender.h:66
std::complex< double > m_noBlendMethodImp_cValue
Definition: Blender.h:252
double m_euclideanDistanceMethodImp_dist1
Definition: Blender.h:264
bool m_sumMethodImp_PointInsideIntersection
Definition: Blender.h:280
const te::rst::Band * getBand(std::size_t i) const
Returns the raster i-th band.
Raster block info.
Definition: Blender.h:160
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
Definition: Grid.cpp:307
bool m_enableProgressInterface
Enable progress interface.
Definition: Blender.h:214
bool blendIntoRaster1()
Execute blending of the given input rasters and write the result into raster1.
Definition: Blender.cpp:1060
BlendIntoRaster1ThreadParams & operator=(const BlendIntoRaster1ThreadParams &rhs)
Definition: Blender.cpp:103
void setBlendFunctionPonter(const BlendMethod blendMethod)
Set the value of m_blendFuncPtr following the given blend method.
Definition: Blender.cpp:673
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
Definition: Macros.h:183
bool m_forceRaster1NoDataValue
Use noDataValue as the input raster 1 no-data value (The original rasters no-data values will be igno...
Definition: Blender.h:215
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
std::auto_ptr< te::rst::Interpolator > m_interp2Ptr
Raster 2 interpolator instance pointer.
Definition: Blender.h:234
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
TECOMMONEXPORT unsigned int GetPhysProcNumber()
Returns the number of physical processors.
double m_euclideanDistanceMethodImp_aux2
Definition: Blender.h:268
std::auto_ptr< te::gm::MultiPolygon > m_r1ValidDataDelimiterPtr
A pointer to a geometry (raster 1 world/projected coords) delimiting the raster region with valid dat...
Definition: Blender.h:222
std::vector< double > m_pixelOffsets1
The values offset to be applied to raster 1 pixel values before the blended value calcule (one elemen...
Definition: Blender.h:237
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
Definition: LineString.cpp:353
TECOMMONEXPORT unsigned long int GetUsedVirtualMemory()
Returns the amount of used virtual memory (bytes) for the current process (physical + swapped)...
An abstract class for raster data strucutures.
Definition: Raster.h:71
std::size_t m_r2IntersectionSegmentsPointsSize
Size of m_r2IntersectionSegmentsPoints;.
Definition: Blender.h:228
te::rst::Raster * m_raster1Ptr
Input raster 1.
Definition: Blender.h:220
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
#define TERP_LOG_AND_THROW(message)
Logs a error message and throws.
Definition: Macros.h:138
Pixels will be summed inside the raster overlapped area.
Definition: Blender.h:68
unsigned int m_sumMethodImp_IntersectionTileIndexersIdx
Definition: Blender.h:279
void euclideanDistanceMethodImp(const double &line1, const double &col1, double *const values)
Implementation for EuclideanDistanceMethod.
Definition: Blender.cpp:748
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:428
Invalid blending method.
Definition: Blender.h:65
boost::ptr_vector< te::rst::TileIndexer > m_intersectionTileIndexers
The Intersection geometry tile indexers( raster 1 indexed coods), one indexer for each intersection p...
Definition: Blender.h:243
std::vector< double > m_pixelOffsets2
The values offset to be applied to raster 2 pixel values before the blended value calcule (one elemen...
Definition: Blender.h:239
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::vector< double > m_raster1NoDataValues
Raster 1 no-data values (on value per band).
Definition: Blender.h:241
unsigned int m_rasterCols2ProcessBound
Definition: Blender.h:169
virtual GeometricTransformation * clone() const =0
Creat a clone copy of this instance.
te::rst::RasterSynchronizer * m_sync1Ptr
Raster 1 syncronizer pointer.
Definition: Blender.h:181
void sumMethodImp(const double &line1, const double &col1, double *const values)
Implementation for SumMethod.
Definition: Blender.cpp:949
virtual void directMap(const GTParameters &params, const double &pt1X, const double &pt1Y, double &pt2X, double &pt2Y) const =0
Direct mapping (from pt1 space into pt2 space).
std::vector< double > m_pixelScales1
The values scale to be applied to raster 1 pixel values before the blended value calcule (one element...
Definition: Blender.h:238
bool m_forceRaster2NoDataValue
Use noDataValue as the input raster 2 no-data value (The original rasters no-data values will be igno...
Definition: Blender.h:216
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
CurvePolygon is a planar surface defined by 1 exterior boundary and 0 or more interior boundaries...
Definition: CurvePolygon.h:57
void getBlendedValues(const double &line, const double &col, double *const values)
Blend a pixel value using the current parameters.
Definition: Blender.h:131
A raster band description.
Definition: Band.h:63
double m_noBlendMethodImp_Point2Col
Definition: Blender.h:251
BlendFunctPtr m_blendFuncPtr
The current blend function.
Definition: Blender.h:219
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
std::vector< unsigned int > m_raster1Bands
Input raster 1 band indexes to use.
Definition: Blender.h:235
std::size_t m_euclideanDistanceMethodImp_vecIdx
Definition: Blender.h:266
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
bool initialize(te::rst::Raster &raster1, const std::vector< unsigned int > &raster1Bands, const te::rst::Raster &raster2, const std::vector< unsigned int > &raster2Bands, const BlendMethod &blendMethod, const te::rst::Interpolator::Method &interpMethod1, const te::rst::Interpolator::Method &interpMethod2, const double &noDataValue, const bool forceRaster1NoDataValue, const bool forceRaster2NoDataValue, const std::vector< double > &pixelOffsets1, const std::vector< double > &pixelScales1, const std::vector< double > &pixelOffsets2, const std::vector< double > &pixelScales2, te::gm::MultiPolygon const *const r1ValidDataDelimiterPtr, te::gm::MultiPolygon const *const r2ValidDataDelimiterPtr, const te::gm::GeometricTransformation &geomTransformation, const unsigned int threadsNumber, const bool enableProgressInterface)
Inititate the blender instance.
Definition: Blender.cpp:170
unsigned int m_blkTotalPixelsNumber
Definition: Blender.h:165
bool m_euclideanDistanceMethodImp_PointInsideIntersection
Definition: Blender.h:270
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
bool getSegments(te::gm::Geometry const *const geometryPtr, std::vector< std::pair< te::gm::Coord2D, te::gm::Coord2D > > &segments) const
Extract segments from the given geometry.
Definition: Blender.cpp:1594
bool getTileIndexers(te::gm::Geometry const *const geometryPtr, boost::ptr_vector< te::rst::TileIndexer > &tileIndexers) const
Creater polygon tile indexers from the given geometry.
Definition: Blender.cpp:1645
std::auto_ptr< te::gm::MultiPolygon > m_r1ValidDataDelimiterPtr
A pointer to a geometry (raster 1 world/projected coords) delimiting the raster region with valid dat...
Definition: Blender.h:199
unsigned int m_euclideanDistanceMethodImp_BandIdx
Definition: Blender.h:262
te::dt::AbstractData * clone() const
It clones the multi polygon.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
bool m_forceRaster1NoDataValue
Use noDataValue as the input rasters no-data value (The original rasters no-data values will be ignor...
Definition: Blender.h:193
#define getPerpendicularDistance(pX, pY, lineAX, lineAY, lineBX, lineBY, aux1, aux2, perpDist)
Definition: Blender.cpp:56
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:143
double m_noDataValue
The value returned where there is no pixel data bo blend.
Definition: Blender.h:192
unsigned int m_noBlendMethodImp_BandIdx
Definition: Blender.h:254
te::gm::Point m_sumMethodImp_auxPoint
Definition: Blender.h:273
te::gm::GeometricTransformation * m_geomTransformationPtr
A transformation mapping raster 1 pixels ( te::gm::GTParameters::TiePoint::first ) to raster 2 ( te::...
Definition: Blender.h:229
unsigned int m_rasterRows2ProcessBound
Definition: Blender.h:167
Euclidean distance method.
Definition: Blender.h:67
te::rst::Interpolator::Method m_interpMethod2
The interpolation method to use when reading raster 2 data.
Definition: Blender.h:231
virtual bool isValid(const GTParameters &params) const =0
Verifies if the supplied parameters already has a valid transformation.
std::auto_ptr< te::rst::Interpolator > m_interp1Ptr
Raster 1 interpolator instance pointer.
Definition: Blender.h:233
double m_noBlendMethodImp_Point2Line
Definition: Blender.h:250
boost::mutex * m_blockProcessedSignalMutexPtr
Mutex used to update the main process progress update.
Definition: Blender.h:185
bool m_forceRaster2NoDataValue
Use noDataValue as the input rasters no-data value (The original rasters no-data values will be ignor...
Definition: Blender.h:194
double m_noBlendMethodImp_Value
Definition: Blender.h:253
BlendMethod m_blendMethod
The blend method to apply.
Definition: Blender.h:190
unsigned int m_sumMethodImp_BandIdx
Definition: Blender.h:278
std::vector< double > m_pixelOffsets2
The values offset to be applied to raster 2 pixel values before the blended value calcule (one elemen...
Definition: Blender.h:197
TECOMMONEXPORT unsigned long int GetTotalPhysicalMemory()
Returns the amount of total physical memory (bytes).
std::auto_ptr< te::gm::MultiPolygon > m_r2ValidDataDelimiterPtr
A pointer to a geometry (raster 2 world/projected coords) delimiting the raster region with valid dat...
Definition: Blender.h:223
unsigned int m_threadsNumber
The number of threads to use (0:automatic , 1:disabled, any other integer dictates the number of thre...
Definition: Blender.h:217
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:157
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
unsigned int m_firstRasterRow2Process
Definition: Blender.h:166
std::complex< double > m_euclideanDistanceMethodImp_cValue1
Definition: Blender.h:260
unsigned int m_euclideanDistanceMethodImp_IntersectionTileIndexersIdx
Definition: Blender.h:269
double m_euclideanDistanceMethodImp_Point2Line
Definition: Blender.h:258
#define TERP_DEBUG_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:356
It is a collection of other geometric objects.
A rectified grid is the spatial support for raster data.
Definition: Grid.h:68
BlendMethod m_blendMethod
The blend method to apply.
Definition: Blender.h:218
std::vector< unsigned int > m_raster1Bands
Input raster 1 band indexes to use.
Definition: Blender.h:188
void noBlendMethodImp(const double &line1, const double &col1, double *const values)
Implementation for NoBlendMethod.
Definition: Blender.cpp:700
std::auto_ptr< te::gm::GeometricTransformation > m_geomTransformationPtr
A transformation mapping raster 1 pixels ( te::gm::GTParameters::TiePoint::first ) to raster 2 pixels...
Definition: Blender.h:201
virtual int getBlockSize() const
It returns the number of bytes ocuppied by a data block.
Definition: Band.cpp:630
te::gm::Point m_euclideanDistanceMethodImp_auxPoint
Definition: Blender.h:257
virtual void inverseMap(const GTParameters &params, const double &pt2X, const double &pt2Y, double &pt1X, double &pt1Y) const =0
Inverse mapping (from pt2 space into pt1 space).
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:149
std::complex< double > m_euclideanDistanceMethodImp_cValue2
Definition: Blender.h:261
std::vector< double > m_pixelScales2
The values scale to be applied to raster 2 pixel values before the blended value calcule (one element...
Definition: Blender.h:198
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
Definition: CurvePolygon.h:193
te::rst::Interpolator::Method m_interpMethod2
The interpolation method to use when reading raster 2 data.
Definition: Blender.h:191
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
Definition: LineString.h:262
std::vector< std::pair< te::gm::Coord2D, te::gm::Coord2D > > m_r1IntersectionSegmentsPoints
A sub-set of the intersection polygon wich is part of raster 1 valid data polygon ( raster 1 indexed ...
Definition: Blender.h:225
TECOMMONEXPORT unsigned long int GetTotalVirtualMemory()
Returns the amount of total virtual memory (bytes) that can be claimed by the current process (physic...
unsigned int m_firstRasterCol2Process
Definition: Blender.h:168