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 
45 {
46  return m_type;
47 }
48 
50 {
51  assert(gpm);
52 
53  //add edge property
55  p->setParent(nullptr);
56  p->setId(0);
57 
58  gpm->getGraph()->addEdgeProperty(p);
59 
60  int pos = gpm->getGraph()->getEdgePropertySize();
61 
62  return pos - 1;
63 }
64 
66 {
67  for(int i = 0; i < gm->getEdgePropertySize(); ++i)
68  {
70  {
71  index = i;
72  return true;
73  }
74  }
75 
76  return false;
77 }
78 
80 {
82 
83  if(sd)
84  return sd->getValue();
85 
86  return 0.;
87 }
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
GPMWeightsStrategyType m_type
Weight Type.
#define TE_SA_WEIGHT_ATTR_NAME
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.
te::gm::Polygon * p
virtual int getEdgePropertySize()=0
Used to verify the number of properties associated to edge elements.
#define TE_SA_DISTANCE_ATTR_NAME
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.
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