29 #include "../../core/translator/Translator.h" 30 #include "../../common/progress/TaskProgress.h" 31 #include "../../core/logger/Logger.h" 32 #include "../../common/UnitsOfMeasureManager.h" 34 #include "../../dataaccess/dataset/DataSetTypeConverter.h" 35 #include "../../dataaccess/dataset/DataSetTypeCapabilities.h" 36 #include "../../dataaccess/datasource/DataSource.h" 37 #include "../../dataaccess/datasource/DataSourceFactory.h" 38 #include "../../dataaccess/datasource/DataSourceInfo.h" 39 #include "../../dataaccess/datasource/DataSourceManager.h" 40 #include "../../dataaccess/query/EqualTo.h" 42 #include "../../datatype/Property.h" 43 #include "../../datatype/SimpleProperty.h" 44 #include "../../datatype/StringProperty.h" 46 #include "../../geometry/Geometry.h" 47 #include "../../geometry/GeometryProperty.h" 48 #include "../../geometry/Line.h" 49 #include "../../geometry/MultiLineString.h" 50 #include "../../geometry/MultiPolygon.h" 51 #include "../../geometry/Point.h" 52 #include "../../geometry/Polygon.h" 54 #include "../../maptools/AbstractLayer.h" 56 #include "../../memory/DataSet.h" 57 #include "../../memory/DataSetItem.h" 59 #include "../../raster/RasterProperty.h" 60 #include "../../raster/RasterFactory.h" 61 #include "../../raster/Utils.h" 62 #include "../../raster/BandProperty.h" 64 #include "../../srs/SpatialReferenceSystemManager.h" 65 #include "../../statistics/core/Enums.h" 74 #include <boost/lexical_cast.hpp> 92 std::unique_ptr<te::da::DataSetType>dsTypeRaster =
m_inDsrc->getDataSetType(
m_inName);
96 std::unique_ptr<te::rst::Raster> raster = ds->getRaster(inProp->
getName());
107 double xmin, xmax, ymin, ymax, zval, pt1X, pt1Y, pt2X, pt2Y;
108 unsigned int col, row;
112 std::map<double, double>
line;
120 double boxLowerLeft = raster->getExtent()->getLowerLeftX();
121 double boxUpperRigth = raster->getExtent()->getUpperRightY();
123 double resX = raster->getResolutionX();
124 double resY = raster->getResolutionY();
127 m_srid = raster->getSRID();
137 for (std::size_t v = 0; v < visadas.size(); ++v)
140 for (std::size_t i = 0; i < l->
getNPoints()-1; i++)
145 collin = raster->getGrid()->geoToGrid(pt1X, pt1Y);
146 col =
static_cast<unsigned int>(collin.
getX());
147 row =
static_cast<unsigned int>(collin.
getY());
149 if (col >= raster->getNumberOfColumns() || row >= raster->getNumberOfRows())
151 raster->getValue(col, row, zval);
156 line.insert(std::map<double, double>::value_type(0.0, zval));
185 int initcol =
static_cast<int>((xmin - boxLowerLeft) / resX);
186 int finalcol =
static_cast<int>((xmax - boxLowerLeft) / resX + .9999);
187 int initline =
static_cast<int>((boxUpperRigth - ymax) / resY);
188 int finalline =
static_cast<int>((boxUpperRigth - ymin) / resY + .9999);
190 double dx = pt2X - pt1X;
191 double dy = pt2Y - pt1Y;
194 if (((finalcol - initcol) > 1) && (fabs(static_cast<double>(dx)) > 1.0e-6))
196 for (
int c = (initcol + 1); c < finalcol; c++)
198 double x = (boxLowerLeft + c * resX);
199 double y = (pt1Y + (dy /
dx) * (x - pt1X));
201 collin = raster->getGrid()->geoToGrid(x, y);
202 col =
static_cast<unsigned int>(collin.
getX());
203 row =
static_cast<unsigned int>(collin.
getY());
205 if (col >= raster->getNumberOfColumns() || row >= raster->getNumberOfRows())
208 raster->getValue(col, row, zval);
211 double dist = sqrt((static_cast<double>(x - pt1X)*static_cast<double>(x - pt1X)) + (static_cast<double>(y - pt1Y)*static_cast<double>(y - pt1Y))) + distbase;
214 line.insert(std::map<double, double>::value_type(dist, zval));
221 if (((finalline - initline) > 1) && (fabs((
double)dy) > 1.0e-6))
223 for (
int ll = (initline + 1); ll < finalline; ll++)
226 double y = boxUpperRigth - (ll * resY);
227 double x = pt1X + (dx / dy) * (y - pt1Y);
229 collin = raster->getGrid()->geoToGrid(x, y);
230 col =
static_cast<unsigned int>(collin.
getX());
231 row =
static_cast<unsigned int>(collin.
getY());
233 if (col >= raster->getNumberOfColumns() || row >= raster->getNumberOfRows())
236 raster->getValue(col, row, zval);
240 double dist = sqrt((static_cast<double>(x - pt1X)*static_cast<double>(x - pt1X)) + (static_cast<double>(y - pt1Y)*static_cast<double>(y - pt1Y))) + distbase;
243 line.insert(std::map<double, double>::value_type(dist, zval));
250 collin = raster->getGrid()->geoToGrid(pt2X, pt2Y);
251 col =
static_cast<unsigned int>(collin.
getX());
252 row =
static_cast<unsigned int>(collin.
getY());
254 if (col >= raster->getNumberOfColumns() || row >= raster->getNumberOfRows())
256 raster->getValue(col, row, zval);
259 double dist = sqrt((static_cast<double>(dx) * static_cast<double>(dx)) + (static_cast<double>(dy)* static_cast<double>(dy))) + distbase;
261 if (ind_pf != ind_pfant)
269 line.insert(std::map<double, double>::value_type(dist, zval));
274 std::map<double, double>::iterator it = line.begin();
276 while (it != line.end())
279 profile->
setPoint(profile->
size() - 1, it->first, it->second);
283 profileSet.push_back(profile);
299 std::map<double, double>
line;
302 for (std::size_t t = 0; t < trajectory.
size() - 1; t++)
306 for (std::size_t i = 0; i < isolines.size(); i++)
309 for (std::size_t j = 0; j < iso->
getNPoints() - 1; j++)
316 line.insert(std::map<double, double>::value_type(dist + dist0, *iso->
getZ()));
323 std::map<double, double>::iterator it = line.begin();
325 while (it != line.end())
328 profile->
setPoint(profile->
size() - 1, it->first, it->second);
337 std::unique_ptr<te::da::DataSetType>dsType =
m_inDsrc->getDataSetType(
m_inName);
347 std::string geostype;
350 if (
ReadSamples(
m_inName,
m_inDsrc,
m_attrZ, 0, 0,
None, mpt, isolines, geostype, env,
m_srid) == 0)
359 std::vector<te::gm::Geometry*> reportline;
360 for (std::size_t v = 0; v < visadas.size(); ++v)
363 linetree.
search(*visadas[v]->getMBR(), reportline);
364 if (reportline.size())
368 profileSet.push_back(profile);
376 std::unique_ptr<te::da::DataSetType>dsType =
m_inDsrc->getDataSetType(
m_inName);
387 inDset->moveBeforeFirst();
389 std::vector<te::gm::Polygon *> vp;
392 std::vector<te::gm::Geometry*> reportline;
396 while (inDset->moveNext())
398 std::unique_ptr<te::gm::Geometry> gin = inDset->getGeometry(geo_pos);
407 for (std::size_t i = 0; i < np; i++)
408 vp.push_back(dynamic_cast<te::gm::Polygon*>(mg->
getGeometryN(i)));
417 for (std::size_t i = 0; i < vp.size(); ++i)
422 for (std::size_t
p = 0;
p < 3;
p++)
429 if (reportline.size())
437 for (std::size_t v = 0; v < visadas.size(); ++v)
440 linetree.
search(*visadas[v]->getMBR(), reportline);
441 if (reportline.size())
445 profileSet.push_back(profile);
454 #ifdef TERRALIB_LOGGER_ENABLED std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
MultiPolygon is a MultiSurface whose elements are Polygons.
A Line is LineString with 2 points.
std::string m_attrZ
Z attribute name.
te::da::DataSourcePtr m_inDsrc
Input Datasource.
int m_srid
Attribute with spatial reference information.
boost::shared_ptr< DataSource > DataSourcePtr
static te::dt::Date dx(2010, 12, 31)
A class that represents an R-tree.
std::string m_inName
Input data name.
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
TEMNTEXPORT double Distance(const te::gm::Coord2D &pt1, const te::gm::Coord2D &pt2)
bool runIsolinesProfile(std::vector< te::gm::LineString * > visadas, std::vector< te::gm::LineString * > &profileSet)
Calculate Profile from isolines.
virtual const char * what() const
It outputs the exception message.
#define TE_CORE_LOG_DEBUG(channel, message)
Use this tag in order to log a message to a specified logger with the DEBUG level.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
bool intersection(const Line &line, Point &coord) const
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
static te::dt::Date ds(2010, 01, 01)
#define TE_TR(message)
It marks a string in order to get translated.
std::unique_ptr< te::rst::Raster > getPrepareRaster()
Reads raster.
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
Utility functions for MNT support.
A LinearRing is a LineString that is both closed and simple.
void setInput(te::da::DataSourcePtr inDsrc, std::string inName, std::unique_ptr< te::da::DataSetType > inDsetType, double dummy, std::string zattr)
Sets input parameters to calculate profile.
MultiPoint is a GeometryCollection whose elements are restricted to points.
LineString is a curve with linear interpolation between points.
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.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
An Envelope defines a 2D rectangular region.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
Profile()
Default constructor.
void setNumCoordinates(std::size_t size)
It reserves room for the number of coordinates in this LineString.
void setCoord(int index, double x, double y, double z=0., double m=0.)
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
void setPointZ(std::size_t i, const double &x, const double &y, const double &z)
It sets the value of the specified point.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
double m_dummy
Nodata value.
TEMNTEXPORT size_t ReadSamples(std::string &inDsetName, te::da::DataSourcePtr &inDsrc, std::string &atrZ, double tol, double max, Simplify alg, te::gm::MultiPoint &mpt, te::gm::MultiLineString &isolines, std::string &geostype, te::gm::Envelope &env, int srid=0)
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
MultiLineString is a MultiCurve whose elements are LineStrings.
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
double getX() const
It returns the x-coordinate.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
std::unique_ptr< te::da::DataSetType > m_inDsType
Input datasettype.
bool runTINProfile(std::vector< te::gm::LineString * > visadas, std::vector< te::gm::LineString * > &profileSet)
Calculate Profile from TIN.
const double & getZ(std::size_t i) const
It returns the n-th z coordinate value.
~Profile()
Virtual destructor.
UnitOfMeasurePtr find(unsigned int id) const
Returns a unit of measure identified by its identificaton.
TEDATAACCESSEXPORT std::size_t GetFirstPropertyPos(const te::da::DataSet *dataset, int datatype)
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
te::gm::LineString * calculateProfile(std::vector< te::gm::Geometry * > &isolines, te::gm::LineString &trajectory)
const double & getX() const
It returns the Point x-coordinate value.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
std::size_t size() const
It returns the number of points (vertexes) in the geometry.
This file contains a class that represents the profile.
TEMNTEXPORT bool convertAngleToPlanar(double &val, te::common::UnitOfMeasurePtr planar, int type)
const std::string & getName() const
It returns the property name.
bool runRasterProfile(std::vector< te::gm::LineString * > visadas, std::vector< te::gm::LineString * > &profileSet)
Calculate Profile from raster.