SequenceMosaic.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/rp/SequenceMosaic.h
22  \brief Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
23  */
24 
25 #ifndef __TERRALIB_RP_INTERNAL_SEQUENCEMOSAIC_H
26 #define __TERRALIB_RP_INTERNAL_SEQUENCEMOSAIC_H
27 
28 #include "Algorithm.h"
29 #include "FeedersRaster.h"
30 #include "Blender.h"
31 #include "TiePointsLocator.h"
32 #include "../raster/Interpolator.h"
33 #include "../dataaccess/datasource/DataSource.h"
34 #include "../geometry/GTParameters.h"
35 
36 #include <vector>
37 #include <string>
38 
39 namespace te
40 {
41  namespace rp
42  {
43  /*!
44  \class SequenceMosaic
45  \brief Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
46  \note When the tie-points detection fails, a new mosaic sequence is generated.
47  \note Each mosaic sequence takes the first raster (of each sequence) as reference for resolution, SRS and equalization parameters.
48  \ingroup rp_mos
49  */
51  {
52  public:
53 
54  /*!
55  \class InputParameters
56  \brief Mosaic input parameters
57  */
59  {
60  public:
61 
62  FeederConstRaster* m_feederRasterPtr; //!< Input rasters feeder.
63 
64  std::vector< std::vector< unsigned int > > m_inputRastersBands; //!< Bands to process for each input raster.
65 
66  std::string m_geomTransfName; //!< The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory inherited classes to find each factory key/name, default:Affine).
67 
68  te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
69 
70  double m_noDataValue; //!< The pixel value used where no raster data is avaliable (defaul:0).
71 
72  bool m_forceInputNoDataValue; //!< If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
73 
74  te::rp::Blender::BlendMethod m_blendMethod; //!< The pixel blending method (default: NoBlendMethod).
75 
76  bool m_autoEqualize; //!< Auto equalization will be performed using the overlaped image areas (default:true).
77 
78  bool m_useRasterCache; //!< Enable(true) or disable the use of raster caching (default:true).
79 
80  bool m_enableMultiThread; //!< Enable/Disable the use of multi-threads (default:true).
81 
82  bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
83 
84  unsigned int m_tiePointsLocationBandIndex; //!< The band used to locate tie-points, this is the index inside each vector of m_inputRastersBands (defaul:0).
85 
86  std::string m_outDataSetsNamePrefix; //!< The raster output data sets names prefix.
87 
88  std::string m_outDataSetsNameSufix; //!< The raster output data sets names sufix.
89 
90  double m_minRequiredTiePointsCoveredAreaPercent; //!< The mininumum required tie-points covered area percent of each raster area - valid range [0,100] (default:25).
91 
92  te::rp::TiePointsLocator::InputParameters m_locatorParams; //!< The parameters used by the tie-points locator when processing each rasters pair (leave untouched to use the default).
93 
95 
97 
98  ~InputParameters();
99 
100  //overload
101  void reset() throw( te::rp::Exception );
102 
103  //overload
104  const InputParameters& operator=( const InputParameters& params );
105 
106  //overload
107  AbstractParameters* clone() const;
108  };
109 
110  /*!
111  \class MosaicSequenceInfo
112  \brief Mosaic sequence info.
113  */
115  {
116  public:
117 
118  std::string m_dataSetName; //!< The generated data set name for this mosaic sequence.
119 
120  std::vector< unsigned int > m_rasterFeederIndexes; //!< The indexes (inside the input rasters feeder) of the rasters written to this mosaic sequence.
121 
122  std::vector< std::vector< te::gm::GTParameters::TiePoint > > m_tiePoints; //!< The generated tie-pionts (te::gm::GTParameters::TiePoint::first are mosaic coods, te::gm::GTParameters::TiePoint::second are the used input raster line/column indexes).
123 
124  void clear(); //!< Clear the internal allocated resources.
125 
126  MosaicSequenceInfo();
127 
128  ~MosaicSequenceInfo();
129  };
130 
131  /*!
132  \class OutputParameters
133  \brief Mosaic output parameters
134  */
136  {
137  public:
138 
139  std::vector< MosaicSequenceInfo > m_sequencesInfo; //! The mosaic sequences info.
140 
141  te::da::DataSource* m_outputDSPtr; //!< The output data source where the mosaic rasters will be created.
142 
144 
146 
147  ~OutputParameters();
148 
149  //overload
150  void reset() throw( te::rp::Exception );
151 
152  //overload
153  const OutputParameters& operator=( const OutputParameters& params );
154 
155  //overload
156  AbstractParameters* clone() const;
157  };
158 
159  SequenceMosaic();
160 
161  ~SequenceMosaic();
162 
163  //overload
164  bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
165 
166  //overload
167  void reset() throw( te::rp::Exception );
168 
169  //overload
170  bool initialize( const AlgorithmInputParameters& inputParams ) throw( te::rp::Exception );
171 
172  bool isInitialized() const;
173 
174  protected:
175 
176  SequenceMosaic::InputParameters m_inputParameters; //!< Input execution parameters.
177 
178  bool m_isInitialized; //!< Tells if this instance is initialized.
179 
180  /*!
181  \brief Raster band statistics calcule.
182 
183  \param band Input raster band.
184 
185  \param forceNoDataValue Force the noDataValue to be used as the band no-data value.
186 
187  \param noDataValue The no-data value to use.
188 
189  \param mean Pixels mean.
190 
191  \param variance Pixels variance.
192  */
193  static void calcBandStatistics( const te::rst::Band& band,
194  const bool& forceNoDataValue,
195  const double& noDataValue,
196  double& mean,
197  double& variance );
198 
199  /*!
200  \brief Create a raster data set from the given raster.
201 
202  \param dataSetName The data set name.
203 
204  \param sourceRaster The source raster.
205 
206  \param dataSourcePtr The output data source pointer.
207 
208  \return true if OK, false on errors.
209  */
210  bool createRasterDataSet( const std::string& dataSetName,
211  const te::rst::Raster& sourceRaster, te::da::DataSource* dataSourcePtr ) const;
212 
213  /*!
214  \brief Create copy of the given raster into a disk file.
215 
216  \param fileName The disk file name.
217 
218  \param sourceRaster The source raster.
219 
220  \return true if OK, false on errors.
221  */
222  bool createDiskRasterCopy( const std::string& fileName,
223  const te::rst::Raster& sourceRaster ) const;
224 
225  };
226 
227  } // end namespace rp
228 } // end namespace te
229 
230 #endif
231 
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
Base exception class for plugin module.
Definition: Exception.h:42
std::vector< std::vector< te::gm::GTParameters::TiePoint > > m_tiePoints
The generated tie-pionts (te::gm::GTParameters::TiePoint::first are mosaic coods, te::gm::GTParameter...
Blended pixel value calculation for two overlaped rasters.
te::rp::TiePointsLocator::InputParameters m_locatorParams
The parameters used by the tie-points locator when processing each rasters pair (leave untouched to u...
bool m_enableProgress
Enable/Disable the progress interface (default:false).
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
Raster Processing algorithm output parameters base interface.
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
std::string m_outDataSetsNamePrefix
The raster output data sets names prefix.
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:119
Raster Processing algorithm base interface class.
std::vector< MosaicSequenceInfo > m_sequencesInfo
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:92
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
Raster Processing algorithm base interface.
Definition: Algorithm.h:41
URI C++ Library.
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
double m_minRequiredTiePointsCoveredAreaPercent
The mininumum required tie-points covered area percent of each raster area - valid range [0...
std::string m_outDataSetsNameSufix
The raster output data sets names sufix.
std::vector< unsigned int > m_rasterFeederIndexes
The indexes (inside the input rasters feeder) of the rasters written to this mosaic sequence...
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
Feeder from a input rasters.
Definition: FeedersRaster.h:46
std::string m_dataSetName
The generated data set name for this mosaic sequence.
TiePointsLocator locator.
Raster Processing algorithm input parameters base interface.
Raster objects feeders.
std::string m_geomTransfName
The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory ...
Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method...
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
unsigned int m_tiePointsLocationBandIndex
The band used to locate tie-points, this is the index inside each vector of m_inputRastersBands (defa...
te::da::DataSource * m_outputDSPtr
The mosaic sequences info.