24 #include "../common.h"
25 #include "../common/progress/TaskProgress.h"
26 #include "../common/Translator.h"
28 #include "../dataaccess/dataset/DataSet.h"
29 #include "../dataaccess/dataset/DataSetAdapter.h"
30 #include "../dataaccess/dataset/DataSetType.h"
31 #include "../dataaccess/dataset/DataSetTypeConverter.h"
32 #include "../dataaccess/dataset/ObjectIdSet.h"
33 #include "../dataaccess/datasource/DataSource.h"
34 #include "../dataaccess/datasource/DataSourceCapabilities.h"
35 #include "../dataaccess/utils/Utils.h"
37 #include "../datatype/Property.h"
38 #include "../datatype/StringProperty.h"
40 #include "../geometry/GeometryProperty.h"
41 #include "../geometry/Polygon.h"
43 #include "../memory/DataSetItem.h"
45 #include "../raster.h"
46 #include "../raster/BandProperty.h"
47 #include "../raster/Grid.h"
48 #include "../raster/RasterFactory.h"
50 #include "../rp/RasterAttributes.h"
52 #include "../statistics/core/Utils.h"
63 std::string inVectorName,
64 std::auto_ptr<te::da::DataSetType> inVectorDsType)
66 m_inVectorDsrc = inVectorDsrc;
67 m_inVectorName = inVectorName;
68 m_inVectorDsType = inVectorDsType;
79 m_selectedAttVec = selectedAttVec;
80 m_resolutionX = resolutionX;
81 m_resolutionY = resolutionY;
84 m_setDummy = setDummy;
98 if(!m_inVectorDsType.get())
101 if(m_outDset.empty() || !m_outDsrc.get())
104 if(m_selectedAttVec.size() == 0)
107 if(m_resolutionX == 0 || m_resolutionY == 0)
110 if(m_columns == 0 || m_rows == 0)
118 std::auto_ptr<te::da::DataSet> inDataSet = m_inVectorDsrc->getDataSet(m_inVectorName);
120 std::size_t propPos = m_inVectorDsType->getPropertyPosition(geomProp->
getName());
127 std::vector<te::rst::BandProperty*> vecBandProp;
129 for(std::size_t i = 0; i < m_selectedAttVec.size(); ++i)
131 te::dt::Property* prop = m_inVectorDsType->getProperty(m_selectedAttVec[i]);
134 if(m_setDummy ==
true)
137 vecBandProp.push_back(bProp);
141 std::map<std::string, std::string> conInfo = m_outDsrc->getConnectionInfo();
147 std::string geomName = geomProp->
getName();
148 std::map<te::gm::Geometry*, std::vector<double> > vectorMap;
150 inDataSet->moveBeforeFirst();
151 while(inDataSet->moveNext())
154 std::vector<double> valueVec;
156 for(std::size_t b = 0; b < m_selectedAttVec.size(); ++b)
158 valueVec.push_back(inDataSet->getDouble(m_selectedAttVec[b]));
161 vectorMap.insert(std::pair<
te::gm::Geometry*, std::vector<double> >(geom, valueVec));
165 task.
setTotalSteps(m_selectedAttVec.size() * vectorMap.size());
168 for(std::size_t i = 0; i < m_selectedAttVec.size(); ++i)
170 std::map<te::gm::Geometry*, std::vector<double> >::iterator vectorIt = vectorMap.begin();
172 while(vectorIt != vectorMap.end())
193 throw te::attributefill::Exception(
TE_TR(
"Operation canceled!"));
boost::shared_ptr< DataSource > DataSourcePtr
A raster band description.
void useTimer(bool flag)
Used to define if task use progress timer information.
This class implements the strategy to iterate with spatial restriction, the iteration occurs inside a...
This class can be used to inform the progress of a task.
An exception class for the Attribute Fill module.
unsigned int getRow() const
Returns the current row in iterator.
double m_noDataValue
Value to indicate elements where there is no data, default is std::numeric_limits::max().
#define TE_TR(message)
It marks a string in order to get translated.
It models a property definition.
bool isActive() const
Verify if the task is active.
void setTotalSteps(int value)
Set the task total stepes.
static PolygonIterator end(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to after the end of the iterator.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
An Envelope defines a 2D rectangular region.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
Vector to Raster processing.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setInput(te::da::DataSourcePtr inVectorDsrc, std::string inVectorName, std::auto_ptr< te::da::DataSetType > inVectorDsType)
void setParams(std::vector< std::string > selectedAttVec, double resolutionX, double resolutionY, int columns, int rows, bool useDummy, int dummy=0)
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
static PolygonIterator begin(const te::rst::Raster *r, const te::gm::Polygon *p)
Returns an iterator referring to the first value of the band.
static Raster * make()
It creates and returns an empty raster with default raster driver.
unsigned int getColumn() const
Returns the current column in iterator.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
A rectified grid is the spatial support for raster data.
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsName)
const std::string & getName() const
It returns the property name.