11 #include "../../common/progress/TaskProgress.h" 15 unsigned int nro_neighb;
22 std::unique_ptr<te::rst::Raster>
rst =
Initialize(
true, nro_neighb, rx1, ry2, NCols, NLines);
30 double ew_region = deltx / (double)nPartsX;
31 double ns_region = delty / (double)nPartsY;
48 for (
unsigned int i = 0; i <
m_nPartsY; i++)
50 double begin_y = Y1 + (i*ns_region);
51 double end_y = Y1 + ((i + 1)*ns_region);
53 double disty = (end_y - begin_y) * percentageDist;
55 for (
unsigned int j = 0; j <
m_nPartsX; j++)
61 double begin_x = X1 + (j*ew_region);
62 double end_x = X1 + ((j + 1)*ew_region);
64 double distx = (end_x - begin_x) * percentageDist;
66 double min_x = begin_x;
67 double min_y = begin_y;
70 bool poucosPontos =
false;
73 double overlapDistX = distx*nOverlaping;
74 double overlapDistY = disty*nOverlaping;
76 int beginLine = std::max((
int)((begin_y - Y1 - overlapDistY) / resY), 0);
77 int endLine = std::min((
int)((end_y - Y1 + overlapDistY) / resY), (
int)NLines);
79 min_y = std::max(Y1, begin_y - overlapDistY);
83 min_y = begin_y - overlapDistY;
85 int beginCol = std::max((
int)((begin_x - X1 - overlapDistX) / resX), 0);
86 int endCol = std::min((
int)((end_x - X1 + overlapDistX) / resX), (
int)NCols);
88 min_x = std::max(X1, begin_x - overlapDistX);
92 min_x = begin_x - overlapDistX;
100 poucosPontos =
m_obsVect.size() < _minimoPontos;
103 }
while (poucosPontos && (nOverlaping < 3));
128 unsigned int firstLine = (
unsigned int)std::max((
int)((begin_y - Y1) / resY), 0);
129 unsigned int lastLine = std::min((
unsigned int)((end_y - Y1) / resY), NLines);
131 unsigned int firstCol = (
unsigned int)std::max((
int)((begin_x - X1) / resX), 0);
132 unsigned int lastCol = std::min((
unsigned int)((end_x - X1) / resX), NCols);
137 for (l = firstLine; l<lastLine; l++)
139 for (c = firstCol; c < lastCol; c++)
146 double interpolation = 0;
147 bool doInterpolation;
153 if (!doInterpolation)
159 interpolation = zdummy;
161 pg.
setZ(interpolation);
185 m_nsply = (
unsigned int)(endLine - beginLine);
200 m_BW = (2 * m_nsply + 1);
202 m_BW = (4 * m_nsply + 3);
213 std::size_t nVectorPoints =
m_dataset.size();
220 for (
unsigned int i = 0; i<nVectorPoints; i++)
226 if ((i_x >= -1) && (i_x < (int)m_nsplx) && (i_y >= -1) && (i_y < (
int)
m_nsply))
236 for (
unsigned int i = 0; i<nVectorPoints; i++)
242 if ((i_x >= -1) && (i_x < (int)m_nsplx) && (i_y >= -1) && (i_y < (
int)
m_nsply))
271 for (
unsigned int h = 0; h <
m_BW; h++)
278 for (
unsigned int i = 0; i <
m_npoints; i++)
284 if ((i_x >= -1) && (i_x < (int)m_nsplx) && (i_y >= -1) && (i_y < (
int)
m_nsply))
289 alpha[0][0] =
phi(csi_x, csi_y);
290 alpha[0][1] =
phi(csi_x, 1 - csi_y);
291 alpha[1][0] =
phi(1 - csi_x, csi_y);
292 alpha[1][1] =
phi(1 - csi_x, 1 - csi_y);
294 for (
unsigned int k = 0; k <= 1; k++)
296 for (
unsigned int h = 0; h <= 1; h++)
300 for (
unsigned int m = k; m <= 1; m++)
305 for (
unsigned int n = n0; n <= 1; n++)
310 order(i_x + (
int)k, i_y + (
int)h,
m_nsply))] += alpha[k][h] * alpha[m][n];
341 for (
unsigned int h = 0; h <
m_BW; h++)
347 for (
unsigned int i = 0; i <
m_npoints; i++)
353 if ((i_x >= -2) && (i_x <= (int)m_nsplx) && (i_y >= -2) && (i_y <= (
int)
m_nsply))
358 alpha[0][0] =
phi_44(1 + csi_x, 1 + csi_y);
359 alpha[0][1] =
phi_43(1 + csi_x, csi_y);
360 alpha[0][2] =
phi_43(1 + csi_x, 1 - csi_y);
361 alpha[0][3] =
phi_44(1 + csi_x, 2 - csi_y);
363 alpha[1][0] =
phi_34(csi_x, 1 + csi_y);
364 alpha[1][1] =
phi_33(csi_x, csi_y);
365 alpha[1][2] =
phi_33(csi_x, 1 - csi_y);
366 alpha[1][3] =
phi_34(csi_x, 2 - csi_y);
368 alpha[2][0] =
phi_34(1 - csi_x, 1 + csi_y);
369 alpha[2][1] =
phi_33(1 - csi_x, csi_y);
370 alpha[2][2] =
phi_33(1 - csi_x, 1 - csi_y);
371 alpha[2][3] =
phi_34(1 - csi_x, 2 - csi_y);
373 alpha[3][0] =
phi_44(2 - csi_x, 1 + csi_y);
374 alpha[3][1] =
phi_43(2 - csi_x, csi_y);
375 alpha[3][2] =
phi_43(2 - csi_x, 1 - csi_y);
376 alpha[3][3] =
phi_44(2 - csi_x, 2 - csi_y);
379 for (
int k = -1; k <= 2; k++)
381 for (
int h = -1; h <= 2; h++)
383 if (((i_x + k) >= 0) && ((i_x + k) < (
int)
m_nsplx) && ((i_y + h) >= 0) && ((i_y + h) < (
int)
m_nsply))
385 for (
int m = k; m <= 2; m++)
390 for (
int n = n0; n <= 2; n++) {
391 if (((i_x + m) >= 0) && ((i_x + m) < (
int)m_nsplx) && ((i_y + n) >= 0) && ((i_y + n) < (
int)m_nsply)) {
392 m_N[(
unsigned int)
order(i_x + k, i_y + h, m_nsply)][(
unsigned int)(
order(i_x + m, i_y + n, m_nsply) - \
393 order(i_x + k, i_y + h, m_nsply))] += alpha[(
unsigned int)(k + 1)][(
unsigned int)(h + 1)] * alpha[(
unsigned int)(m + 1)][(
unsigned int)(n + 1)];
397 m_TN[(
unsigned int)
order(i_x + k, i_y + h, m_nsply)] += pp3D.
getZ() * alpha[(
unsigned int)(k + 1)][(
unsigned int)(h + 1)];
416 double lambdaX, lambdaY;
423 alpha[0] = 2 * lambdaX + 2 * lambdaY;
427 for (i = 0; i < parNum; i++) {
428 m_N[i][0] += alpha[0];
430 if ((i + 1) < parNum)
431 m_N[i][1] += alpha[2];
433 if ((i + 1 * m_nsply) < parNum)
434 m_N[i][1 * m_nsply] += alpha[1];
446 unsigned int i, j, k;
451 for (j = 0; j <
m_BW; j++)
454 for (k = 1; k <
m_BW; k++)
455 if ((
int(i - k) >= 0) && ((j + k) < m_BW))
456 somma -= T[i - k][k] * T[i - k][j + k];
460 T[i][0] = sqrt(somma);
462 else T[i][j] = somma / T[i][0];
490 if ((i_x >= -1) && (i_x <(
int)
m_nsplx) && (i_y >= -1) && (i_y < (
int)
m_nsply))
495 alpha[0][0] =
phi(csi_x, csi_y);
496 alpha[0][1] =
phi(csi_x, 1 - csi_y);
498 alpha[1][0] =
phi(1 - csi_x, csi_y);
499 alpha[1][1] =
phi(1 - csi_x, 1 - csi_y);
501 for (k = 0; k <= 1; k++)
503 for (h = 0; h <= 1; h++)
505 if (((i_x + k) >= 0) && ((i_x + k) < (
int)m_nsplx) && ((i_y + h) >= 0) && ((i_y + h) < (
int)m_nsply))
506 z +=
m_parVect[(
unsigned int)
order(i_x + k, i_y + h, m_nsply)] * alpha[(
unsigned int)k][(
unsigned int)h];
536 if ((i_x >= -2) && (i_x <= (
int)
m_nsplx) && (i_y >= -2) && (i_y <= (
int)
m_nsply)) {
541 alpha[0][0] =
phi_44(1 + csi_x, 1 + csi_y);
542 alpha[0][1] =
phi_43(1 + csi_x, csi_y);
543 alpha[0][2] =
phi_43(1 + csi_x, 1 - csi_y);
544 alpha[0][3] =
phi_44(1 + csi_x, 2 - csi_y);
546 alpha[1][0] =
phi_34(csi_x, 1 + csi_y);
547 alpha[1][1] =
phi_33(csi_x, csi_y);
548 alpha[1][2] =
phi_33(csi_x, 1 - csi_y);
549 alpha[1][3] =
phi_34(csi_x, 2 - csi_y);
551 alpha[2][0] =
phi_34(1 - csi_x, 1 + csi_y);
552 alpha[2][1] =
phi_33(1 - csi_x, csi_y);
553 alpha[2][2] =
phi_33(1 - csi_x, 1 - csi_y);
554 alpha[2][3] =
phi_34(1 - csi_x, 2 - csi_y);
556 alpha[3][0] =
phi_44(2 - csi_x, 1 + csi_y);
557 alpha[3][1] =
phi_43(2 - csi_x, csi_y);
558 alpha[3][2] =
phi_43(2 - csi_x, 1 - csi_y);
559 alpha[3][3] =
phi_44(2 - csi_x, 2 - csi_y);
561 for (k = -1; k <= 2; k++)
563 for (h = -1; h <= 2; h++)
565 if (((i_x + k) >= 0) && ((i_x + k) < (
int)m_nsplx) && ((i_y + h) >= 0) && ((i_y + h) < (
int)m_nsply))
566 z +=
m_parVect[(
unsigned int)
order(i_x + k, i_y + h, m_nsply)] * alpha[(
unsigned int)(k + 1)][(
unsigned int)(h + 1)];
580 std::vector< std::vector<double> > T;
593 for (j = 0; j < i; j++)
595 m_parVect[i] = m_parVect[i] / T[i][0];
599 m_parVect[m_nparameters - 1] =
m_parVect[m_nparameters - 1] / T[m_nparameters - 1][0];
600 for (
int ii = (
int)m_nparameters - 2; ii >= 0; ii--)
640 if (npts <= 3 || snap == 0.)
643 for (
size_t i = 0; i < npts; i++)
645 ptlist->
setPointZ(i, vxy[i].getX(), vxy[i].getY(), Zvalue);
653 if (vxy[0] == vxy[npte - 1])
664 size_t numpf = npt - 1;
678 while (numa < (npt - 1))
688 aa1 = sqrt(a * a + 1.);
695 for (k = numa + 1; k < numpf; k++)
699 d = fabs(axy.
getX() - vxy[k].
getX());
701 d = fabs(vxy[k].getY() - a*vxy[k].getX() -
b) / aa1;
731 if ((
Distance(vxy[i], vxy[i - 1]) < snap) || (
Distance(vxy[i], vxy[0]) < snap))
742 for (i = 0; i < npts; i++)
744 ptlist->
setPointZ(i, vxy[i].getX(), vxy[i].getY(), Zvalue);
748 ptlist->
setPointZ(npts, vxy[0].getX(), vxy[0].getY(), Zvalue);
764 double z = ptol->
getZ(0);
766 std::vector<te::gm::Point> pts;
768 double xA, yA, xB, yB;
769 for (std::size_t i = 0; i < npte - 1; i++)
773 xB = vxy[i + 1].
getX();
774 yB = vxy[i + 1].
getY();
775 double dist = sqrt((xA - xB)*(xA - xB) + (yA - yB)*(yA - yB));
776 int nsteps = (
int)((dist / maxDist) + 1);
779 for (
int j = 0; j < nsteps; j++)
781 double t = (double)j / (
double)nsteps;
782 double x = (xB - xA)*t + xA;
783 double y = (yB - yA)*t + yA;
807 for (
size_t i = 0; i < pts.size(); i++)
double m_mean
Media da area local.
double m_nodatavalue
no data value
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.
int order(int i_x, int i_y, unsigned int yNum)
Node order computation.
unsigned int m_nsplx
Numero de colunas do spline.
double pointsControlMean()
std::unique_ptr< te::rst::Raster > Initialize(bool spline, unsigned int &nro_neighb, double &rx1, double &ry2, unsigned int &outputWidth, unsigned int &outputHeight)
Coord2D * getCoordinates() const
It returns a pointer to the internal array of coordinates.
unsigned int m_nPartsY
number of parts considered in the x and y directions
std::vector< te::gm::Point > m_obsVect
Interpolation and least-square vectors.
bool tcholDec(std::vector< std::vector< double > > &)
Tcholetsky decomposition -> T= Lower Triangular Matrix.
TEMNTEXPORT double Distance(const te::gm::Coord2D &pt1, const te::gm::Coord2D &pt2)
unsigned int nPointInterest()
const double & getUpperRightX() const
It returns a constant refernce to the x coordinate of the upper right corner.
This class can be used to inform the progress of a task.
std::vector< double > m_TN
double phi_34(double csi_x, double csi_y)
Design matrix coefficients computation.
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
bool tcholSolve()
Tcholetsky matrix solution.
double phi(double csi_x, double csi_y)
Design matrix coefficients computation.
bool calculateGrid(double xMin, double yMin)
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
double m_max
Output DTM limits.
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.
Interpolator m_inter
selected interpolation method
Utility functions for MNT support.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
LineString is a curve with linear interpolation between points.
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
void normalDefBilin(double xMin, double yMin)
Normal system computation for bilinear spline interpolation.
void node_y(double y, int &i_y, double &csi_y, double yMin, double deltaY)
Ordinate node index computation.
void setControlPoints(double xMin, double yMin)
static te::dt::DateTime d(2010, 8, 9, 15, 58, 39)
void setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
te::gm::Envelope m_env
Attribute used to restrict the area to generate the raster.
void setPointZ(std::size_t i, const double &x, const double &y, const double &z)
It sets the value of the specified point.
std::vector< double > m_parVect
Interpolating and least-square vectors.
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
unsigned int m_npoints
Numero de pontos de interesse.
unsigned int m_nsply
Numero de linhas do spline.
void initInterpolation(int beginLine, int endLine, int beginCol, int endCol)
double dataInterpolateBilin(double x, double y, double xMin, double yMin, bool &interp)
Data interpolation in a generic point.
double getX() const
It returns the x-coordinate.
std::vector< std::pair< te::gm::Coord2D, te::gm::Point > > m_dataset
double phi_43(double csi_x, double csi_y)
Design matrix coefficients computation.
void setX(const double &x)
It sets the Point x-coordinate value.
std::vector< std::vector< double > > m_N
Interpolation and least-square matrix.
void node_x(double x, int &i_x, double &csi_x, double xMin, double deltaX)
Ordinate node index computation.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
This file contains a class to calculate retangular grid from Samples using Spline Grass Interpolation...
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
double phi_44(double csi_x, double csi_y)
Design matrix coefficients computation.
void setPointN(std::size_t i, const Point &p)
It sets the value of the specified point to this new one.
void setY(const double &y)
It sets the Point y-coordinate value.
double dataInterpolateBicubic(double x, double y, double xMin, double yMin, bool &interp)
Data interpolation in a generic point.
unsigned int m_nparameters
void normalDefBicubic(double xMin, double yMin)
Normal system computation for bicubic spline interpolation.
double m_resy
grid resolution in X and Y
double m_overlapping
overlap value considered
void nCorrectGrad()
1-DELTA discretization
const double & getX() const
It returns the Point x-coordinate value.
unsigned int m_minpoints
minimum of points considered
static bool AdjustLinear(te::gm::LineString *ptol, double maxDist)
METHOD TO ADJUST A LINEAR CURVE TO A SET OF LINE POINTS.
double phi_33(double csi_x, double csi_y)
Design matrix coefficients computation.
void setZ(const double &z)
It sets the Point z-coordinate value.
double m_tolerance
tolerance used to simplify lines
static te::gm::LineString * pointListSimplify(te::gm::LineString *ls, double snap, double Zvalue)