All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LandREntity.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 /**
33  @file LandREntity.hpp
34 
35  @author Aline LIBRES <aline.libres@gmail.com>
36  @author Michael RABOTIN <michael.rabotin@supagro.inra.fr>
37  */
38 
39 #ifndef __OPENFLUID_LANDR_LANDRENTITY_HPP__
40 #define __OPENFLUID_LANDR_LANDRENTITY_HPP__
41 
42 #include <geos/planargraph/GraphComponent.h>
43 #include <map>
44 #include <set>
45 #include <string>
46 #include <openfluid/dllexport.hpp>
47 
48 namespace geos { namespace geom {
49 class Geometry;
50 class Point;
51 } }
52 
53 namespace openfluid {
54 namespace core {
55 class Value;
56 
57 }
58 namespace landr {
59 
60 /**
61  @brief Interface for a landscape representation element.
62 */
63 class OPENFLUID_API LandREntity : public geos::planargraph::GraphComponent
64 {
65  private:
66 
67  LandREntity();
68 
69  LandREntity(const LandREntity&);
70 
71 
72  protected:
73  /**
74  @brief The geos::geom::Geometry of this LandREntity.
75  */
76  const geos::geom::Geometry* mp_Geom;
77 
78  /**
79  @brief The identifier of this LandREntity.
80  */
81  unsigned int m_OfldId;
82 
83  /**
84  @brief The centroid of this LandREntity.
85  */
86  geos::geom::Point* mp_Centroid;
87 
88  /**
89  @brief The area of this LandREntity.
90  */
91  double m_Area;
92 
93  /**
94  @brief The length of this LandREntity.
95  */
96  double m_Length;
97 
98  /**
99  @brief A set of LandREntity neighbours of this LandREntity.
100  */
101  std::set<LandREntity*>* mp_Neighbours;
102 
103  /**
104  @brief A map of attributes of this LandREntity.
105  */
106 
107  std::map<std::string, core::Value*> m_Attributes;
108 
109  // for limiting access to m_Attributes creation/deletion to LandRGraph class
110  friend class LandRGraph;
111 
112  /**
113  @brief Computes the neighbours of this LandREntity.
114  */
115  virtual void computeNeighbours() = 0;
116 
117 
118  public:
119 
120  LandREntity(const geos::geom::Geometry* Geom, unsigned int OfldId);
121 
122  virtual ~LandREntity();
123 
124  virtual LandREntity* clone() = 0;
125 
126  /**
127  @brief Returns the geos::geom::Geometry of this LandREntity.
128  */
129  const geos::geom::Geometry* geometry();
130 
131  /**
132  @brief Returns the identifier of this LandREntity.
133  */
134  unsigned int getOfldId() const;
135 
136  /**
137  @brief Returns the centroid of this LandREntity.
138  */
139  geos::geom::Point* centroid() const;
140 
141  /**
142  @brief Returns the area of this LandREntity.
143  */
144  double getArea() const;
145 
146  /**
147  @brief Returns the length of this LandREntity.
148  */
149  double getLength() const;
150 
151  /**
152  @brief Returns a set of LandREntity neighbours of this LandREntity.
153  */
154  std::set<LandREntity*>* neighbours();
155 
156  /**
157  @brief Gets the value of an attribute.
158  @param AttributeName The name of the attribute to get.
159  @param Value The core::Value to assign the attribute value.
160  @return True if the attribute exists, false otherwise.
161  */
162  bool getAttributeValue(const std::string& AttributeName, core::Value& Value) const;
163 
164  /**
165  @brief Sets the value of an attribute.
166  @details Takes the ownership of Value.
167  @param AttributeName The name of the attribute to set.
168  @param Value The core::Value assign to the attribute value.
169  @return True if the attribute exists, false otherwise.
170  */
171  bool setAttributeValue(const std::string& AttributeName, const core::Value* Value);
172 
173  /**
174  @brief Gets the distance between this LandREntity centroid and Other LandREntity centroid.
175  */
176  double getDistCentroCentro(LandREntity& Other);
177 
178  /**
179  @brief Gets the LandREntity neighbour that has the minimum centroid-to-centroid distance.
180  */
181  LandREntity* neighbour_MinDistCentroCentro();
182 
183 };
184 
185 } } // namespaces landr, openfluid
186 
187 #endif /* __OPENFLUID_LANDR_LANDRENTITY_HPP__ */
double m_Area
The area of this LandREntity.
Definition: LandREntity.hpp:91
Interface for a graph composed of LandREntity.
Definition: LandRGraph.hpp:78
std::map< std::string, core::Value * > m_Attributes
A map of attributes of this LandREntity.
Definition: LandREntity.hpp:107
Definition: Value.hpp:64
std::set< LandREntity * > * mp_Neighbours
A set of LandREntity neighbours of this LandREntity.
Definition: LandREntity.hpp:101
Interface for a landscape representation element.
Definition: LandREntity.hpp:63
const geos::geom::Geometry * mp_Geom
The geos::geom::Geometry of this LandREntity.
Definition: LandREntity.hpp:76
unsigned int m_OfldId
The identifier of this LandREntity.
Definition: LandREntity.hpp:81
double m_Length
The length of this LandREntity.
Definition: LandREntity.hpp:96
#define OPENFLUID_API
Definition: dllexport.hpp:87
geos::geom::Point * mp_Centroid
The centroid of this LandREntity.
Definition: LandREntity.hpp:86