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 
40 #ifndef __OPENFLUID_LANDR_LANDRENTITY_HPP__
41 #define __OPENFLUID_LANDR_LANDRENTITY_HPP__
42 
43 
44 #include <map>
45 #include <set>
46 #include <string>
47 
48 #include <geos/planargraph/GraphComponent.h>
49 
50 #include <openfluid/dllexport.hpp>
51 
52 
53 namespace geos { namespace geom {
54 class Geometry;
55 class Point;
56 } }
57 
58 namespace openfluid {
59 namespace core {
60 class Value;
61 }
62 
63 
64 namespace landr {
65 
66 /**
67  @brief Interface for a landscape representation element.
68 */
69 class OPENFLUID_API LandREntity : public geos::planargraph::GraphComponent
70 {
71  private:
72 
73  LandREntity();
74 
75  LandREntity(const LandREntity&);
76 
77 
78  protected:
79  /**
80  @brief The geos::geom::Geometry of this LandREntity.
81  */
82  const geos::geom::Geometry* mp_Geom;
83 
84  /**
85  @brief The identifier of this LandREntity.
86  */
87  unsigned int m_OfldId;
88 
89  /**
90  @brief The centroid of this LandREntity.
91  */
92  geos::geom::Point* mp_Centroid;
93 
94  /**
95  @brief The area of this LandREntity.
96  */
97  double m_Area;
98 
99  /**
100  @brief The length of this LandREntity.
101  */
102  double m_Length;
103 
104  /**
105  @brief A set of LandREntity neighbours of this LandREntity.
106  */
107  std::set<LandREntity*>* mp_Neighbours;
108 
109  /**
110  @brief A map of attributes of this LandREntity.
111  */
112 
113  std::map<std::string, core::Value*> m_Attributes;
114 
115  // for limiting access to m_Attributes creation/deletion to LandRGraph class
116  friend class LandRGraph;
117 
118  /**
119  @brief Computes the neighbours of this LandREntity.
120  */
121  virtual void computeNeighbours() = 0;
122 
123 
124  public:
125 
126  LandREntity(const geos::geom::Geometry* Geom, unsigned int OfldId);
127 
128  virtual ~LandREntity();
129 
130  virtual LandREntity* clone() = 0;
131 
132  /**
133  @brief Returns the geos::geom::Geometry of this LandREntity.
134  */
135  const geos::geom::Geometry* geometry();
136 
137  /**
138  @brief Returns the identifier of this LandREntity.
139  */
140  unsigned int getOfldId() const;
141 
142  /**
143  @brief Returns the centroid of this LandREntity.
144  */
145  geos::geom::Point* centroid() const;
146 
147  /**
148  @brief Returns the area of this LandREntity.
149  */
150  double getArea() const;
151 
152  /**
153  @brief Returns the length of this LandREntity.
154  */
155  double getLength() const;
156 
157  /**
158  @brief Returns a set of LandREntity neighbours of this LandREntity.
159  */
160  std::set<LandREntity*>* neighbours();
161 
162  /**
163  @brief Gets the value of an attribute.
164  @param AttributeName The name of the attribute to get.
165  @param Value The core::Value to assign the attribute value.
166  @return True if the attribute exists, false otherwise.
167  */
168  bool getAttributeValue(const std::string& AttributeName, core::Value& Value) const;
169 
170  /**
171  @brief Sets the value of an attribute.
172  @details Takes the ownership of Value.
173  @param AttributeName The name of the attribute to set.
174  @param Value The core::Value assign to the attribute value.
175  @return True if the attribute exists, false otherwise.
176  */
177  bool setAttributeValue(const std::string& AttributeName, const core::Value* Value);
178 
179  /**
180  @brief Gets the distance between this LandREntity centroid and Other LandREntity centroid.
181  */
182  double getDistCentroCentro(LandREntity& Other);
183 
184  /**
185  @brief Gets the LandREntity neighbour that has the minimum centroid-to-centroid distance.
186  */
187  LandREntity* neighbour_MinDistCentroCentro();
188 
189 };
190 
191 } } // namespaces landr, openfluid
192 
193 #endif /* __OPENFLUID_LANDR_LANDRENTITY_HPP__ */
Definition: Value.hpp:64
double m_Area
The area of this LandREntity.
Definition: LandREntity.hpp:97
Interface for a graph composed of LandREntity.
Definition: LandRGraph.hpp:83
std::map< std::string, core::Value * > m_Attributes
A map of attributes of this LandREntity.
Definition: LandREntity.hpp:113
std::set< LandREntity * > * mp_Neighbours
A set of LandREntity neighbours of this LandREntity.
Definition: LandREntity.hpp:107
Interface for a landscape representation element.
Definition: LandREntity.hpp:69
Definition: LandREntity.hpp:53
const geos::geom::Geometry * mp_Geom
The geos::geom::Geometry of this LandREntity.
Definition: LandREntity.hpp:82
Definition: ApplicationException.hpp:47
unsigned int m_OfldId
The identifier of this LandREntity.
Definition: LandREntity.hpp:87
#define OPENFLUID_API
Definition: dllexport.hpp:87
double m_Length
The length of this LandREntity.
Definition: LandREntity.hpp:102
geos::geom::Point * mp_Centroid
The centroid of this LandREntity.
Definition: LandREntity.hpp:92