All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GPMWeightsAbstractStrategy.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file GPMWeightsAbstractStrategy.cpp
22 
23  \brief This class defines a an Abstract class to calculates a weight for a GPM.
24 */
25 
26 // Terralib Includes
27 #include "../../datatype/AbstractData.h"
28 #include "../../datatype/SimpleData.h"
29 #include "../../datatype/SimpleProperty.h"
30 #include "../../graph/core/Edge.h"
31 #include "../../graph/core/GraphMetadata.h"
34 
35 // STL Includes
36 #include <cassert>
37 
39 {
40 }
41 
43 {
44 }
45 
47 {
48  return m_type;
49 }
50 
52 {
53  assert(gpm);
54 
55  //add edge property
57  p->setParent(0);
58  p->setId(0);
59 
60  gpm->getGraph()->addEdgeProperty(p);
61 
62  int pos = gpm->getGraph()->getEdgePropertySize();
63 
64  return pos - 1;
65 }
66 
68 {
69  for(int i = 0; i < gm->getEdgePropertySize(); ++i)
70  {
72  {
73  index = i;
74  return true;
75  }
76  }
77 
78  return false;
79 }
80 
82 {
84 
85  if(sd)
86  return sd->getValue();
87 
88  return 0.;
89 }
An atomic property like an integer or double.
virtual te::dt::Property * getEdgeProperty(int idx)
Get a edge property given a index.
This class defines a Generalized Proximity Matrix.
virtual void addEdgeProperty(te::dt::Property *p)=0
Add a new property associated to the edge element.
bool getDistanceAttributeIndex(te::graph::GraphMetadata *gm, int &index)
Function used to get the distance attribute index.
T getValue() const
It returns the associated value.
Definition: SimpleData.h:139
void setId(unsigned int id)
It sets the property identifier.
Definition: Property.h:118
int createWeightAttribute(GeneralizedProximityMatrix *gpm)
Added to the edge a new attribute for weight information and return the attr index.
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
Definition: Edge.h:58
virtual ~GPMWeightsAbstractStrategy()
Virtual destructor.
double getDistanceAttributeValue(te::graph::Edge *e, const int index)
Function used to get the distance value from a edge element.
#define TE_SA_WEIGHT_ATTR_NAME
Definition: Config.h:41
#define TE_SA_DISTANCE_ATTR_NAME
Definition: Config.h:38
virtual int getEdgePropertySize()=0
Used to verify the number of properties associated to edge elements.
This class defines a an Abstract class to calculates a weight for a GPM.
virtual int getEdgePropertySize()
Used to verify the number of properties associated to edge elements.
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
Definition: Edge.cpp:81
GPMWeightsStrategyType
Strategies to calculate the weight for a GPM.
Definition: Enums.h:51
Class used to define the graph metadata informations.
Definition: GraphMetadata.h:56
const std::string & getName() const
It returns the property name.
Definition: Property.h:127
This class defines the GPM class.
void setParent(Property *p)
It associate this property to the informed parent.
Definition: Property.h:177