27 #include "../common/STLUtils.h"
28 #include "../geometry/Coord2D.h"
29 #include "../geometry/Envelope.h"
30 #include "../srs/Converter.h"
58 te::rst::Raster*
te::rst::Reproject(
te::rst::Raster const *
const rin,
int srid,
double llx,
double lly,
double urx,
double ury,
double resx,
double resy,
const std::map<std::string, std::string>& routinfo,
int m)
71 throw te::rst::Exception(
"Input/Output SRID not recognized.");
85 ncols =
static_cast<unsigned int>((urx-llx)/rin->
getResolutionX())+1;
86 nrows =
static_cast<unsigned int>((ury-lly)/rin->
getResolutionY())+1;
92 if (resx == 0 || resy == 0)
100 ncols =
static_cast<unsigned int>(env->
getWidth() / resx) + 1;
101 nrows =
static_cast<unsigned int>(env->
getHeight() / resy) + 1;
107 std::vector<te::rst::BandProperty*> bands;
138 int x1 = (int) (pxoll.
x-0.5);
139 int y1 = (int) (pxoll.
y+0.5);
142 int x2 = (int)(pxour.
x+0.5);
143 int y2 = (int)(pxour.
y-0.5);
170 pob((polr.
x-poll.
x)/2.+poll.
x, poll.
y),
171 pol(poll.
x, (poul.
y-poll.
y)/2.+poll.
y),
172 por(polr.
x, (pour.
y-polr.
y)/2.+polr.
y);
224 double dxl((pxill.
x-pxiul.
x)/(y2-y1));
225 double dyl((pxill.
y-pxiul.
y)/(y2-y1));
226 double dxr((pxilr.
x-pxiur.
x)/(y2-y1));
227 double dyr((pxilr.
y-pxiur.
y)/(y2-y1));
230 double xl = pxiul.
x-1;
231 double yl = pxiul.
y-1;
234 double xr = pxiur.
x+1;
235 double yr = pxiur.
y+1;
238 double dx = (xr-xl)/(x2-x1);
239 double dy = (yr-yl)/(x2-x1);
248 std::complex<double> value;
249 for (j = y1; j <= y2; ++j)
251 for (i = x1; i <= x2; ++i)
259 interpolator->
getValue(x, y, value, b);
275 dx = (xr-xl)/(x2-x1);
276 dy = (yr-yl)/(x2-x1);
284 int px = (int)(p.
x/tol);
285 int py = (int)(p.
y/tol);
287 int qx = (int)(q.
x/tol);
288 int qy = (int)(q.
y/tol);
290 int tx = (int)(t.
x/tol);
291 int ty = (int)(t.
y/tol);
296 if (dx <= 2 && dy <= 2)
299 int q1 = (qy-py)*(tx-px);
300 int q2 = (ty-py)*(qx-px);
304 if (q1 == 0 && q2 == 0 && q3 == 0 && q4 == 0)
307 if (abs(q1 - q2) > (std::max(abs(q3), abs(q4))))
It gives access to values in one band (dimension) of a raster.
bool isValid() const
It tells if the rectangle is valid or not.
virtual void setValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the attribute value in a band of a cell.
double getWidth() const
It returns the envelope width.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
It describes one band (or dimension) of a raster.
Grid * getGrid()
It returns the raster grid.
static Raster * make()
It creates and returns an empty raster with default raster driver.
void getValue(const double &c, const double &r, std::complex< double > &v, const std::size_t &b)
Get the interpolated value at specific band.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
double getHeight() const
It returns the envelope height.
A rectified grid is the spatial support for raster data.
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
An utility struct for representing 2D coordinates.
Coord2D getUpperRight() const
It returns the upper right coordinate of the envelope.
void setTargetSRID(int targetSRID)
Sets the target SRS identifier.
An exception class for the Raster module.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
A rectified grid is the spatial support for raster data.
bool InterpolateIn(te::rst::Raster const *const rin, te::rst::Raster *rout, te::gm::Envelope *box, te::srs::Converter *conv, int m=te::rst::Interpolator::NearestNeighbor)
int getSRID() const
Returns the raster spatial reference system identifier.
It contains the algorithm to reproject raster data.
void setSourceSRID(int sourceSRID)
Sets the source SRS identifier.
TERASTEREXPORT te::rst::Raster * Reproject(te::rst::Raster const *const rin, int srid, const std::map< std::string, std::string > &routinfo, int m=te::rst::Interpolator::NearestNeighbor)
Reprojects a raster to another SRS.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
bool isPointInGrid(unsigned int col, unsigned int row) const
bool IsPointOnLine(te::gm::Coord2D &p, te::gm::Coord2D &q, te::gm::Coord2D &t, double tol)
A raster band description.
This is the abstract factory for Rasters.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
It interpolates one pixel based on a selected algorithm.
An abstract class for raster data strucutures.
BandProperty * getProperty()
Returns the band property.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
An Envelope defines a 2D rectangular region.
Near neighborhood interpolation method.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
An abstract class for raster data strucutures.
Coord2D getLowerLeft() const
It returns the lower left coordinate of the envelope.
bool invert(double *xIn, double *yIn, double *xOut, double *yOut, long numCoord, int coordOffset=1) const
Inverts a vector of coordinates from target SRS to dource SRS.