All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoMosaic.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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/GeoMosaic.cpp
22  \brief Create a mosaic from a set of geo-referenced rasters.
23 */
24 
25 #include "GeoMosaic.h"
26 
27 #include "Macros.h"
28 #include "../raster/Interpolator.h"
29 #include "../raster/Enums.h"
30 #include "../raster/RasterFactory.h"
31 #include "../raster/Grid.h"
32 #include "../raster/Band.h"
33 #include "../raster/BandProperty.h"
34 #include "../raster/PositionIterator.h"
35 #include "../raster/Utils.h"
36 #include "../memory/CachedRaster.h"
37 #include "../geometry/Envelope.h"
38 #include "../geometry/GTFactory.h"
39 #include "../geometry/Polygon.h"
40 #include "../geometry/LinearRing.h"
41 #include "../geometry/MultiPolygon.h"
42 #include "../srs/Converter.h"
43 
44 #include <climits>
45 #include <cfloat>
46 #include <cmath>
47 #include <memory>
48 #include <cstdio>
49 
50 namespace te
51 {
52  namespace rp
53  {
54 
56  {
57  reset();
58  }
59 
61  {
62  reset();
63  operator=( other );
64  }
65 
67  {
68  reset();
69  }
70 
71  void GeoMosaic::InputParameters::reset() throw( te::rp::Exception )
72  {
73  m_feederRasterPtr = 0;
74  m_inputRastersBands.clear();
76  m_noDataValue = 0.0;
77  m_forceInputNoDataValue = false;
78  m_blendMethod = te::rp::Blender::NoBlendMethod;
79  m_autoEqualize = true;
80  m_useRasterCache = true;
81  }
82 
84  const GeoMosaic::InputParameters& params )
85  {
86  reset();
87 
88  m_feederRasterPtr = params.m_feederRasterPtr;
89  m_inputRastersBands = params.m_inputRastersBands;
90  m_interpMethod = params.m_interpMethod;
91  m_noDataValue = params.m_noDataValue;
92  m_forceInputNoDataValue = params.m_forceInputNoDataValue;
93  m_blendMethod = params.m_blendMethod;
94  m_autoEqualize = params.m_autoEqualize;
95  m_useRasterCache = params.m_useRasterCache;
96 
97  return *this;
98  }
99 
101  {
102  return new InputParameters( *this );
103  }
104 
106  {
107  reset();
108  }
109 
111  {
112  reset();
113  operator=( other );
114  }
115 
117  {
118  reset();
119  }
120 
121  void GeoMosaic::OutputParameters::reset() throw( te::rp::Exception )
122  {
123  m_rType.clear();
124  m_rInfo.clear();
125  m_outputRasterPtr.reset();
126  }
127 
129  const GeoMosaic::OutputParameters& params )
130  {
131  reset();
132 
133  m_rType = params.m_rType;
134  m_rInfo = params.m_rInfo;
135  m_outputRasterPtr.reset();;
136 
137  return *this;
138  }
139 
141  {
142  return new OutputParameters( *this );
143  }
144 
146  {
147  reset();
148  }
149 
151  {
152  }
153 
155  throw( te::rp::Exception )
156  {
157  if( ! m_isInitialized ) return false;
158 
159  GeoMosaic::OutputParameters* outParamsPtr = dynamic_cast<
160  GeoMosaic::OutputParameters* >( &outputParams );
161  TERP_TRUE_OR_THROW( outParamsPtr, "Invalid paramters" );
162 
164 
165  // First pass: getting global mosaic info
166 
167  double mosaicXResolution = 0.0;
168  double mosaicYResolution = 0.0;
169  double mosaicLLX = DBL_MAX; // world coords
170  double mosaicLLY = DBL_MAX; // world coords
171  double mosaicURX = -1.0 * DBL_MAX; // world coords
172  double mosaicURY = -1.0 * DBL_MAX; // world coords
173  int mosaicSRID = 0;
174  std::vector< double > mosaicBandsRangeMin;
175  std::vector< double > mosaicBandsRangeMax;
176  te::rst::BandProperty mosaicBaseBandProperties( 0, 0, "" );
177  std::vector< te::gm::Polygon > rastersBBoxes; // all rasters bounding boxes (under the first raster world coords.
178 
179  {
180  te::gm::Polygon auxPolygon( 0, te::gm::PolygonType, 0 );
181  te::gm::LinearRing* auxLinearRingPtr = 0;
182  te::rst::Raster const* inputRasterPtr = 0;
183  unsigned int inputRasterIdx = 0;
184  te::srs::Converter convInstance;
185  te::gm::Coord2D llCoord1;
186  te::gm::Coord2D urCoord1;
187  te::gm::Coord2D llCoord2;
188  te::gm::Coord2D urCoord2;
189 
191  while( ( inputRasterPtr = m_inputParameters.m_feederRasterPtr->getCurrentObj() ) )
192  {
195  inputRasterPtr->getAccessPolicy() & te::common::RAccess,
196  "Invalid raster" );
197 
198  // Defining the base mosaic info
199 
200  if( inputRasterIdx == 0 )
201  {
202  mosaicXResolution = inputRasterPtr->getGrid()->getResolutionX();
203  mosaicYResolution = inputRasterPtr->getGrid()->getResolutionY();
204 
205  mosaicLLX = inputRasterPtr->getGrid()->getExtent()->m_llx;
206  mosaicLLY = inputRasterPtr->getGrid()->getExtent()->m_lly;
207  mosaicURX = inputRasterPtr->getGrid()->getExtent()->m_urx;
208  mosaicURY = inputRasterPtr->getGrid()->getExtent()->m_ury;
209 
210  mosaicSRID = inputRasterPtr->getGrid()->getSRID();
211 
212  mosaicBaseBandProperties = *inputRasterPtr->getBand( 0 )->getProperty();
213 
214  // finding the current raster bounding box polygon (first raster world coordinates)
215  auxPolygon.clear();
216  auxLinearRingPtr = new te::gm::LinearRing(5, te::gm::LineStringType);
217  auxLinearRingPtr->setPoint( 0, mosaicLLX, mosaicURY );
218  auxLinearRingPtr->setPoint( 1, mosaicURX, mosaicURY );
219  auxLinearRingPtr->setPoint( 2, mosaicURX, mosaicLLY );
220  auxLinearRingPtr->setPoint( 3, mosaicLLX, mosaicLLY );
221  auxLinearRingPtr->setPoint( 4, mosaicLLX, mosaicURY );
222  auxPolygon.push_back( auxLinearRingPtr );
223  auxPolygon.setSRID( mosaicSRID );
224  rastersBBoxes.push_back( auxPolygon );
225  }
226  else
227  {
228  if( mosaicSRID == inputRasterPtr->getGrid()->getSRID() )
229  {
230  urCoord1.x = inputRasterPtr->getGrid()->getExtent()->m_urx;
231  urCoord1.y = inputRasterPtr->getGrid()->getExtent()->m_ury;
232  llCoord1.x = inputRasterPtr->getGrid()->getExtent()->m_llx;
233  llCoord1.y = inputRasterPtr->getGrid()->getExtent()->m_lly;
234  }
235  else
236  {
237  convInstance.setSourceSRID( inputRasterPtr->getGrid()->getSRID() );
238  convInstance.setTargetSRID( mosaicSRID );
239 
240  convInstance.convert(
241  inputRasterPtr->getGrid()->getExtent()->m_urx,
242  inputRasterPtr->getGrid()->getExtent()->m_ury,
243  urCoord1.x,
244  urCoord1.y );
245  convInstance.convert(
246  inputRasterPtr->getGrid()->getExtent()->m_llx,
247  inputRasterPtr->getGrid()->getExtent()->m_lly,
248  llCoord1.x,
249  llCoord1.y );
250  }
251 
252  // expanding mosaic area
253 
254  mosaicLLX = std::min( mosaicLLX, urCoord1.x );
255  mosaicLLX = std::min( mosaicLLX, llCoord1.x );
256 
257  mosaicLLY = std::min( mosaicLLY, urCoord1.y );
258  mosaicLLY = std::min( mosaicLLY, llCoord1.y );
259 
260  mosaicURX = std::max( mosaicURX, urCoord1.x );
261  mosaicURX = std::max( mosaicURX, llCoord1.x );
262 
263  mosaicURY = std::max( mosaicURY, urCoord1.y );
264  mosaicURY = std::max( mosaicURY, llCoord1.y );
265 
266  // finding the current raster bounding box polygon (first raster world coordinates)
267 
268  auxPolygon.clear();
269  auxLinearRingPtr = new te::gm::LinearRing(5, te::gm::LineStringType);
270  auxLinearRingPtr->setPoint( 0, llCoord1.x, urCoord1.y );
271  auxLinearRingPtr->setPoint( 1, urCoord1.x, urCoord1.y );
272  auxLinearRingPtr->setPoint( 2, urCoord1.x, llCoord1.y );
273  auxLinearRingPtr->setPoint( 3, llCoord1.x, llCoord1.y );
274  auxLinearRingPtr->setPoint( 4, llCoord1.x, urCoord1.y );
275  auxPolygon.push_back( auxLinearRingPtr );
276  auxPolygon.setSRID( mosaicSRID );
277  rastersBBoxes.push_back( auxPolygon );
278  }
279 
280  // checking the input bands
281 
282  for( std::vector< unsigned int >::size_type inputRastersBandsIdx = 0 ;
283  inputRastersBandsIdx <
284  m_inputParameters.m_inputRastersBands[ inputRasterIdx ].size() ;
285  ++inputRastersBandsIdx )
286  {
287  const unsigned int& currBand =
288  m_inputParameters.m_inputRastersBands[ inputRasterIdx ][ inputRastersBandsIdx ];
289 
290  TERP_TRUE_OR_RETURN_FALSE( currBand < inputRasterPtr->getNumberOfBands(),
291  "Invalid band" )
292  }
293 
294 
296  }
297  }
298 
299  // creating the output raster
300 
301  te::rst::Raster* outputRasterPtr = 0;
302 
303  {
304  mosaicBandsRangeMin.resize(
305  m_inputParameters.m_inputRastersBands[ 0 ].size(), 0 );
306  mosaicBandsRangeMax.resize(
307  m_inputParameters.m_inputRastersBands[ 0 ].size(), 0 );
308 
309  std::vector< te::rst::BandProperty* > bandsProperties;
310  for( std::vector< unsigned int >::size_type bandIdx = 0 ; bandIdx <
311  m_inputParameters.m_inputRastersBands[ 0 ].size() ; ++bandIdx )
312  {
313  bandsProperties.push_back( new te::rst::BandProperty( mosaicBaseBandProperties ) );
314  bandsProperties[ bandIdx ]->m_colorInterp = te::rst::GrayIdxCInt;
315  bandsProperties[ bandIdx ]->m_noDataValue = m_inputParameters.m_noDataValue;
316 
317  te::rst::GetDataTypeRanges( bandsProperties[ bandIdx ]->m_type,
318  mosaicBandsRangeMin[ bandIdx ],
319  mosaicBandsRangeMax[ bandIdx ]);
320  }
321 
322  te::rst::Grid* outputGrid = new te::rst::Grid( mosaicXResolution,
323  mosaicYResolution, new te::gm::Envelope( mosaicLLX, mosaicLLY, mosaicURX,
324  mosaicURY ), mosaicSRID );
325 
326  outParamsPtr->m_outputRasterPtr.reset(
328  outParamsPtr->m_rType,
329  outputGrid,
330  bandsProperties,
331  outParamsPtr->m_rInfo,
332  0,
333  0 ) );
334  TERP_TRUE_OR_RETURN_FALSE( outParamsPtr->m_outputRasterPtr.get(),
335  "Output raster creation error" );
336 
337  outputRasterPtr = outParamsPtr->m_outputRasterPtr.get();
338  }
339 
340  std::auto_ptr< te::mem::CachedRaster > cachedRasterInstancePtr;
341 
343  {
344  cachedRasterInstancePtr.reset( new te::mem::CachedRaster(
345  *(outParamsPtr->m_outputRasterPtr.get()), 25, 0 ) );
346 
347  outputRasterPtr = cachedRasterInstancePtr.get();
348  }
349 
350  te::rst::Raster& outputRaster = *outputRasterPtr;
351 
352  // fill output with no data values
353 
354  {
355  const unsigned int nBands = outputRasterPtr->getNumberOfBands();
356  const unsigned int nRows = outputRasterPtr->getNumberOfRows();
357  const unsigned int nCols = outputRasterPtr->getNumberOfColumns();
358  unsigned int col = 0;
359  unsigned int row = 0;
360  unsigned int bandIdx = 0;
361 
362  for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
363  {
364  te::rst::Band& outBand = ( *( outputRasterPtr->getBand( bandIdx ) ) );
365 
366  for( row = 0 ; row < nRows ; ++row )
367  {
368  for( col = 0 ; col < nCols ; ++col )
369  {
370  outBand.setValue( col, row, m_inputParameters.m_noDataValue );
371  }
372  }
373  }
374  }
375 
376  // Copying the first image data to the output mosaic
377  // and find the base mosaic mean and offset values
378 
379  std::vector< double > mosaicTargetMeans( outputRasterPtr->getNumberOfBands(), 0 );
380  std::vector< double > mosaicTargetVariances( outputRasterPtr->getNumberOfBands(), 0 );
381 
382  {
384 
385  te::rst::Raster const* inputRasterPtr =
387  TERP_DEBUG_TRUE_OR_RETURN_FALSE( inputRasterPtr, "Invalid raster pointer" );
388 
389  double inXStartGeo = 0;
390  double inYStartGeo = 0;
391  inputRasterPtr->getGrid()->gridToGeo( 0.0, 0.0, inXStartGeo, inYStartGeo );
392  double outRowStartDouble = 0;
393  double outColStartDouble = 0;
394  outputRasterPtr->getGrid()->geoToGrid( inXStartGeo, inYStartGeo,
395  outColStartDouble, outRowStartDouble );
396 
397  const unsigned int outRowStart = (unsigned int)std::max( 0.0, outRowStartDouble );
398  const unsigned int outColStart = (unsigned int)std::max( 0.0, outColStartDouble );
399  const unsigned int outRowsBound = std::min( outRowStart +
400  inputRasterPtr->getNumberOfRows(),
401  outputRasterPtr->getNumberOfRows() );
402  const unsigned int outColsBound = std::min( outColStart +
403  inputRasterPtr->getNumberOfColumns(),
404  outputRasterPtr->getNumberOfColumns() );
405 
406  const unsigned int nBands = (unsigned int)
408  unsigned int outCol = 0;
409  unsigned int outRow = 0;
410  double inCol = 0;
411  double inRow = 0;
412  double bandNoDataValue = -1.0 * DBL_MAX;
413  std::complex< double > pixelCValue = 0;
414  te::rst::Interpolator interpInstance( inputRasterPtr,
416  unsigned int inputBandIdx = 0;
417 
418  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
419  nBands ; ++inputRastersBandsIdx )
420  {
421  inputBandIdx = m_inputParameters.m_inputRastersBands[ 0 ][
422  inputRastersBandsIdx ] ;
423  bandNoDataValue = m_inputParameters.m_forceInputNoDataValue ?
424  m_inputParameters.m_noDataValue : inputRasterPtr->getBand( inputBandIdx
426  te::rst::Band& outBand =
427  (*outputRasterPtr->getBand( inputRastersBandsIdx ));
428  unsigned int validPixelsNumber = 0;
429 
430  double& mean = mosaicTargetMeans[ inputRastersBandsIdx ];
431  mean = 0;
432 
433  for( outRow = outRowStart ; outRow < outRowsBound ; ++outRow )
434  {
435  inRow = ((double)outRow) - outRowStartDouble;
436 
437  for( outCol = outColStart ; outCol < outColsBound ; ++outCol )
438  {
439  inCol = ((double)outCol) - outColStartDouble;
440 
441  interpInstance.getValue( inCol, inRow, pixelCValue, inputBandIdx );
442 
443  if( pixelCValue.real() != bandNoDataValue )
444  {
445  outBand.setValue( outCol, outRow, pixelCValue );
446  mean += pixelCValue.real();
447  ++validPixelsNumber;
448  }
449  }
450  }
451 
452  mean /= ( (double)validPixelsNumber );
453 
454  // variance calcule
455 
457  {
458  double& variance = mosaicTargetVariances[ inputRastersBandsIdx ];
459  variance = 0;
460 
461  double pixelValue = 0;
462 
463  for( outRow = outRowStart ; outRow < outRowsBound ; ++outRow )
464  {
465  for( outCol = outColStart ; outCol < outColsBound ; ++outCol )
466  {
467  outBand.getValue( outCol, outRow, pixelValue );
468 
469  if( pixelValue != m_inputParameters.m_noDataValue )
470  {
471  variance += ( ( pixelValue - mean ) * ( pixelValue -
472  mean ) ) / ( (double)validPixelsNumber );
473  }
474  }
475  }
476  }
477  }
478  }
479 
480  TERP_DEBUG_TRUE_OR_THROW( rastersBBoxes.size() ==
482  "Rasters bounding boxes number mismatch" );
483 
484  // Initiating the mosaic bounding boxes union
485 
486  std::auto_ptr< te::gm::MultiPolygon > mosaicBBoxesUnionPtr(
488  outputRaster.getSRID(), 0 ) );
489  mosaicBBoxesUnionPtr->add( (te::gm::Polygon*)rastersBBoxes[ 0 ].clone() );
490 
491  // skipping the first raster
492 
495 
496  // iterating over the other rasters
497 
498  te::rst::Raster const* originalInputRasterPtr = 0;
499 
500  std::vector< unsigned int > outputRasterBands;
501  std::vector< double > dummyRasterOffsets;
502  std::vector< double > dummyRasterScales;
503  for( unsigned int outputRasterBandsIdx = 0 ; outputRasterBandsIdx <
504  outputRaster.getNumberOfBands() ; ++outputRasterBandsIdx )
505  {
506  outputRasterBands.push_back( outputRasterBandsIdx );
507  dummyRasterOffsets.push_back( 0.0 );
508  dummyRasterScales.push_back( 1.0 );
509  }
510 
511  while( ( originalInputRasterPtr = m_inputParameters.m_feederRasterPtr->getCurrentObj() ) )
512  {
513  const unsigned int inputRasterIdx = m_inputParameters.m_feederRasterPtr->getCurrentOffset();
514 
515  TERP_DEBUG_TRUE_OR_THROW( rastersBBoxes[ inputRasterIdx ].getSRID() == outputRaster.getSRID(),
516  "Invalid boxes SRID" );
517 
518  te::rst::Raster const* inputRasterPtr = originalInputRasterPtr;
519 
520  // reprojection issues
521 
522  std::auto_ptr< te::rst::Raster > reprojectedInputRasterPtr;
523  std::string reprojectedRasterFileName;
524 
525  if( outputRaster.getSRID() != inputRasterPtr->getSRID() )
526  {
527  char fileNameBuffer[L_tmpnam];
528  tmpnam(fileNameBuffer);
529 
530  reprojectedRasterFileName = fileNameBuffer;
531  reprojectedRasterFileName += ".tif";
532 
533  std::map< std::string, std::string > rInfo;
534  rInfo[ "URI" ] = reprojectedRasterFileName;
535 
536  reprojectedInputRasterPtr.reset( inputRasterPtr->transform(
537  outputRaster.getSRID(), rInfo,
539  inputRasterPtr = reprojectedInputRasterPtr.get();
540  TERP_TRUE_OR_RETURN_FALSE( inputRasterPtr, "Reprojection error" );
541  }
542 
543  // Caching issues
544 
545  std::auto_ptr< te::mem::CachedRaster > cachedInputRasterPtr;
547  {
548  cachedInputRasterPtr.reset( new te::mem::CachedRaster(
549  *inputRasterPtr, 25, 0 ) );
550  inputRasterPtr = cachedInputRasterPtr.get();
551  }
552 
553  // The transformation mapping outputRaster pixels
554  // ( te::gm::GTParameters::TiePoint::first ) to input pixels
555  // ( te::gm::GTParameters::TiePoint::second )
556  // (Note: all coords are indexed by lines/columns).
557 
558  std::auto_ptr< te::gm::GeometricTransformation > transPtr;
559 
560  {
561  te::gm::GTParameters transParams;
562  double auxX;
563  double auxY;
565 
566  auxTP.first.x = 0;
567  auxTP.first.y = 0;
568  outputRaster.getGrid()->gridToGeo( auxTP.first.x, auxTP.first.y, auxX, auxY );
569  inputRasterPtr->getGrid()->geoToGrid( auxX, auxY, auxTP.second.x, auxTP.second.y );
570  transParams.m_tiePoints.push_back( auxTP );
571 
572  auxTP.first.x = 0;
573  auxTP.first.y = (double)outputRaster.getNumberOfRows();
574  outputRaster.getGrid()->gridToGeo( auxTP.first.x, auxTP.first.y, auxX, auxY );
575  inputRasterPtr->getGrid()->geoToGrid( auxX, auxY, auxTP.second.x, auxTP.second.y );
576  transParams.m_tiePoints.push_back( auxTP );
577 
578  auxTP.first.x = (double)outputRaster.getNumberOfColumns();
579  auxTP.first.y = 0;
580  outputRaster.getGrid()->gridToGeo( auxTP.first.x, auxTP.first.y, auxX, auxY );
581  inputRasterPtr->getGrid()->geoToGrid( auxX, auxY, auxTP.second.x, auxTP.second.y );
582  transParams.m_tiePoints.push_back( auxTP );
583 
584  auxTP.first.x = (double)outputRaster.getNumberOfColumns();
585  auxTP.first.y = (double)outputRaster.getNumberOfRows();
586  outputRaster.getGrid()->gridToGeo( auxTP.first.x, auxTP.first.y, auxX, auxY );
587  inputRasterPtr->getGrid()->geoToGrid( auxX, auxY, auxTP.second.x, auxTP.second.y );
588  transParams.m_tiePoints.push_back( auxTP );
589 
590  transPtr.reset( te::gm::GTFactory::make( "RST" ) );
591  TERP_TRUE_OR_RETURN_FALSE( transPtr.get(), "Could not instantiate a geometric transformation" );
592 
593  TERP_TRUE_OR_RETURN_FALSE( transPtr->initialize( transParams ),
594  "Could not initialize a geometric transformation" );
595  }
596 
597  // Generating the offset and gain info for eath band from the current raster
598 
599  std::vector< double > currentRasterBandsOffsets;
600  std::vector< double > currentRasterBandsScales;
601 
603  {
604  double currentRasterVariance = 0;
605  double currentRasterMean = 0;
606 
607  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
608  m_inputParameters.m_inputRastersBands[ inputRasterIdx ].size() ;
609  ++inputRastersBandsIdx )
610  {
611  const unsigned int inputBandIdx = m_inputParameters.m_inputRastersBands[ inputRasterIdx ][
612  inputRastersBandsIdx ];
613 
614  calcBandStatistics( (*inputRasterPtr->getBand( inputBandIdx ) ),
617  currentRasterMean,
618  currentRasterVariance );
619 
620  currentRasterBandsScales.push_back( std::sqrt( mosaicTargetVariances[ inputRastersBandsIdx ] /
621  currentRasterVariance ) );
622  currentRasterBandsOffsets.push_back( mosaicTargetMeans[ inputRastersBandsIdx ] -
623  ( currentRasterBandsScales[ inputRastersBandsIdx ] * currentRasterMean ) );
624  }
625  }
626  else
627  {
628  currentRasterBandsOffsets = dummyRasterOffsets;
629  currentRasterBandsScales = dummyRasterScales;
630  }
631 
632  // Processing each one of the mosaic boxes union components
633  // blending each overlapped area
634 
635  for( std::size_t mosaicBBoxesUnionIdx = 0 ; mosaicBBoxesUnionIdx <
636  mosaicBBoxesUnionPtr->getNumGeometries() ; ++mosaicBBoxesUnionIdx )
637  {
638  te::gm::Polygon const* mosaicBBoxesUnionElementPtr =
639  dynamic_cast< te::gm::Polygon const*>(
640  mosaicBBoxesUnionPtr->getGeometryN( mosaicBBoxesUnionIdx ) );
641  TERP_DEBUG_TRUE_OR_THROW( mosaicBBoxesUnionElementPtr,
642  "Invalid pointer" );
643 
644  // calculating the overlapped image areas
645 
646  std::auto_ptr< te::gm::MultiPolygon > overlappedResult; // under the mosaic SRID
647 
648  {
649  std::auto_ptr< te::gm::Geometry > auxResultPtr(
650  rastersBBoxes[ inputRasterIdx ].intersection( mosaicBBoxesUnionElementPtr ) );
651 
652  if( auxResultPtr.get() )
653  {
654  auxResultPtr->setSRID( mosaicBBoxesUnionElementPtr->getSRID() );
655 
656  if( auxResultPtr->getGeomTypeId() == te::gm::MultiPolygonType )
657  {
658  overlappedResult.reset( (te::gm::MultiPolygon*)auxResultPtr.release() );
659  }
660  else if( auxResultPtr->getGeomTypeId() == te::gm::PolygonType )
661  {
662  // transforming it into a te::gm::MultiPolygon
663  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
664  te::gm::MultiPolygonType, auxResultPtr->getSRID(), 0 );
665  auxMultiPol->add( auxResultPtr.release() );
666  overlappedResult.reset( auxMultiPol );
667  }
668  }
669  }
670 
671  // the overlapped result under the current raster SRID
672 
673  std::auto_ptr< te::gm::MultiPolygon > overlappedResultUnderCurrentSRID;
674 
675  if( overlappedResult.get() )
676  {
677  overlappedResultUnderCurrentSRID.reset( (te::gm::MultiPolygon*)
678  overlappedResult->clone() );
679  }
680 
681  // blending
682 
683  if( overlappedResult.get() )
684  {
685  te::rp::Blender blenderInstance;
686 
687  TERP_TRUE_OR_RETURN_FALSE( blenderInstance.initialize(
688  outputRaster,
689  outputRasterBands,
690  *inputRasterPtr,
691  m_inputParameters.m_inputRastersBands[ inputRasterIdx ],
697  dummyRasterOffsets,
698  dummyRasterScales,
699  currentRasterBandsOffsets,
700  currentRasterBandsScales,
701  mosaicBBoxesUnionElementPtr,
702  0,
703  *transPtr ), "Blender initiazing error" );
704 
705  for( unsigned int overlappedResultIdx = 0 ; overlappedResultIdx <
706  overlappedResult->getNumGeometries() ; ++overlappedResultIdx )
707  {
708  te::gm::Polygon const* overlappedResultElementPtr =
709  dynamic_cast< te::gm::Polygon const* >(
710  overlappedResult->getGeometryN( overlappedResultIdx ) );
711  TERP_DEBUG_TRUE_OR_THROW( overlappedResultElementPtr,
712  "Invalid pointer" );
713 
714  te::gm::Polygon const* overlappedResultUnderCurrentSRIDElementPtr =
715  dynamic_cast< te::gm::Polygon const* >(
716  overlappedResultUnderCurrentSRID->getGeometryN( overlappedResultIdx ) );
717  TERP_DEBUG_TRUE_OR_THROW(overlappedResultUnderCurrentSRIDElementPtr,
718  "Invalid pointer" );
719 
721  outputRasterPtr,
722  (te::gm::Polygon const*)overlappedResult->getGeometryN( overlappedResultIdx ) );
724  outputRasterPtr,
725  (te::gm::Polygon const*)overlappedResult->getGeometryN( overlappedResultIdx ) );
726 
727  std::vector< double > blendedValues( outputRasterPtr->getNumberOfBands() );
728  unsigned int outputRow = 0;
729  unsigned int outputCol = 0;
730  const unsigned int nBands = outputRasterPtr->getNumberOfBands();
731  unsigned int outBandIdx = 0;
732  te::rst::Raster& outputRaster = *outputRasterPtr;
733 
734  while( itB != itE )
735  {
736  outputRow = itB.getRow();
737  outputCol = itB.getColumn();
738 
739  blenderInstance.getBlendedValues( outputRow, outputCol, blendedValues );
740 
741  for( outBandIdx = 0 ; outBandIdx < nBands ; ++outBandIdx )
742  {
743  double& blendedValue = blendedValues[ outBandIdx ];
744 
745  if( blendedValue != m_inputParameters.m_noDataValue )
746  {
747  blendedValue = std::max( blendedValue ,
748  mosaicBandsRangeMin[ outBandIdx ] );
749  blendedValue = std::min( blendedValue ,
750  mosaicBandsRangeMax[ outBandIdx ] );
751 
752  outputRaster.setValue( outputCol, outputRow, blendedValue, outBandIdx );
753  }
754  }
755 
756  ++itB;
757  }
758  }
759  }
760  }
761 
762  // calculating the non-overlapped image area
763 
764  std::auto_ptr< te::gm::MultiPolygon > nonOverlappedResult; // under the mosaic SRID
765 
766  {
767  std::auto_ptr< te::gm::Geometry > auxResultPtr(
768  rastersBBoxes[ inputRasterIdx ].difference( mosaicBBoxesUnionPtr.get() ) );
769 
770  if( auxResultPtr.get() )
771  {
772  auxResultPtr->setSRID( mosaicBBoxesUnionPtr->getSRID() );
773 
774  if( auxResultPtr->getGeomTypeId() == te::gm::MultiPolygonType )
775  {
776  nonOverlappedResult.reset( (te::gm::MultiPolygon*)auxResultPtr.release() );
777  }
778  else if( auxResultPtr->getGeomTypeId() == te::gm::PolygonType )
779  {
780  // transforming it into a te::gm::MultiPolygon
781  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
782  te::gm::MultiPolygonType, auxResultPtr->getSRID(), 0 );
783  auxMultiPol->add( auxResultPtr.release() );
784  nonOverlappedResult.reset( auxMultiPol );
785  }
786  }
787  else
788  {
789  // Creating a multipolygon with the current raster bounding box
790 
791  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
792  te::gm::MultiPolygonType, rastersBBoxes[ inputRasterIdx ].getSRID(), 0 );
793  auxMultiPol->add( (te::gm::Polygon*) rastersBBoxes[ inputRasterIdx ].clone() );
794  nonOverlappedResult.reset( auxMultiPol );
795  }
796  }
797 
798  // copying each non overlaped image area
799 
800  if( nonOverlappedResult.get() )
801  {
802  te::rst::Interpolator interpInstance( inputRasterPtr,
804 
805  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
806  m_inputParameters.m_inputRastersBands[ inputRasterIdx ].size() ;
807  ++inputRastersBandsIdx )
808  {
809  const unsigned int inputBandIdx = m_inputParameters.m_inputRastersBands[ inputRasterIdx ][
810  inputRastersBandsIdx ];
811  te::rst::Band& outputBand = (*outputRaster.getBand( inputRastersBandsIdx ));
812 
813  double outputBandRangeMin = 0;
814  double outputBandRangeMax = 0;
816  outputBandRangeMin, outputBandRangeMax );
817 
818  const std::size_t nonOverlappednResultSize =
819  nonOverlappedResult->getNumGeometries();
820  const double inputBandNoDataValue = m_inputParameters.m_forceInputNoDataValue ?
821  m_inputParameters.m_noDataValue : inputRasterPtr->getBand(
822  inputBandIdx )->getProperty()->m_noDataValue;
823  const double& outputBandNoDataValue = m_inputParameters.m_noDataValue;
824 
825  for( unsigned int nonOverlappednResultIdx = 0 ; nonOverlappednResultIdx < nonOverlappednResultSize ;
826  ++nonOverlappednResultIdx )
827  {
828  te::gm::Polygon const* const nonOverlappednResultElementPtr =
829  dynamic_cast< te::gm::Polygon const* >(
830  nonOverlappedResult->getGeometryN( nonOverlappednResultIdx ) );
831  TERP_DEBUG_TRUE_OR_THROW( nonOverlappednResultElementPtr,
832  "Invalid pointer" );
833 
834  unsigned int outputRow = 0;
835  unsigned int outputCol = 0;
836  double inputRow = 0;
837  double inputCol = 0;
838  double outputX = 0;
839  double outputY = 0;
840  const te::rst::Grid& inputGrid = (*inputRasterPtr->getGrid());
841  const te::rst::Grid& outputGrid = (*outputRaster.getGrid());
842  std::complex< double > pixelCValue = 0;
843  double pixelValue = 0;
844 
846  nonOverlappednResultElementPtr );
848  nonOverlappednResultElementPtr );
849 
850  while( itB != itE )
851  {
852  outputRow = itB.getRow();
853  outputCol = itB.getColumn();
854 
855  outputGrid.gridToGeo( (double)outputCol, (double)outputRow, outputX, outputY );
856  inputGrid.geoToGrid( outputX, outputY, inputCol, inputRow );
857 
858  interpInstance.getValue( inputCol, inputRow, pixelCValue, inputBandIdx );
859 
860  if( pixelCValue.real() == inputBandNoDataValue )
861  {
862  outputBand.setValue( outputCol, outputRow, outputBandNoDataValue );
863  }
864  else
865  {
866  pixelValue = pixelCValue.real() * currentRasterBandsScales[
867  inputRastersBandsIdx ] + currentRasterBandsOffsets[
868  inputRastersBandsIdx ];
869  pixelValue = std::max( pixelValue, outputBandRangeMin );
870  pixelValue = std::min( pixelValue, outputBandRangeMax );
871 
872  outputBand.setValue( outputCol, outputRow, pixelValue );
873  }
874 
875  ++itB;
876  }
877  }
878  }
879  }
880 
881  // updating the gloabal mosaic boxes
882 
883  std::auto_ptr< te::gm::Geometry > boxesUnionResultPtr; // under the mosaic SRID
884  boxesUnionResultPtr.reset( mosaicBBoxesUnionPtr->Union(
885  &( rastersBBoxes[ inputRasterIdx ] ) ) );
886  TERP_TRUE_OR_THROW( boxesUnionResultPtr.get(), "Invalid pointer" );
887  boxesUnionResultPtr->setSRID( outputRaster.getSRID() );
888 
889  if( boxesUnionResultPtr->getGeomTypeId() == te::gm::MultiPolygonType )
890  {
891  mosaicBBoxesUnionPtr.reset( (te::gm::MultiPolygon*)boxesUnionResultPtr.release() );
892  }
893  else if( boxesUnionResultPtr->getGeomTypeId() == te::gm::PolygonType )
894  {
895  // transforming it into a te::gm::MultiPolygon
896  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
897  te::gm::MultiPolygonType, boxesUnionResultPtr->getSRID(), 0 );
898  auxMultiPol->add( boxesUnionResultPtr.release() );
899 
900  mosaicBBoxesUnionPtr.reset( auxMultiPol );
901  }
902  else
903  {
904  TERP_LOG_AND_THROW( "Invalid union geometry type" );
905  }
906 
907  // Reseting the input cache
908 
909  if( cachedInputRasterPtr.get() ) cachedInputRasterPtr.reset();
910 
911  // deleting the reprojected raster
912 
913  if( reprojectedInputRasterPtr.get() )
914  {
915  reprojectedInputRasterPtr.reset();
916  remove( reprojectedRasterFileName.c_str() );
917  }
918 
919  // moving to the next raster
920 
922  }
923 
924  // reseting the output cache
925 
926  if( cachedRasterInstancePtr.get() ) cachedRasterInstancePtr.reset();
927 
928  return true;
929  }
930 
931  void GeoMosaic::reset() throw( te::rp::Exception )
932  {
934  m_isInitialized = false;
935  }
936 
938  throw( te::rp::Exception )
939  {
940  reset();
941 
942  GeoMosaic::InputParameters const* inputParamsPtr = dynamic_cast<
943  GeoMosaic::InputParameters const* >( &inputParams );
944  TERP_TRUE_OR_THROW( inputParamsPtr, "Invalid paramters pointer" );
945 
946  m_inputParameters = *inputParamsPtr;
947 
948  // Checking the feeder
949 
951  "Invalid m_feederRasterPtr" )
952 
955  "Invalid number of rasters" )
956 
957  // checking m_inputRastersBands
958 
960  ((unsigned int)m_inputParameters.m_inputRastersBands.size()) ==
962  "Bands mismatch" );
963 
964  for( std::vector< std::vector< unsigned int > >::size_type
965  inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
966  m_inputParameters.m_inputRastersBands.size() ; ++inputRastersBandsIdx )
967  {
969  inputRastersBandsIdx ].size() > 0, "Invalid bands number" );
970 
972  inputRastersBandsIdx ].size() == m_inputParameters.m_inputRastersBands[
973  0 ].size(), "Bands number mismatch" );
974  }
975 
976  m_isInitialized = true;
977 
978  return true;
979  }
980 
982  {
983  return m_isInitialized;
984  }
985 
987  const bool& forceNoDataValue,
988  const double& noDataValue,
989  double& mean, double& variance )
990  {
991  mean = 0;
992  variance = 0;
993 
994  double internalNoDataValue = 0;
995  if( forceNoDataValue )
996  internalNoDataValue = noDataValue;
997  else
998  internalNoDataValue = band.getProperty()->m_noDataValue;
999 
1000  const unsigned int nCols = band.getProperty()->m_blkw *
1001  band.getProperty()->m_nblocksx;
1002  const unsigned int nLines = band.getProperty()->m_blkh *
1003  band.getProperty()->m_nblocksy;
1004 
1005  double pixelsNumber = 0;
1006  double value = 0;
1007  unsigned int col = 0;
1008  unsigned int line = 0;
1009 
1010  for( line = 0 ; line < nLines ; ++line )
1011  for( col = 0 ; col < nCols ; ++col )
1012  {
1013  band.getValue( col, line, value );
1014 
1015  if( value != internalNoDataValue )
1016  {
1017  mean += value;
1018  ++pixelsNumber;
1019  }
1020  }
1021 
1022  if( pixelsNumber != 0.0 )
1023  {
1024  mean /= pixelsNumber;
1025 
1026  for( line = 0 ; line < nLines ; ++line )
1027  for( col = 0 ; col < nCols ; ++col )
1028  {
1029  band.getValue( col, line, value );
1030 
1031  if( value != internalNoDataValue )
1032  {
1033  variance += ( ( value - mean ) * ( value - mean ) ) / pixelsNumber;
1034  }
1035  }
1036 
1037  }
1038  }
1039 
1040  } // end namespace rp
1041 } // end namespace te
1042 
virtual unsigned int getObjsCount() const =0
Return the total number of feeder objects.
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: GeoMosaic.cpp:71
#define TERP_DEBUG_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:356
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:189
virtual te::rst::Raster const * getCurrentObj() const =0
Return the current sequence object.
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: GeoMosaic.h:102
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
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
Definition: GeoMosaic.h:62
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
unsigned int getRow() const
Returns the current row in iterator.
virtual unsigned int getCurrentOffset() const =0
Return the index of the current object.
bool m_isInitialized
Tells if this instance is initialized.
Definition: GeoMosaic.h:141
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
double y
y-coordinate.
Definition: Coord2D.h:87
GeoMosaic output parameters.
Definition: GeoMosaic.h:96
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
bool convert(double *xIn, double *yIn, double *xOut, double *yOut, long numCoord, int coordOffset=1) const
Converts a vector of coordinates from source SRS to target SRS.
Definition: Converter.cpp:211
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Definition: GeoMosaic.cpp:121
static Raster * make()
It creates and returns an empty raster with default raster driver.
No blending performed.
Definition: Blender.h:61
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
double getResolutionY() const
Returns the grid vertical (y-axis) resolution.
Definition: Grid.cpp:261
void getValue(const double &c, const double &r, std::complex< double > &v, const std::size_t &b)
Get the interpolated value at specific band.
Definition: Interpolator.h:84
int m_nblocksy
The number of blocks in y.
Definition: BandProperty.h:146
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
const OutputParameters & operator=(const OutputParameters &params)
Definition: GeoMosaic.cpp:128
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: GeoMosaic.h:64
Blended pixel value calculation for two overlaped rasters.
Definition: Blender.h:53
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
Definition: Interpolator.h:51
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
void getBlendedValues(const double &line, const double &col, std::vector< double > &values)
Blend a pixel value using the current parameters.
Definition: Blender.h:118
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band.
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
Definition: GeoMosaic.h:68
void setTargetSRID(int targetSRID)
Sets the target SRS identifier.
Definition: Converter.cpp:156
void add(Geometry *g)
It adds the geometry into the collection.
#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
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Definition: GeoMosaic.h:66
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: GeoMosaic.cpp:100
int m_type
The data type of the elements in the band.
Definition: BandProperty.h:133
Abstract parameters base interface.
std::vector< TiePoint > m_tiePoints
Tie points.
Definition: GTParameters.h:95
A raster band description.
Definition: Band.h:63
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
double m_lly
Lower left corner y-coordinate.
Definition: Envelope.h:345
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
int getSRID() const
Returns the raster spatial reference system identifier.
Definition: Raster.cpp:203
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
AbstractParameters * clone() const
Create a clone copy of this instance.
Definition: GeoMosaic.cpp:140
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
Definition: GeoMosaic.cpp:981
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output mosaic raster.
Definition: GeoMosaic.h:104
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
Definition: Grid.cpp:276
void clear()
It deletes all the rings of the CurvePolygon and clear it.
void setSourceSRID(int sourceSRID)
Sets the source SRS identifier.
Definition: Converter.cpp:101
double getResolutionX() const
Returns the grid horizontal (x-axis) resolution.
Definition: Grid.cpp:256
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Definition: GeoMosaic.cpp:154
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
unsigned int getColumn() const
Returns the current column in iterator.
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
Definition: GeoMosaic.h:74
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Definition: GeoMosaic.cpp:937
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
const Algorithm & operator=(const Algorithm &)
Definition: Algorithm.cpp:43
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
Definition: LineString.cpp:313
A raster band description.
Definition: BandProperty.h:61
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
Definition: GeoMosaic.h:72
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
Definition: GeoMosaic.h:60
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits&lt;double&gt;::max().
Definition: BandProperty.h:136
virtual void reset()=0
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
Definition: Grid.cpp:302
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:149
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
Definition: Converter.h:53
A RAM cache adaptor to an external existent raster that must always be avaliable. ...
Definition: CachedRaster.h:50
static void calcBandStatistics(const te::rst::Band &band, const bool &forceNoDataValue, const double &noDataValue, double &mean, double &variance)
Raster band statistics calcule.
Definition: GeoMosaic.cpp:986
Raster Processing algorithm output parameters base interface.
double m_llx
Lower left corner x-coordinate.
Definition: Envelope.h:344
int m_nblocksx
The number of blocks in x.
Definition: BandProperty.h:145
An abstract class for raster data strucutures.
Definition: Raster.h:70
BandProperty * getProperty()
Returns the band property.
Definition: Band.cpp:370
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Create a mosaic from a set of geo-referenced rasters.
#define TERP_LOG_AND_THROW(message)
Logs a error message and throws.
Definition: Macros.h:138
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
int getSRID() const
Returns the grid spatial reference system identifier.
Definition: Grid.cpp:266
GeoMosaic input parameters.
Definition: GeoMosaic.h:56
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
Definition: GeoMosaic.cpp:931
2D Geometric transformation parameters.
Definition: GTParameters.h:50
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
double x
x-coordinate.
Definition: Coord2D.h:86
const InputParameters & operator=(const InputParameters &params)
Definition: GeoMosaic.cpp:83
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
GeoMosaic::InputParameters m_inputParameters
Input execution parameters.
Definition: GeoMosaic.h:139
Near neighborhood interpolation method.
Definition: Interpolator.h:60
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
Definition: Utils.cpp:331
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: GeoMosaic.h:100
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:308
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
Definition: GeoMosaic.h:70
Index into a lookup table.
Definition: Enums.h:57
void push_back(Curve *ring)
It adds the curve to the curve polygon.
Definition: CurvePolygon.h:279
bool initialize(const 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 forceInputNoDataValue, const std::vector< double > &pixelOffsets1, const std::vector< double > &pixelScales1, const std::vector< double > &pixelOffsets2, const std::vector< double > &pixelScales2, te::gm::Polygon const *const r1ValidDataDelimiterPtr, te::gm::Polygon const *const r2ValidDataDelimiterPtr, const te::gm::GeometricTransformation &geomTransformation)
Inititate the blender instance.
Definition: Blender.cpp:81
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
virtual bool moveNext()=0
Advances to the next sequence obeject.
Raster Processing algorithm input parameters base interface.
#define TERP_DEBUG_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:371