32 #include "../../common/Exception.h" 
   33 #include "../../common/Translator.h" 
   34 #include "../../common/progress/TaskProgress.h" 
   35 #include "../../dataaccess/datasource/DataSource.h" 
   36 #include "../../dataaccess/datasource/DataSourceManager.h" 
   37 #include "../../dataaccess/utils/Utils.h" 
   38 #include "../../datatype/SimpleProperty.h" 
   39 #include "../../geometry/Geometry.h" 
   40 #include "../../geometry/GeometryProperty.h" 
   41 #include "../../memory/DataSet.h" 
   42 #include "../../memory/DataSetItem.h" 
   59   assert(m_inputParams->m_ds.get());
 
   60   assert(m_inputParams->m_dsType.get());
 
   63   std::auto_ptr<te::da::DataSetType> outDsType = createDataSetType(m_inputParams->m_dsType.get());
 
   65   std::auto_ptr<te::mem::DataSet> outDs = createDataSet(m_inputParams->m_ds.get(), outDsType.get());
 
   68   std::size_t eventIdx = outDsType->getPropertyPosition(m_inputParams->m_eventAttrName);
 
   69   std::size_t popIdx = outDsType->getPropertyPosition(m_inputParams->m_populationAttrName);
 
   72   runBayesGlobal(outDs.get(), eventIdx, popIdx, bayesIdx);
 
   75   saveDataSet(outDs.get(), outDsType.get());
 
   80   m_inputParams.reset(inParams);
 
   81   m_outputParams.reset(outParams);
 
   89   std::map<std::string, std::string> options;
 
   91   m_outputParams->m_ds->createDataSet(dsType, options);
 
   93   m_outputParams->m_ds->add(m_outputParams->m_outputDataSetName, dataSet, options);
 
   98   std::auto_ptr<te::da::DataSetType> dataSetType(
new te::da::DataSetType(m_outputParams->m_outputDataSetName));
 
  101   std::vector<te::dt::Property*> propertyVec = dsType->
getProperties();
 
  103   for(std::size_t t = 0; t < propertyVec.size(); ++t)
 
  111     dataSetType->add(newProp);
 
  116   dataSetType->add(bayesProperty);
 
  134     for(std::size_t t = 0; t < nProp; ++t)
 
  145     outDataset->add(outDSetItem);
 
  153   std::vector<double> eventVecY;
 
  154   std::vector<double> popVecN;
 
  155   std::vector<double> rateVec;
 
  157   double sumEventY = 0.;
 
  173       double eventAttr = ds->
getDouble(eventIdx);
 
  174       eventVecY.push_back(eventAttr);
 
  177       popVecN.push_back(popAttr);
 
  182       rateVec.push_back(eventVecY[count-1] / popVecN[count-1]);
 
  184       sumEventY += eventVecY[count-1];
 
  185       sumPopN += popVecN[count-1];
 
  196   double mean = sumEventY / sumPopN;
 
  198   double meanPop = sumPopN / (double)count;
 
  200   double variance = 0.;
 
  202   for(
int i = 0; i < count; ++i)
 
  204     variance += popVecN[i] * pow((rateVec[i] - mean), 2);
 
  209   double aux = variance - (mean / meanPop);
 
  226       double eventAttr = ds->
getDouble(eventIdx);
 
  231       if(aux != 0. || mean != 0.)
 
  232         wI = aux / (aux + (mean / popAttr));
 
  234       double thetaI = wI * (eventAttr / popAttr) + ( 1 - wI) * mean;
 
  236       ds->
setDouble(bayesIdx, thetaI * m_inputParams->m_rate);
 
std::size_t size() const 
It returns the collection size, if it is known. 
 
Class that represents the Bayes output parameters. 
 
void setMessage(const std::string &message)
Set the task message. 
 
Utility functions for the data access module. 
 
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. 
 
std::auto_ptr< te::mem::DataSet > createDataSet(te::da::DataSet *inputDataSet, te::da::DataSetType *dsType)
 
A class that models the description of a dataset. 
 
virtual Property * clone() const =0
It returns a clone of the object. 
 
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. 
 
void execute()
Function to execute the bayes operation. 
 
#define TE_TR(message)
It marks a string in order to get translated. 
 
This file contains a class that represents the bayes global operation. 
 
It models a property definition. 
 
bool isActive() const 
Verify if the task is active. 
 
void setTotalSteps(int value)
Set the task total stepes. 
 
void setId(unsigned int id)
It sets the property identifier. 
 
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection. 
 
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
 
void saveDataSet(te::da::DataSet *dataSet, te::da::DataSetType *dsType)
 
const std::vector< Property * > & getProperties() const 
It returns the list of properties describing the CompositeProperty. 
 
~BayesGlobalOperation()
Virtual destructor. 
 
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1. 
 
A base class for values that can be retrieved from the data access module. 
 
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset. 
 
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
 
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection. 
 
bool moveNext()
It moves the internal pointer to the next item of the collection. 
 
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
 
A dataset is the unit of information manipulated by the data access module of TerraLib. 
 
double getDouble(std::size_t i) const 
Method for retrieving a double attribute value. 
 
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection. 
 
BayesGlobalOperation()
Default constructor. 
 
void setParameters(te::sa::BayesInputParams *inParams, te::sa::BayesOutputParams *outParams)
 
void runBayesGlobal(te::mem::DataSet *ds, std::size_t eventIdx, std::size_t popIdx, std::size_t bayesIdx)
 
#define TE_SA_BAYES_ATTR_NAME
 
std::auto_ptr< te::da::DataSetType > createDataSetType(te::da::DataSetType *dsType)
 
void setDouble(std::size_t i, double value)
 
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const 
Method for retrieving any other type of data value stored in the data source. 
 
void setParent(Property *p)
It associate this property to the informed parent.