All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TiePointsMosaic.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/TiePointsMosaic.cpp
22  \brief Create a mosaic from a set of rasters using tie-points.
23 */
24 
25 #include "TiePointsMosaic.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 <boost/shared_ptr.hpp>
45 
46 #include <climits>
47 #include <cfloat>
48 #include <cmath>
49 #include <memory>
50 
51 namespace te
52 {
53  namespace rp
54  {
55 
57  {
58  reset();
59  }
60 
62  {
63  reset();
64  operator=( other );
65  }
66 
68  {
69  reset();
70  }
71 
72  void TiePointsMosaic::InputParameters::reset() throw( te::rp::Exception )
73  {
74  m_feederRasterPtr = 0;
75  m_inputRastersBands.clear();
76  m_tiePoints.clear();
77  m_geomTransfName = "Affine";
79  m_noDataValue = 0.0;
80  m_forceInputNoDataValue = false;
81  m_blendMethod = te::rp::Blender::NoBlendMethod;
82  m_autoEqualize = true;
83  m_useRasterCache = true;
84  }
85 
87  const TiePointsMosaic::InputParameters& params )
88  {
89  reset();
90 
91  m_feederRasterPtr = params.m_feederRasterPtr;
92  m_inputRastersBands = params.m_inputRastersBands;
93  m_tiePoints = params.m_tiePoints;
94  m_geomTransfName = params.m_geomTransfName;
95  m_interpMethod = params.m_interpMethod;
96  m_noDataValue = params.m_noDataValue;
97  m_forceInputNoDataValue = params.m_forceInputNoDataValue;
98  m_blendMethod = params.m_blendMethod;
99  m_autoEqualize = params.m_autoEqualize;
100  m_useRasterCache = params.m_useRasterCache;
101 
102  return *this;
103  }
104 
106  {
107  return new InputParameters( *this );
108  }
109 
111  {
112  reset();
113  }
114 
116  {
117  reset();
118  operator=( other );
119  }
120 
122  {
123  reset();
124  }
125 
126  void TiePointsMosaic::OutputParameters::reset() throw( te::rp::Exception )
127  {
128  m_rType.clear();
129  m_rInfo.clear();
130  m_outputRasterPtr.reset();
131  }
132 
134  const TiePointsMosaic::OutputParameters& params )
135  {
136  reset();
137 
138  m_rType = params.m_rType;
139  m_rInfo = params.m_rInfo;
140 
141  return *this;
142  }
143 
145  {
146  return new OutputParameters( *this );
147  }
148 
150  {
151  reset();
152  }
153 
155  {
156  }
157 
159  throw( te::rp::Exception )
160  {
161  if( ! m_isInitialized ) return false;
162 
163  TiePointsMosaic::OutputParameters* outParamsPtr = dynamic_cast<
164  TiePointsMosaic::OutputParameters* >( &outputParams );
165  TERP_TRUE_OR_THROW( outParamsPtr, "Invalid paramters" );
166 
167  // First pass: getting global mosaic info
168 
169  double mosaicXResolution = 0.0;
170  double mosaicYResolution = 0.0;
171  double mosaicLLX = DBL_MAX; // world coords
172  double mosaicLLY = DBL_MAX; // world coords
173  double mosaicURX = -1.0 * DBL_MAX; // world coords
174  double mosaicURY = -1.0 * DBL_MAX; // world coords
175  int mosaicSRID = 0;
176  std::vector< double > mosaicBandsRangeMin;
177  std::vector< double > mosaicBandsRangeMax;
178  te::rst::BandProperty mosaicBaseBandProperties( 0, 0, "" );
179  std::vector< te::gm::Polygon > rastersBBoxes; // all rasters bounding boxes (under the first raster world coords.
180 
181  {
182  std::vector< boost::shared_ptr< te::gm::GeometricTransformation > >
183  eachRasterPixelToFirstRasterPixelGeomTransfms;
184  // Mapping indexed points from each raster to the first raster indexed points.
185  // te::gm::GTParameters::TiePoint::first are mosaic reaster indexed points (lines/cols),
186  // te::gm::GTParameters::TiePoint::second are the other rasters indexed points (lines/cols).
187 
188  std::vector< te::rst::Grid > rastersGrids; //all rasters original grids under their original SRSs
189 
190  te::gm::Polygon auxPolygon( 0, te::gm::PolygonType, 0 );
191  te::gm::LinearRing* auxLinearRingPtr = 0;
192  te::rst::Raster const* inputRasterPtr = 0;
193  unsigned int inputRasterIdx = 0;
194  te::srs::Converter convInstance;
195  boost::shared_ptr< te::gm::GeometricTransformation > auxTransPtr;
196  te::gm::Coord2D llCoord1;
197  te::gm::Coord2D urCoord1;
198  te::gm::Coord2D llCoord2;
199  te::gm::Coord2D urCoord2;
200 
202  while( ( inputRasterPtr = m_inputParameters.m_feederRasterPtr->getCurrentObj() ) )
203  {
206  inputRasterPtr->getAccessPolicy() & te::common::RAccess,
207  "Invalid raster" );
208 
209  rastersGrids.push_back( (*inputRasterPtr->getGrid()) );
210 
211  // Defining the base mosaic info
212 
213  if( inputRasterIdx == 0 )
214  {
215  mosaicXResolution = inputRasterPtr->getGrid()->getResolutionX();
216  mosaicYResolution = inputRasterPtr->getGrid()->getResolutionY();
217 
218  mosaicLLX = inputRasterPtr->getGrid()->getExtent()->m_llx;
219  mosaicLLY = inputRasterPtr->getGrid()->getExtent()->m_lly;
220  mosaicURX = inputRasterPtr->getGrid()->getExtent()->m_urx;
221  mosaicURY = inputRasterPtr->getGrid()->getExtent()->m_ury;
222 
223  mosaicSRID = inputRasterPtr->getGrid()->getSRID();
224 
225  mosaicBaseBandProperties = *inputRasterPtr->getBand( 0 )->getProperty();
226 
227  // finding the current raster bounding box polygon (first raster world coordinates)
228 
229  auxPolygon.clear();
230  auxLinearRingPtr = new te::gm::LinearRing(5, te::gm::LineStringType);
231  auxLinearRingPtr->setPoint( 0, mosaicLLX, mosaicURY );
232  auxLinearRingPtr->setPoint( 1, mosaicURX, mosaicURY );
233  auxLinearRingPtr->setPoint( 2, mosaicURX, mosaicLLY );
234  auxLinearRingPtr->setPoint( 3, mosaicLLX, mosaicLLY );
235  auxLinearRingPtr->setPoint( 4, mosaicLLX, mosaicURY );
236  auxPolygon.push_back( auxLinearRingPtr );
237  auxPolygon.setSRID( mosaicSRID );
238  rastersBBoxes.push_back( auxPolygon );
239  }
240  else
241  {
242  te::gm::GTParameters transParams;
243 
244  if( ( inputRasterIdx == 1 ) ||
246  {
247  transParams.m_tiePoints = m_inputParameters.m_tiePoints[ inputRasterIdx - 1 ];
248  }
249  else
250  {
251  // converting the current tie-points to map coords from the
252  // current raster to the first one
253 
255  const std::vector< te::gm::GTParameters::TiePoint >& inputTPs =
256  m_inputParameters.m_tiePoints[ inputRasterIdx - 1 ];
257  const unsigned int inputTPsSize = inputTPs.size();
258  const te::gm::GeometricTransformation& lastTransf =
259  (*eachRasterPixelToFirstRasterPixelGeomTransfms[ inputRasterIdx - 2 ].get());
260 
261  for( unsigned int inputTPsIdx = 0 ; inputTPsIdx < inputTPsSize ;
262  ++inputTPsIdx )
263  {
264  auxTP.second = inputTPs[ inputTPsIdx ].second;
265  lastTransf.inverseMap( inputTPs[ inputTPsIdx ].first, auxTP.first );
266  transParams.m_tiePoints.push_back( auxTP );
267  }
268  }
269 
270  auxTransPtr.reset( te::gm::GTFactory::make(
272  TERP_TRUE_OR_RETURN_FALSE( auxTransPtr.get() != 0,
273  "Geometric transformation instatiation error" );
274  TERP_TRUE_OR_RETURN_FALSE( auxTransPtr->initialize( transParams ),
275  "Geometric transformation parameters calcule error" );
276  eachRasterPixelToFirstRasterPixelGeomTransfms.push_back( auxTransPtr );
277 
278  // current raster corner coords (line/column)
279 
280  urCoord2.x = ((double)inputRasterPtr->getGrid()->getNumberOfColumns())
281  - 1.0;
282  urCoord2.y = 0.0;
283  llCoord2.x = 0.0;
284  llCoord2.y = ((double)inputRasterPtr->getGrid()->getNumberOfRows())
285  - 1.0;
286 
287  // current raster corner coords (line/column) over the
288  // first raster coords system (lines/columns)
289 
290  auxTransPtr->inverseMap( urCoord2, urCoord1 );
291  auxTransPtr->inverseMap( llCoord2, llCoord1 );
292 
293  // the respective coords in world space (first raster)
294 
295  rastersGrids[ 0 ].gridToGeo( urCoord1.x, urCoord1.y, urCoord2.x,
296  urCoord2.y );
297  rastersGrids[ 0 ].gridToGeo( llCoord1.x, llCoord1.y, llCoord2.x,
298  llCoord2.y );
299 
300  // expanding mosaic area
301 
302  mosaicLLX = std::min( mosaicLLX, urCoord2.x );
303  mosaicLLX = std::min( mosaicLLX, llCoord2.x );
304 
305  mosaicLLY = std::min( mosaicLLY, urCoord2.y );
306  mosaicLLY = std::min( mosaicLLY, llCoord2.y );
307 
308  mosaicURX = std::max( mosaicURX, urCoord2.x );
309  mosaicURX = std::max( mosaicURX, llCoord2.x );
310 
311  mosaicURY = std::max( mosaicURY, urCoord2.y );
312  mosaicURY = std::max( mosaicURY, llCoord2.y );
313 
314  // finding the current raster bounding box polygon (first raster world coordinates)
315 
316  auxPolygon.clear();
317  auxLinearRingPtr = new te::gm::LinearRing(5, te::gm::LineStringType);
318  auxLinearRingPtr->setPoint( 0, llCoord2.x, urCoord2.y );
319  auxLinearRingPtr->setPoint( 1, urCoord2.x, urCoord2.y );
320  auxLinearRingPtr->setPoint( 2, urCoord2.x, llCoord2.y );
321  auxLinearRingPtr->setPoint( 3, llCoord2.x, llCoord2.y );
322  auxLinearRingPtr->setPoint( 4, llCoord2.x, urCoord2.y );
323  auxPolygon.push_back( auxLinearRingPtr );
324  auxPolygon.setSRID( mosaicSRID );
325  rastersBBoxes.push_back( auxPolygon );
326  }
327 
328  // checking the input bands
329 
330  for( std::vector< unsigned int >::size_type inputRastersBandsIdx = 0 ;
331  inputRastersBandsIdx <
332  m_inputParameters.m_inputRastersBands[ inputRasterIdx ].size() ;
333  ++inputRastersBandsIdx )
334  {
335  const unsigned int& currBand =
336  m_inputParameters.m_inputRastersBands[ inputRasterIdx ][ inputRastersBandsIdx ];
337 
338  TERP_TRUE_OR_RETURN_FALSE( currBand < inputRasterPtr->getNumberOfBands(),
339  "Invalid band" )
340  }
341 
342 
344  }
345 
346 
347  }
348 
349  // creating the output raster
350 
351  te::rst::Raster* outputRasterPtr = 0;
352 
353  {
354  mosaicBandsRangeMin.resize(
355  m_inputParameters.m_inputRastersBands[ 0 ].size(), 0 );
356  mosaicBandsRangeMax.resize(
357  m_inputParameters.m_inputRastersBands[ 0 ].size(), 0 );
358 
359  std::vector< te::rst::BandProperty* > bandsProperties;
360  for( std::vector< unsigned int >::size_type bandIdx = 0 ; bandIdx <
361  m_inputParameters.m_inputRastersBands[ 0 ].size() ; ++bandIdx )
362  {
363  bandsProperties.push_back( new te::rst::BandProperty( mosaicBaseBandProperties ) );
364  bandsProperties[ bandIdx ]->m_colorInterp = te::rst::GrayIdxCInt;
365  bandsProperties[ bandIdx ]->m_noDataValue = m_inputParameters.m_noDataValue;
366 
367  te::rst::GetDataTypeRanges( bandsProperties[ bandIdx ]->m_type,
368  mosaicBandsRangeMin[ bandIdx ],
369  mosaicBandsRangeMax[ bandIdx ]);
370  }
371 
372  te::rst::Grid* outputGrid = new te::rst::Grid( mosaicXResolution,
373  mosaicYResolution, new te::gm::Envelope( mosaicLLX, mosaicLLY, mosaicURX,
374  mosaicURY ), mosaicSRID );
375 
376  outParamsPtr->m_outputRasterPtr.reset(
378  outParamsPtr->m_rType,
379  outputGrid,
380  bandsProperties,
381  outParamsPtr->m_rInfo,
382  0,
383  0 ) );
384  TERP_TRUE_OR_RETURN_FALSE( outParamsPtr->m_outputRasterPtr.get(),
385  "Output raster creation error" );
386 
387  outputRasterPtr = outParamsPtr->m_outputRasterPtr.get();
388  }
389 
390  std::auto_ptr< te::mem::CachedRaster > cachedOutputRasterInstancePtr;
391 
393  {
394  cachedOutputRasterInstancePtr.reset( new te::mem::CachedRaster(
395  *(outParamsPtr->m_outputRasterPtr.get()), 25, 0 ) );
396 
397  outputRasterPtr = cachedOutputRasterInstancePtr.get();
398  }
399 
400  // Finding the transformation mapping indexed points from each raster to the first raster indexed points.
401  // te::gm::GTParameters::TiePoint::first are mosaic reaster indexed points (lines/cols),
402  // te::gm::GTParameters::TiePoint::second are the other rasters indexed points (lines/cols).
403 
404  std::vector< boost::shared_ptr< te::gm::GeometricTransformation > >
405  eachRasterPixelToMosaicRasterPixelGeomTransfms;
406 
407  {
408  const double firstRasterColOffset = std::abs( rastersBBoxes[ 0 ].getMBR()->m_llx -
409  outParamsPtr->m_outputRasterPtr->getGrid()->getExtent()->getLowerLeftX() ) /
410  outParamsPtr->m_outputRasterPtr->getGrid()->getResolutionX();
411  const double firstRasterLinOffset = std::abs( rastersBBoxes[ 0 ].getMBR()->m_ury -
412  outParamsPtr->m_outputRasterPtr->getGrid()->getExtent()->getUpperRightY() ) /
413  outParamsPtr->m_outputRasterPtr->getGrid()->getResolutionY();
414 
415  for( unsigned int tiePointsIdx = 0 ; tiePointsIdx < m_inputParameters.m_tiePoints.size() ;
416  ++tiePointsIdx )
417  {
418  te::gm::GTParameters transfParams;
419  transfParams.m_tiePoints = m_inputParameters.m_tiePoints[ tiePointsIdx ];
420 
421  const double prevRasterColOffset = std::abs( rastersBBoxes[ tiePointsIdx ].getMBR()->m_llx -
422  outParamsPtr->m_outputRasterPtr->getGrid()->getExtent()->getLowerLeftX() ) /
423  outParamsPtr->m_outputRasterPtr->getGrid()->getResolutionX();
424  const double prevRasterLinOffset = std::abs( rastersBBoxes[ tiePointsIdx ].getMBR()->m_ury -
425  outParamsPtr->m_outputRasterPtr->getGrid()->getExtent()->getUpperRightY() ) /
426  outParamsPtr->m_outputRasterPtr->getGrid()->getResolutionY();
427 
428  for( unsigned int tpIdx = 0 ; tpIdx < transfParams.m_tiePoints.size() ;
429  ++tpIdx )
430  {
432  {
433  transfParams.m_tiePoints[ tpIdx ].first.x += firstRasterColOffset;
434  transfParams.m_tiePoints[ tpIdx ].first.y += firstRasterLinOffset;
435  }
436  else
437  {
438  transfParams.m_tiePoints[ tpIdx ].first.x += prevRasterColOffset;
439  transfParams.m_tiePoints[ tpIdx ].first.y += prevRasterLinOffset;
440  }
441  }
442 
443  boost::shared_ptr< te::gm::GeometricTransformation > auxTransPtr(
445  TERP_TRUE_OR_RETURN_FALSE( auxTransPtr.get() != 0,
446  "Geometric transformation instatiation error" );
447  TERP_TRUE_OR_RETURN_FALSE( auxTransPtr->initialize( transfParams ),
448  "Geometric transformation parameters calcule error" );
449  eachRasterPixelToMosaicRasterPixelGeomTransfms.push_back( auxTransPtr );
450  }
451  }
452 
453  // fill output with no data values
454 
455  {
456  const unsigned int nBands = outputRasterPtr->getNumberOfBands();
457  const unsigned int nRows = outputRasterPtr->getNumberOfRows();
458  const unsigned int nCols = outputRasterPtr->getNumberOfColumns();
459  unsigned int col = 0;
460  unsigned int row = 0;
461  unsigned int bandIdx = 0;
462 
463  for( bandIdx = 0 ; bandIdx < nBands ; ++bandIdx )
464  {
465  te::rst::Band& outBand = ( *( outputRasterPtr->getBand( bandIdx ) ) );
466 
467  for( row = 0 ; row < nRows ; ++row )
468  {
469  for( col = 0 ; col < nCols ; ++col )
470  {
471  outBand.setValue( col, row, m_inputParameters.m_noDataValue );
472  }
473  }
474  }
475  }
476 
477  // Copying the first image data to the output mosaic
478  // and find the base mosaic mean and offset values
479 
480  std::vector< double > mosaicTargetMeans( outputRasterPtr->getNumberOfBands(), 0 );
481  std::vector< double > mosaicTargetVariances( outputRasterPtr->getNumberOfBands(), 0 );
482 
483  {
485 
486  te::rst::Raster const* inputRasterPtr =
488  TERP_DEBUG_TRUE_OR_RETURN_FALSE( inputRasterPtr, "Invalid raster pointer" );
489 
490  double inXStartGeo = 0;
491  double inYStartGeo = 0;
492  inputRasterPtr->getGrid()->gridToGeo( 0.0, 0.0, inXStartGeo, inYStartGeo );
493  double outRowStartDouble = 0;
494  double outColStartDouble = 0;
495  outputRasterPtr->getGrid()->geoToGrid( inXStartGeo, inYStartGeo,
496  outColStartDouble, outRowStartDouble );
497 
498  const unsigned int outRowStart = (unsigned int)std::max( 0.0, outRowStartDouble );
499  const unsigned int outColStart = (unsigned int)std::max( 0.0, outColStartDouble );
500  const unsigned int outRowsBound = std::min( outRowStart +
501  inputRasterPtr->getNumberOfRows(),
502  outputRasterPtr->getNumberOfRows() );
503  const unsigned int outColsBound = std::min( outColStart +
504  inputRasterPtr->getNumberOfColumns(),
505  outputRasterPtr->getNumberOfColumns() );
506 
507  const unsigned int nBands = (unsigned int)
509  unsigned int outCol = 0;
510  unsigned int outRow = 0;
511  double inCol = 0;
512  double inRow = 0;
513  double bandNoDataValue = -1.0 * DBL_MAX;
514  std::complex< double > pixelCValue = 0;
515  te::rst::Interpolator interpInstance( inputRasterPtr,
517  unsigned int inputBandIdx = 0;
518 
519  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
520  nBands ; ++inputRastersBandsIdx )
521  {
522  inputBandIdx = m_inputParameters.m_inputRastersBands[ 0 ][
523  inputRastersBandsIdx ] ;
524  bandNoDataValue = m_inputParameters.m_forceInputNoDataValue ?
525  m_inputParameters.m_noDataValue : inputRasterPtr->getBand( inputBandIdx
527  te::rst::Band& outBand =
528  (*outputRasterPtr->getBand( inputRastersBandsIdx ));
529  unsigned int validPixelsNumber = 0;
530 
531  double& mean = mosaicTargetMeans[ inputRastersBandsIdx ];
532  mean = 0;
533 
534  for( outRow = outRowStart ; outRow < outRowsBound ; ++outRow )
535  {
536  inRow = ((double)outRow) - outRowStartDouble;
537 
538  for( outCol = outColStart ; outCol < outColsBound ; ++outCol )
539  {
540  inCol = ((double)outCol) - outColStartDouble;
541 
542  interpInstance.getValue( inCol, inRow, pixelCValue, inputBandIdx );
543 
544  if( pixelCValue.real() != bandNoDataValue )
545  {
546  outBand.setValue( outCol, outRow, pixelCValue );
547  mean += pixelCValue.real();
548  ++validPixelsNumber;
549  }
550  }
551  }
552 
553  mean /= ( (double)validPixelsNumber );
554 
555  // variance calcule
556 
558  {
559  double& variance = mosaicTargetVariances[ inputRastersBandsIdx ];
560  variance = 0;
561 
562  double pixelValue = 0;
563 
564  for( outRow = outRowStart ; outRow < outRowsBound ; ++outRow )
565  {
566  for( outCol = outColStart ; outCol < outColsBound ; ++outCol )
567  {
568  outBand.getValue( outCol, outRow, pixelValue );
569 
570  if( pixelValue != m_inputParameters.m_noDataValue )
571  {
572  variance += ( ( pixelValue - mean ) * ( pixelValue -
573  mean ) ) / ( (double)validPixelsNumber );
574  }
575  }
576  }
577  }
578  }
579  }
580 
581  // Initiating the mosaic bounding boxes union
582 
583  std::auto_ptr< te::gm::MultiPolygon > mosaicBBoxesUnionPtr(
585  outParamsPtr->m_outputRasterPtr->getSRID(), 0 ) );
586  mosaicBBoxesUnionPtr->add( (te::gm::Polygon*)rastersBBoxes[ 0 ].clone() );
587 
588  // globals
589 
590  std::vector< unsigned int > outputRasterBands;
591  std::vector< double > dummyRasterOffsets;
592  std::vector< double > dummyRasterScales;
593  for( unsigned int outputRasterBandsIdx = 0 ; outputRasterBandsIdx <
594  outputRasterPtr->getNumberOfBands() ; ++outputRasterBandsIdx )
595  {
596  outputRasterBands.push_back( outputRasterBandsIdx );
597  dummyRasterOffsets.push_back( 0.0 );
598  dummyRasterScales.push_back( 1.0 );
599  }
600 
601  // iterating over the other rasters
602 
603  te::rst::Raster const* nonCachedInputRasterPtr = 0;
604 
607 
608  while( ( nonCachedInputRasterPtr = m_inputParameters.m_feederRasterPtr->getCurrentObj() ) )
609  {
610  const unsigned int inputRasterIdx = m_inputParameters.m_feederRasterPtr->getCurrentOffset();
611 
612  te::rst::Raster const* inputRasterPtr = nonCachedInputRasterPtr;
613 
614  std::auto_ptr< te::mem::CachedRaster > cachedInputRasterPtr;
616  {
617  cachedInputRasterPtr.reset( new te::mem::CachedRaster(
618  *nonCachedInputRasterPtr, 25, 0 ) );
619  inputRasterPtr = cachedInputRasterPtr.get();
620  }
621 
622  // Generating the offset and gain info for eath band from the current raster
623 
624  std::vector< double > currentRasterBandsOffsets;
625  std::vector< double > currentRasterBandsScales;
626 
628  {
629  double currentRasterVariance = 0;
630  double currentRasterMean = 0;
631 
632  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
633  m_inputParameters.m_inputRastersBands[ inputRasterIdx ].size() ;
634  ++inputRastersBandsIdx )
635  {
636  const unsigned int inputBandIdx = m_inputParameters.m_inputRastersBands[ inputRasterIdx ][
637  inputRastersBandsIdx ];
638 
639  calcBandStatistics( (*inputRasterPtr->getBand( inputBandIdx ) ),
642  currentRasterMean,
643  currentRasterVariance );
644 
645  currentRasterBandsScales.push_back( std::sqrt( mosaicTargetVariances[ inputRastersBandsIdx ] /
646  currentRasterVariance ) );
647  currentRasterBandsOffsets.push_back( mosaicTargetMeans[ inputRastersBandsIdx ] -
648  ( currentRasterBandsScales[ inputRastersBandsIdx ] * currentRasterMean ) );
649  }
650  }
651  else
652  {
653  currentRasterBandsOffsets = dummyRasterOffsets;
654  currentRasterBandsScales = dummyRasterScales;
655  }
656 
658  {
659  // No blend required
660 
661  // Copying the current image data to the output mosaic
662  // obeying the dummy value constraints and
663  // applying gain and offset values
664 
665  const double currentRasterColOffset = std::abs( rastersBBoxes[ inputRasterIdx ].getMBR()->m_llx -
666  outParamsPtr->m_outputRasterPtr->getGrid()->getExtent()->getLowerLeftX() ) /
667  outParamsPtr->m_outputRasterPtr->getGrid()->getResolutionX();
668  const double currentRasterRowOffset = std::abs( rastersBBoxes[ inputRasterIdx ].getMBR()->m_ury -
669  outParamsPtr->m_outputRasterPtr->getGrid()->getExtent()->getUpperRightY() ) /
670  outParamsPtr->m_outputRasterPtr->getGrid()->getResolutionY();
671 
672  const unsigned int outRowStart = (unsigned int)std::max( 0.0, currentRasterRowOffset );
673  const unsigned int outColStart = (unsigned int)std::max( 0.0, currentRasterColOffset );
674  const unsigned int outRowsBound = std::min( outRowStart +
675  inputRasterPtr->getNumberOfRows(),
676  outputRasterPtr->getNumberOfRows() );
677  const unsigned int outColsBound = std::min( outColStart +
678  inputRasterPtr->getNumberOfColumns(),
679  outputRasterPtr->getNumberOfColumns() );
680  const unsigned int nBands = outputRasterPtr->getNumberOfBands();
681 
682  te::rst::Interpolator interpInstance( inputRasterPtr,
684  const te::gm::GeometricTransformation& transformation =
685  *(eachRasterPixelToMosaicRasterPixelGeomTransfms[ inputRasterIdx - 1 ]);
686 
687  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
688  nBands ; ++inputRastersBandsIdx )
689  {
690  const unsigned int inputBandIdx =
691  m_inputParameters.m_inputRastersBands[ inputRasterIdx ][ inputRastersBandsIdx ];
692  const double inputNoDataValue =
695  :
696  inputRasterPtr->getBand( inputBandIdx )->getProperty()->m_noDataValue;
697  te::rst::Band& outBand =
698  (*outputRasterPtr->getBand( inputRastersBandsIdx ));
699 
700  double outputBandRangeMin = 0;
701  double outputBandRangeMax = 0;
703  outputBandRangeMin, outputBandRangeMax );
704 
705  unsigned int outCol = 0;
706  unsigned int outRow = 0;
707  double inCol = 0;
708  double inRow = 0;
709  std::complex< double > pixelCValue = 0;
710  double pixelValue = 0;
711 
712  for( outRow = outRowStart ; outRow < outRowsBound ; ++outRow )
713  {
714  for( outCol = outColStart ; outCol < outColsBound ; ++outCol )
715  {
716  transformation.directMap( (double)outCol, (double)outRow, inCol, inRow );
717 
718  interpInstance.getValue( inCol, inRow, pixelCValue, inputBandIdx );
719 
720  if( pixelCValue.real() != inputNoDataValue )
721  {
722  pixelValue = pixelCValue.real() * currentRasterBandsScales[
723  inputRastersBandsIdx ] + currentRasterBandsOffsets[
724  inputRastersBandsIdx ];
725  pixelValue = std::max( pixelValue, outputBandRangeMin );
726  pixelValue = std::min( pixelValue, outputBandRangeMax );
727 
728  outBand.setValue( outCol, outRow, pixelValue );
729  }
730  }
731  }
732  }
733  }
734  else
735  {
736  // Blend required
737 
738  // Processing each one of the mosaic boxes union components
739  // blending each overlapped area
740 
741  for( std::size_t mosaicBBoxesUnionIdx = 0 ; mosaicBBoxesUnionIdx <
742  mosaicBBoxesUnionPtr->getNumGeometries() ; ++mosaicBBoxesUnionIdx )
743  {
744  te::gm::Polygon const* mosaicBBoxesUnionElementPtr =
745  dynamic_cast< te::gm::Polygon const*>(
746  mosaicBBoxesUnionPtr->getGeometryN( mosaicBBoxesUnionIdx ) );
747  TERP_DEBUG_TRUE_OR_THROW( mosaicBBoxesUnionElementPtr,
748  "Invalid pointer" );
749 
750  // calculating the overlapped image areas
751 
752  std::auto_ptr< te::gm::MultiPolygon > overlappedResult; // under the mosaic SRID
753 
754  {
755  std::auto_ptr< te::gm::Geometry > auxResultPtr(
756  rastersBBoxes[ inputRasterIdx ].intersection( mosaicBBoxesUnionElementPtr ) );
757 
758  if( auxResultPtr.get() )
759  {
760  auxResultPtr->setSRID( mosaicBBoxesUnionElementPtr->getSRID() );
761 
762  if( auxResultPtr->getGeomTypeId() == te::gm::MultiPolygonType )
763  {
764  overlappedResult.reset( (te::gm::MultiPolygon*)auxResultPtr.release() );
765  }
766  else if( auxResultPtr->getGeomTypeId() == te::gm::PolygonType )
767  {
768  // transforming it into a te::gm::MultiPolygon
769  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
770  te::gm::MultiPolygonType, auxResultPtr->getSRID(), 0 );
771  auxMultiPol->add( auxResultPtr.release() );
772  overlappedResult.reset( auxMultiPol );
773  }
774  }
775  }
776 
777  // blending
778 
779  if( overlappedResult.get() )
780  {
781  te::rp::Blender blenderInstance;
782 
783  TERP_TRUE_OR_RETURN_FALSE( blenderInstance.initialize(
784  *outputRasterPtr,
785  outputRasterBands,
786  *inputRasterPtr,
787  m_inputParameters.m_inputRastersBands[ inputRasterIdx ],
793  dummyRasterOffsets,
794  dummyRasterScales,
795  currentRasterBandsOffsets,
796  currentRasterBandsScales,
797  mosaicBBoxesUnionElementPtr,
798  0,
799  *( eachRasterPixelToMosaicRasterPixelGeomTransfms[ inputRasterIdx - 1 ] ) ),
800  "Blender initiazing error" );
801 
802  for( unsigned int overlappedResultIdx = 0 ; overlappedResultIdx <
803  overlappedResult->getNumGeometries() ; ++overlappedResultIdx )
804  {
806  outputRasterPtr,
807  (te::gm::Polygon const*)overlappedResult->getGeometryN( overlappedResultIdx ) );
809  outputRasterPtr,
810  (te::gm::Polygon const*)overlappedResult->getGeometryN( overlappedResultIdx ) );
811 
812  std::vector< double > blendedValues( outputRasterPtr->getNumberOfBands() );
813  unsigned int outputRow = 0;
814  unsigned int outputCol = 0;
815  const unsigned int nBands = outputRasterPtr->getNumberOfBands();
816  unsigned int outBandIdx = 0;
817  te::rst::Raster& outputRaster = *outputRasterPtr;
818 
819  while( itB != itE )
820  {
821  outputRow = itB.getRow();
822  outputCol = itB.getColumn();
823 
824  blenderInstance.getBlendedValues( outputRow, outputCol, blendedValues );
825 
826  for( outBandIdx = 0 ; outBandIdx < nBands ; ++outBandIdx )
827  {
828  double& blendedValue = blendedValues[ outBandIdx ];
829 
830  if( blendedValue != m_inputParameters.m_noDataValue )
831  {
832  blendedValue = std::max( blendedValue ,
833  mosaicBandsRangeMin[ outBandIdx ] );
834  blendedValue = std::min( blendedValue ,
835  mosaicBandsRangeMax[ outBandIdx ] );
836 
837  outputRaster.setValue( outputCol, outputRow, blendedValue, outBandIdx );
838  }
839  }
840 
841  ++itB;
842  }
843  }
844  }
845  }
846 
847  // calculating the non-overlapped image area
848 
849  std::auto_ptr< te::gm::MultiPolygon > nonOverlappedResult; // under the mosaic SRID
850 
851  {
852  std::auto_ptr< te::gm::Geometry > auxResultPtr(
853  rastersBBoxes[ inputRasterIdx ].difference( mosaicBBoxesUnionPtr.get() ) );
854 
855  if( auxResultPtr.get() )
856  {
857  auxResultPtr->setSRID( mosaicBBoxesUnionPtr->getSRID() );
858 
859  if( auxResultPtr->getGeomTypeId() == te::gm::MultiPolygonType )
860  {
861  nonOverlappedResult.reset( (te::gm::MultiPolygon*)auxResultPtr.release() );
862  }
863  else if( auxResultPtr->getGeomTypeId() == te::gm::PolygonType )
864  {
865  // transforming it into a te::gm::MultiPolygon
866  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
867  te::gm::MultiPolygonType, auxResultPtr->getSRID(), 0 );
868  auxMultiPol->add( auxResultPtr.release() );
869  nonOverlappedResult.reset( auxMultiPol );
870  }
871  }
872  else
873  {
874  // Creating a multipolygon with the current raster bounding box
875 
876  te::gm::MultiPolygon* auxMultiPol = new te::gm::MultiPolygon( 0,
877  te::gm::MultiPolygonType, rastersBBoxes[ inputRasterIdx ].getSRID(), 0 );
878  auxMultiPol->add( (te::gm::Polygon*) rastersBBoxes[ inputRasterIdx ].clone() );
879  nonOverlappedResult.reset( auxMultiPol );
880  }
881  }
882 
883  // copying each non overlaped image area
884 
885  if( nonOverlappedResult.get() )
886  {
887  te::rst::Interpolator interpInstance( inputRasterPtr,
889  const te::gm::GeometricTransformation& transformation =
890  *(eachRasterPixelToMosaicRasterPixelGeomTransfms[ inputRasterIdx - 1 ]);
891 
892  for( unsigned int inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
893  m_inputParameters.m_inputRastersBands[ inputRasterIdx ].size() ;
894  ++inputRastersBandsIdx )
895  {
896  const unsigned int inputBandIdx = m_inputParameters.m_inputRastersBands[ inputRasterIdx ][
897  inputRastersBandsIdx ];
898  te::rst::Band& outputBand = (*outputRasterPtr->getBand( inputRastersBandsIdx ));
899 
900  double outputBandRangeMin = 0;
901  double outputBandRangeMax = 0;
903  outputBandRangeMin, outputBandRangeMax );
904 
905  const std::size_t nonOverlappednResultSize =
906  nonOverlappedResult->getNumGeometries();
907  const double inputBandNoDataValue = m_inputParameters.m_forceInputNoDataValue ?
908  m_inputParameters.m_noDataValue : inputRasterPtr->getBand(
909  inputBandIdx )->getProperty()->m_noDataValue;
910 
911  for( unsigned int nonOverlappednResultIdx = 0 ; nonOverlappednResultIdx < nonOverlappednResultSize ;
912  ++nonOverlappednResultIdx )
913  {
914  te::gm::Polygon const* const nonOverlappednResultElementPtr =
915  dynamic_cast< te::gm::Polygon const* >(
916  nonOverlappedResult->getGeometryN( nonOverlappednResultIdx ) );
917  TERP_DEBUG_TRUE_OR_THROW( nonOverlappednResultElementPtr,
918  "Invalid pointer" );
919 
920  unsigned int outputRow = 0;
921  unsigned int outputCol = 0;
922  double inputRow = 0;
923  double inputCol = 0;
924  std::complex< double > pixelCValue = 0;
925  double pixelValue = 0;
926 
928  nonOverlappednResultElementPtr );
930  nonOverlappednResultElementPtr );
931 
932  while( itB != itE )
933  {
934  outputRow = itB.getRow();
935  outputCol = itB.getColumn();
936 
937  transformation.directMap( (double)outputCol, (double)outputRow, inputCol, inputRow );
938 
939  interpInstance.getValue( inputCol, inputRow, pixelCValue, inputBandIdx );
940 
941  if( pixelCValue.real() != inputBandNoDataValue )
942  {
943  pixelValue = pixelCValue.real() * currentRasterBandsScales[
944  inputRastersBandsIdx ] + currentRasterBandsOffsets[
945  inputRastersBandsIdx ];
946  pixelValue = std::max( pixelValue, outputBandRangeMin );
947  pixelValue = std::min( pixelValue, outputBandRangeMax );
948 
949  outputBand.setValue( outputCol, outputRow, pixelValue );
950  }
951 
952  ++itB;
953  }
954  }
955  }
956  }
957  }
958 
959  // moving to the next raster
960 
962  }
963 
964  return true;
965  }
966 
967  void TiePointsMosaic::reset() throw( te::rp::Exception )
968  {
970  m_isInitialized = false;
971  }
972 
974  throw( te::rp::Exception )
975  {
976  reset();
977 
978  TiePointsMosaic::InputParameters const* inputParamsPtr = dynamic_cast<
979  TiePointsMosaic::InputParameters const* >( &inputParams );
980  TERP_TRUE_OR_THROW( inputParamsPtr, "Invalid paramters pointer" );
981 
982  m_inputParameters = *inputParamsPtr;
983 
984  // Checking the feeder
985 
987  "Invalid m_feederRasterPtr" )
988 
991  "Invalid number of rasters" )
992 
993  // checking m_inputRastersBands
994 
996  ((unsigned int)m_inputParameters.m_inputRastersBands.size()) ==
998  "Bands mismatch" );
999 
1000  for( std::vector< std::vector< unsigned int > >::size_type
1001  inputRastersBandsIdx = 0 ; inputRastersBandsIdx <
1002  m_inputParameters.m_inputRastersBands.size() ; ++inputRastersBandsIdx )
1003  {
1005  inputRastersBandsIdx ].size() > 0, "Invalid bands number" );
1006 
1008  inputRastersBandsIdx ].size() == m_inputParameters.m_inputRastersBands[
1009  0 ].size(), "Bands number mismatch" );
1010  }
1011 
1012  // checking other parameters
1013 
1015  ( m_inputParameters.m_tiePoints.size() ==
1017  "Bands mismatch" );
1018 
1019  m_isInitialized = true;
1020 
1021  return true;
1022  }
1023 
1025  {
1026  return m_isInitialized;
1027  }
1028 
1030  const bool& forceNoDataValue,
1031  const double& noDataValue,
1032  double& mean, double& variance )
1033  {
1034  mean = 0;
1035  variance = 0;
1036 
1037  double internalNoDataValue = 0;
1038  if( forceNoDataValue )
1039  internalNoDataValue = noDataValue;
1040  else
1041  internalNoDataValue = band.getProperty()->m_noDataValue;
1042 
1043  const unsigned int nCols = band.getProperty()->m_blkw *
1044  band.getProperty()->m_nblocksx;
1045  const unsigned int nLines = band.getProperty()->m_blkh *
1046  band.getProperty()->m_nblocksy;
1047 
1048  double pixelsNumber = 0;
1049  double value = 0;
1050  unsigned int col = 0;
1051  unsigned int line = 0;
1052 
1053  for( line = 0 ; line < nLines ; ++line )
1054  for( col = 0 ; col < nCols ; ++col )
1055  {
1056  band.getValue( col, line, value );
1057 
1058  if( value != internalNoDataValue )
1059  {
1060  mean += value;
1061  ++pixelsNumber;
1062  }
1063  }
1064 
1065  if( pixelsNumber != 0.0 )
1066  {
1067  mean /= pixelsNumber;
1068 
1069  for( line = 0 ; line < nLines ; ++line )
1070  for( col = 0 ; col < nCols ; ++col )
1071  {
1072  band.getValue( col, line, value );
1073 
1074  if( value != internalNoDataValue )
1075  {
1076  variance += ( ( value - mean ) * ( value - mean ) ) / pixelsNumber;
1077  }
1078  }
1079 
1080  }
1081  }
1082 
1083  } // end namespace rp
1084 } // end namespace te
1085 
virtual unsigned int getObjsCount() const =0
Return the total number of feeder objects.
int m_blkh
Block height (pixels).
Definition: BandProperty.h:144
#define TERP_DEBUG_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:356
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
Definition: Geometry.h:189
static void calcBandStatistics(const te::rst::Band &band, const bool &forceNoDataValue, const double &noDataValue, double &mean, double &variance)
Raster band statistics calcule.
virtual te::rst::Raster const * getCurrentObj() const =0
Return the current sequence object.
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::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output mosaic raster.
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.
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
double y
y-coordinate.
Definition: Coord2D.h:87
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
static Raster * make()
It creates and returns an empty raster with default raster driver.
No blending performed.
Definition: Blender.h:61
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
double getResolutionY() const
Returns the grid vertical (y-axis) resolution.
Definition: Grid.cpp:261
Tie-points linking any raster to the first sequence raster (te::gm::GTParameters::TiePoint::first are...
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.
TiePointsMosaic::InputParameters m_inputParameters
Input execution parameters.
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
bool m_isInitialized
Tells if this instance is initialized.
unsigned int getNumberOfRows() const
Returns the grid number of rows.
Definition: Grid.cpp:215
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 isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
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
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
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
const OutputParameters & operator=(const OutputParameters &params)
int m_blkw
Block width (pixels).
Definition: BandProperty.h:143
std::string m_geomTransfName
The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory ...
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
double m_ury
Upper right corner y-coordinate.
Definition: Envelope.h:347
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
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.
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...
double m_urx
Upper right corner x-coordinate.
Definition: Envelope.h:346
unsigned int getColumn() const
Returns the current column in iterator.
Create a mosaic from a set of rasters using tie-points.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
const Algorithm & operator=(const Algorithm &)
Definition: Algorithm.cpp:43
const InputParameters & operator=(const InputParameters &params)
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
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
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
virtual void reset()=0
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
2D Geometric transformation base class.
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
AbstractParameters * clone() const
Create a clone copy of this instance.
A RAM cache adaptor to an external existent raster that must always be avaliable. ...
Definition: CachedRaster.h:50
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
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.
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
Definition: Grid.cpp:205
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
TiePointsLinkType m_tiePointsLinkType
The given tie points linking type, see TiePointsLinkType.
AbstractParameters * clone() const
Create a clone copy of this instance.
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
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
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
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
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
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).
Index into a lookup table.
Definition: Enums.h:57
std::vector< std::vector< te::gm::GTParameters::TiePoint > > m_tiePoints
Tie-points between each adjacent raster pair (te::gm::GTParameters::TiePoint::first are raster (with ...
void push_back(Curve *ring)
It adds the curve to the curve polygon.
Definition: CurvePolygon.h:279
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
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 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).
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