FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTcoordinate.hpp
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 FMTCOORD_H_INCLUDED
9#define FMTCOORD_H_INCLUDED
10
11#include <memory>
12#include <boost/unordered_map.hpp>
13#include <vector>
14#include <array>
15#include <boost/serialization/serialization.hpp>
16#include <boost/serialization/nvp.hpp>
17#include <boost/serialization/array.hpp>
18#include <string>
19#include <set>
20#include "FMTexception.hpp"
21
22namespace Spatial
23 {
25 {
26 friend class boost::serialization::access;
27 template<class Archive>
28 void serialize(Archive& ar, const unsigned int version)
29 {
30 ar & BOOST_SERIALIZATION_NVP(x);
31 ar & BOOST_SERIALIZATION_NVP(y);
32 }
33 unsigned int x,y;
34 void getxygap(const FMTcoordinate& rhs, int& xgap, int& y_gap) const;
35 double distanceapproximation(const FMTcoordinate& coord) const;
36 public:
38 ~FMTcoordinate()=default;
39 FMTcoordinate(unsigned int lx, unsigned int ly);
41 FMTcoordinate at(unsigned int id) const;
42 double distance(const FMTcoordinate& coord) const;
43 template<typename T>
44 bool within(const T& ldistance,const FMTcoordinate& coord) const;
45 void upenveloppe(std::vector<FMTcoordinate>& enveloppe) const;
46 size_t hash() const;
47 FMTcoordinate& operator = (const FMTcoordinate& rhs);
48 unsigned int getx() const;
49 unsigned int gety() const;
50 const std::vector<double> getSpatialCoordinate(std::vector<double> geoTransform) const;
51 bool operator == (const FMTcoordinate& rhs) const;
52 bool operator < (const FMTcoordinate& rhs) const;
53 std::set<FMTcoordinate>::const_iterator closest(const std::vector<std::set<FMTcoordinate>::const_iterator>& coordinates, double& approximation) const;
54 operator std::string() const;
55 std::set<FMTcoordinate> getneighbors(const unsigned int& nsize,const bool& circle=false) const;
56 };
57 }
58
59namespace boost {
60
61 template <>
62 struct hash<Spatial::FMTcoordinate>
63 {
64 std::size_t operator()(const Spatial::FMTcoordinate& coord) const
65 {
66 unsigned int x = coord.getx();
67 unsigned int y = coord.gety();
68 return (boost::hash<unsigned int>()(x) && hash<unsigned int>()(y));
69 }
70 };
71
72}
73
74#endif // FMTCOORD_H_INCLUDED
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTcoordinate.hpp:25
const std::vector< double > getSpatialCoordinate(std::vector< double > geoTransform) const
unsigned int getx() const
FMTcoordinate at(unsigned int id) const
FMTcoordinate(unsigned int lx, unsigned int ly)
std::set< FMTcoordinate >::const_iterator closest(const std::vector< std::set< FMTcoordinate >::const_iterator > &coordinates, double &approximation) const
double distance(const FMTcoordinate &coord) const
void upenveloppe(std::vector< FMTcoordinate > &enveloppe) const
std::set< FMTcoordinate > getneighbors(const unsigned int &nsize, const bool &circle=false) const
unsigned int gety() const
size_t hash() const
bool within(const T &ldistance, const FMTcoordinate &coord) const
FMTcoordinate(const FMTcoordinate &rhs)
The spatial namespace provides classes for spatialy explicit simulation/optimization based on raster ...
Definition: FMTareaparser.hpp:36
Definition: FMTaction.hpp:364
std::size_t operator()(const Spatial::FMTcoordinate &coord) const
Definition: FMTcoordinate.hpp:64