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 FeederConstRaster* m_feederRasterPtr; //!< Input rasters feeder.
80
81 std::vector< std::vector< unsigned int > > m_inputRastersBands; //!< Bands to process for each input raster.
82
83 te::rst::Interpolator::Method m_interpMethod; //!< The raster interpolator method (default:NearestNeighbor).
84
85 double m_noDataValue; //!< The pixel value used where no raster data is avaliable (defaul:0).
86
87 bool m_forceInputNoDataValue; //!< If true, m_noDataValue will be used as the no-data value for input rasters (defalt:false).
88
89 te::rp::Blender::BlendMethod m_blendMethod; //!< The pixel blending method (default: NoBlendMethod).
90
91 EqType m_equalizationType; //!< Equalization type (default:CenterEqType ).
92
93 bool m_useRasterCache; //!< Enable(true) or disable the use of raster caching (default:true).
94
95 bool m_enableProgress; //!< Enable/Disable the progress interface (default:false).
96
97 bool m_enableMultiThread; //!< Enable/disable the use of threads (default:true).
98
99 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).
100
101 std::vector< double > m_mosaicTargetMeans; //!< An empty vector for automatic mosaic target means calcule or a vector of target means for each mosaic baind.
102
103 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.
104
105 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).
106
107 bool m_skipInsideRasters; //!< Rasters covering mosaic areas already covered by other rasters will be skipped (default: false).
108
110
112
114
115 //overload
116 void reset() _NOEXCEPT_OP(false);
117
118 //overload
119 const InputParameters& operator=( const InputParameters& params );
120
121 //overload
122 AbstractParameters* clone() const;
123
124 //overload
125 bool serialize ( AlgorithmParametersSerializer& serializer ) const;
126
127 /*!
128 \brief Returns all current supported equalization type infos.
129 \param eqTypesInfo current supported equalization type infos.
130 */
131 static void getEqTypesInfo( std::vector< std::pair< EqType, std::string > >& eqTypesInfo );
132
133 protected :
134
135 BlenderRule const * m_blenderRulePtr;
136 };
137
138 /*!
139 \class OutputParameters
140 \brief GeoMosaic output parameters
141 */
143 {
144 public:
145
146 std::string m_rType; //!< Output raster data source type (as described in te::raster::RasterFactory ).
147
148 std::map< std::string, std::string > m_rInfo; //!< The necessary information to create the output rasters (as described in te::raster::RasterFactory).
149
150 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).
151
153
155
157
158 //overload
159 void reset() _NOEXCEPT_OP(false);
160
161 //overload
162 const OutputParameters& operator=( const OutputParameters& params );
163
164 //overload
165 AbstractParameters* clone() const;
166 };
167
169
171
172 //overload
173 bool execute( AlgorithmOutputParameters& outputParams ) _NOEXCEPT_OP(false);
174
175 //overload
176 void reset() _NOEXCEPT_OP(false);
177
178 //overload
179 bool initialize( const AlgorithmInputParameters& inputParams ) _NOEXCEPT_OP(false);
180
181 // overload
182 bool isInitialized() const;
183
184 protected:
185
186 /*!
187 \typedef BlendedRasterInfosDataT Blended raster info type definition.
188 \brief GeoMosaic output parameters
189 */
190 typedef std::tuple<
191 std::shared_ptr< te::gm::MultiPolygon >, // valid data area
192 std::vector< double >, // means
193 std::vector< double > > // std devs
195
196 /*!
197 \typedef BlendedRastersInfosT Blended rasters info container type definition.
198 \brief GeoMosaic output parameters
199 */
201
202 GeoMosaic::InputParameters m_inputParameters; //!< Input execution parameters.
203
204 bool m_isInitialized; //!< Tells if this instance is initialized.
205
206 /*!
207 \brief Calcule of raster statistics.
208 \param inputRastersBands Input raster bands to use.
209 \param validAreaDelimiterPolPtr A pointer to a valid geometry where the raster valid data is or a null pointer to processe the entire raster.
210 \param rasterMeans Output means values
211 \param rasterStdDevs Output standart deviation values
212 */
213 bool getRasterStats(
214 const te::rst::Raster& inRaster,
215 const std::vector< unsigned int >& inputRastersBands,
216 te::gm::MultiPolygon const * const validAreaDelimiterPolPtr,
217 std::vector< double >& rasterMeans,
218 std::vector< double >& rasterStdDevs ) const;
219
220 /*!
221 \brief Calcule of input raster equalization parameters.
222 \param inputRastersBands Input raster bands to use.
223 \param blendedRastersInfos Infos about rasters that already were blended into the mosaic.
224 \param blendedRastersInfosTree A tree indexing blendedRastersInfos.
225 \param validAreaDelimiterPolPtr A pointer (or a null pointer) to the current input raster valid data area.
226 \param mosaicValidAreaDelimiterPolPtr A pointer (or a null pointer) to the current mosaic raster valid data area.
227 \param rasterMeans InRaster calculated original means values.
228 \param rasterStdDevs InRaster calculated original standart deviation values.
229 \param offsets InRaster calculated offsets to mosaic.
230 \param scales InRaster calculated scales to mosaic.
231 \param newRasterMeans InRaster calculated new means values after merging into the mosaic.
232 \param newRasterStdDevs InRaster calculated new standart deviation values after merging into the mosaic.
233 */
234 bool getEqualizationParams(
235 const te::rst::Raster& inRaster,
236 const std::vector< unsigned int >& inputRastersBands,
237 const BlendedRastersInfosT& blendedRastersInfos,
238 const te::sam::rtree::Index< std::size_t >& blendedRastersInfosTree,
239 te::gm::MultiPolygon const * const validAreaDelimiterPolPtr,
240 const te::rst::Raster& mosaicRaster,
241 te::gm::MultiPolygon const * const mosaicValidAreaDelimiterPolPtr,
242 std::vector< double >& rasterMeans,
243 std::vector< double >& rasterStdDevs,
244 std::vector< double >& offsets,
245 std::vector< double >& scales,
246 std::vector< double >& newRasterMeans,
247 std::vector< double >& newRasterStdDevs ) const;
248
249
250
251 };
252
253 } // end namespace rp
254} // end namespace te
255
256#endif
257
Blended pixel value calculation for two overlaped rasters.
Raster objects feeders.
#define _NOEXCEPT_OP(x)
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.
Definition: FeedersRaster.h:47
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:87
te::rst::Interpolator::Method m_interpMethod
The raster interpolator method (default:NearestNeighbor).
Definition: GeoMosaic.h:83
EqType m_equalizationType
Equalization type (default:CenterEqType ).
Definition: GeoMosaic.h:91
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:101
bool m_skipInsideRasters
Rasters covering mosaic areas already covered by other rasters will be skipped (default: false).
Definition: GeoMosaic.h:107
bool m_enableProgress
Enable/Disable the progress interface (default:false).
Definition: GeoMosaic.h:95
FeederConstRaster * m_feederRasterPtr
Input rasters feeder.
Definition: GeoMosaic.h:79
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:105
te::rp::Blender::BlendMethod m_blendMethod
The pixel blending method (default: NoBlendMethod).
Definition: GeoMosaic.h:89
double m_noDataValue
The pixel value used where no raster data is avaliable (defaul:0).
Definition: GeoMosaic.h:85
bool m_enableMultiThread
Enable/disable the use of threads (default:true).
Definition: GeoMosaic.h:97
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:99
std::vector< std::vector< unsigned int > > m_inputRastersBands
Bands to process for each input raster.
Definition: GeoMosaic.h:81
bool m_useRasterCache
Enable(true) or disable the use of raster caching (default:true).
Definition: GeoMosaic.h:93
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:103
GeoMosaic output parameters.
Definition: GeoMosaic.h:143
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Definition: GeoMosaic.h:146
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:148
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:150
void reset() _NOEXCEPT_OP(false)
Clear all internal allocated resources and reset the parameters instance to its initial state.
Create a mosaic from a set of geo-referenced rasters.
Definition: GeoMosaic.h:54
std::tuple< std::shared_ptr< te::gm::MultiPolygon >, std::vector< double >, std::vector< double > > BlendedRasterInfosDataT
Definition: GeoMosaic.h:194
std::vector< BlendedRasterInfosDataT > BlendedRastersInfosT
Definition: GeoMosaic.h:200
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.