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 
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 
127 
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 
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 
160 
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  \param raster Input raster
183  \param bandIndex Input raster band index.
184  \param forceNoDataValue Force the noDataValue to be used as the band no-data value.
185  \param noDataValue The no-data value to use.
186  \param mean Pixels mean.
187  \param variance Pixels variance.
188  */
189  static void calcBandStatistics( const te::rst::Raster& raster,
190  const unsigned int bandIndex,
191  const bool& forceNoDataValue,
192  const double& noDataValue,
193  double& mean,
194  double& variance );
195 
196  /*!
197  \brief Create a raster data set from the given raster.
198 
199  \param dataSetName The data set name.
200 
201  \param sourceRaster The source raster.
202 
203  \param dataSourcePtr The output data source pointer.
204 
205  \return true if OK, false on errors.
206  */
207  bool createRasterDataSet( const std::string& dataSetName,
208  const te::rst::Raster& sourceRaster, te::da::DataSource* dataSourcePtr ) const;
209 
210  /*!
211  \brief Create copy of the given raster into a disk file.
212 
213  \param fileName The disk file name.
214 
215  \param sourceRaster The source raster.
216 
217  \return true if OK, false on errors.
218  */
219  bool createDiskRasterCopy( const std::string& fileName,
220  const te::rst::Raster& sourceRaster ) const;
221 
222  };
223 
224  } // end namespace rp
225 } // end namespace te
226 
227 #endif
228 
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:122
te::rp::SequenceMosaic::MosaicSequenceInfo
Mosaic sequence info.
Definition: SequenceMosaic.h:115
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::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:120
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:141
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:136
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()
te::rp::Blender::BlendMethod
BlendMethod
Definition: Blender.h:66
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:118
te::rp::SequenceMosaic::OutputParameters::m_sequencesInfo
std::vector< MosaicSequenceInfo > m_sequencesInfo
Definition: SequenceMosaic.h:139
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()