FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTEvent.h
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Qu�bec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8#ifndef FMTEVENT_Hm_included
9#define FMTEVENT_Hm_included
10
11#include "FMTCoordinate.h"
12#include <random>
13#include <limits>
14#include <iterator>
15#include <boost/serialization/serialization.hpp>
16#include <boost/serialization/nvp.hpp>
17#include <boost/serialization/set.hpp>
18#include <array>
19
20namespace Spatial
21{
22class FMTEventRelation;
23// DocString: FMTEvent
28 {
29 public:
30 // DocString: FMTEvent::midPosition()
35 std::set<FMTCoordinate>::const_iterator midPosition() const;
36 // DocString: ~FMTEvent()
40 ~FMTEvent() = default;
41 // DocString: FMTEvent(const FMTEvent&)
46 FMTEvent(const FMTEvent& rhs) = default;
47 // DocString: FMTEvent::operator=
53 FMTEvent& operator=(const FMTEvent& rhs) = default;
54 // DocString: FMTEvent()
58 FMTEvent() = default;
59 // DocString: FMTsaevent(const FMTCoordinate&,const int&,const int&)
67 FMTEvent(const FMTCoordinate& p_location,
68 int p_actionId,
69 int p_period,
70 size_t p_centroidGraphFamily);
71 // DocString: FMTEvent::empty()
76 bool empty() const;
77 // DocString: FMTEvent::size()
82 size_t size() const;
83 // DocString: FMTEvent::hash()
88 size_t hash() const;
89 // DocString: FMTEvent::getRelation(const FMTEvent&)
96 // DocString: FMTEvent::operator==(const FMTEvent&)
102 bool operator==(const FMTEvent& rhs) const;
103 // DocString: FMTEvent::operator!=(const FMTEvent&)
109 bool operator!=(const FMTEvent& rhs) const;
110 // DocString: FMTEvent::operator<(const FMTEvent&)
116 bool operator<(const FMTEvent& rhs) const;
117 // DocString: FMTEvent::perimeter()
122 size_t perimeter() const;
123 // DocString: FMTEvent::height()
128 size_t height() const;
129 // DocString: FMTEvent::width()
134 size_t width() const;
135 // DocString: FMTEvent::averageCentroid()
141 // DocString: FMTEvent::getStatsHeader()
146 static std::string getStatsHeader();
147 // DocString: FMTEvent::getStats()
152 std::string getStats() const;
153 // DocString: FMTEvent::erase(const FMTCoordinate&)
158 virtual void erase(const FMTCoordinate& newlocation);
159 // DocString: FMTEvent::merge(const FMTEvent& event)
164 virtual void merge(const FMTEvent& event);
165 // DocString: FMTEvent::insert(const FMTCoordinate&)
170 virtual void insert(const FMTCoordinate& newlocation);
171 // DocString: FMTEvent::setActionId(const int&)
176 void setActionId(const int& laction_id);
177 // DocString: FMTEvent::getActionId()
182 const int& getActionId() const;
183 // DocString: FMTEvent::getPeriod()
188 const int& getPeriod() const;
189 // DocString: FMTEvent::getGraphFamily()
194 const size_t& getGraphFamily() const;
195 // DocString: FMTEvent::getElements
200 const std::set<FMTCoordinate>& getElements() const;
201 // DocString: FMTEvent::ignit(const FMTspatialaction&, const FMTCoordinate&, const int&, const int&)
211 virtual std::vector<std::set<FMTCoordinate>::const_iterator> ignit(const size_t& eventmaximalsize,
212 const std::set<FMTCoordinate>::const_iterator& ignit, int p_actionId, int p_period, size_t p_GraphFamily);
213 // DocString: FMTEvent::spread(const size_t& eventminimalsize,const size_t& eventmaximalsize,const size_t& neighboringsize,const std::set<FMTCoordinate>& territory, std::vector<std::set<FMTCoordinate>::const_iterator> active)
223 virtual bool spread(const size_t& eventminimalsize,const size_t& eventmaximalsize,
224 const size_t& neighboringsize,const std::set<FMTCoordinate>& territory, std::vector<std::set<FMTCoordinate>::const_iterator> active);
225 // DocString: FMTEvent::distance(const FMTEvent&)
231 double distance(const FMTEvent& rhs) const;
232 // DocString: FMTEvent::within(unsigned int, const FMTEvent&)
240 template<typename T>
241 bool within(const T& dist, const FMTEvent& rhs) const;
242 // DocString: FMTEvent::withinc(unsigned int, const FMTCoordinate&)
250 template<typename T>
251 bool within(const T& dist, const FMTCoordinate& location) const;
252 // DocString: FMTEvent::contain(const FMTCoordinate&)
258 bool contain(const FMTCoordinate& coord)const;
259 // DocString: FMTEvent::willSplitEvent(const FMTCoordinate&)
265 bool willSplitEvent(const FMTCoordinate& p_coordinate) const;
266 // DocString: FMTEvent::splitEvent(const unsigned int&, std::vector<FMTsaevent>&)
272 bool splitEvent(std::vector<FMTEvent>& splittedevents) const;
273 // DocString: FMTEvent::getTerritory
279 std::set<FMTCoordinate>getTerritory(const size_t& distance) const;
280 // DocString: FMTEvent::getBorders
285 std::vector<std::set<FMTCoordinate>::const_iterator>getBorders() const;
286 // DocString: FMTEvent::getOutsideBorders
291 std::vector<std::pair<FMTCoordinate,FMTCoordinate>>getOutsideBordersPair() const;
292 // DocString: FMTEvent::getenveloppe
297 std::array<FMTCoordinate,4>getEnveloppe() const;
298 // DocString: FMTEvent::getclosescoordinate
306 std::set<FMTCoordinate>::const_iterator& thiscoordinate,
307 std::set<FMTCoordinate>::const_iterator& rhscoordinate) const;
308 private:
309 friend class boost::serialization::access;
310 // DocString: FMTEvent::serialize
317 template<class Archive>
318 void serialize(Archive& ar, const unsigned int version)
319 {
320 ar& BOOST_SERIALIZATION_NVP(m_actionId);
321 ar& BOOST_SERIALIZATION_NVP(m_period);
322 ar& BOOST_SERIALIZATION_NVP(m_elements);
323 }
324 // DocString: FMTEvent::m_actionId
328 int m_actionId;
329 // DocString: FMTEvent::m_period
333 int m_period;
334 // DocString: FMTEvent::m_centroidGraphFamily
338 size_t m_centroidGraphFamily;
339 // DocString: FMTEvent::m_elements
343 std::set<FMTCoordinate>m_elements;
344 };
345
346}
347
348namespace boost {
349
350 template <>
351 struct hash<Spatial::FMTEvent>
352 {
353 std::size_t operator()(const Spatial::FMTEvent& event) const
354 {
355 return (event.hash());
356 }
357 };
358
359}
360#endif // FMTEVENT_Hm_included
#define FMTEXPORT
Definition: FMTutility.h:125
Spatially referenced coordinate holding an x and y position on a raster grid.
Definition: FMTCoordinate.h:29
Relation between two spatial events, holding the from and to action, period and coordinate of the clo...
Definition: FMTEventRelation.h:26
Base class for a spatial event (FMTsaevent or FMTsesevent): a set of FMTCoordinate corresponding to t...
Definition: FMTEvent.h:28
FMTEvent(const FMTCoordinate &p_location, int p_actionId, int p_period, size_t p_centroidGraphFamily)
Construct a FMTEvent from a location, an action id, a period and a centroid graph family.
std::vector< std::pair< FMTCoordinate, FMTCoordinate > > getOutsideBordersPair() const
Return the outside borders of the event as pairs of coordinates.
std::set< FMTCoordinate > getTerritory(const size_t &distance) const
Return the adjacent territory of the event based on a distance.
size_t height() const
Return the height of the event.
bool contain(const FMTCoordinate &coord) const
Return true if a coordinate is in the elements of the event.
FMTEvent()=default
Default constructor for FMTEvent.
const size_t & getGraphFamily() const
Return the graph family of the event.
const std::set< FMTCoordinate > & getElements() const
Return the elements (coordinates) of the event.
virtual std::vector< std::set< FMTCoordinate >::const_iterator > ignit(const size_t &eventmaximalsize, const std::set< FMTCoordinate >::const_iterator &ignit, int p_actionId, int p_period, size_t p_GraphFamily)
Ignite the event at a coordinate for an action, a period and a graph family, up to a maximal size.
double distance(const FMTEvent &rhs) const
Return the distance between this event and another one.
bool operator!=(const FMTEvent &rhs) const
Comparison operator for FMTEvent.
FMTEvent(const FMTEvent &rhs)=default
Copy constructor for FMTEvent.
bool splitEvent(std::vector< FMTEvent > &splittedevents) const
Split the event, filling a vector with the split events and removing the elements from the current ev...
bool within(const T &dist, const FMTCoordinate &location) const
Return true if a coordinate is within a distance of the event's coordinates.
~FMTEvent()=default
Default destructor for FMTEvent.
FMTCoordinate averageCentroid() const
Return the centroid based on the envelope of the event.
virtual bool spread(const size_t &eventminimalsize, const size_t &eventmaximalsize, const size_t &neighboringsize, const std::set< FMTCoordinate > &territory, std::vector< std::set< FMTCoordinate >::const_iterator > active)
Spread the event within a territory from the active coordinates, respecting the size bounds.
bool operator<(const FMTEvent &rhs) const
Less than operator for FMTEvent.
bool within(const T &dist, const FMTEvent &rhs) const
Return true if the event is within a distance of another event's envelope.
const int & getActionId() const
Return the action id of the event.
virtual void erase(const FMTCoordinate &newlocation)
Erase a coordinate from the event.
static std::string getStatsHeader()
Return the header of the patch stats (size, perimeter, height and width).
std::vector< std::set< FMTCoordinate >::const_iterator > getBorders() const
Return the coordinates of the border of the event.
std::set< FMTCoordinate >::const_iterator midPosition() const
Get the mid point of the elements of the event.
std::array< FMTCoordinate, 4 > getEnveloppe() const
Return the four coordinates that create the envelope of the event.
void getClosesCoordinates(const FMTEvent &rhs, std::set< FMTCoordinate >::const_iterator &thiscoordinate, std::set< FMTCoordinate >::const_iterator &rhscoordinate) const
Return the closest coordinates between this event and another one.
std::string getStats() const
Return the patch stats (size, perimeter, height and width) as a string.
void setActionId(const int &laction_id)
Set the action id of the event.
virtual void merge(const FMTEvent &event)
Merge another event into this one.
virtual void insert(const FMTCoordinate &newlocation)
Insert a coordinate in the event.
bool operator==(const FMTEvent &rhs) const
Comparison operator for FMTEvent.
const int & getPeriod() const
Return the period of the event.
bool empty() const
Test whether the event is empty.
FMTEventRelation getRelation(const FMTEvent &rhs) const
Return the relation between this event and another one.
size_t perimeter() const
Return the perimeter of the event, including any internal holes.
size_t size() const
Return the size of the event.
bool willSplitEvent(const FMTCoordinate &p_coordinate) const
Return true if removing a coordinate will split the event.
FMTEvent & operator=(const FMTEvent &rhs)=default
Copy assignment operator for FMTEvent.
size_t width() const
Return the width of the event.
size_t hash() const
Hash the event.
Definition: FMTAreaParser.h:40
Definition: FMTAction.h:463
std::size_t operator()(const Spatial::FMTEvent &event) const
Definition: FMTEvent.h:353