12 #include "../../common/progress/TaskProgress.h" 13 #include "../../common/StringUtils.h" 14 #include "../../dataaccess/utils/Utils.h" 15 #include "../../dataaccess/dataset/DataSetAdapter.h" 16 #include "../../dataaccess/dataset/DataSetTypeConverter.h" 17 #include "../../geometry/GeometryProperty.h" 18 #include "../../geometry/GEOSWriter.h" 19 #include "../../raster.h" 20 #include "../../srs/SpatialReferenceSystemManager.h" 22 #include <geos/geom/Point.h> 23 #include <geos/geom/Polygon.h> 24 #include <geos/geosAlgorithm.h> 31 std::string inrstDsetName,
32 std::unique_ptr<te::da::DataSetType> inrstDsetType,
34 std::string invecDsetName,
35 std::unique_ptr<te::da::DataSetType> invecDsetType,
64 std::unique_ptr<te::da::DataSet> inDsetSrc;
74 inDsetSrc->moveBeforeFirst();
76 int flin, llin, fcol, lcol;
77 std::vector <te::gm::Polygon *> pols;
79 while (inDsetSrc->moveNext())
81 std::unique_ptr<te::gm::Geometry> gin = inDsetSrc->getGeometry(geo_pos);
87 pols.push_back(dynamic_cast<te::gm::Polygon*>(gin.get()->clone()));
94 for (
size_t p = 0; p < dynamic_cast<te::gm::GeometryCollection*>(mp)->getNumGeometries();
p++)
96 pols.push_back(dynamic_cast<te::gm::Polygon*>(dynamic_cast<te::gm::GeometryCollection*>(mp)->getGeometryN(
p)->clone()));
101 for (
size_t p = 0;
p < pols.size();
p++)
102 if (
DefLC(pols[
p], flin, llin, fcol, lcol))
105 std::string attr = inDsetSrc->getString(
m_attr);
106 if (
CVGrd(pols[p], flin, llin, fcol, lcol, attr))
130 cg =
m_raster->getGrid()->geoToGrid(llpt.getX(), llpt.getY());
133 cg =
m_raster->getGrid()->geoToGrid(urpt.getX(), urpt.getY());
137 if (((
int)
m_raster->getNumberOfColumns() <= fcol) || (lcol < 0) ||
138 ((
int)
m_raster->getNumberOfRows() <= flin) || (llin < 0))
145 if ((
int)
m_raster->getNumberOfColumns() <= lcol)
146 lcol = (
int)
m_raster->getNumberOfColumns() - 1;
147 if ((
int)
m_raster->getNumberOfRows() <= llin)
148 llin = (
int)
m_raster->getNumberOfRows() - 1;
159 double volcorte = 0.;
160 double volaterro = 0.;
163 std::string msg(
"Calculating Volume - Pol(");
168 double rx =
m_raster->getResolutionX();
169 double ry =
m_raster->getResolutionY();
185 areatotal = areabase;
188 geos::geom::Coordinate pt;
192 geos::algorithm::PointLocator loc;
195 for (
int i = flin; i <= llin; i++)
197 for (
int j = fcol; j <= lcol; j++)
200 cg =
m_raster->getGrid()->gridToGeo(j, i);
203 if (loc.locate(
pt1, polGeom.get()) == geos::geom::Location::INTERIOR)
206 m_raster->getValue((
unsigned)j, (
unsigned)i, value);
216 volaterro += (
m_quota - value);
219 areatotal += areabase;
221 nrozs = nrozs + (double)1.0;
230 volaterro *= areabase;
231 volcorte *= areabase;
247 std::vector<std::string> &cortevec,
248 std::vector<std::string> &aterrovec,
249 std::vector<std::string> &areavec,
250 std::vector<std::string> &iquotavec)
TEDATAACCESSEXPORT te::rst::RasterProperty * GetFirstRasterProperty(const DataSetType *dt)
MultiPolygon is a MultiSurface whose elements are Polygons.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
boost::shared_ptr< DataSource > DataSourcePtr
bool DefLC(te::gm::Polygon *pol, int &flin, int &llin, int &fcol, int &lcol)
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.
void setParams(double quota, std::string &attr, double dummy)
const double & getLowerLeftY() const
It returns a constant refernce to the y coordinate of the lower left corner.
An utility struct for representing 2D coordinates.
double getY() const
It returns the y-coordinate.
const double & getUpperRightY() const
It returns a constant refernce to the x coordinate of the upper right corner.
std::unique_ptr< te::da::DataSetType > m_inrstDsetType
te::da::DataSourcePtr m_inrstDsrc
void getResults(std::vector< std::string > &polyvec, std::vector< std::string > &cortevec, std::vector< std::string > &aterrovec, std::vector< std::string > &areavec, std::vector< std::string > &iquotavec)
void setInput(te::da::DataSourcePtr inrstDsrc, std::string inrstDsetName, std::unique_ptr< te::da::DataSetType > inrstDsetType, te::da::DataSourcePtr invecDsrc, std::string invecDsetName, std::unique_ptr< te::da::DataSetType > invecDsetType, const te::da::ObjectIdSet *OidSet)
static SpatialReferenceSystemManager & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
std::unique_ptr< te::rst::Raster > m_raster
This class represents a set of unique ids created in the same context. i.e. from the same data set...
te::da::DataSourcePtr m_invecDsrc
int m_srid
Attribute with spatial reference information.
TERASTEREXPORT int Round(double val)
Round a double value to a integer value.
CurvePolygon is a planar surface defined by 1 exterior boundary and 0 or more interior boundaries...
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
Utility functions for the data access module.
static geos::geom::Geometry * write(const Geometry *teGeom)
It reads a TerraLib geometry and make a GEOS geometry.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
bool CVGrd(te::gm::Polygon *pol, int flin, int llin, int fcol, int lcol, std::string &polid)
std::vector< std::string > m_polyvec
Attribute with structure to save results.
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.
const double & getLowerLeftX() const
It returns a constant reference to the x coordinate of the lower left corner.
std::vector< std::string > m_aterrovec
Attribute with structure to save results.
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)
std::string Convert2String(boost::int16_t value)
It converts a short integer value to a string.
std::vector< std::string > m_cortevec
Attribute with structure to save results.
const te::da::ObjectIdSet * m_OidSet
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
This file contains a class to calculate volume. Adapted from SPRING.
std::unique_ptr< te::da::DataSetType > m_invecDsetType
std::vector< std::string > m_areavec
Attribute with structure to save results.
std::vector< std::string > m_iquotavec
Attribute with structure to save results.
std::string m_invecDsetName
TEMNTEXPORT bool convertAngleToPlanar(double &val, te::common::UnitOfMeasurePtr planar, int type)
const std::string & getName() const
It returns the property name.
std::string m_inrstDsetName