24 #include "../common/progress/TaskProgress.h" 
   25 #include "../common/Translator.h" 
   27 #include "../dataaccess/dataset/DataSet.h" 
   28 #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.h" 
   42 #include "../memory/DataSetItem.h" 
   44 #include "../raster/RasterProperty.h" 
   45 #include "../raster/Utils.h" 
   47 #include "../rp/RasterAttributes.h" 
   48 #include "../rp/Texture.h" 
   50 #include "../statistics/core/Utils.h" 
   56 #include <boost/lexical_cast.hpp> 
   63                                               std::string inRasterName,
 
   64                                               std::auto_ptr<te::da::DataSetType> inRasterDsType,
 
   66                                               std::string inVectorName,
 
   67                                               std::auto_ptr<te::da::DataSetType> inVectorDsType)
 
   69   m_inRasterDsrc = inRasterDsrc;
 
   70   m_inRasterName = inRasterName;
 
   71   m_inRasterDsType = inRasterDsType;
 
   72   m_inVectorDsrc = inVectorDsrc;
 
   73   m_inVectorName = inVectorName;
 
   74   m_inVectorDsType = inVectorDsType;
 
   78                                                std::vector<te::stat::StatisticalSummary> statSum,
 
   94   if (!m_inVectorDsType.get())
 
   97   if (!m_inVectorDsType->hasGeom())
 
  100   if (m_outDset.empty() || !m_outDsrc.get())
 
  109   std::auto_ptr<te::da::DataSetType> outDsType = getDataSetType();
 
  111   std::auto_ptr<te::mem::DataSet> outDataset(
new te::mem::DataSet(outDsType.get()));
 
  116   std::auto_ptr<te::da::DataSet> dsRaster = m_inRasterDsrc->getDataSet(m_inRasterName);
 
  117   std::auto_ptr<te::rst::Raster> raster = dsRaster->getRaster(rasterProp->
getName());
 
  122   std::auto_ptr<te::da::DataSet> dsVector = m_inVectorDsrc->getDataSet(m_inVectorName);
 
  128   task.
setTotalSteps(dsVector->size() * m_statSum.size() * m_bands.size());
 
  131   dsVector->moveBeforeFirst();
 
  132   while(dsVector->moveNext())
 
  136     std::vector<te::dt::Property*> vecProp = m_inVectorDsType->getProperties();
 
  137     for(std::size_t i = 0; i < vecProp.size(); ++i)
 
  139       outDSetItem->
setValue(i, dsVector->getValue(i).release());
 
  143     std::auto_ptr<te::gm::Geometry> geom = dsVector->getGeometry(vectorProp->
getName());
 
  146     std::vector<std::vector<double> > valuesFromRaster;
 
  147     valuesFromRaster.resize(m_bands.size());
 
  154       for(std::size_t n = 0; n < n_geom; ++n)
 
  157         std::vector<std::vector<double> > tempValues = rasterAtt->
getValuesFromRaster(*raster, *polygon, m_bands);
 
  159         for(std::size_t band = 0; band < tempValues.size(); ++band)
 
  161           std::vector<double>::iterator it;
 
  162           it = valuesFromRaster[band].end();
 
  164           valuesFromRaster[band].insert(it,
 
  165                                         tempValues[band].begin(),
 
  166                                         tempValues[band].end());
 
  180     std::size_t init_index = m_inVectorDsType->getProperties().size();
 
  183     for(std::size_t band = 0; band < valuesFromRaster.size(); ++band)
 
  186       int current_index = init_index + m_statSum.size();
 
  188       for(
int it = 0, i = init_index; i < current_index; ++it, ++i)
 
  237             if (!summary.
m_mode.empty())
 
  239               mode = boost::lexical_cast<std::string>(summary.
m_mode[0]);
 
  240               for(std::size_t m=1; m<summary.
m_mode.size(); ++m)
 
  243                 mode += boost::lexical_cast<std::string>(summary.
m_mode[m]);
 
  260       std::vector<te::rp::Texture> metrics;
 
  261       init_index = current_index;
 
  263       if(m_texture == 
true)
 
  265         metrics = getTexture(raster.get(), geom.get(), m_bands.size());
 
  267         for(
int t = 0, i = init_index; i < current_index; ++t,++i)
 
  273               outDSetItem->
setDouble(i, metrics[band].m_contrast);
 
  278               outDSetItem->
setDouble(i, metrics[band].m_dissimilarity);
 
  283               outDSetItem->
setDouble(i, metrics[band].m_energy);
 
  288               outDSetItem->
setDouble(i, metrics[band].m_entropy);
 
  293               outDSetItem->
setDouble(i, metrics[band].m_homogeneity);
 
  300       init_index = current_index;
 
  303     outDataset->add(outDSetItem);
 
  306       throw te::attributefill::Exception(
TE_TR(
"Operation canceled!"));
 
  309   return save(outDataset,outDsType);
 
  316   outdsType->setCompositeName(m_outDset);
 
  317   outdsType->setName(m_outDset);
 
  318   outdsType->setTitle(m_outDset);
 
  322   std::string name = pk->
getName();
 
  323   name += 
"_" + m_outDset;
 
  326   for(std::size_t b = 0; b < m_bands.size(); ++b)
 
  328     for(std::size_t i = 0; i < m_statSum.size(); ++i)
 
  335           outdsType->add(prop);
 
  339           outdsType->add(prop);
 
  343           outdsType->add(prop);
 
  347           outdsType->add(prop);
 
  351           outdsType->add(prop);
 
  355           outdsType->add(prop);
 
  359           outdsType->add(prop);
 
  363           outdsType->add(prop);
 
  367           outdsType->add(prop);
 
  371           outdsType->add(prop);
 
  375           outdsType->add(prop);
 
  379           outdsType->add(prop);
 
  383           outdsType->add(prop);
 
  387           outdsType->add(prop);
 
  393     if(m_texture == 
true)
 
  396       outdsType->add(propContrast);
 
  399       outdsType->add(propDissimilarity);
 
  402       outdsType->add(propEnergy);
 
  405       outdsType->add(propEntropy);
 
  408       outdsType->add(propHomogeneity);
 
  420   std::vector<te::rp::Texture> textureVec;
 
  434   for(
int i = 0; i < bands; ++i)
 
  436     boost::numeric::ublas::matrix<double> glcm = rattributes.
getGLCM(*rst, i, 1, 1, *polygon);
 
  438     textureVec.push_back(metrics);
 
  451   std::map<std::string, std::string> options;
 
  453   m_outDsrc->createDataSet(dsTypeResult, options);
 
  456   result->moveBeforeFirst();
 
  457   m_outDsrc->add(dsTypeResult->getName(),result.get(), options);
 
  460   if (m_outDsrc->getCapabilities().getDataSetTypeCapabilities().supportsPrimaryKey())
 
  462     std::string pk_name = dsTypeResult->getName() + 
"_pkey";
 
  464     pk->
add(dsTypeResult->getProperty(0));
 
  465     m_outDsrc->addPrimaryKey(m_outDset,pk);
 
virtual void setName(const std::string &name)
It sets the constraint name. 
 
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 structure to hold the set of statistics from a set of numerical values. 
 
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key. 
 
void setDouble(std::size_t i, double value)
It sets the value of the i-th property. 
 
An atomic property like an integer or double. 
 
boost::shared_ptr< DataSource > DataSourcePtr
 
A class that models the description of a dataset. 
 
void useTimer(bool flag)
Used to define if task use progress timer information. 
 
void setOutput(te::da::DataSourcePtr outDsrc, std::string dsName)
 
DataSetType * getResult() const 
 
This class can be used to inform the progress of a task. 
 
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property. 
 
std::vector< double > m_mode
 
An exception class for the Attribute Fill module. 
 
void setParams(std::vector< unsigned int > bands, std::vector< te::stat::StatisticalSummary > statSum, bool texture)
 
boost::numeric::ublas::matrix< double > getGLCM(const te::rst::Raster &rin, unsigned int band, int dx, int dy)
Computes the Gray-Level CoOccurrence Matrix (GLCM) from a raster band. 
 
#define TE_TR(message)
It marks a string in order to get translated. 
 
bool isActive() const 
Verify if the task is active. 
 
Extraction of attributes from Raster, Bands, and Polygons. 
 
std::vector< te::rp::Texture > getTexture(te::rst::Raster *rst, te::gm::Geometry *geom, int bands)
 
void setTotalSteps(int value)
Set the task total stepes. 
 
An converter for DataSetType. 
 
std::auto_ptr< te::da::DataSetType > getDataSetType()
 
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
 
An abstract class for raster data strucutures. 
 
Raster to Vector processing. 
 
std::vector< std::vector< double > > getValuesFromRaster(const te::rst::Raster &raster, const te::gm::Polygon &polygon, std::vector< unsigned int > bands)
Returns the pixel values for all the bands in raster, inside the polygon. 
 
te::rp::Texture getGLCMMetrics(boost::numeric::ublas::matrix< double > glcm)
Compute texture metrics from GLCM matrix. 
 
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1. 
 
The type for string types: FIXED_STRING, VAR_STRING or STRING. 
 
void setInput(te::da::DataSourcePtr inRasterDsrc, std::string inRasterName, std::auto_ptr< te::da::DataSetType > inRasterDsType, te::da::DataSourcePtr inVectorDsrc, std::string inVectorName, std::auto_ptr< te::da::DataSetType > inVectorDsType)
 
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. 
 
te::stat::NumericStatisticalSummary getStatistics(std::vector< double > &pixels)
Returns several statistics from a set of pixels. 
 
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. 
 
bool save(std::auto_ptr< te::mem::DataSet > result, std::auto_ptr< te::da::DataSetType > outDsType)
 
It describes a primary key (pk) constraint. 
 
A structure to hold the set of GLCM metrics. 
 
StatisticalSummary
Define grouping functions type. 
 
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property. 
 
virtual const std::string & getName() const 
It returns the constraint name. 
 
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
 
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
 
const std::string & getName() const 
It returns the property name.