12 #include "../../common/progress/TaskProgress.h" 13 #include "../../dataaccess/utils/Utils.h" 14 #include "../../geometry/GeometryProperty.h" 15 #include "../../raster.h" 16 #include "../../raster/BandProperty.h" 17 #include "../../raster/Grid.h" 18 #include "../../raster/RasterFactory.h" 19 #include "../../srs/SpatialReferenceSystemManager.h" 29 std::string inDsetName,
30 std::unique_ptr<te::da::DataSetType> inDsetType)
55 std::unique_ptr<te::rst::Raster> in_raster;
61 in_raster = dsRaster->getRaster(rasterProp->
getName());
62 m_env = *in_raster->getExtent();
63 m_resx = in_raster->getResolutionX();
64 m_resy = in_raster->getResolutionY();
65 in_raster->getBand(0)->getProperty()->m_noDataValue =
m_dummy;
88 std::vector<te::rst::BandProperty*>
bands;
91 bands[0]->m_nblocksx = 1;
92 bands[0]->m_nblocksy = (
int)outputHeight;
93 bands[0]->m_blkw = (
int)outputWidth;
106 int32_t flin, llin, fcol, lcol;
111 for (
unsigned int i = 0; i < (
unsigned int)m_ltriang; i++)
118 if (!
NodesId((int32_t)i, nodesid))
124 m1 = m2 = std::numeric_limits<double>::max();
125 if ((
m_node[(
unsigned int)nodesid[1]].getY() -
m_node[(
unsigned int)nodesid[0]].getY()) != 0.0)
126 m1 = (
m_node[(
unsigned int)nodesid[1]].getX() -
m_node[(
unsigned int)nodesid[0]].getX()) /
127 (
m_node[(
unsigned int)nodesid[1]].getY() -
m_node[(
unsigned int)nodesid[0]].getY());
129 if ((
m_node[(
unsigned int)nodesid[2]].getY() -
m_node[(
unsigned int)nodesid[0]].getY()) != 0.0)
130 m2 = (
m_node[(
unsigned int)nodesid[2]].getX() -
m_node[(
unsigned int)nodesid[0]].getX()) /
131 (
m_node[(
unsigned int)nodesid[2]].getY() -
m_node[(
unsigned int)nodesid[0]].getY());
133 if (fabs(m1 - m2) <
m_tol)
145 double pi180 = 180. / 3.1415927;
148 double EPSILON = 1.0e-40;
150 m_min = in_raster->getBand(0)->getMinValue(
true, 0, 0, outputHeight-1, outputWidth-1).real();
151 m_max = in_raster->getBand(0)->getMaxValue(
true, 0, 0, outputHeight-1, outputWidth-1).real();
165 for (
unsigned l = 1; l < in_raster->getNumberOfRows() - 1; l++)
167 for (
unsigned c = 1; c < in_raster->getNumberOfColumns() - 1; c++)
177 zvalue = (pi180*atan(sqrt((dzdx*dzdx) + (dzdy*dzdy))));
179 zvalue = (sqrt((dzdx*dzdx) + (dzdy*dzdy))*100.);
183 if ((dzdx > (-EPSILON)) && (dzdx < EPSILON)){
186 else if (dzdy < (-EPSILON))
192 zvalue = 90. - (pi180*atan2(dzdy, dzdx));
193 if (zvalue < 0.) zvalue = 360. + zvalue;
194 zvalue = 360. - zvalue;
214 double moduv, decliv;
215 double pi180 = 180. / 3.1415927;
219 for (j = 0; j < 3; j++)
221 p3da[j].
setX(
m_node[(
unsigned int)nodesid[j]].getX());
222 p3da[j].
setY(
m_node[(
unsigned int)nodesid[j]].getY());
223 p3da[j].
setZ(
m_node[(
unsigned int)nodesid[j]].getZ());
227 m1 = m2 = std::numeric_limits<double>::max();
229 if ((p3da[1].getY() - p3da[0].getY()) != 0.0)
230 m1 = (p3da[1].
getX() - p3da[0].
getX()) / (p3da[1].getY() - p3da[0].
getY());
232 if ((p3da[2].getY() - p3da[0].getY()) != 0.0)
233 m2 = (p3da[2].
getX() - p3da[0].
getX()) / (p3da[2].getY() - p3da[0].
getY());
235 if (fabs(m1 - m2) <
m_tol)
243 if ((p3da[0].getZ() == p3da[1].
getZ()) && (p3da[0].getZ() == p3da[2].
getZ()))
254 moduv = sqrt(pow(nvector[0], 2.) + pow(nvector[1], 2.) + pow(nvector[2], 2.));
259 if (slopetype ==
'g')
260 decliv = pi180*acos(nvector[2] / moduv);
262 decliv = tan(acos(nvector[2] / moduv)) * 100.;
267 decliv = 90. - pi180*atan2(nvector[1], nvector[0]);
269 decliv = 360. + decliv;
277 bool gradient =
true;
288 raster->getValue(c - 1, l - 1, pixlantcant);
289 raster->getValue(c, l - 1, pixlantc);
290 raster->getValue(c + 1, l - 1, pixlantcpos);
291 raster->getValue(c - 1, l, pixlcant);
292 raster->getValue(c + 1, l, pixlcpos);
293 raster->getValue(c - 1, l + 1, pixlposcant);
294 raster->getValue(c, l + 1, pixlposc);
295 raster->getValue(c + 1, l + 1, pixlposcpos);
297 if ((pixlantc <= m_max && pixlantc >=
m_min) && (pixlcant <= m_max && pixlcant >=
m_min) &&
298 (pixlposc <= m_max && pixlposc >=
m_min) && (pixlcpos <= m_max && pixlcpos >=
m_min))
300 if ((pixlantcant <= m_max && pixlantcant >=
m_min) && (pixlantcpos <= m_max && pixlantcpos >=
m_min) &&
301 (pixlposcant <= m_max && pixlposcant >=
m_min) && (pixlposcpos <= m_max && pixlposcpos >=
m_min))
304 dzdx = (((pixlposcpos + 2.*pixlcpos + pixlantcpos)
305 - (pixlposcant + 2.*pixlcant + pixlantcant)) / (8.*
m_dx));
306 dzdy = (((pixlposcpos + 2.*pixlposc + pixlposcant)
307 - (pixlantcpos + 2.*pixlantc + pixlantcant)) / (8.*
m_dy));
312 dzdx = ((pixlcpos - pixlcant) / (2.*
m_dx));
313 dzdy = ((pixlposc - pixlantc) / (2.*
m_dy));
318 if ((pixlantcant <= m_max && pixlantcant >=
m_min) && (pixlantcpos <= m_max && pixlantcpos >=
m_min) &&
319 (pixlposcant <= m_max && pixlposcant >=
m_min) && (pixlposcpos <= m_max && pixlposcpos >=
m_min))
322 dzdx = (((pixlposcpos + pixlantcpos)
323 - (pixlposcant + pixlantcant)) / (4.*
m_dx));
324 dzdy = (((pixlposcpos + pixlposcant)
325 - (pixlantcpos + pixlantcant)) / (4.*
m_dy));
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.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
void setOutput(std::map< std::string, std::string > &dsinfo)
bool CalcGradientRst(std::unique_ptr< te::rst::Raster > &raster, unsigned l, unsigned c, double &dzdx, double &dzdy)
METHOD TO CALCULATE GRADIENT VECTOR COMPONENTS IN THE POINT L,C OF THE GRID.
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.
This class can be used to inform the progress of a task.
double getWidth() const
It returns the envelope width.
An utility struct for representing 2D coordinates.
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
bool isActive() const
Verify if the task is active.
This file contains a class to generate a Slope grid. Adapted from SPRING.
te::da::DataSourcePtr m_inDsrc
std::unique_ptr< te::da::DataSetType > m_inDsetType
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.
const double & getY() const
It returns the Point y-coordinate value.
static SpatialReferenceSystemManager & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
std::map< std::string, std::string > m_dsinfo
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType)
Utility functions for the data access module.
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
void setX(const double &x)
It sets the Point x-coordinate value.
std::vector< TinNode > m_node
Triangulation nodes vector.
static Raster * make()
It creates and returns an empty raster with default raster driver.
mntType m_inputType
Input type (TIN, GRID)
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
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, char gradtype, char slopetype, int srid, double dummy)
void setY(const double &y)
It sets the Point y-coordinate value.
A rectified grid is the spatial support for raster data.
int32_t m_ltriang
Triangulation last triangle number.
TEMNTEXPORT bool triangleNormalVector(te::gm::Point *, double *)
Function that defines the triangle normal vector.
double getHeight() const
It returns the envelope height.
double TriangleGradient(int32_t *nodesid, char gradtype, char slopetype)
Method that calculates a gradient value (slope or aspect) 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.
const std::string & getName() const
It returns the property name.