28 #include "../geometry/GeometricTransformation.h"
29 #include "../geometry/GTFactory.h"
30 #include "../raster/RasterFactory.h"
31 #include "../raster/Band.h"
32 #include "../raster/BandProperty.h"
33 #include "../raster/Grid.h"
34 #include "../raster/Utils.h"
64 m_inputRasterBands.clear();
67 m_outputResolutionX = 1.0;
68 m_outputResolutionY = 1.0;
71 m_geomTransfName =
"Affine";
73 m_outputBoundingBox.m_llx = m_outputBoundingBox.m_lly =
74 m_outputBoundingBox.m_urx = m_outputBoundingBox.m_ury = 0.0;
122 m_outputRasterPtr.reset();
151 throw( te::rp::Exception )
161 std::auto_ptr< te::gm::GeometricTransformation > transformationPtr;
174 "Geometric transformation instatiation error" );
176 "Geometric transformation parameters calcule error" );
181 double lowerLeftX = DBL_MAX;
182 double lowerLeftY = DBL_MAX;
183 double upperRightX = -1.0 * DBL_MAX;
184 double upperRightY = -1.0 * DBL_MAX;
206 "Indexed extent creation error" );
211 for( std::size_t extentIdx = 0 ; extentIdx < indexedDetailedExtent.
size() ;
214 transformationPtr->directMap( indexedDetailedExtent.
getX( extentIdx ),
215 indexedDetailedExtent.
getY( extentIdx ), mappedX, mappedY );
217 lowerLeftX = std::min( lowerLeftX, mappedX );
218 lowerLeftY = std::min( lowerLeftY, mappedY );
219 upperRightX = std::max( upperRightX, mappedX );
220 upperRightY = std::max( upperRightY, mappedY );
227 std::vector< te::rst::BandProperty* > bandsProperties;
228 for(
unsigned int inputRasterBandsIdx = 0 ; inputRasterBandsIdx <
238 gridMbr->
m_llx = lowerLeftX;
239 gridMbr->
m_lly = lowerLeftY;
240 gridMbr->
m_urx = upperRightX;
241 gridMbr->
m_ury = upperRightY;
254 "Output raster creation error" );
266 unsigned int outRow = 0;
267 unsigned int outCol = 0;
272 std::complex< double > cValue;
274 for(
unsigned int inputRasterBandsIdx = 0 ; inputRasterBandsIdx <
281 double outputBandRangeMin = 0;
282 double outputBandRangeMax = 0;
284 outputBandRangeMin, outputBandRangeMax );
286 for( outRow = 0 ; outRow < nRows ; ++outRow )
288 for( outCol = 0 ; outCol < nCols ; ++outCol )
290 outputGrid.
gridToGeo( (
double)outCol, (
double)outRow, outX, outY );
292 geomTransf.
inverseMap( outX, outY, inCol, inRow );
294 interpInstance.
getValue( inCol, inRow, cValue, inputBandIdx );
296 if( cValue.real() == inputBandNoDataValue )
302 outputBand.
setValue( outCol, outRow, std::max( outputBandRangeMin,
303 std::min( outputBandRangeMax, cValue.real() ) ) );
320 throw( te::rp::Exception )
333 "Invalid m_inputRasterPtr" )
340 "Invalid raster bands number" );
342 for(
unsigned int inRasterBandsIdx = 0 ; inRasterBandsIdx <
348 "Invalid raster bands" );
356 "Invalid geometric transformation" );
360 std::auto_ptr< te::gm::GeometricTransformation > transformationPtr(
363 "Geometric transformation instatiation error" );
366 transformationPtr->getMinRequiredTiePoints(),
367 "Invalid tie-points number" )
373 "Invalid m_outputSRID" )
376 "Invalid m_outputResolutionX" )
379 "Invalid m_outputResolutionY" )
Near neighborhood interpolation method.
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().
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
Raster Processing functions.
#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.
A LinearRing is a LineString that is both closed and simple.
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.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
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.
bool GetIndexedDetailedExtent(const te::rst::Grid &grid, te::gm::LinearRing &indexedDetailedExtent)
Create a indexed (lines,columns) datailed extent from the given grid.
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 ).
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.
std::size_t size() const
It returns the number of points (vertexes) in the geometry.