28 #include "../common/progress/TaskProgress.h" 29 #include "../common/STLUtils.h" 30 #include "../geometry/Coord2D.h" 31 #include "../geometry/Envelope.h" 32 #include "../geometry/Polygon.h" 33 #include "../srs/Converter.h" 122 converter->setSourceSRID(
getSRID());
123 converter->setTargetSRID(srid);
132 li=
static_cast<unsigned int>(aux.
y);
133 ci=
static_cast<unsigned int>(aux.
x);
136 lf=
static_cast<unsigned int>(aux.
y);
137 cf=
static_cast<unsigned int>(aux.
x);
141 converter->convert(aux.
x,aux.
y);
146 converter->convert(aux.
x,aux.
y);
151 for (
unsigned int c=ci; c<cf; ++c)
154 if (converter->convert(aux.
x,aux.
y))
156 if(llx > aux.
x) llx = aux.
x;
157 if(lly > aux.
y) lly = aux.
y;
158 if(urx < aux.
x) urx = aux.
x;
159 if(ury < aux.
y) ury = aux.
y;
164 for (
unsigned int c=ci; c<cf; ++c)
167 if (converter->convert(aux.
x,aux.
y))
169 if(llx > aux.
x) llx = aux.
x;
170 if(lly > aux.
y) lly = aux.
y;
171 if(urx < aux.
x) urx = aux.
x;
172 if(ury < aux.
y) ury = aux.
y;
177 for (
unsigned int l=li; l<lf; ++l)
180 if (converter->convert(aux.
x,aux.
y))
182 if(llx > aux.
x) llx = aux.
x;
183 if(lly > aux.
y) lly = aux.
y;
184 if(urx < aux.
x) urx = aux.
x;
185 if(ury < aux.
y) ury = aux.
y;
190 for (
unsigned int l=li; l<lf; ++l)
193 if (converter->convert(aux.
x,aux.
y))
195 if(llx > aux.
x) llx = aux.
x;
196 if(lly > aux.
y) lly = aux.
y;
197 if(urx < aux.
x) urx = aux.
x;
198 if(ury < aux.
y) ury = aux.
y;
278 std::complex<double> v;
306 std::ostringstream output;
309 output <<
"Raster Name......: " <<
m_name << std::endl;
313 output <<
"SRID.............: " <<
getSRID() << std::endl;
341 this->
operator[](
b) += rhs.operator[](
b);
349 this->
operator[](
b) += cvalue;
359 this->
operator[](
b) -= rhs.operator[](
b);
367 this->
operator[](
b) -= cvalue;
377 this->
operator[](
b) *= rhs.operator[](
b);
385 this->
operator[](
b) *= cvalue;
395 this->
operator[](
b) /= rhs.operator[](
b);
403 this->
operator[](
b) /= cvalue;
431 const unsigned int firstInputRow = (
unsigned int)
438 std::floor( curenv.
getY() )
441 const unsigned int firstInputCol = (
unsigned int)
448 std::floor( cllenv.
getX() )
451 const unsigned int lastInputRow = (
unsigned int)
458 std::ceil( cllenv.
getY() )
461 const unsigned int lastInputCol = (
unsigned int)
468 std::ceil( curenv.
getX() )
472 if( ( lastInputRow <= firstInputRow ) || ( lastInputCol <= firstInputCol ) )
477 const unsigned int outputWidth = lastInputCol - firstInputCol + 1;
478 const unsigned int outputHeight = lastInputRow - firstInputRow + 1;
483 ((
double)firstInputRow) - 0.5 ) );
488 std::vector<te::rst::BandProperty*>
bands;
493 bands[
b ]->m_nblocksx = 1;
494 bands[
b ]->m_nblocksy = outputHeight;
495 bands[
b ]->m_blkw = outputWidth;
496 bands[
b ]->m_blkh = 1;
505 std::vector<std::complex<double> > values;
511 for( ri = firstInputRow, ro = 0; ro < outputHeight; ri++, ro++)
513 for( ci = firstInputCol, co = 0; co < outputWidth; ci++, co++)
526 const std::vector< te::gm::Geometry const *> geometries,
527 const std::map<std::string, std::string>& rinfo,
528 const std::string& rType )
const 540 std::vector<te::rst::BandProperty*>
bands;
548 std::vector<std::complex<double> > v;
576 unsigned int dcolumn,
unsigned int height,
unsigned int width,
577 unsigned int newheight,
unsigned int newwidth,
578 const std::map<std::string, std::string>& rinfo)
const 585 ((
double)(drow + height)) - 0.5);
595 std::vector<te::rst::BandProperty*>
bands;
600 bands[
b ]->m_blkh = 1;
601 bands[
b ]->m_blkw = newwidth;
602 bands[
b ]->m_nblocksx = 1;
603 bands[
b ]->m_nblocksy = newheight;
609 std::vector<std::complex<double> > v;
614 double ripp = ((double)(height-1)) / ((
double)(newheight-1));
616 double cipp = ((double)(width-1)) / ((
double)(newwidth-1));
622 for (
unsigned r = 0; r < newheight; r++, ri+=ripp)
625 for (
unsigned c = 0; c < newwidth; c++, ci+=cipp)
661 double transformedResolutionX = transformedEnvelope.
getWidth() /
663 double transformedResolutionY = transformedEnvelope.
getHeight() /
673 transformedResolutionX,
674 transformedResolutionY,
695 vectorizer.
run(g, polygonsValues);
708 for (
unsigned int i = 0; i < g.size(); i++)
710 vp.push_back(bvalue % 255);
712 bvalue = bvalue >= 127? bvalue - 126: bvalue > 255? 0: bvalue + 127;
720 for (
unsigned int i = 0; i < g.size(); i++)
722 std::vector<te::gm::Geometry*> geoms;
726 for (std::size_t j = 0; j < geoms.size(); ++j)
virtual void setIValue(unsigned int c, unsigned int r, const double value)=0
Sets the imaginary attribute value in a complex band of a cell.
TERASTEREXPORT te::rst::RasterPtr CropRaster(const te::rst::Raster &rin, const te::gm::Polygon &pin, const std::map< std::string, std::string > &rinfo, const std::string &rType=std::string("GDAL"))
Creates a raster crop using a polygon delimiter.
An exception class for the Raster module.
unsigned int getNumberOfRows() const
Returns the grid number of rows.
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.
virtual void setValues(unsigned int c, unsigned int r, const std::vector< double > &values)
Sets the imaginary attribute values in all complex bands of a cell.
te::gm::Envelope * getExtent()
Returns the geographic extension of the raster data.
void getValues(const double &c, const double &r, std::vector< std::complex< double > > &values)
Get the interpolated value for all bands.
virtual void vectorize(std::vector< te::gm::Geometry * > &g, std::size_t b, unsigned int mp=0, std::vector< double > *const polygonsValues=0)
Vectorizes a given raster band, using GDALPolygonize function.
It gives access to values in one band (dimension) of a raster.
void setMessage(const std::string &message)
Set the task message.
It describes one band (or dimension) of a raster.
std::complex< double > getOffsetValue() const
It returns the offset values (real and imaginary) to be applied to the band.
It contains the algorithm to reproject raster data.
double applyScale(int i, const double &v) const
Scales a value according to a specific resampling scale.
A raster band description.
virtual Raster & operator/=(Raster &rhs)
It returns the raster division (pixel by pixel).
int getSRID() const
Returns the grid spatial reference system identifier.
unsigned int getNumberOfColumns() const
Returns the raster number of columns.
It interpolates one pixel based on a selected algorithm. Methods currently available are Nearest Neig...
virtual Raster * trim(const te::gm::Envelope *env, const std::map< std::string, std::string > &rinfo) const
Subsetting operation for trimming (cropping) the raster.
virtual void getValues(unsigned int c, unsigned int r, std::vector< double > &values) const
Returns the imaginary attribute values in all complex bands of a cell.
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
This class can be used to inform the progress of a task.
virtual Raster * resample(int method, unsigned int drow, unsigned int dcolumn, unsigned int height, unsigned int width, unsigned int newheight, unsigned int newwidth, const std::map< std::string, std::string > &rinfo) const
Resample a subset of the raster, given a box.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
An abstract class for raster data strucutures.
double getWidth() const
It returns the envelope width.
virtual void setIValue(unsigned int c, unsigned int r, const double value, std::size_t b=0)
Sets the imaginary attribute value in a complex band of a cell.
unsigned int getRow() const
Returns the current row in iterator.
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
virtual Raster & operator*=(Raster &rhs)
It returns the raster product (pixel by pixel).
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
#define TE_TR(message)
It marks a string in order to get translated.
void setAccessPolicy(te::common::AccessPolicy p)
Sets the raster access policy.
TEGEOMEXPORT void Multi2Single(const te::gm::Geometry *g, std::vector< te::gm::Geometry * > &geoms)
It will get a GeometryCollection and distribute in a vector.
bool isActive() const
Verify if the task is active.
void geoToGrid(const double &x, const double &y, double &col, double &row) const
Get the grid point associated to a spatial location.
virtual void getIValue(unsigned int c, unsigned int r, double &value) const =0
Returns the imaginary attribute value in a complex band of a cell.
double getResolutionY() const
Returns the grid vertical (y-axis) resolution.
void setTotalSteps(int value)
Set the task total stepes.
te::common::AccessPolicy getAccessPolicy() const
Returns the raster access policy.
std::string m_name
The raster name.
Utility functions for the raster module.
Grid * m_grid
The spatial support for raster data.
Grid * getResampledGrid(int scale) const
Return the raster grid for a specific scale.
AccessPolicy
Supported data access policies (can be used as bitfield).
This is the abstract factory for Rasters.
Raster()
Default constructor.
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
virtual std::complex< double > getMaxValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the maximum occurring value in a window of the band.
virtual std::complex< double > getStdValue(unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the standard deviation of the occurring values in a window of the band...
An Envelope defines a 2D rectangular region.
An abstract class for raster data strucutures.
unsigned int getNumberOfRows() const
Returns the raster number of rows.
virtual std::size_t getNumberOfBands() const =0
Returns the number of bands (dimension of cells attribute values) in the raster.
virtual ~Raster()
Virtual destructor.
BandProperty * getProperty()
Returns the band property.
virtual void rasterize(std::vector< te::gm::Geometry * > g, std::vector< double > vp, std::size_t b=0)
Rasterizes a given vector of geometries.
virtual Raster & operator-=(Raster &rhs)
It returns the raster subtraction (pixel by pixel).
unsigned int getNumberOfColumns() const
Returns the grid number of columns.
double getResolutionX() const
Returns the raster horizontal (x-axis) resolution.
double getResolutionX() const
Returns the grid horizontal (x-axis) resolution.
void setName(const std::string name)
Sets the raster name.
It implements the vectorizer, based on TerraLib 4 algorithm.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
A raster band description.
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
std::complex< double > getScaleValue() const
It returns the scale values (real and imaginary) to be applied to the band.
Grid * getGrid()
It returns the raster grid.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
virtual Raster & operator=(const Raster &rhs)
Assignment operator.
virtual void getValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the attribute value of a band of a cell.
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p, const IterationType iterationType)
Returns an iterator referring to the first value of the band.
virtual void setValue(unsigned int c, unsigned int r, const double value)=0
Sets the cell attribute value.
A Converter is responsible for the conversion of coordinates between different Coordinate Systems (CS...
std::string toString(void) const
It returns the data value in a string notation.
int getSRID() const
Returns the raster spatial reference system identifier.
const std::string & getName() const
Returns the raster name.
virtual Raster * transform(int srid, const std::map< std::string, std::string > &rinfo, int m=1) const
Reprojects this raster to a distinct SRS. This method reprojects this raster to a distinct SRS...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
double getX() const
It returns the x-coordinate.
A rectified grid is the spatial support for raster data.
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::NearestNeighbor)
Reprojects a raster to another SRS.
virtual std::complex< double > getMinValue(bool readall=false, unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the minimum occurring value in a window of the band.
static Raster * make()
It creates and returns an empty raster with default raster driver.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
virtual std::complex< double > getMeanValue(unsigned int rs=0, unsigned int cs=0, unsigned int rf=0, unsigned int cf=0) const
It computes and returns the mean of the occurring values in a window of the band. ...
te::gm::Envelope * getExtent()
Returns the geographic extension of the grid.
virtual Raster * getRaster() const =0
Returns the associated raster.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
double getResolutionY() const
Returns the raster vertical (y-axis) resolution.
virtual void getIValue(unsigned int c, unsigned int r, double &value, std::size_t b=0) const
Returns the imaginary attribute value in a complex band of a cell.
virtual Raster * clip(const std::vector< te::gm::Geometry const * > geometries, const std::map< std::string, std::string > &rinfo, const std::string &rType) const
Subsetting operation for clipping the raster.
bool run(std::vector< te::gm::Geometry * > &polygons, std::vector< double > *const polygonsValues=0)
Returns true if current algorithm implementation runs ok, false otherwise.
std::string m_description
A description.
unsigned int getColumn() const
Returns the current column in iterator.
A rectified grid is the spatial support for raster data.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
double getHeight() const
It returns the envelope height.
te::common::AccessPolicy m_policy
The access policy, can be te::common::{NoAccess, RAccess, RWAccess, WAccess}.
virtual Raster & operator+=(Raster &rhs)
It returns the raster sum (pixel by pixel).
It interpolates one pixel based on a selected algorithm.
virtual void getValue(unsigned int c, unsigned int r, double &value) const =0
Returns the cell attribute value.