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 std::vector<int> attrsIdx;
66 for(std::size_t t = 0; t <
m_inputParams->m_attrs.size(); ++t)
70 std::size_t idx =
m_inputParams->m_dsType->getPropertyPosition(attrName);
74 attrsIdx.push_back(gpmIdx);
100 std::vector<std::size_t> roots;
114 std::string gpmLink =
m_inputParams->m_gpm->getAttributeName();
143 std::vector<te::dt::Property*> propertyVec = dsType->
getProperties();
145 for(std::size_t t = 0; t < propertyVec.size(); ++t)
153 dataSetType->add(newProp);
158 dataSetType->add(skaterClass);
176 std::string idStrValue = inputDataSet->
getAsString(linkName);
178 for(std::size_t t = 0; t < nProp; ++t)
189 outDataset->add(outDSetItem);
200 std::map<std::string, std::string> options;
238 for(std::size_t t = 0; t < attrsIdx.size(); ++t)
243 weight += (valueTo - valueFrom) * (valueTo - valueFrom);
251 std::map<int, int> skaterMap;
253 for(std::size_t t = 0; t < roots.size(); ++t)
255 std::size_t rootId = roots[t];
258 std::queue<int> queue;
259 std::set<int> visited;
261 queue.push(static_cast<int>(rootId));
262 visited.insert(static_cast<int>(rootId));
265 while(!queue.empty())
267 int currentId = queue.front();
276 skaterMap.insert(std::map<int, int>::value_type(currentId, (
int)t));
280 std::set<int>::iterator itNeighbours = neighbours.begin();
282 while(itNeighbours != neighbours.end())
298 if(visited.find(vTo->
getId()) == visited.end())
301 queue.push(vTo->
getId());
302 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.
#define TE_SA_SKATER_ATTR_CLASS_NAME
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the edge elements.
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)
#define TE_SA_SKATER_ATTR_WEIGHT_NAME
virtual te::graph::Edge * getEdge(int id)=0
It returns the edge element if it's exist.
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::unique_ptr< te::sa::SkaterOutputParams > m_outputParams
Attribute with the skater output parameters.
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
virtual Property * clone() const =0
It returns a clone of the object.
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.
std::unique_ptr< te::da::DataSetType > createDataSetType(te::da::DataSetType *dsType)
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...
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.
Utility functions for the data access module.
int m_nClassGroups
Number of classes (clusters) generated.
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=static_cast< int >(te::gm::UnknownGeometryType))
Function used to set a an attribute valeu from a dataset to the vertex objects from a gpm...
std::unique_ptr< te::sa::SkaterInputParams > m_inputParams
Attribute with the skater input parameters.
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 std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
std::unique_ptr< te::mem::DataSet > createDataSet(te::da::DataSet *inputDataSet, te::da::DataSetType *dsType, std::map< int, int > &skaterMap, std::string linkName)
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.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
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.
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.