29 #include "../../dataaccess/datasource/DataSource.h" 
   30 #include "../../dataaccess/datasource/DataSourceManager.h" 
   31 #include "../../dataaccess/utils/Utils.h" 
   32 #include "../../datatype/SimpleProperty.h" 
   33 #include "../../datatype/SimpleData.h" 
   34 #include "../../graph/core/AbstractGraph.h" 
   35 #include "../../graph/core/AbstractGraphFactory.h" 
   36 #include "../../graph/core/Edge.h" 
   37 #include "../../graph/core/GraphMetadata.h" 
   38 #include "../../graph/core/Vertex.h" 
   39 #include "../../graph/iterator/MemoryIterator.h" 
   40 #include "../../graph/Globals.h" 
   41 #include "../../memory/DataSet.h" 
   42 #include "../../memory/DataSetItem.h" 
   64   assert(m_inputParams->m_ds.get());
 
   65   assert(m_inputParams->m_dsType.get());
 
   68   std::vector<int> attrsIdx;
 
   70   for(std::size_t t = 0; t < m_inputParams->m_attrs.size(); ++t)
 
   72     std::string attrName = m_inputParams->m_attrs[t];
 
   74     std::size_t idx = m_inputParams->m_dsType->getPropertyPosition(attrName);
 
   75     int type = m_inputParams->m_ds->getPropertyDataType(idx);
 
   78     attrsIdx.push_back(gpmIdx);
 
   82   if(m_inputParams->m_attrPop != 
"")
 
   84     std::size_t idx = m_inputParams->m_dsType->getPropertyPosition(m_inputParams->m_attrPop);
 
   86     int type = m_inputParams->m_ds->getPropertyDataType(idx);
 
   94   createWeightAttribute(edgeWeightIdx, attrsIdx);
 
  104   std::vector<std::size_t> roots;
 
  107     roots = sp.
execute(m_inputParams->m_nClusters, m_inputParams->m_attrPop, m_inputParams->m_minPop);
 
  109     roots = sp.
execute(m_inputParams->m_attrPop, m_inputParams->m_minPop);
 
  111   m_nClassGroups = (int)roots.size();
 
  113   std::map<int, int> skaterMap = createSkaterMap(graph, roots);
 
  116   std::auto_ptr<te::da::DataSetType> outDsType = createDataSetType(m_inputParams->m_dsType.get());
 
  118   std::string gpmLink = m_inputParams->m_gpm->getAttributeName();
 
  120   std::auto_ptr<te::mem::DataSet> outDs = createDataSet(m_inputParams->m_ds.get(), outDsType.get(), skaterMap, gpmLink);
 
  123   saveDataSet(outDs.get(), outDsType.get());
 
  133   m_inputParams.reset(inParams);
 
  134   m_outputParams.reset(outParams);
 
  139   return m_nClassGroups;
 
  144   std::auto_ptr<te::da::DataSetType> dataSetType(
new te::da::DataSetType(m_outputParams->m_outputDataSetName));
 
  147   std::vector<te::dt::Property*> propertyVec = dsType->
getProperties();
 
  149   for(std::size_t t = 0; t < propertyVec.size(); ++t)
 
  157     dataSetType->add(newProp);
 
  162   dataSetType->add(skaterClass);
 
  180     std::string idStrValue = inputDataSet->
getAsString(linkName);
 
  182     for(std::size_t t = 0; t < nProp; ++t)
 
  193     outDataset->add(outDSetItem);
 
  204   std::map<std::string, std::string> options;
 
  206   m_outputParams->m_dataSource->createDataSet(dsType, options);
 
  208   m_outputParams->m_dataSource->add(m_outputParams->m_outputDataSetName, dataSet, options);
 
  228       double weight = calculateWeight(attrsIdx, vFrom, vTo);
 
  242   for(std::size_t t = 0; t < attrsIdx.size(); ++t)
 
  247     weight += (valueTo - valueFrom) * (valueTo - valueFrom);
 
  255   std::map<int, int> skaterMap;
 
  257   for(std::size_t t = 0; t < roots.size(); ++t)
 
  259     std::size_t rootId = roots[t];
 
  262     std::queue<int> queue;
 
  263     std::set<int> visited;
 
  266     visited.insert(rootId);
 
  269     while(!queue.empty())
 
  271       int currentId = queue.front();
 
  280         skaterMap.insert(std::map<int, int>::value_type(currentId, (
int)t));
 
  284         std::set<int>::iterator itNeighbours = neighbours.begin();
 
  286         while(itNeighbours != neighbours.end())
 
  302             if(visited.find(vTo->
getId()) == visited.end())
 
  305               queue.push(vTo->
getId());
 
  306               visited.insert(vTo->
getId());
 
Class that represents the skater partition operation. 
 
void execute()
Function to execute the skater operation. 
 
virtual te::graph::Edge * getNextEdge()
It returns a pointer to the next edge element of a graph. 
 
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the edge elements. 
 
Utility functions for the data access module. 
 
An atomic property like an integer or double. 
 
This file contains a class that represents the skater operation. 
 
A class that models the description of a dataset. 
 
void saveDataSet(te::da::DataSet *dataSet, te::da::DataSetType *dsType)
 
virtual te::graph::Edge * getEdge(int id)=0
It returns the edge element if it's exist. 
 
std::auto_ptr< te::mem::DataSet > createDataSet(te::da::DataSet *inputDataSet, te::da::DataSetType *dsType, std::map< int, int > &skaterMap, std::string linkName)
 
virtual Property * clone() const =0
It returns a clone of the object. 
 
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property. 
 
double calculateWeight(std::vector< int > attrsIdx, te::graph::Vertex *vFrom, te::graph::Vertex *vTo)
Function to calculate the weight attribute using the euclidean distance. 
 
~SkaterOperation()
Virtual destructor. 
 
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element. 
 
It models a property definition. 
 
Class that represents the skater output parameters. 
 
This file contains a class that represents the Minimum Spanning Tree operation. 
 
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
 
void setId(unsigned int id)
It sets the property identifier. 
 
virtual te::graph::GraphMetadata * getMetadata()=0
Function used to access the graph metadata. 
 
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property. 
 
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
 
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...
 
This file contains a class that represents the skater partition operation. 
 
const std::vector< Property * > & getProperties() const 
It returns the list of properties describing the CompositeProperty. 
 
std::vector< std::size_t > execute(std::size_t nGroups, std::string popAttr="", std::size_t minPop=0)
Function to execute the skater partition. 
 
void createWeightAttribute(int weightAttrIdx, std::vector< int > attrsIdx)
Function to create the weight attribute. 
 
Abstract class used to define the main functions of graph struct. All graph implementations must used...
 
std::auto_ptr< te::da::DataSetType > createDataSetType(te::da::DataSetType *dsType)
 
void setParameters(te::sa::SkaterInputParams *inParams, te::sa::SkaterOutputParams *outParams)
 
virtual std::string getAsString(std::size_t i, int precision=0) const 
Method for retrieving a data value as a string plain representation. 
 
A base class for values that can be retrieved from the data access module. 
 
std::map< int, int > createSkaterMap(te::graph::AbstractGraph *graph, std::vector< std::size_t > &roots)
 
int getIdFrom()
It returns the vertex origin identification. 
 
std::set< int > & getNeighborhood()
Returns the Neighborhood vector. 
 
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset. 
 
virtual te::graph::Edge * getFirstEdge()
It returns a pointer to the first edge element of a graph. 
 
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. 
 
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection. 
 
#define TE_SA_SKATER_ATTR_WEIGHT_NAME
 
#define TE_SA_SKATER_ATTR_CLASS_NAME
 
int getId()
It returns the vertex id. 
 
A template for atomic data types (integers, floats, strings and others). 
 
TESAEXPORT int AddGraphEdgeAttribute(te::graph::AbstractGraph *graph, std::string attrName, int dataType)
Function used to create the edge attribute metadata in the graph of the gpm. 
 
TESAEXPORT double GetDataValue(te::dt::AbstractData *ad)
Function used to get the numeric value from a gpm property. 
 
TESAEXPORT int AssociateGPMVertexAttribute(te::sa::GeneralizedProximityMatrix *gpm, te::da::DataSource *ds, std::string dataSetName, std::string attrLink, std::string attr, int dataType, int srid=TE_UNKNOWN_SRS, int subType=te::gm::UnknownGeometryType)
Function used to set a an attribute valeu from a dataset to the vertex objects from a gpm...
 
virtual te::graph::Vertex * getVertex(int id)=0
It returns the vertex element if it's exist. 
 
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element. 
 
SkaterOperation()
Default constructor. 
 
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. 
 
int getIdTo()
It returns the vertex destiny identification. 
 
This class defines the GPM class. 
 
void setParent(Property *p)
It associate this property to the informed parent.