11 #include "../../common/progress/TaskProgress.h" 12 #include "../../raster.h" 13 #include "../../raster/BandProperty.h" 14 #include "../../raster/Grid.h" 15 #include "../../raster/RasterFactory.h" 47 std::vector<te::rst::BandProperty*>
bands;
50 bands[0]->m_nblocksx = 1;
51 bands[0]->m_nblocksy = (
int)outputHeight;
52 bands[0]->m_blkw = (
int)outputWidth;
60 m_rst = rst.release();
83 int32_t flin, llin, fcol, lcol;
90 for (
unsigned int i = 0; i <
m_triang.size(); i++)
95 if (!
NodesId((int32_t)i, nodesid))
99 for (j = 0; j < 3; j++)
101 p3da[j].
setX(
m_node[(
unsigned int)nodesid[j]].getNPoint().getX());
102 p3da[j].
setY(
m_node[(
unsigned int)nodesid[j]].getNPoint().getY());
103 p3da[j].
setZ(
m_node[(
unsigned int)nodesid[j]].getZ());
106 if ((p3da[0].getZ() == dummyvalue) ||
107 (p3da[1].getZ() == dummyvalue) ||
108 (p3da[2].getZ() == dummyvalue))
110 FillGridValue((int32_t)i, flin, llin, fcol, lcol, dummyvalue);
112 else if ((p3da[0].getZ() == p3da[1].getZ()) &&
114 FillGridValue((int32_t)i, flin, llin, fcol, lcol, p3da[0].getZ());
119 for (j = 0; j < 3; j++)
120 if (neighsid[j] == -1)
142 std::string inDsetName,
143 std::unique_ptr<te::da::DataSetType> inDsetType)
178 double x1_x0, x2_x0, y1_y0, y2_y0, z1_z0, z2_z0,
182 x1_x0 = p3da[1].
getX() - p3da[0].
getX();
183 x2_x0 = p3da[2].
getX() - p3da[0].
getX();
184 y1_y0 = p3da[1].
getY() - p3da[0].
getY();
185 y2_y0 = p3da[2].
getY() - p3da[0].
getY();
186 z1_z0 = (double)(p3da[1].getZ() - p3da[0].
getZ());
187 z2_z0 = (double)(p3da[2].getZ() - p3da[0].
getZ());
188 for (nlin = flin; nlin <= llin; nlin++){
189 for (ncol = fcol; ncol <= lcol; ncol++){
195 detx = ((y1_y0 * z2_z0) - (y2_y0 * z1_z0)) *
197 dety = ((z1_z0 * x2_x0) - (z2_z0 * x1_x0)) *
199 detz = (x1_x0 * y2_y0) - (x2_x0 * y1_y0);
201 zvalue = ((detx + dety - detz * p3da[0].
getZ()) / -detz);
203 m_rst->
setValue((
unsigned int)ncol, (
unsigned int)nlin, zvalue);
226 double u, v, ap, bp, cp, dp, x0, y0,
227 p00, p01, p02, p03, p04, p05,
228 p10, p11, p12, p13, p14,
237 p00 = coef[0]; p01 = coef[1]; p02 = coef[2]; p03 = coef[3]; p04 = coef[4]; p05 = coef[5];
238 p10 = coef[6]; p11 = coef[7]; p12 = coef[8]; p13 = coef[9]; p14 = coef[10];
239 p20 = coef[11]; p21 = coef[12]; p22 = coef[13]; p23 = coef[14];
240 p30 = coef[15]; p31 = coef[16]; p32 = coef[17];
241 p40 = coef[18]; p41 = coef[19];
245 ap = coef[21]; bp = coef[22]; cp = coef[23]; dp = coef[24];
246 x0 = coef[25]; y0 = coef[26];
248 for (nlin = flin; nlin <= llin; nlin++)
250 for (ncol = fcol; ncol <= lcol; ncol++)
258 u = ap*(pg.
getX() - x0) +
260 v = cp*(pg.
getX() - x0) +
264 p0 = p00 + v*(p01 + v*(p02 + v*(p03 + v*(p04 + v*p05))));
265 p1 = p10 + v*(p11 + v*(p12 + v*(p13 + v*p14)));
266 p2 = p20 + v*(p21 + v*(p22 + v*p23));
267 p3 = p30 + v*(p31 + v*p32);
270 zvalue = p0 + u*(p1 + u*(p2 + u*(p3 + u*(p4 + u*p50))));
271 m_rst->
setValue((
unsigned int)ncol, (
unsigned int)nlin, zvalue);
int m_srid
Attribute with spatial reference information.
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.
bool FillGridLinear(int32_t triid, te::gm::Point *p3da, int32_t flin, int32_t llin, int32_t fcol, int32_t lcol)
Method that fills the grid locations, inside a triangle, with a zvalue linearly evaluated.
bool ContainsPoint(int32_t triangId, te::gm::Point &pt)
Method that verifies if a triangle contains a given point.
Index into a lookup table.
bool FillGridValue(int32_t triid, int32_t flin, int32_t llin, int32_t fcol, int32_t lcol, double zvalue)
Method that fills the grid locations, inside a triangle, with a zvalue.
bool NodesId(int32_t triangId, int32_t *nodeIds)
Method that reads the identification number of the nodes of a given triangle.
boost::shared_ptr< DataSource > DataSourcePtr
A raster band description.
bool NodeDerivatives()
Method that calculates the first and second derivatives in the nodes of a given triangle.
te::gm::Envelope m_env
Attribute used to restrict the area to generate the samples.
bool run()
Method that generates a regular Grid from a given TIN.
This class can be used to inform the progress of a task.
double getWidth() const
It returns the envelope width.
bool FillGridQuintic(int32_t triid, int32_t flin, int32_t llin, int32_t fcol, int32_t lcol, double *coef)
Method that fills the grid locations, inside a triangle, with a zvalue evaluated by a quintic polynom...
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits<double>::max().
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
int32_t m_fbnode
First break node number.
std::vector< TinTriang > m_triang
Triangulation triangles vector.
bool DefineInterLinesColumns(int32_t *nodesid, int32_t &flin, int32_t &llin, int32_t &fcol, int32_t &lcol)
Method that calculates the lines and the columns intercepted by a triangle.
Utility functions for MNT support.
std::vector< TinNode > m_nsderiv
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
bool NeighborsId(int32_t triangId, int32_t *neighsId)
BandProperty * getProperty()
Returns the band property.
std::unique_ptr< te::da::DataSetType > m_inDsetType
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
std::map< std::string, std::string > m_dsinfo
virtual const Band * getBand(std::size_t i) const =0
Returns the raster i-th band.
Grid * getGrid()
It returns the raster grid.
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
double getX() const
It returns the x-coordinate.
This file contains a class to calculate a grid from a TIN. Adapted from SPRING.
void setX(const double &x)
It sets the Point x-coordinate value.
std::vector< TinNode > m_node
Triangulation nodes vector.
te::da::DataSourcePtr m_inDsrc
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.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType)
It sets the Datasource that is being used to generate TIN.
void gridToGeo(const double &col, const double &row, double &x, double &y) const
Get the spatial location of a grid point.
bool LoadTin(te::da::DataSourcePtr &inDsrc, std::string &inDsetName, double zmin=std::numeric_limits< double >::min(), double zmax=std::numeric_limits< double >::max())
Method used to load a triangular network (TIN)
void setParams(double resx, double resy, Interpolator gt)
It sets the parameters that is being used to save TIN.
void setOutput(std::map< std::string, std::string > &dsinfo)
It sets the Datasource that is being used to save TIN.
void setY(const double &y)
It sets the Point y-coordinate value.
A rectified grid is the spatial support for raster data.
double getHeight() const
It returns the envelope height.
bool DefineAkimaCoeficients(int32_t triid, double *coef)
Method that defines the coefficients of the Akima polynomium fitted in a given triangle.
const double & getX() const
It returns the Point x-coordinate value.
void setZ(const double &z)
It sets the Point z-coordinate value.