28 #include "../common/progress/TaskProgress.h"
29 #include "../common/Logger.h"
30 #include "../common/Translator.h"
32 #include "../dataaccess/dataset/DataSet.h"
33 #include "../dataaccess/dataset/DataSetAdapter.h"
34 #include "../dataaccess/utils/Utils.h"
36 #include "../geometry/GeometryProperty.h"
38 #include "../memory/DataSet.h"
39 #include "../memory/DataSetItem.h"
56 std::auto_ptr<te::da::DataSetType> outDsType = buildOutDataSetType();
60 std::string geomName = geomProp->
getName();
63 std::auto_ptr<te::da::DataSet> inDsetSrc;
66 inDsetSrc = m_inDsrc->getDataSet(m_inDsetName);
68 inDsetSrc = m_inDsrc->getDataSet(m_inDsetName, m_oidSet);
70 std::auto_ptr<te::da::DataSetAdapter> inDset(
te::da::CreateAdapter(inDsetSrc.get(), m_converter.get()));
72 std::auto_ptr<te::mem::DataSet> outDSet(
new te::mem::DataSet(outDsType.get()));
78 inDset->moveBeforeFirst();
79 while(inDset->moveNext())
82 bool geomState =
true;
92 std::auto_ptr<te::gm::Geometry> geom = inDset->getGeometry(geomPos);
99 std::auto_ptr<te::gm::MultiPolygon> polygonResult = line2Polygon(geom.get());
100 if(!polygonResult->isValid() || polygonResult->isEmpty())
103 outDsItem->
setGeometry(i, polygonResult.release());
109 outDSet->add(outDsItem);
112 throw te::vp::Exception(
TE_TR(
"Operation canceled!"));
117 te::vp::Save(m_outDsrc.get(), outDSet.get(), outDsType.get());
123 std::vector<te::gm::Polygon*> polygons;
126 getPolygons(geom, polygons);
128 if(polygons.size() > 1)
130 for(std::size_t i = 0; i < polygons.size(); ++i)
131 polygonResult->add(polygons[i]);
135 polygonResult->add(polygons[0]);
138 return polygonResult;
149 getPolygons(dynamic_cast<te::gm::GeometryCollection*>(geom), polygons);
153 getPolygons(dynamic_cast<te::gm::LineString*>(geom), polygons);
179 for(std::size_t i = 0; i < l->
getNPoints(); ++i)
184 getPolygons(p, polygons);
191 polygons.push_back(p);
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
void add(Curve *ring)
It adds the ring to the curve polygon.
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
MultiPolygon is a MultiSurface whose elements are Polygons.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
Utility functions for the data access module.
std::string getPropertyName(std::size_t pos) const
It returns the name of the pos-th property.
std::auto_ptr< te::gm::MultiPolygon > line2Polygon(te::gm::Geometry *geom)
int getPropertyDataType(std::size_t pos) const
It returns the type of the pos-th property.
void useTimer(bool flag)
Used to define if task use progress timer information.
void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType)
This class can be used to inform the progress of a task.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
#define TE_TR(message)
It marks a string in order to get translated.
std::size_t getNumProperties() const
It returns the number of properties.
bool isActive() const
Verify if the task is active.
bool isClosed() const
It returns true if the curve is closed (startPoint = endPoint).
const double & getY(std::size_t i) const
It returns the n-th y coordinate value.
void setTotalSteps(int value)
Set the task total stepes.
A LinearRing is a LineString that is both closed and simple.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
LineString is a curve with linear interpolation between points.
void getPolygons(te::gm::Geometry *geom, std::vector< te::gm::Polygon * > &polygons)
void setPoint(std::size_t i, const double &x, const double &y)
It sets the value of the specified point.
const double & getX(std::size_t i) const
It returns the n-th x coordinate value.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
It is a collection of other geometric objects.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
Line to Polygon Vector Processing functions.
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
const std::string & getName() const
It returns the property name.