Loading...
Searching...
No Matches
GeoMosaic.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/GeoMosaic.h
22 \brief Create a mosaic from a set of geo-referenced rasters.
23 */
24
25#ifndef __TERRALIB_RP_INTERNAL_GEOMOSAIC_H
26#define __TERRALIB_RP_INTERNAL_GEOMOSAIC_H
27
28#include "Algorithm.h"
29#include "FeedersRaster.h"
30#include "Blender.h"
31#include "../raster/Interpolator.h"
32#include "../geometry/MultiPolygon.h"
33#include "../sam/rtree/Index.h"
34
35#include <vector>
36#include <string>
37#include <map>
38#include <memory>
39#include <utility>
40#include <tuple>
41
42namespace te
43{
44 namespace rp
45 {
46 class GeoComposition;
47
48 /*!
49 \class GeoMosaic
50 \brief Create a mosaic from a set of geo-referenced rasters.
51 \ingroup rp_mos
52 */
54 {
55 public:
56
57 /*!
58 \class InputParameters
59 \brief GeoMosaic input parameters
60 */
62 {
63 public:
64
65 friend class GeoMosaic;
66 friend class GeoComposition;
67
68 /*! \enum EqType The mosaic equalization type.*/
69 enum EqType
70 {
71 InvalidEqType = 0, //!< Invalid equalization type.
72 NoEqType = 1, //!< No equalization performed.
73 CenterEqType = 2, //!< Mosaic will be equalized following the center raster.
74 TargetEqtype = 3, //!< Mosaic will be equalized following the supplied target means (m_mosaicTargetMeans) and std devs (m_mosaicTargetStdDevs).
75 LocalEqType = 4, //!< Mosaic will be equalized following a local strategy using adjacent rasters.
76 OverLapEqType = 5 //!< Mosaic will be equalized following a local strategy using adjacent rasters.
77 };
78
79 /*! \enum EqType The method used to define the rasters processing order.*/
81 {
82 InvalidRSMethod = 0, //!< Invalid method.
83 FixedMosaicCenterSMethod = 1, //!< A method based on the fixed global mosaic center.
84 BlendedRCenterSMethod = 2 //!< A method based on a blended rasters dynamic center.
85 };
86
87 FeederConstRaster* m_feederRasterPtr; //!< Input rasters feeder.
88
89 std::vector< std::vector< unsigned int > > m_inputRastersBands; //!< Bands to process for each input raster.
90
91 te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
92
93 double m_noDataValue; //!< The pixel value used where no raster data is avaliable (defaul:0).
94
95 bool m_forceInputNoDataValue; //!< If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
96
97 te::rp::Blender::BlendMethod m_blendMethod; //!< The pixel blending method (default: NoBlendMethod).
98
99 EqType m_equalizationType; //!< Equalization type (default:CenterEqType ).
100
101 bool m_useRasterCache; //!< Enable(true) or disable the use of raster caching (default:true).
102
103 bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
104
105 bool m_enableMultiThread; //!< Enable/disable the use of threads (default:true).
106
107 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).
108
109 std::vector< double > m_mosaicTargetMeans; //!< An empty vector for automatic mosaic target means calcule or a vector of target means for each mosaic baind.
110
111 std::vector< double > m_mosaicTargetStdDevs; //!< An empty vector for automatic mosaic target standart deviation values calcule or a vector of target standart deviantion values for each mosaic baind.
112
113 bool m_abortOnFirstError; //!< if true the processing will be stopped on the first error, if false the processing of the next rasters will continue on the event of an error (default: true).
114
115 bool m_skipInsideRasters; //!< Rasters covering mosaic areas already covered by other rasters will be skipped (default: false).
116
117 RasterSortingMethod m_rasterOrdermethod; //!< The method used to define the rasters processing order.
118
120
122
124
125 //overload
126 void reset() _NOEXCEPT_OP(false);
127
128 //overload
129 const InputParameters& operator=( const InputParameters& params );
130
131 //overload
132 AbstractParameters* clone() const;
133
134 //overload
135 bool serialize ( AlgorithmParametersSerializer& serializer ) const;
136
137 /*!
138 \brief Returns all current supported equalization type infos.
139 \param eqTypesInfo current supported equalization type infos.
140 */
141 static void getEqTypesInfo( std::vector< std::pair< EqType, std::string > >& eqTypesInfo );
142
143 protected :
144
145 BlenderRule const * m_blenderRulePtr;
146 };
147
148 /*!
149 \class OutputParameters
150 \brief GeoMosaic output parameters
151 */
153 {
154 public:
155
156 std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
157
158 std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
159
160 std::unique_ptr< te::rst::Raster > m_outputRasterPtr; //!< The generated output mosaic raster (A 1024x1024 blocked raster will be created if the choosen output driver supports blocking scheme).
161
163
165
167
168 //overload
169 void reset() _NOEXCEPT_OP(false);
170
171 //overload
172 const OutputParameters& operator=( const OutputParameters& params );
173
174 //overload
175 AbstractParameters* clone() const;
176 };
177
179
181
182 //overload
183 bool execute( AlgorithmOutputParameters& outputParams ) _NOEXCEPT_OP(false);
184
185 //overload
186 void reset() _NOEXCEPT_OP(false);
187
188 //overload
189 bool initialize( const AlgorithmInputParameters& inputParams ) _NOEXCEPT_OP(false);
190
191 // overload
192 bool isInitialized() const;
193
194 protected:
195
196 /*!
197 \typedef ProcessedRasterInfosDataT Processed raster info type definition.
198 */
200 {
201 public:
203 {
204 Invalid = 0,
205 NotProcessed = 1,
206 UnderProcessing = 2,
207 Skipped = 3,
208 Blended = 4
209 };
210
212 std::unique_ptr< te::gm::Polygon > m_bBoxPolPtr; // under mosaic SRID
213 std::unique_ptr< te::gm::Polygon > m_validDataAreaPolPtr;
214 std::unique_ptr< te::gm::MultiPolygon > m_validDataAreaMultiPolPtr;
215 std::vector< double > m_bandsMeans;
216 std::vector< double > m_bandsStdDevs;
217
219 : m_procStatus( Invalid )
220 {};
221 };
222
223 /*!
224 \typedef ProcessedRastersInfosT Processed rasters info container type definition.
225 \note Key:raster index
226 */
227 typedef std::vector< ProcessedRasterInfosDataT > ProcessedRastersInfosT;
228
229 GeoMosaic::InputParameters m_inputParameters; //!< Input execution parameters.
230
231 bool m_isInitialized; //!< Tells if this instance is initialized.
232
233 /*!
234 \brief Calcule of raster statistics.
235 \param inputRastersBands Input raster bands to use.
236 \param validAreaDelimiterPolPtr A pointer to a valid geometry where the raster valid data is or a null pointer to processe the entire raster.
237 \param rasterMeans Output means values
238 \param rasterStdDevs Output standart deviation values
239 */
241 const te::rst::Raster& inRaster,
242 const std::vector< unsigned int >& inputRastersBands,
243 te::gm::MultiPolygon const * const validAreaDelimiterPolPtr,
244 std::vector< double >& rasterMeans,
245 std::vector< double >& rasterStdDevs ) const;
246
247 /*!
248 \brief Calcule of input raster equalization parameters.
249 \param inRaster Input raster.
250 \param inRasterIndex Input raster index.
251 \param inputRastersBands Input raster bands to use.
252 \param processedRastersInfos Current processed rasters info.
253 \param blendedRastersInfosTree A tree indexing blendedRastersInfos.
254 \param validAreaDelimiterPolPtr A pointer (or a null pointer) to the current input raster valid data area.
255 \param mosaicRaster The mosaic raster reference.
256 \param mosaicValidAreaDelimiterPolPtr A pointer (or a null pointer) to the current mosaic raster valid data area.
257 \param rasterMeans InRaster calculated original means values.
258 \param rasterStdDevs InRaster calculated original standart deviation values.
259 \param offsets InRaster calculated offsets to mosaic.
260 \param scales InRaster calculated scales to mosaic.
261 \param newRasterMeans InRaster calculated new means values after merging into the mosaic.
262 \param newRasterStdDevs InRaster calculated new standart deviation values after merging into the mosaic.
263 \param mosaicCenterRasterIdx The index of the first blended raster at the mosaic center.
264 */
266 const te::rst::Raster& inRaster,
267 const unsigned int inRasterIndex,
268 const std::vector< unsigned int >& inputRastersBands,
269 ProcessedRastersInfosT& processedRastersInfos,
270 const te::sam::rtree::Index< unsigned int >& blendedRastersInfosTree,
271 te::gm::MultiPolygon const * const validAreaDelimiterPolPtr,
272 const te::rst::Raster& mosaicRaster,
273 const unsigned int mosaicCenterRasterIdx,
274 te::gm::MultiPolygon const * const mosaicValidAreaDelimiterPolPtr,
275 std::vector< double >& rasterMeans,
276 std::vector< double >& rasterStdDevs,
277 std::vector< double >& offsets,
278 std::vector< double >& scales,
279 std::vector< double >& newRasterMeans,
280 std::vector< double >& newRasterStdDevs ) const;
281
282 /*!
283 \brief Find the index of the next raster to process.
284 \param globalMosaicCenterX Global mosaic center X.
285 \param globalMosaicCenterY Global mosaic center Y.
286 \param procRastersInfos Global processed rasters infos.
287 \param mosaicValidAreasUnionPtr Current blended rasters area union geometry.
288 \param mextRasterIndex The found next raster index to process.
289 \param mextRasterWasFound True if the next raster was found.
290 \return true if OK, false on errors.
291 */
293 const double& globalMosaicCenterX,
294 const double& globalMosaicCenterY,
295 ProcessedRastersInfosT& procRastersInfos,
296 te::gm::MultiPolygon const* const mosaicValidAreasUnionPtr,
297 bool& mextRasterWasFound,
298 unsigned int& mextRasterIndex );
299
300 /*!
301 \brief Returns the given raster valid data area
302 \param inputRaster Input Raster to process.
303 \param inputRasterIdx Input raster index.
304 \param vAreaPolygon Data valid area in a polygon form.
305 \param vAreaMultiPolygon Data valid area in a multi-polygon form.
306 \return true if OK, false on errors.
307 */
309 const te::rst::Raster& inputRaster,
310 const unsigned int inputRasterIdx,
311 std::unique_ptr< te::gm::Polygon >& vAreaPolygon,
312 std::unique_ptr< te::gm::MultiPolygon >& vAreaMultiPolygon );
313
314 };
315
316 } // end namespace rp
317} // end namespace te
318
319#endif
320
Blended pixel value calculation for two overlaped rasters.
Raster objects feeders.
#define _NOEXCEPT_OP(x)
MultiPolygon is a MultiSurface whose elements are Polygons.
Raster Processing algorithm input parameters base interface.
Raster Processing algorithm output parameters base interface.
A class to standardize algorithm parameters serialization.
Raster Processing algorithm base interface.
Definition Algorithm.h:42
Feeder from a input rasters.
GeoMosaic input parameters.
Definition GeoMosaic.h:62
bool m_forceInputNoDataValue
If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
Definition GeoMosaic.h:95
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition GeoMosaic.h:91
EqType m_equalizationType
Equalization type (default:CenterEqType ).
Definition GeoMosaic.h:99
std::vector< double > m_mosaicTargetMeans
An empty vector for automatic mosaic target means calcule or a vector of target means for each mosaic...
Definition GeoMosaic.h:109
bool m_skipInsideRasters
Rasters covering mosaic areas already covered by other rasters will be skipped (default: false).
Definition GeoMosaic.h:115
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition GeoMosaic.h:103
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
Definition GeoMosaic.h:87
RasterSortingMethod m_rasterOrdermethod
The method used to define the rasters processing order.
Definition GeoMosaic.h:117
InputParameters(const InputParameters &)
bool m_abortOnFirstError
if true the processing will be stopped on the first error, if false the processing of the next raster...
Definition GeoMosaic.h:113
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
Definition GeoMosaic.h:97
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Definition GeoMosaic.h:93
bool m_enableMultiThread
Enable/disable the use of threads (default:true).
Definition GeoMosaic.h:105
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
bool m_enableAutoValidAreaDetect
Enable/disable the auto-detection of raster valid area pixels (this option allows better mosaic resul...
Definition GeoMosaic.h:107
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
Definition GeoMosaic.h:89
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
Definition GeoMosaic.h:101
std::vector< double > m_mosaicTargetStdDevs
An empty vector for automatic mosaic target standart deviation values calcule or a vector of target s...
Definition GeoMosaic.h:111
GeoMosaic output parameters.
Definition GeoMosaic.h:153
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition GeoMosaic.h:156
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
Definition GeoMosaic.h:158
OutputParameters(const OutputParameters &)
std::unique_ptr< te::rst::Raster > m_outputRasterPtr
The generated output mosaic raster (A 1024x1024 blocked raster will be created if the choosen output ...
Definition GeoMosaic.h:160
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
std::unique_ptr< te::gm::Polygon > m_bBoxPolPtr
Definition GeoMosaic.h:212
std::unique_ptr< te::gm::MultiPolygon > m_validDataAreaMultiPolPtr
Definition GeoMosaic.h:214
std::unique_ptr< te::gm::Polygon > m_validDataAreaPolPtr
Definition GeoMosaic.h:213
Create a mosaic from a set of geo-referenced rasters.
Definition GeoMosaic.h:54
GeoMosaic::InputParameters m_inputParameters
Input execution parameters.
Definition GeoMosaic.h:229
bool getRasterDataValidArea(const te::rst::Raster &inputRaster, const unsigned int inputRasterIdx, std::unique_ptr< te::gm::Polygon > &vAreaPolygon, std::unique_ptr< te::gm::MultiPolygon > &vAreaMultiPolygon)
Returns the given raster valid data area.
bool getEqualizationParams(const te::rst::Raster &inRaster, const unsigned int inRasterIndex, const std::vector< unsigned int > &inputRastersBands, ProcessedRastersInfosT &processedRastersInfos, const te::sam::rtree::Index< unsigned int > &blendedRastersInfosTree, te::gm::MultiPolygon const *const validAreaDelimiterPolPtr, const te::rst::Raster &mosaicRaster, const unsigned int mosaicCenterRasterIdx, te::gm::MultiPolygon const *const mosaicValidAreaDelimiterPolPtr, std::vector< double > &rasterMeans, std::vector< double > &rasterStdDevs, std::vector< double > &offsets, std::vector< double > &scales, std::vector< double > &newRasterMeans, std::vector< double > &newRasterStdDevs) const
Calcule of input raster equalization parameters.
bool getRasterStats(const te::rst::Raster &inRaster, const std::vector< unsigned int > &inputRastersBands, te::gm::MultiPolygon const *const validAreaDelimiterPolPtr, std::vector< double > &rasterMeans, std::vector< double > &rasterStdDevs) const
Calcule of raster statistics.
bool getNextRasterIndex2Process(const double &globalMosaicCenterX, const double &globalMosaicCenterY, ProcessedRastersInfosT &procRastersInfos, te::gm::MultiPolygon const *const mosaicValidAreasUnionPtr, bool &mextRasterWasFound, unsigned int &mextRasterIndex)
Find the index of the next raster to process.
bool m_isInitialized
Tells if this instance is initialized.
Definition GeoMosaic.h:231
std::vector< ProcessedRasterInfosDataT > ProcessedRastersInfosT
Definition GeoMosaic.h:227
An abstract class for raster data strucutures.
Definition Raster.h:72
A class that represents an R-tree.
Definition Index.h:57
InterpolationMethod
Allowed interpolation methods.
Definition Enums.h:93
TerraLib.
#define TERPEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition Config.h:139
Abstract algorithm.