27 #include "../geometry/Coord2D.h" 28 #include "../geometry/Envelope.h" 51 throw te::rst::Exception(
"Unable to compute affine parameters");
62 double resX,
double resY,
77 double resX,
double resY,
89 throw te::rst::Exception(
"Unable to compute affine parameters");
110 throw te::rst::Exception(
"Missing extent");
119 throw te::rst::Exception(
"Unable to compute affine parameters");
189 throw te::rst::Exception(
"Unable to compute affine parameters");
205 throw te::rst::Exception(
"Unable to compute affine parameters");
218 const double extentWidth = ((double)
m_nCols) * resX;
219 const double extentheight = ((double)
m_nRows) * resY;
224 throw te::rst::Exception(
"Unable to compute affine parameters");
242 throw te::rst::Exception(
"Unable to compute the inverse affine parameters");
297 double minX = std::min(std::min(ll.
x, ul.
x), std::min(lr.
x, ur.
x));
298 double minY = std::min(std::min(ll.
y, ul.
y), std::min(lr.
y, ur.
y));
299 double maxX = std::max(std::max(ll.
x, ul.
x), std::max(lr.
x, ur.
x));
300 double maxY = std::max(std::max(ll.
y, ul.
y), std::max(lr.
y, ur.
y));
308 y = col * m_geoT[3] + row * m_geoT[4] + m_geoT[5];
314 row = x * m_geoTInverse[3] + y * m_geoTInverse[4] + m_geoTInverse[5];
338 const double extentHeight,
const unsigned int nColumns,
339 const unsigned int nRows,
const double extentULX,
340 const double extentULY,
double* affineParamsPtr,
341 double* inverseAffineParamsPtr )
const 343 affineParamsPtr[0] = extentWidth / ((double)nColumns);
344 affineParamsPtr[1] = 0.0;
345 affineParamsPtr[2] = extentULX + ( extentWidth /
static_cast<double>(nColumns) / 2.0 );
346 affineParamsPtr[3] = 0.0;
347 affineParamsPtr[4] = -1.0 * extentHeight / ((double)nRows);
348 affineParamsPtr[5] = extentULY - ( extentHeight /
static_cast<double>(nRows) / 2.0 );
354 double* inverseAffineParamsPtr )
const 356 const double determinant = ( affineParamsPtr[0] * affineParamsPtr[4] ) -
357 ( affineParamsPtr[1] * affineParamsPtr[3] );
358 if( determinant == 0.0 )
363 inverseAffineParamsPtr[0] = affineParamsPtr[4] / determinant;
364 inverseAffineParamsPtr[1] = ( -1.0 * affineParamsPtr[1] ) / determinant;
365 inverseAffineParamsPtr[2] =
367 ( affineParamsPtr[1] * affineParamsPtr[5] )
369 ( affineParamsPtr[2] * affineParamsPtr[4] )
373 inverseAffineParamsPtr[3] = ( -1.0 * affineParamsPtr[3] ) / determinant;
374 inverseAffineParamsPtr[4] = ( affineParamsPtr[0] ) / determinant;
375 inverseAffineParamsPtr[5] =
377 ( -1.0 * ( affineParamsPtr[0] * affineParamsPtr[5] ) )
379 ( affineParamsPtr[3] * affineParamsPtr[2] )
An exception class for the Raster module.
unsigned int getNumberOfRows() const
Returns the grid number of rows.
te::gm::Envelope * m_extent
The grid extent.
bool computeInverseParameters(double *const affineParamsPtr, double *inverseAffineParamsPtr) const
Compute inverse affine parameters.
int getSRID() const
Returns the grid spatial reference system identifier.
Grid & operator=(const Grid &rhs)
Assignment operator.
Grid(unsigned int nCols=0, unsigned int nRows=0, te::gm::Envelope *mbr=0, int srid=TE_UNKNOWN_SRS)
Constructor.
double getWidth() const
It returns the envelope width.
An utility struct for representing 2D coordinates.
void setGeoreference(const te::gm::Coord2D &ulLocation, int srid, double resX, double resY)
Sets the information needed to georeference the grid.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
double getResolutionY() const
Returns the grid vertical (y-axis) resolution.
unsigned int unsigned int nCols
double m_llx
Lower left corner x-coordinate.
An Envelope defines a 2D rectangular region.
int m_srid
The associated SRS.
unsigned int m_nCols
Number of columns.
const double * getGeoreference() const
Returns a list of 6 coefficients describing an affine transformation to georeference a grid...
bool operator==(const Grid &rhs) const
Equal operator.
double m_geoT[6]
A list of 6 coefficients describing an affine transformation to georeference a grid.
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
double getResolutionX() const
Returns the grid horizontal (x-axis) resolution.
void setNumberOfRows(unsigned int nRows)
Sets the grid number of rows.
bool equals(const Envelope &rhs) const
It returns true if the envelopes are "spatially equal".
bool computeAffineParameters(const double extentWidth, const double extentHeight, const unsigned int nColumns, const unsigned int nRows, const double extentULX, const double extentULY, double *affineParamsPtr, double *inverseAffineParamsPtr) const
Compute affine parameters from the given input parameters.
void setNumberOfColumns(unsigned int nCols)
Sets the grid number of columns.
A rectified grid is the spatial support for raster data.
double m_ury
Upper right corner y-coordinate.
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
void setSRID(int srid)
Just sets the grid spatial reference system identifier.
A rectified grid is the spatial support for raster data.
double getHeight() const
It returns the envelope height.
void computeExtent() const
Computes the geographic extension of the grid.
double m_geoTInverse[6]
A list of 6 coefficients describing an inverse affine transformation to georeference a grid...
unsigned int m_nRows
Number of rows.