27 #include "../geometry/GeometricTransformation.h"
28 #include "../geometry/GTFactory.h"
29 #include "../raster/RasterFactory.h"
30 #include "../raster/Band.h"
31 #include "../raster/BandProperty.h"
32 #include "../raster/Grid.h"
33 #include "../raster/Utils.h"
63 m_inputRasterBands.clear();
66 m_outputResolutionX = 1.0;
67 m_outputResolutionY = 1.0;
70 m_geomTransfName =
"Affine";
72 m_outputBoundingBox.m_llx = m_outputBoundingBox.m_lly =
73 m_outputBoundingBox.m_urx = m_outputBoundingBox.m_ury = 0.0;
121 m_outputRasterPtr.reset();
150 throw( te::rp::Exception )
160 std::auto_ptr< te::gm::GeometricTransformation > transformationPtr;
173 "Geometric transformation instatiation error" );
175 "Geometric transformation parameters calcule error" );
180 double lowerLeftX = DBL_MAX;
181 double lowerLeftY = DBL_MAX;
182 double upperRightX = -1.0 * DBL_MAX;
183 double upperRightY = -1.0 * DBL_MAX;
205 transformationPtr->directMap( -0.5, -0.5, mappedX, mappedY );
206 lowerLeftX = std::min( lowerLeftX, mappedX );
207 lowerLeftY = std::min( lowerLeftY, mappedY );
208 upperRightX = std::max( upperRightX, mappedX );
209 upperRightY = std::max( upperRightY, mappedY );
211 transformationPtr->directMap(
213 -0.5, mappedX, mappedY );
214 lowerLeftX = std::min( lowerLeftX, mappedX );
215 lowerLeftY = std::min( lowerLeftY, mappedY );
216 upperRightX = std::max( upperRightX, mappedX );
217 upperRightY = std::max( upperRightY, mappedY );
219 transformationPtr->directMap(
223 lowerLeftX = std::min( lowerLeftX, mappedX );
224 lowerLeftY = std::min( lowerLeftY, mappedY );
225 upperRightX = std::max( upperRightX, mappedX );
226 upperRightY = std::max( upperRightY, mappedY );
228 transformationPtr->directMap(
232 lowerLeftX = std::min( lowerLeftX, mappedX );
233 lowerLeftY = std::min( lowerLeftY, mappedY );
234 upperRightX = std::max( upperRightX, mappedX );
235 upperRightY = std::max( upperRightY, mappedY );
241 std::vector< te::rst::BandProperty* > bandsProperties;
242 for(
unsigned int inputRasterBandsIdx = 0 ; inputRasterBandsIdx <
252 gridMbr->
m_llx = lowerLeftX;
253 gridMbr->
m_lly = lowerLeftY;
254 gridMbr->
m_urx = upperRightX;
255 gridMbr->
m_ury = upperRightY;
268 "Output raster creation error" );
280 unsigned int outRow = 0;
281 unsigned int outCol = 0;
286 std::complex< double > cValue;
288 for(
unsigned int inputRasterBandsIdx = 0 ; inputRasterBandsIdx <
295 double outputBandRangeMin = 0;
296 double outputBandRangeMax = 0;
298 outputBandRangeMin, outputBandRangeMax );
300 for( outRow = 0 ; outRow < nRows ; ++outRow )
302 for( outCol = 0 ; outCol < nCols ; ++outCol )
304 outputGrid.
gridToGeo( (
double)outCol, (
double)outRow, outX, outY );
306 geomTransf.
inverseMap( outX, outY, inCol, inRow );
308 interpInstance.
getValue( inCol, inRow, cValue, inputBandIdx );
310 if( cValue.real() == inputBandNoDataValue )
316 outputBand.
setValue( outCol, outRow, std::max( outputBandRangeMin,
317 std::min( outputBandRangeMax, cValue.real() ) ) );
334 throw( te::rp::Exception )
347 "Invalid m_inputRasterPtr" )
354 "Invalid raster bands number" );
356 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
362 "Invalid raster bands" );
370 "Invalid geometric transformation" );
374 std::auto_ptr< te::gm::GeometricTransformation > transformationPtr(
377 "Geometric transformation instatiation error" );
380 transformationPtr->getMinRequiredTiePoints(),
381 "Invalid tie-points number" )
387 "Invalid m_outputSRID" )
390 "Invalid m_outputResolutionX" )
393 "Invalid m_outputResolutionY" )
const OutputParameters & operator=(const OutputParameters ¶ms)
std::vector< TiePoint > m_tiePoints
Tie points.
TERASTEREXPORT void GetDataTypeRanges(const int &dataType, double &min, double &max)
Return the values range of a given data type.
bool execute(AlgorithmOutputParameters &outputParams)
Executes the algorithm using the supplied parameters.
A raster band description.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
Performs raster data registering into a SRS using a set of tie points.
AbstractParameters * clone() const
Create a clone copy of this instance.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
Raster Processing algorithm output parameters base interface.
double m_urx
Upper right corner x-coordinate.
void getValue(const double &c, const double &r, std::complex< double > &v, const std::size_t &b)
Get the interpolated value at specific band.
int m_type
The data type of the elements in the band.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
#define TERP_TRUE_OR_RETURN_FALSE(value, message)
Checks if value is true. For false values a warning message will be logged and a return of context wi...
const Algorithm & operator=(const Algorithm &)
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
bool initialize(const AlgorithmInputParameters &inputParams)
Initialize the algorithm instance making it ready for execution.
double m_llx
Lower left corner x-coordinate.
bool isInitialized() const
Returns true if the algorithm instance is initialized and ready for execution.
Register::InputParameters m_inputParameters
Input execution parameters.
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
void reset()
Clear all internal allocated objects and reset the algorithm to its initial state.
BandProperty * getProperty()
Returns the band property.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
std::map< std::string, std::string > m_rInfo
The necessary information to create the output rasters (as described in te::raster::RasterFactory).
A raster band description.
Grid * getGrid()
It returns the raster grid.
static GeometricTransformation * make(const std::string &factoryKey)
It creates an object with the appropriated factory.
std::auto_ptr< te::rst::Raster > m_outputRasterPtr
The generated output registered raster.
double m_lly
Lower left corner y-coordinate.
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
Abstract parameters base interface.
bool m_isInitialized
Tells if this instance is initialized.
double m_ury
Upper right corner y-coordinate.
static Raster * make()
It creates and returns an empty raster with default raster driver.
Register output parameters.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
2D Geometric transformation parameters.
std::string m_rType
Output raster data source type (as described in te::raster::RasterFactory ).
Near neighborhood interpolation method.
A rectified grid is the spatial support for raster data.
void reset()
Clear all internal allocated resources and reset the parameters instance to its initial state...
#define TERP_TRUE_OR_THROW(value, message)
Checks if value is true and throws an exception if not.