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 
94  bool m_enableAutoValidAreaDetect; //!< Enable/disable the auto-detection of raster valid area pixels (this option allows better mosaic result for rasters with no-data pixels on borders. Default:true).
95 
97 
99 
101 
102  //overload
103  void reset() throw( te::rp::Exception );
104 
105  //overload
106  const InputParameters& operator=( const InputParameters& params );
107 
108  //overload
109  AbstractParameters* clone() const;
110  };
111 
112  /*!
113  \class MosaicSequenceInfo
114  \brief Mosaic sequence info.
115  */
117  {
118  public:
119 
120  std::string m_dataSetName; //!< The generated data set name for this mosaic sequence.
121 
122  std::vector< unsigned int > m_rasterFeederIndexes; //!< The indexes (inside the input rasters feeder) of the rasters written to this mosaic sequence.
123 
124  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).
125 
126  void clear(); //!< Clear the internal allocated resources.
127 
129 
131  };
132 
133  /*!
134  \class OutputParameters
135  \brief Mosaic output parameters
136  */
138  {
139  public:
140 
141  std::vector< MosaicSequenceInfo > m_sequencesInfo; //! The mosaic sequences info.
142 
143  te::da::DataSource* m_outputDSPtr; //!< The output data source where the mosaic rasters will be created.
144 
146 
148 
150 
151  //overload
152  void reset() throw( te::rp::Exception );
153 
154  //overload
155  const OutputParameters& operator=( const OutputParameters& params );
156 
157  //overload
158  AbstractParameters* clone() const;
159  };
160 
162 
164 
165  //overload
166  bool execute( AlgorithmOutputParameters& outputParams ) throw( te::rp::Exception );
167 
168  //overload
169  void reset() throw( te::rp::Exception );
170 
171  //overload
172  bool initialize( const AlgorithmInputParameters& inputParams ) throw( te::rp::Exception );
173 
174  bool isInitialized() const;
175 
176  protected:
177 
178  SequenceMosaic::InputParameters m_inputParameters; //!< Input execution parameters.
179 
180  bool m_isInitialized; //!< Tells if this instance is initialized.
181 
182  /*!
183  \brief Raster band statistics calcule.
184  \param raster Input raster
185  \param bandIndex Input raster band index.
186  \param forceNoDataValue Force the noDataValue to be used as the band no-data value.
187  \param noDataValue The no-data value to use.
188  \param mean Pixels mean.
189  \param variance Pixels variance.
190  */
191  static void calcBandStatistics( const te::rst::Raster& raster,
192  const unsigned int bandIndex,
193  const bool& forceNoDataValue,
194  const double& noDataValue,
195  double& mean,
196  double& variance );
197 
198  /*!
199  \brief Create a raster data set from the given raster.
200 
201  \param dataSetName The data set name.
202 
203  \param sourceRaster The source raster.
204 
205  \param dataSourcePtr The output data source pointer.
206 
207  \return true if OK, false on errors.
208  */
209  bool createRasterDataSet( const std::string& dataSetName,
210  const te::rst::Raster& sourceRaster, te::da::DataSource* dataSourcePtr ) const;
211 
212  /*!
213  \brief Create copy of the given raster into a disk file.
214 
215  \param fileName The disk file name.
216 
217  \param sourceRaster The source raster.
218 
219  \return true if OK, false on errors.
220  */
221  bool createDiskRasterCopy( const std::string& fileName,
222  const te::rst::Raster& sourceRaster );
223 
224  };
225 
226  } // end namespace rp
227 } // end namespace te
228 
229 #endif
230 
te::rp::SequenceMosaic::InputParameters::m_locatorParams
te::rp::TiePointsLocator::InputParameters m_locatorParams
The parameters used by the tie-points locator when processing each rasters pair (leave untouched to u...
Definition: SequenceMosaic.h:92
te::rp::SequenceMosaic::MosaicSequenceInfo::m_tiePoints
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...
Definition: SequenceMosaic.h:124
te::rp::SequenceMosaic::MosaicSequenceInfo
Mosaic sequence info.
Definition: SequenceMosaic.h:117
te::rp::SequenceMosaic::InputParameters::m_noDataValue
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Definition: SequenceMosaic.h:70
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::rp::AlgorithmOutputParameters
Raster Processing algorithm output parameters base interface.
Definition: AlgorithmOutputParameters.h:40
te::rp::SequenceMosaic::InputParameters::~InputParameters
~InputParameters()
te::rp::SequenceMosaic::InputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::SequenceMosaic::InputParameters::m_outDataSetsNamePrefix
std::string m_outDataSetsNamePrefix
The raster output data sets names prefix.
Definition: SequenceMosaic.h:86
te::rp::SequenceMosaic::OutputParameters::reset
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state.
te::rp::SequenceMosaic::MosaicSequenceInfo::clear
void clear()
Clear the internal allocated resources.
te::rp::AlgorithmInputParameters
Raster Processing algorithm input parameters base interface.
Definition: AlgorithmInputParameters.h:40
te::rp::blender::BlendMethod
BlendMethod
Definition: BlenderTypeDefs.h:33
te::rp::SequenceMosaic::InputParameters::m_interpMethod
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: SequenceMosaic.h:68
te::rp::SequenceMosaic::OutputParameters::OutputParameters
OutputParameters()
te::rp::FeederConstRaster
Feeder from a input rasters.
Definition: FeedersRaster.h:47
te::rp::SequenceMosaic::MosaicSequenceInfo::MosaicSequenceInfo
MosaicSequenceInfo()
te::rp::SequenceMosaic::InputParameters::m_useRasterCache
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
Definition: SequenceMosaic.h:78
te::rp::SequenceMosaic::InputParameters::m_forceInputNoDataValue
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
Definition: SequenceMosaic.h:72
te::rp::SequenceMosaic::InputParameters::m_blendMethod
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
Definition: SequenceMosaic.h:74
te::rp::SequenceMosaic::InputParameters::m_minRequiredTiePointsCoveredAreaPercent
double m_minRequiredTiePointsCoveredAreaPercent
The mininumum required tie-points covered area percent of each raster area - valid range [0,...
Definition: SequenceMosaic.h:90
TiePointsLocator.h
TiePointsLocator locator.
te::rp::SequenceMosaic::InputParameters::m_autoEqualize
bool m_autoEqualize
Auto equalization will be performed using the overlaped image areas (default:true).
Definition: SequenceMosaic.h:76
te::rp::Algorithm
Raster Processing algorithm base interface.
Definition: Algorithm.h:42
te::rp::SequenceMosaic::MosaicSequenceInfo::m_rasterFeederIndexes
std::vector< unsigned int > m_rasterFeederIndexes
The indexes (inside the input rasters feeder) of the rasters written to this mosaic sequence.
Definition: SequenceMosaic.h:122
FeedersRaster.h
Raster objects feeders.
te::rp::SequenceMosaic
Create mosaics from a sequence of overlapped rasters using an automatic tie-points detection method.
Definition: SequenceMosaic.h:51
te::rst::InterpolationMethod
InterpolationMethod
Allowed interpolation methods.
Definition: Enums.h:93
Blender.h
Blended pixel value calculation for two overlaped rasters.
te::rp::SequenceMosaic::InputParameters::m_enableProgress
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: SequenceMosaic.h:82
te::Exception
Base exception class for plugin module.
Definition: Exception.h:42
te::rp::SequenceMosaic::OutputParameters::m_outputDSPtr
te::da::DataSource * m_outputDSPtr
The mosaic sequences info.
Definition: SequenceMosaic.h:143
te::rp::SequenceMosaic::InputParameters::m_feederRasterPtr
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
Definition: SequenceMosaic.h:62
TERPEXPORT
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:139
te::rp::SequenceMosaic::OutputParameters
Mosaic output parameters.
Definition: SequenceMosaic.h:138
te::rp::SequenceMosaic::InputParameters::m_geomTransfName
std::string m_geomTransfName
The name of the geometric transformation used if tie-points are supplied (see each te::gm::GTFactory ...
Definition: SequenceMosaic.h:66
te::rp::SequenceMosaic::InputParameters::m_enableMultiThread
bool m_enableMultiThread
Enable/Disable the use of multi-threads (default:true).
Definition: SequenceMosaic.h:80
te::rp::SequenceMosaic::MosaicSequenceInfo::~MosaicSequenceInfo
~MosaicSequenceInfo()
te::rp::SequenceMosaic::OutputParameters::~OutputParameters
~OutputParameters()
Algorithm.h
Abstract algorithm.
te::da::DataSource
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
te::rp::SequenceMosaic::InputParameters::m_tiePointsLocationBandIndex
unsigned int m_tiePointsLocationBandIndex
The band used to locate tie-points, this is the index inside each vector of m_inputRastersBands (defa...
Definition: SequenceMosaic.h:84
te::rp::SequenceMosaic::InputParameters::InputParameters
InputParameters(const InputParameters &)
te::rp::TiePointsLocatorInputParameters
TiePointsLocator input parameters.
Definition: TiePointsLocatorInputParameters.h:49
te::rp::SequenceMosaic::InputParameters::m_inputRastersBands
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
Definition: SequenceMosaic.h:64
te::rp::SequenceMosaic::MosaicSequenceInfo::m_dataSetName
std::string m_dataSetName
The generated data set name for this mosaic sequence.
Definition: SequenceMosaic.h:120
te::rp::SequenceMosaic::OutputParameters::m_sequencesInfo
std::vector< MosaicSequenceInfo > m_sequencesInfo
Definition: SequenceMosaic.h:141
te::rp::SequenceMosaic::InputParameters::m_enableAutoValidAreaDetect
bool m_enableAutoValidAreaDetect
Enable/disable the auto-detection of raster valid area pixels (this option allows better mosaic resul...
Definition: SequenceMosaic.h:94
te::rp::SequenceMosaic::InputParameters
Mosaic input parameters.
Definition: SequenceMosaic.h:59
te::rp::SequenceMosaic::OutputParameters::OutputParameters
OutputParameters(const OutputParameters &)
te::rp::SequenceMosaic::InputParameters::m_outDataSetsNameSufix
std::string m_outDataSetsNameSufix
The raster output data sets names sufix.
Definition: SequenceMosaic.h:88
te::rp::SequenceMosaic::InputParameters::InputParameters
InputParameters()