All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GeometricRefining.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/GeometricRefining.cpp
22  \brief Geometric (and positioning) correction of a already geo-referenced raster using a set of reference rasters.
23 */
24 
25 #include "GeometricRefining.h"
26 #include "../geometry/MultiPoint.h"
27 #include "../geometry/Point.h"
28 #include "../geometry/Polygon.h"
29 #include "../geometry/Envelope.h"
30 #include "../geometry/GTFactory.h"
31 #include "../geometry/GTFilter.h"
32 #include "../memory/CachedRaster.h"
33 #include "../raster/Grid.h"
34 #include "../common/progress/TaskProgress.h"
35 #include "Register.h"
36 #include "Functions.h"
37 
38 #include <limits>
39 #include <memory>
40 #include <cmath>
41 
42 #include <boost/lexical_cast.hpp>
43 
44 namespace te
45 {
46  namespace rp
47  {
48 
50  {
51  reset();
52  }
53 
55  {
56  reset();
57  operator=( other );
58  }
59 
61  {
62  reset();
63  }
64 
65  void GeometricRefining::InputParameters::reset() throw( te::rp::Exception )
66  {
67  m_inRasterPtr = 0;
68  m_inRasterBands2Process.clear();
69  m_inRasterTPLocationBands.clear();
70  m_referenceRastersPtr = 0;
71  m_referenceRastersWeights.clear();
72  m_referenceTPLocationBands.clear();
73  m_enableMultiThread = true;
74  m_enableProgress = false;
76  m_locatorParams.reset();
77  m_minInRasterCoveredAreaPercent = 25.0;
78  m_minrReferenceRasterCoveredAreaPercent = 50.0;
79  m_minrReferenceRasterRequiredTiePointsFactor = 1.5;
80  m_inRasterSubSectorsFactor = 3;
81  m_inRasterExpectedRowError = 10;
82  m_inRasterExpectedColError = 10;
83  m_inRasterExpectedRowDisplacement = 0;
84  m_inRasterExpectedColDisplacement = 0;
85  m_processAllReferenceRasters = true;
86  m_enableRasterCache = true;
87  m_geomTransfName = "Affine";
88  m_geomTransfMaxTiePointError = 2.0;
89  m_outliersRemotionAssurance = 0.75;
90  m_outliersRemotionMaxIterations = 0;
91  m_outputNoDataValue = 0.0;
92  }
93 
96  {
97  reset();
98 
99  m_inRasterPtr = params.m_inRasterPtr;
100  m_inRasterBands2Process = params.m_inRasterBands2Process;
101  m_inRasterTPLocationBands = params.m_inRasterTPLocationBands;
102  m_referenceRastersPtr = params.m_referenceRastersPtr;
103  m_referenceRastersWeights = params.m_referenceRastersWeights;
104  m_referenceTPLocationBands = params.m_referenceTPLocationBands;
105  m_enableMultiThread = params.m_enableMultiThread;
106  m_enableProgress = params.m_enableProgress;
107  m_interpMethod = params.m_interpMethod;
108  m_locatorParams = params.m_locatorParams;
109  m_minInRasterCoveredAreaPercent = params.m_minInRasterCoveredAreaPercent;
110  m_minrReferenceRasterCoveredAreaPercent = params.m_minrReferenceRasterCoveredAreaPercent;
111  m_minrReferenceRasterRequiredTiePointsFactor = params.m_minrReferenceRasterRequiredTiePointsFactor;
112  m_inRasterSubSectorsFactor = params.m_inRasterSubSectorsFactor;
113  m_inRasterExpectedRowError = params.m_inRasterExpectedRowError;
114  m_inRasterExpectedColError = params.m_inRasterExpectedColError;
115  m_inRasterExpectedRowDisplacement = params.m_inRasterExpectedRowDisplacement;
116  m_inRasterExpectedColDisplacement = params.m_inRasterExpectedColDisplacement;
117  m_processAllReferenceRasters = params.m_processAllReferenceRasters;
118  m_enableRasterCache = params.m_enableRasterCache;
119  m_geomTransfName = params.m_geomTransfName;
120  m_geomTransfMaxTiePointError = params.m_geomTransfMaxTiePointError;
121  m_outliersRemotionAssurance = params.m_outliersRemotionAssurance;
122  m_outliersRemotionMaxIterations = params.m_outliersRemotionMaxIterations;
123  m_outputNoDataValue = params.m_outputNoDataValue;
124 
125  return *this;
126  }
127 
129  {
130  return new InputParameters( *this );
131  }
132 
133  // ----------------------------------------------------------------------
134 
136  {
137  reset();
138  }
139 
141  {
142  reset();
143  operator=( other );
144  }
145 
147  {
148  reset();
149  }
150 
151  void GeometricRefining::OutputParameters::reset() throw( te::rp::Exception )
152  {
153  m_inRasterCoveredAreaPercent = 0.0;
154  m_rType.clear();
155  m_rInfo.clear();
156  m_outputRasterPtr.reset();
157  m_matchingResult.clear();
158  m_geomTransPtr.reset();
159  m_tiePoints.clear();
160  }
161 
164  {
165  reset();
166 
167  m_inRasterCoveredAreaPercent = params.m_inRasterCoveredAreaPercent;
168  m_rType = params.m_rType;
169  m_rInfo = params.m_rInfo;
170  m_matchingResult = params.m_matchingResult;
171  m_geomTransPtr.reset( params.m_geomTransPtr->clone() );
172  m_tiePoints = params.m_tiePoints;
173 
174  return *this;
175  }
176 
178  {
179  return new OutputParameters( *this );
180  }
181 
182  // ----------------------------------------------------------------------
183 
185  {
186  reset();
187  }
188 
190  {
191  }
192 
194  throw( te::rp::Exception )
195  {
196  if( ! m_isInitialized ) return false;
197 
198  GeometricRefining::OutputParameters* outParamsPtr = dynamic_cast<
199  GeometricRefining::OutputParameters* >( &outputParams );
200  TERP_TRUE_OR_THROW( outParamsPtr, "Invalid paramters" );
201 
202  outParamsPtr->m_outputRasterPtr.reset();
203 
204  {
205  outParamsPtr->m_matchingResult.resize(
207  for( unsigned int idx = 0 ; idx < outParamsPtr->m_matchingResult.size() ;
208  ++idx )
209  {
210  outParamsPtr->m_matchingResult[ idx ].m_status =
212  outParamsPtr->m_matchingResult[ idx ].m_referenceRasterIndex = idx;
213  }
214  }
215 
216 
217  // progress
218 
219  std::auto_ptr< te::common::TaskProgress > progressPtr;
221  {
222  progressPtr.reset( new te::common::TaskProgress );
223 
224  progressPtr->setTotalSteps(
226 
227  progressPtr->setMessage( "Analysing reference images" );
228  }
229 
230  // A global pointer to the Input raster
231 
232  te::rst::Raster const* inputRasterPtr = m_inputParameters.m_inRasterPtr;
233 
234  // Raster cache issues
235 
236  std::auto_ptr< te::mem::CachedRaster > inputCachedRasterPtr;
237 
239  {
240  inputCachedRasterPtr.reset( new te::mem::CachedRaster( *inputRasterPtr,
241  10, 0 ) );
242  inputRasterPtr = inputCachedRasterPtr.get();
243  }
244 
245  // splitting the reference rasters by sector
246 
247  std::vector< std::vector< unsigned int > > refRastersIndexesBySector(
250  unsigned int validReferenceRastersNumber = 0;
251 
252  {
253  // reference rasters weights
254 
255  std::vector< double > referenceRastersWeights;
257  {
258  referenceRastersWeights = m_inputParameters.m_referenceRastersWeights;
259  }
260  else
261  {
262  referenceRastersWeights.resize( m_inputParameters.m_referenceRastersPtr->getObjsCount(),
263  1.0 );
264  }
265 
266  // The search area
267 
268  const double inRasterExpectedXError = ((double)m_inputParameters.m_inRasterExpectedColError)
269  * inputRasterPtr->getResolutionX();
270  const double inRasterExpectedYError = ((double)m_inputParameters.m_inRasterExpectedRowError)
271  * inputRasterPtr->getResolutionY();
272  const double inRasterExpectedXDisplacement = ((double)m_inputParameters.m_inRasterExpectedColDisplacement)
273  * inputRasterPtr->getResolutionX();
274  const double inRasterExpectedYDisplacement = ((double)m_inputParameters.m_inRasterExpectedRowDisplacement)
275  * inputRasterPtr->getResolutionY();
276 
277  const double searchAreaMinX = inputRasterPtr->getGrid()->getExtent()->getLowerLeftX() -
278  inRasterExpectedXError + inRasterExpectedXDisplacement;
279  const double searchAreaMaxX = inputRasterPtr->getGrid()->getExtent()->getUpperRightX() +
280  inRasterExpectedXError + inRasterExpectedXDisplacement;
281 
282  const double searchAreaMinY = inputRasterPtr->getGrid()->getExtent()->getLowerLeftY() -
283  inRasterExpectedYError + inRasterExpectedYDisplacement;
284  const double searchAreaMaxY = inputRasterPtr->getGrid()->getExtent()->getUpperRightY() +
285  inRasterExpectedYError + inRasterExpectedYDisplacement;
286 
287  // Retriving each reference raster bounding boxes
288 
289  std::vector< te::gm::Envelope > selectedRefRastersBBoxes;
290  std::vector< unsigned int > selectedRefRastersIndexes;
291  te::rst::Raster const* refRasterPtr = 0;
292 
294 
295  while( ( refRasterPtr = m_inputParameters.m_referenceRastersPtr->getCurrentObj() ) )
296  {
297  te::gm::Envelope refRasterEnvelope( *refRasterPtr->getExtent() );
298 
299  // Reprojecting the reference raster bounding box, if needed
300 
301  if( refRasterPtr->getSRID() != inputRasterPtr->getSRID() )
302  {
303  refRasterEnvelope.transform( refRasterPtr->getSRID(),
304  inputRasterPtr->getSRID() );
305  }
306 
307  if(
308  ( refRasterEnvelope.getLowerLeftX() > searchAreaMinX )
309  && ( refRasterEnvelope.getLowerLeftX() < searchAreaMaxX )
310  && ( refRasterEnvelope.getUpperRightX() > searchAreaMinX )
311  && ( refRasterEnvelope.getUpperRightX() < searchAreaMaxX )
312  && ( refRasterEnvelope.getLowerLeftY() > searchAreaMinY )
313  && ( refRasterEnvelope.getLowerLeftY() < searchAreaMaxY )
314  && ( refRasterEnvelope.getUpperRightY() > searchAreaMinY )
315  && ( refRasterEnvelope.getUpperRightY() < searchAreaMaxY )
316  )
317  {
318  selectedRefRastersBBoxes.push_back( refRasterEnvelope );
319  selectedRefRastersIndexes.push_back(
321  ++validReferenceRastersNumber;
322  }
323 
324  // Moving to the next reference raster
325 
327 
328  // Progress
329 
331  {
332  progressPtr->pulse();
333  if( ! progressPtr->isActive() ) return false;
334  }
335  }
336 
337  // defining sectors
338 
339  double sectoXSize = ( searchAreaMaxX - searchAreaMinX ) /
341  double sectoYSize = ( searchAreaMaxY - searchAreaMinY ) /
343 
344  te::gm::Coord2D center;
345  unsigned int sectoXOff = 0;
346  unsigned int sectoYOff = 0;
347  unsigned int refRastersIndexesBySectorIdx = 0;
348 
349  for( unsigned int selectedRefRastersBBoxesIdx = 0 ; selectedRefRastersBBoxesIdx <
350  selectedRefRastersBBoxes.size() ; ++selectedRefRastersBBoxesIdx )
351  {
352  center = selectedRefRastersBBoxes[ selectedRefRastersBBoxesIdx ].getCenter();
353  sectoXOff = (unsigned int)std::floor( ( center.x - searchAreaMinX ) / sectoXSize );
354  sectoYOff = (unsigned int)std::floor( ( center.y - searchAreaMinY ) / sectoYSize );
355 
356  refRastersIndexesBySectorIdx = ( sectoYOff * m_inputParameters.m_inRasterSubSectorsFactor ) +
357  sectoXOff;
358  assert( refRastersIndexesBySectorIdx < refRastersIndexesBySector.size() );
359 
360  refRastersIndexesBySector[ refRastersIndexesBySectorIdx ].push_back(
361  selectedRefRastersIndexes[ selectedRefRastersBBoxesIdx ] );
362  }
363 
364  // sorting the rasters inside each sector by the given weights
365  // the first reference raster with higher weight
366 
367  unsigned int sectorRastersIndexesIdx = 0;
368  unsigned int sectorRastersIndexesIdxBound = 0;
369  unsigned int sectorRastersIndexesNextIdx = 0;
370  unsigned int rasterIdx = 0;
371  unsigned int nextRasterIdx = 0;
372 
373  for( refRastersIndexesBySectorIdx = 0 ; refRastersIndexesBySectorIdx <
374  refRastersIndexesBySector.size() ; ++refRastersIndexesBySectorIdx )
375  {
376  std::vector< unsigned int >& sectorRastersIndexes =
377  refRastersIndexesBySector[ refRastersIndexesBySectorIdx ];
378 
379  if( sectorRastersIndexes.size() > 1 )
380  {
381  sectorRastersIndexesIdxBound = sectorRastersIndexes.size() - 1;
382 
383  while( sectorRastersIndexesIdxBound != 0 )
384  {
385  for( sectorRastersIndexesIdx = 0 ; sectorRastersIndexesIdx <
386  sectorRastersIndexesIdxBound ; ++sectorRastersIndexesIdx )
387  {
388  sectorRastersIndexesNextIdx = sectorRastersIndexesIdx + 1;
389 
390  rasterIdx = sectorRastersIndexes[ sectorRastersIndexesIdx ];
391  nextRasterIdx = sectorRastersIndexes[ sectorRastersIndexesNextIdx ];
392 
393  if(
394  referenceRastersWeights[ rasterIdx ]
395  <
396  referenceRastersWeights[ nextRasterIdx ]
397  )
398  {
399  sectorRastersIndexes[ sectorRastersIndexesIdx ] = nextRasterIdx;
400  sectorRastersIndexes[ sectorRastersIndexesNextIdx ] = rasterIdx;
401  }
402  }
403 
404  --sectorRastersIndexesIdxBound;
405  }
406  }
407  }
408  }
409 
410  // matching the reference rasters
411 
413  {
414  progressPtr.reset();
415  progressPtr.reset( new te::common::TaskProgress );
416 
417  progressPtr->setTotalSteps( validReferenceRastersNumber );
418 
419  progressPtr->setMessage( "Matching reference images" );
420  }
421 
422  outParamsPtr->m_geomTransPtr.reset( te::gm::GTFactory::make(
424  if( outParamsPtr->m_geomTransPtr.get() == 0 )
425  {
426  return false;
427  }
428  const unsigned int minimumRequiredTiePointsNumber = (unsigned int)
429  (
431  *
432  ((double)outParamsPtr->m_geomTransPtr->getMinRequiredTiePoints() )
433  );
434  outParamsPtr->m_geomTransPtr.reset();
435 
436  std::vector< InternalMatchingInfo > refRastersMatchingInfo;
437 
438  bool continueOnLoop = true;
439 
440  while( continueOnLoop )
441  {
442  bool aRefRasterWasProcessed = false;
443 
444  for( unsigned int refRastersIndexesBySectorIdx = 0 ; refRastersIndexesBySectorIdx <
445  refRastersIndexesBySector.size() ; ++refRastersIndexesBySectorIdx )
446  {
447  std::vector< unsigned int >& sector =
448  refRastersIndexesBySector[ refRastersIndexesBySectorIdx ];
449 
450  for( unsigned int sectorIdx = 0 ; sectorIdx < sector.size() ; ++sectorIdx )
451  {
452  const unsigned int refRasterIdx = sector[ sectorIdx ];
453 
454  if( refRasterIdx < m_inputParameters.m_referenceRastersPtr->getObjsCount() )
455  {
456  // Mark the reference raster as processed
457 
458  sector[ sectorIdx ] = std::numeric_limits< unsigned int >::max();
459 
460  aRefRasterWasProcessed = true;
461 
462  // open the reference raster
463 
465  "Rasters feeder mover error" );
466 
467  te::rst::Raster const* refRasterPtr =
469 
470  // Reprojection issues
471 
472 /* te::rp::Copy2DiskRaster( *refRasterPtr, "refRaster_" +
473  boost::lexical_cast< std::string >( refRasterIdx ) + ".tif" ); */
474 
475  std::auto_ptr< te::rst::Raster > reprojectedRefRasterPtr;
476 
477  if( inputRasterPtr->getSRID() != refRasterPtr->getSRID() )
478  {
479  std::map< std::string, std::string > rInfo;
480  rInfo[ "FORCE_MEM_DRIVER" ] = "TRUE";
481 
482  reprojectedRefRasterPtr.reset( refRasterPtr->transform(
483  inputRasterPtr->getSRID(), rInfo, te::rst::Interpolator::NearestNeighbor ) );
484 
485  TERP_TRUE_OR_RETURN_FALSE( reprojectedRefRasterPtr.get(),
486  "Raster reprojection error" );
487 
488  refRasterPtr = reprojectedRefRasterPtr.get();
489  }
490 
491 // te::rp::Copy2DiskRaster( *refRasterPtr, "refRaster_" +
492 // boost::lexical_cast< std::string >( refRasterIdx ) + "_reprojected.tif" );
493 
494  // The reference image position over the input image
495 
496  const double searchAreaULX = refRasterPtr->getGrid()->getExtent()->getLowerLeftX();
497  const double searchAreaULY = refRasterPtr->getGrid()->getExtent()->getUpperRightY();
498 
499  // The search area over the input image
500 
501  double searchAreaULRow = 0;
502  double searchAreaULCol = 0;
503  inputRasterPtr->getGrid()->geoToGrid( searchAreaULX, searchAreaULY, searchAreaULCol, searchAreaULRow );
504 
505  double searchAreaLRRow = searchAreaULRow - 1.0 + ((double)refRasterPtr->getNumberOfRows());
506  double searchAreaLRCol = searchAreaULCol - 1.0 + ((double)refRasterPtr->getNumberOfColumns());
507 
508  searchAreaULRow += ((double)m_inputParameters.m_inRasterExpectedRowDisplacement);
509  searchAreaULRow -= ((double)m_inputParameters.m_inRasterExpectedRowError);
510  searchAreaULRow = std::max( 0.0, searchAreaULRow );
511  searchAreaULRow = std::min( searchAreaULRow, (double)( inputRasterPtr->getNumberOfRows() - 1 ) );
512 
513  searchAreaLRRow += ((double)m_inputParameters.m_inRasterExpectedRowDisplacement);
514  searchAreaLRRow += ((double)m_inputParameters.m_inRasterExpectedRowError);
515  searchAreaLRRow = std::max( 0.0, searchAreaLRRow );
516  searchAreaLRRow = std::min( searchAreaLRRow, (double)( inputRasterPtr->getNumberOfRows() - 1 ) );
517 
518  searchAreaULCol += ((double)m_inputParameters.m_inRasterExpectedColDisplacement);
519  searchAreaULCol -= ((double)m_inputParameters.m_inRasterExpectedColError);
520  searchAreaULCol = std::max( 0.0, searchAreaULCol );
521  searchAreaULCol = std::min( searchAreaULCol, (double)( inputRasterPtr->getNumberOfColumns() - 1 ) );
522 
523  searchAreaLRCol += ((double)m_inputParameters.m_inRasterExpectedColDisplacement);
524  searchAreaLRCol += ((double)m_inputParameters.m_inRasterExpectedColError);
525  searchAreaLRCol = std::max( 0.0, searchAreaLRCol );
526  searchAreaLRCol = std::min( searchAreaLRCol, (double)( inputRasterPtr->getNumberOfColumns() - 1 ) );
527 
528  const unsigned int searchAreaWidth = (unsigned int)( searchAreaLRCol - searchAreaULCol + 1.0 );
529  const unsigned int searchAreaHeight = (unsigned int)( searchAreaLRRow - searchAreaULRow + 1.0 );
530 
531  if( ( searchAreaWidth > 1 ) && ( searchAreaHeight > 1 ) )
532  {
533  outParamsPtr->m_matchingResult[ refRasterIdx ].m_searchAreaRowStart = (unsigned int)
534  searchAreaULRow;
535  outParamsPtr->m_matchingResult[ refRasterIdx ].m_searchAreaColStart = (unsigned int)
536  searchAreaULCol;
537 
538  outParamsPtr->m_matchingResult[ refRasterIdx ].m_searchAreaWidth =
539  searchAreaWidth;
540  outParamsPtr->m_matchingResult[ refRasterIdx ].m_searchAreaHeigh =
541  searchAreaHeight;
542 
543  // Matching the reference image
544 
545  te::rp::TiePointsLocator::InputParameters locatorInputParams =
547  locatorInputParams.m_inRaster1Ptr = inputRasterPtr;
548  locatorInputParams.m_inMaskRaster1Ptr = 0;
550  locatorInputParams.m_raster1TargetAreaLineStart = (unsigned int)searchAreaULRow;
551  locatorInputParams.m_raster1TargetAreaColStart = (unsigned int)searchAreaULCol;
552  locatorInputParams.m_raster1TargetAreaWidth = searchAreaWidth;
553  locatorInputParams.m_raster1TargetAreaHeight = searchAreaHeight;
554  locatorInputParams.m_inRaster2Ptr = refRasterPtr;
555  locatorInputParams.m_inMaskRaster2Ptr = 0;
556  locatorInputParams.m_inRaster2Bands =
558  locatorInputParams.m_raster2TargetAreaLineStart = 0;
559  locatorInputParams.m_raster2TargetAreaColStart = 0;
560  locatorInputParams.m_raster2TargetAreaWidth = 0;
561  locatorInputParams.m_raster2TargetAreaHeight = 0;
563  locatorInputParams.m_enableProgress = false;
564  locatorInputParams.m_pixelSizeXRelation = inputRasterPtr->getResolutionX() /
565  refRasterPtr->getResolutionX();
566  locatorInputParams.m_pixelSizeYRelation = inputRasterPtr->getResolutionY() /
567  refRasterPtr->getResolutionY();
570  locatorInputParams.m_maxR1ToR2Offset = 0;
571  locatorInputParams.m_enableGeometryFilter = true;
573 
574  te::rp::TiePointsLocator locator;
575 
576  if( locator.initialize( locatorInputParams ) )
577  {
578  te::rp::TiePointsLocator::OutputParameters locatorOutputParams;
579 
580  if( locator.execute( locatorOutputParams ) )
581  {
582  if(
583  ( locatorOutputParams.m_transformationPtr.get() != 0 )
584  &&
585  (
586  locatorOutputParams.m_tiePoints.size()
587  >=
588  minimumRequiredTiePointsNumber
589  )
590  )
591  {
592  const double convexHullAreaPercent =
593  (
594  getTPConvexHullArea( locatorOutputParams.m_tiePoints, true )
595  /
596  (double)
597  (
598  refRasterPtr->getNumberOfColumns()
599  *
600  refRasterPtr->getNumberOfRows()
601  )
602  );
603 
604  if( ( 100.0 * convexHullAreaPercent ) >=
606  {
607  InternalMatchingInfo matchingInfo;
608  matchingInfo.m_referenceRasterIndex = refRasterIdx;
609  matchingInfo.m_convexHullAreaPercent = convexHullAreaPercent;
610 
612  for( unsigned int tpIdx = 0 ; tpIdx < locatorOutputParams.m_tiePoints.size() ;
613  ++tpIdx )
614  {
615  tiePoint.first.x = locatorOutputParams.m_tiePoints[ tpIdx ].first.x;
616  tiePoint.first.y = locatorOutputParams.m_tiePoints[ tpIdx ].first.y;
617 
618  refRasterPtr->getGrid()->gridToGeo(
619  locatorOutputParams.m_tiePoints[ tpIdx ].second.x,
620  locatorOutputParams.m_tiePoints[ tpIdx ].second.y,
621  tiePoint.second.x,
622  tiePoint.second.y );
623 
624  matchingInfo.m_tiePoints.push_back( tiePoint );
625  outParamsPtr->m_matchingResult[ refRasterIdx ].m_tiePoints.push_back(
626  tiePoint );
627  }
628 
629  refRastersMatchingInfo.push_back( matchingInfo );
630 
631  outParamsPtr->m_matchingResult[ refRasterIdx ].m_status =
633  }
634  else
635  {
637  for( unsigned int tpIdx = 0 ; tpIdx < locatorOutputParams.m_tiePoints.size() ;
638  ++tpIdx )
639  {
640  tiePoint.first.x = locatorOutputParams.m_tiePoints[ tpIdx ].first.x;
641  tiePoint.first.y = locatorOutputParams.m_tiePoints[ tpIdx ].first.y;
642 
643  refRasterPtr->getGrid()->gridToGeo(
644  locatorOutputParams.m_tiePoints[ tpIdx ].second.x,
645  locatorOutputParams.m_tiePoints[ tpIdx ].second.y,
646  tiePoint.second.x,
647  tiePoint.second.y );
648 
649  outParamsPtr->m_matchingResult[ refRasterIdx ].m_tiePoints.push_back(
650  tiePoint );
651  }
652 
653  outParamsPtr->m_matchingResult[ refRasterIdx ].m_status =
655  }
656 
657  double ulCol = 0;
658  double ulRow = 0;
659  locatorOutputParams.m_transformationPtr->inverseMap(
660  0.0, 0.0, ulCol, ulRow );
661 
662  double lrCol = 0;
663  double lrRow = 0;
664  locatorOutputParams.m_transformationPtr->inverseMap(
665  (double)( refRasterPtr->getNumberOfColumns() - 1 ),
666  (double)( refRasterPtr->getNumberOfRows() - 1 ), lrCol, lrRow );
667 
668  outParamsPtr->m_matchingResult[ refRasterIdx ].m_matchedPositionRowStart =
669  (unsigned int)std::min( ulRow, lrRow );
670  outParamsPtr->m_matchingResult[ refRasterIdx ].m_matchedPositionColStart =
671  (unsigned int)std::min( ulCol, lrCol );
672 
673  outParamsPtr->m_matchingResult[ refRasterIdx ].m_matchedPositionWidth =
674  (unsigned int)std::abs( lrCol - ulCol );
675  outParamsPtr->m_matchingResult[ refRasterIdx ].m_matchedPositionHeight =
676  (unsigned int)std::abs( lrRow - ulRow );
677  }
678  else
679  {
680  outParamsPtr->m_matchingResult[ refRasterIdx ].m_tiePoints =
681  locatorOutputParams.m_tiePoints;
682  outParamsPtr->m_matchingResult[ refRasterIdx ].m_status =
684  }
685  }
686  else
687  {
688  outParamsPtr->m_matchingResult[ refRasterIdx ].m_status =
690  }
691  }
692  else
693  {
694  outParamsPtr->m_matchingResult[ refRasterIdx ].m_status =
696  }
697  }
698  else
699  {
700  outParamsPtr->m_matchingResult[ refRasterIdx ].m_status =
702  }
703 
704  //skip to the next sector
705 
706  sectorIdx = sector.size();
707 
708  // Finding the tie-points in agreement with the choosen geometric transformation model
709 
711  {
712  if( getTransformation( refRastersMatchingInfo, outParamsPtr->m_geomTransPtr,
713  outParamsPtr->m_tiePoints, outParamsPtr->m_inRasterCoveredAreaPercent ) )
714  {
715  // No need to precess more reference rasters
716  // Break the loop
717 
718  refRastersIndexesBySectorIdx = refRastersIndexesBySector.size();
719  continueOnLoop = false;
720  }
721  }
722 
723  // Progress
724 
726  {
727  progressPtr->pulse();
728  if( ! progressPtr->isActive() ) return false;
729  }
730  }
731  }
732  }
733 
734  if( ! aRefRasterWasProcessed )
735  {
736  continueOnLoop = false;
737  }
738  }
739 
740  // Finding the tie-points in agreement with the choosen geometric transformation model
741 
743  {
744  if( ! getTransformation( refRastersMatchingInfo, outParamsPtr->m_geomTransPtr,
745  outParamsPtr->m_tiePoints, outParamsPtr->m_inRasterCoveredAreaPercent ) )
746  {
747  return false;
748  }
749  }
750  else
751  {
752 
753  if( outParamsPtr->m_geomTransPtr.get() == 0 )
754  {
755  return false;
756  }
757  }
758 
759  // Generating the refined output raster
760 
762  regInParams.m_inputRasterPtr = inputRasterPtr;
764  regInParams.m_tiePoints.clear();
765  regInParams.m_outputSRID = inputRasterPtr->getSRID();
766  regInParams.m_outputResolutionX = inputRasterPtr->getResolutionX();
767  regInParams.m_outputResolutionY = inputRasterPtr->getResolutionY();
770  regInParams.m_geomTransfName.clear();
771  regInParams.m_geomTransfPtr = outParamsPtr->m_geomTransPtr.get();
772 
774  regOutParams.m_rType = outParamsPtr->m_rType;
775  regOutParams.m_rInfo = outParamsPtr->m_rInfo;
776 
777  te::rp::Register registerInstance;
778 
779  if( ! registerInstance.initialize( regInParams ) )
780  {
781  return false;
782  }
783 
784  if( ! registerInstance.execute( regOutParams ) )
785  {
786  return false;
787  }
788 
789  outParamsPtr->m_outputRasterPtr.reset( regOutParams.m_outputRasterPtr.release() );
790 
791  return true;
792  }
793 
794  void GeometricRefining::reset() throw( te::rp::Exception )
795  {
797  m_isInitialized = false;
798  }
799 
801  throw( te::rp::Exception )
802  {
803  reset();
804 
805  GeometricRefining::InputParameters const* inputParamsPtr = dynamic_cast<
806  GeometricRefining::InputParameters const* >( &inputParams );
807  TERP_TRUE_OR_THROW( inputParamsPtr, "Invalid paramters pointer" );
808 
809  m_inputParameters = *inputParamsPtr;
810 
811  // checking input raster
812 
814  "Invalid raster pointer" );
815 
818  "Invalid raster" );
819 
820  // Checking input raster bands
821 
822  for( unsigned int inRasterBands2ProcessIdx = 0 ; inRasterBands2ProcessIdx <
824  ++inRasterBands2ProcessIdx )
825  {
827  inRasterBands2ProcessIdx ] < m_inputParameters.m_inRasterPtr->getNumberOfBands(),
828  "Invalid raster bands" );
829  }
830 
831  for( unsigned int inRasterTPLocationBandsIdx = 0 ; inRasterTPLocationBandsIdx <
833  ++inRasterTPLocationBandsIdx )
834  {
836  inRasterTPLocationBandsIdx ] < m_inputParameters.m_inRasterPtr->getNumberOfBands(),
837  "Invalid raster bands" );
838  }
839 
840  // Checking the feeder
841 
843  "Invalid reference rasters feeder pointer" )
844 
847  "Invalid number of reference rasters" )
848 
849  // Checking reference rasters weights
850 
855  "Invalid reference rasters weights" );
856 
857  // checking other parameters
858 
862  "Invalid parameter m_minRasterCoveredAreaPercent" );
863 
867  "Invalid parameter m_minrReferenceRasterCoveredAreaPercent" );
868 
871  "Invalid parameter m_minrReferenceRasterRequiredTiePointsFactor" );
872 
875  "Invalid parameter m_rasterSubSectorsFactor" );
876 
879  "Invalid parameter m_inRasterRowMaxError" );
880 
883  "Invalid parameter m_inRasterColMaxError" );
884 
885  m_isInitialized = true;
886 
887  return true;
888  }
889 
891  {
892  return m_isInitialized;
893  }
894 
896  const std::vector< InternalMatchingInfo >& inTiePoints,
897  std::vector< te::gm::GTParameters::TiePoint >& outTiePoints,
898  std::vector< double >& outTiePointsWeights ) const
899  {
900  outTiePoints.clear();
901  outTiePointsWeights.clear();
902 
903  // Guessing limits
904 
905  std::auto_ptr< te::gm::GeometricTransformation > baseGeometricTransformPtr(
907  TERP_DEBUG_TRUE_OR_THROW( baseGeometricTransformPtr.get(), "Invalid transformation" );
908 
909  const unsigned int minimumRequiredTiePointsNumber = (unsigned int)
910  (
912  *
913  ((double)baseGeometricTransformPtr->getMinRequiredTiePoints() )
914  );
915 
916  double referenceImagesWeightsMin = std::numeric_limits< double >::max();
917  double referenceImagesWeightsMax = -1.0 * referenceImagesWeightsMin;
918  unsigned int inTiePointsIdx = 0;
919  unsigned int mInfoTiePointsIdx = 0;
920  double minTPNumberByRefRaster = std::numeric_limits< double >::max();
921  double maxTPNumberByRefRaster = -1.0 * minTPNumberByRefRaster;
922  double minConvexHullAreaPercentByRefRaster = std::numeric_limits< double >::max();
923  double maxConvexHullAreaPercentByRefRaster = -1.0 * minConvexHullAreaPercentByRefRaster;
924  double realTiePointsNumber = 0;
925 
926  for( inTiePointsIdx = 0 ; inTiePointsIdx < inTiePoints.size() ; ++inTiePointsIdx )
927  {
928  const InternalMatchingInfo& mInfo = inTiePoints[ inTiePointsIdx ];
929 
930  realTiePointsNumber = (double)( mInfo.m_tiePoints.size() - minimumRequiredTiePointsNumber );
931 
932  if( minTPNumberByRefRaster > realTiePointsNumber )
933  {
934  minTPNumberByRefRaster = realTiePointsNumber;
935  }
936 
937  if( maxTPNumberByRefRaster < realTiePointsNumber )
938  {
939  maxTPNumberByRefRaster = realTiePointsNumber;
940  }
941 
942  if( minConvexHullAreaPercentByRefRaster > mInfo.m_convexHullAreaPercent )
943  {
944  minConvexHullAreaPercentByRefRaster = mInfo.m_convexHullAreaPercent;
945  }
946 
947  if( maxConvexHullAreaPercentByRefRaster < mInfo.m_convexHullAreaPercent )
948  {
949  maxConvexHullAreaPercentByRefRaster = mInfo.m_convexHullAreaPercent;
950  }
951 
953  {
954  if( referenceImagesWeightsMin >
956  {
957  referenceImagesWeightsMin =
959  }
960 
961  if( referenceImagesWeightsMax <
963  {
964  referenceImagesWeightsMax =
966  }
967  }
968  }
969 
970  double weight = 0;
971  const double convexHullAreaPercentGain = ( maxConvexHullAreaPercentByRefRaster ==
972  minConvexHullAreaPercentByRefRaster ) ? 0.0 :
973  1.0 / ( maxConvexHullAreaPercentByRefRaster - minConvexHullAreaPercentByRefRaster );
974  const double convexHullAreaPercentOffset = (convexHullAreaPercentGain == 0.0 ) ?
975  1.0 : -1.0 * minConvexHullAreaPercentByRefRaster;
976  const double tiePointsNumberGain = ( maxTPNumberByRefRaster ==
977  minTPNumberByRefRaster ) ? 0.0 :
978  1.0 / ( maxTPNumberByRefRaster - minTPNumberByRefRaster );
979  const double tiePointsNumberOffset = ( tiePointsNumberGain == 0.0 ) ? 1.0 : -1.0 * minTPNumberByRefRaster;
980 
981  double referenceImagesWeightsGain = 0.0;
982  double referenceImagesWeightsOffset = 0.0;
984  {
985  referenceImagesWeightsGain = ( referenceImagesWeightsMax ==
986  referenceImagesWeightsMin ) ? 0.0 :
987  1.0 / ( referenceImagesWeightsMax - referenceImagesWeightsMin );
988  referenceImagesWeightsOffset = (referenceImagesWeightsGain == 0.0 ) ?
989  1.0 : -1.0 * referenceImagesWeightsMin;
990  }
991 
992  for( inTiePointsIdx = 0 ; inTiePointsIdx < inTiePoints.size() ; ++inTiePointsIdx )
993  {
994  const InternalMatchingInfo& mInfo = inTiePoints[ inTiePointsIdx ];
995 
996  realTiePointsNumber = (double)( mInfo.m_tiePoints.size() - minimumRequiredTiePointsNumber );
997 
998  weight =
999  (
1000  (
1001  ( mInfo.m_convexHullAreaPercent + convexHullAreaPercentOffset )
1002  *
1003  convexHullAreaPercentGain
1004  )
1005  +
1006  (
1007  ( realTiePointsNumber + tiePointsNumberOffset )
1008  *
1009  tiePointsNumberGain
1010  )
1011  +
1012  (
1014  ?
1015  (
1016  1.0
1017  )
1018  :
1019  (
1020  (
1022  +
1023  referenceImagesWeightsOffset
1024  )
1025  *
1026  referenceImagesWeightsGain
1027  )
1028  )
1029  )
1030  /
1031  3.0;
1032 
1033  for( mInfoTiePointsIdx = 0 ; mInfoTiePointsIdx < mInfo.m_tiePoints.size() ;
1034  ++mInfoTiePointsIdx )
1035  {
1036  outTiePoints.push_back( mInfo.m_tiePoints[ mInfoTiePointsIdx ] );
1037  outTiePointsWeights.push_back( weight );
1038  }
1039  }
1040  }
1041 
1043  const std::vector< te::gm::GTParameters::TiePoint >& tiePoints,
1044  const bool useTPSecondCoordPair ) const
1045  {
1046  std::auto_ptr< te::gm::Surface > convexHullPtr;
1047  if( !getTPConvexHull( tiePoints, useTPSecondCoordPair, convexHullPtr ) )
1048  {
1049  return 0.0;
1050  }
1051  else
1052  {
1053  return convexHullPtr->getArea();
1054  }
1055  }
1056 
1058  const std::vector< te::gm::GTParameters::TiePoint >& tiePoints,
1059  const bool useTPSecondCoordPair,
1060  std::auto_ptr< te::gm::Surface >& convexHullPtr ) const
1061  {
1062  if( tiePoints.size() < 3 )
1063  {
1064  return false;
1065  }
1066  else
1067  {
1069 
1070  for( unsigned int tiePointsIdx = 0 ; tiePointsIdx < tiePoints.size() ;
1071  ++tiePointsIdx )
1072  {
1073  if( useTPSecondCoordPair )
1074  points.add( new te::gm::Point( tiePoints[ tiePointsIdx ].second.x,
1075  tiePoints[ tiePointsIdx ].second.y ) );
1076  else
1077  points.add( new te::gm::Point( tiePoints[ tiePointsIdx ].first.x,
1078  tiePoints[ tiePointsIdx ].first.y ) );
1079  }
1080 
1081  std::auto_ptr< te::gm::Geometry > geomPtr( points.convexHull() );
1082 
1083  if( dynamic_cast< te::gm::Surface* >( geomPtr.get() ) )
1084  {
1085  convexHullPtr.reset(
1086  dynamic_cast< te::gm::Surface* >( geomPtr.release() ) );
1087  return true;
1088  }
1089  else
1090  {
1091  return false;
1092  }
1093  }
1094  }
1095 
1096  bool GeometricRefining::getTransformation( const std::vector< InternalMatchingInfo >& inTiePoints,
1097  std::auto_ptr< te::gm::GeometricTransformation >& geometricTransformPtr,
1098  std::vector< te::gm::GTParameters::TiePoint >& baseTransAgreementTiePoints,
1099  double& convexHullAreaPercent ) const
1100  {
1101  geometricTransformPtr.reset();
1102  baseTransAgreementTiePoints.clear();
1103  convexHullAreaPercent = 0.0;
1104 
1105  te::gm::GTParameters geoTransParams;
1106  std::vector< double > tiePointsWeights;
1107  convert( inTiePoints, geoTransParams.m_tiePoints, tiePointsWeights );
1108 
1109  te::gm::GTFilter filter;
1110 
1111  if(
1112  ! filter.applyRansac(
1114  geoTransParams,
1115  (
1117  *
1118  (
1119  std::min(
1122  )
1123  )
1124  ),
1129  tiePointsWeights,
1130  baseTransAgreementTiePoints,
1131  geometricTransformPtr
1132  )
1133  )
1134  {
1135  geometricTransformPtr.reset();
1136  baseTransAgreementTiePoints.clear();
1137  return false;
1138  }
1139 
1140  convexHullAreaPercent =
1141  (
1142  100.0
1143  *
1144  getTPConvexHullArea( baseTransAgreementTiePoints, false )
1145  /
1146  (double)
1147  (
1149  *
1151  )
1152  );
1153 
1154  if( convexHullAreaPercent >= m_inputParameters.m_minInRasterCoveredAreaPercent )
1155  {
1156  return true;
1157  }
1158  else
1159  {
1160  geometricTransformPtr.reset();
1161  baseTransAgreementTiePoints.clear();
1162  return false;
1163  }
1164  }
1165 
1166  } // end namespace rp
1167 } // end namespace te
1168 
1169 
unsigned int m_inRasterExpectedColError
The expected column position error for the given input raster (pixels units), default value:10...
virtual unsigned int getObjsCount() const =0
Return the total number of feeder objects.
double m_outputNoDataValue
The pixel value used where no output raster data is avaliable (defaul:0).
Register input parameters.
Definition: Register.h:56
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
Definition: Raster.cpp:104
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The generated tie-pionts (te::gm::GTParameters::TiePoint::first are raster 1 line/column indexes...
double m_geomTransfMaxError
The maximum allowed transformation error (pixel units, default:2).
bool m_enableGeometryFilter
Enable/disable the geometry filter/outliers remotion (default:true).
bool getTransformation(const std::vector< InternalMatchingInfo > &inTiePoints, std::auto_ptr< te::gm::GeometricTransformation > &baseGeometricTransformPtr, std::vector< te::gm::GTParameters::TiePoint > &baseTransAgreementTiePoints, double &convexHullAreaPercent) const
Try to instantiate a valid geometric transformation following the user parameters.
std::vector< TiePoint > m_tiePoints
Tie points.
Definition: GTParameters.h:95
bool m_enableProgress
Enable/Disable the progress interface (default:false).
double y
y-coordinate.
Definition: Coord2D.h:87
te::rst::Raster const * m_inputRasterPtr
Input raster.
Definition: Register.h:60
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
Definition: Register.cpp:149
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
double m_pixelSizeXRelation
The pixel resolution relation m_pixelSizeXRelation = raster1_pixel_res_x / raster2_pixel_res_x (defau...
double m_inRasterCoveredAreaPercent
The area percent (from the input raster ) covered by tie-points - valid range [0,100].
double m_minrReferenceRasterCoveredAreaPercent
The mininumum required area percent (from each reference raster ) covered by tie-points - valid range...
double x
x-coordinate.
Definition: Coord2D.h:86
int m_inRasterExpectedRowDisplacement
The expected input raster row displacement (pixel units, default:0)
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Definition: Raster.cpp:213
Performs raster data registering into a SRS using a set of tie points.
double m_geomTransfMaxTiePointError
The maximum allowed tie-point error (pixels unit, default: 2);.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:410
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
te::rst::Raster const * m_inRaster2Ptr
Input raster 2.
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
TiePointsLocator input parameters.
Raster Processing algorithm output parameters base interface.
unsigned int m_raster1TargetAreaLineStart
The first line of the raster 1 target area to process (default:0 - The entire raster will be consider...
double m_minInRasterCoveredAreaPercent
The mininumum required area percent (from the input raster ) covered by tie-points - valid range [0...
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
Definition: Envelope.h:400
te::rst::Raster const * m_inRasterPtr
Input raster pointer.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
Definition: Envelope.h:420
double m_outputResolutionY
The output raster Y axis resolution (default:1).
Definition: Register.h:70
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
std::pair< Coord2D, Coord2D > TiePoint
Tie point type definition.
Definition: GTParameters.h:59
2D Geometric transformation tie-points filter (outliers remotion).
Definition: GTFilter.h:52
unsigned int m_raster2TargetAreaWidth
The raster 2 target area width (default:0 - The entire raster will be considered).
void convert(const std::vector< InternalMatchingInfo > &inTiePoints, std::vector< te::gm::GTParameters::TiePoint > &outTiePoints, std::vector< double > &outTiePointsWeights) const
Convesion from matching infor tie-points to a vector of tie-points.
te::gm::GeometricTransformation const * m_geomTransfPtr
An optional pointer to a valid geometric transformation instance (direct mapping raster lines/columns...
Definition: Register.h:78
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
Raster Processing functions.
unsigned int m_raster2TargetAreaLineStart
The first line of the raster 2 target area to process (default:0 - The entire raster will be consider...
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
Tie-points between each raster point (te::gm::GTParameters::TiePoint::first are raster lines/columns ...
Definition: Register.h:64
#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
const Algorithm & operator=(const Algorithm &)
Definition: Algorithm.cpp:43
Geometric (and positioning) correction of a already geo-referenced raster using a set of reference ra...
bool m_enableMultiThread
Enable/Disable the use of threads (default:true).
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
Definition: Raster.cpp:89
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
std::auto_ptr< te::gm::GeometricTransformation > m_geomTransPtr
The geometric transformation (direct mapping raster lines/cols to input raster corrected world coords...
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
Definition: Register.cpp:333
std::vector< unsigned int > m_inRaster2Bands
Bands to be used from the input raster 2.
bool applyRansac(const std::string &transfName, const GTParameters &inputParams, const double maxDirectMapError, const double maxInverseMapError, const RansacItCounterT &maxIterations, const double &assurance, const bool enableMultiThread, const std::vector< double > &tiePointsWeights, std::vector< te::gm::GTParameters::TiePoint > &outTiePoints, std::auto_ptr< GeometricTransformation > &outTransf)
Apply a RANSAC based outliers remotion strategy.
Definition: GTFilter.cpp:199
te::rst::Raster const * m_inRaster1Ptr
Input raster 1.
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Definition: Register.h:74
std::vector< std::vector< unsigned int > > m_referenceTPLocationBands
Reference rasters bands used for tie-points location.
virtual bool moveTo(const unsigned int index)=0
Jump to the given object index.
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
A pointer the generated output raster.
bool m_isInitialized
Tells if this instance is initialized.
std::vector< double > m_referenceRastersWeights
A vector of weights for each reference raster, or an empty vector if all reference rasters have the s...
AbstractParameters * clone() const
Create a clone copy of this instance.
A point with x and y coordinate values.
Definition: Point.h:50
virtual void reset()=0
Reset the feeder to the first position (subsequent accesses will start from the first sequence obejct...
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
std::auto_ptr< te::gm::GeometricTransformation > m_transformationPtr
The generated geometric transformation with the base mininum required tie-points set ( depending on t...
An abstract class for raster data strucutures.
Definition: Raster.h:71
std::vector< unsigned int > m_inputRasterBands
Bands to process from the input raster.
Definition: Register.h:62
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: Register.h:72
unsigned int getNumberOfRows() const
Returns the raster number of rows.
Definition: Raster.cpp:208
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::string m_geomTransfName
The name of the geometric transformation used to ensure tie-points consistency (see each te::gm::GTFa...
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition: Register.h:108
GeometricRefining::InputParameters m_inputParameters
Input execution parameters.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
Definition: Raster.cpp:218
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The tie-points generated by matching (first: input rasters lines/cols, second:input raster world coor...
bool m_enableRasterCache
If true, a internal raster data cache will be used (defaul:true).
A RAM cache adaptor to an external existent raster that must always be avaliable. ...
Definition: CachedRaster.h:50
std::vector< unsigned int > m_inRasterTPLocationBands
Input raster bands used for tie-points location.
unsigned int m_raster1TargetAreaWidth
The raster 1 target area width (default:0 - The entire raster will be considered).
Grid * getGrid()
It returns the raster grid.
Definition: Raster.cpp:94
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
TiePointsLocator output parameters.
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output registered raster.
Definition: Register.h:110
unsigned int m_raster1TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
unsigned int m_inRasterExpectedRowError
The expected row position error for the given input raster (pixels units), default value:10...
double m_pixelSizeYRelation
The pixel resolution relation m_pixelSizeYRelation = raster1_pixel_res_y / raster2_pixel_res_y (defau...
unsigned int m_raster2TargetAreaColStart
The first column of the raster 2 target area to process (default:0 - The entire raster will be consid...
const OutputParameters & operator=(const OutputParameters &params)
unsigned int m_inRasterSubSectorsFactor
A positive factor used to devide the input raster area into sectors ,(efault value: 3 ( 3 x 3 = 9 sub...
const InputParameters & operator=(const InputParameters &params)
Tie points locator.
Abstract parameters base interface.
double getTPConvexHullArea(const std::vector< te::gm::GTParameters::TiePoint > &tiePoints, const bool useTPSecondCoordPair) const
Returns the tie points converx hull area.
std::map< std::string, std::string > m_rInfo
The necessary information to create the raster (as described in te::raster::RasterFactory).
int getSRID() const
Returns the raster spatial reference system identifier.
Definition: Raster.cpp:203
Performs raster data registering into a SRS using a set of tie points.
Definition: Register.h:48
int m_outputSRID
The output raster SRID (default:0).
Definition: Register.h:66
double m_outliersRemotionAssurance
The error-free selection assurance - valid range (0-1) - Use Lower values for good tie-points sets - ...
unsigned int m_referenceRasterIndex
Reference raster index.
double m_outputResolutionX
The output raster X axis resolution (default:1).
Definition: Register.h:68
void add(Geometry *g)
It adds the geometry into the collection.
int m_inRasterExpectedColDisplacement
The expected input raster row displacement (pixel units, default:0)
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
Definition: Envelope.h:390
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
Definition: Grid.cpp:275
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Register output parameters.
Definition: Register.h:102
double m_convexHullAreaPercent
The tie points covered area percent [0,1].
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
Definition: Raster.cpp:223
virtual Geometry * convexHull() const
This method calculates the Convex Hull of a geometry.
Definition: Geometry.cpp:439
bool m_enableProgress
Enable/Disable the progress interface (default:false).
unsigned int m_outliersRemotionMaxIterations
The maximum number of iterations (Use 0-zero to let this number be automatically found, default:0).
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
Raster Processing algorithm input parameters base interface.
te::rst::Raster const * m_inMaskRaster2Ptr
Optional one band input mask raster 2 (tie-points will not be generated inside mask image areas marke...
2D Geometric transformation parameters.
Definition: GTParameters.h:50
std::vector< unsigned int > m_inRasterBands2Process
Bands to process from the input raster.
FeederConstRaster * m_referenceRastersPtr
A feeder of reference rasters.
unsigned int m_maxR1ToR2Offset
The maximum offset (pixels units) between a raster 1 point end the respective raster 2 point (default...
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: Register.h:106
virtual bool moveNext()=0
Advances to the next sequence obeject.
std::string m_geomTransfName
The name of the geometric transformation used to ensure tie-points consistency (see each te::gm::GTFa...
double m_geometryFilterAssurance
Geometry assurance (the error-free selection percent assurance) - valid range (0-1) - default:0...
Near neighborhood interpolation method.
Definition: Interpolator.h:63
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
#define TERP_DEBUG_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:356
std::string m_geomTransfName
The name of the geometric transformation used (see each te::gm::GTFactory inherited classes to find e...
Definition: Register.h:76
virtual te::rst::Raster const * getCurrentObj() const =0
Return the current sequence object.
std::vector< MatchingResult > m_matchingResult
The matching result status for all given reference rasters.
bool getTPConvexHull(const std::vector< te::gm::GTParameters::TiePoint > &tiePoints, const bool useTPSecondCoordPair, std::auto_ptr< te::gm::Surface > &convexHullPtr) const
Returns the tie points converx hull.
std::vector< unsigned int > m_inRaster1Bands
Bands to be used from the input raster 1.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
Definition: Envelope.cpp:90
unsigned int m_raster1TargetAreaHeight
The raster 1 target area height (default:0 - The entire raster will be considered).
bool m_processAllReferenceRasters
If true, all reference rasters will be processed, if false the matching can finish when minimum quali...
unsigned int m_raster2TargetAreaHeight
The raster 2 target area height (default:0 - The entire raster will be considered).
virtual unsigned int getCurrentOffset() const =0
Return the index of the current object.
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.
Definition: Macros.h:149
te::rst::Raster const * m_inMaskRaster1Ptr
Optional one band input mask raster 1 (tie-points will not be generated inside mask image areas marke...
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
AbstractParameters * clone() const
Create a clone copy of this instance.
te::rp::TiePointsLocator::InputParameters m_locatorParams
The parameters used by the tie-points locator when matching each raster (feeder) against the input ra...
std::vector< te::gm::GTParameters::TiePoint > m_tiePoints
The tie-points in agreenment with the geometric transformation given by m_geomTransPtr (first: input ...
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
double m_minrReferenceRasterRequiredTiePointsFactor
The mininumum required tie-points factor over the minimum number of tie-points required by the choose...