8#ifndef FMTLAYER_H_INCLUDED
9#define FMTLAYER_H_INCLUDED
15#include <boost/serialization/nvp.hpp>
35 template<
class Archive>
36 void serialize(Archive& ar,
const unsigned int version)
38 ar & boost::serialization::make_nvp(
"FMTobject", boost::serialization::base_object<FMTobject>(*
this));
40 ar & BOOST_SERIALIZATION_NVP(
maxx);
41 ar & BOOST_SERIALIZATION_NVP(
maxy);
42 ar & BOOST_SERIALIZATION_NVP(
SRS_WKT);
43 ar & BOOST_SERIALIZATION_NVP(
cellsize);
44 ar & BOOST_SERIALIZATION_NVP(
mapping);
68 typedef typename std::map<FMTcoordinate,T>::value_type
value_type;
71 typedef typename std::map<FMTcoordinate,T>::iterator
iterator;
137 return mapping.find(coordinate);
145 return mapping.find(coordinate);
164 maxx(std::move(rhs.maxx)),
165 maxy(std::move(rhs.maxy)),
166 SRS_WKT(std::move(rhs.SRS_WKT)),
168 mapping(std::move(rhs.mapping))
177 const unsigned int& lmaxx,
178 const unsigned int& lmaxy,
179 const std::string& lSRS_WKT,
191 FMTlayer(
const std::map<FMTcoordinate,T>& lmapping,
192 const std::vector<double>& lgeotransform,
193 const unsigned int& lmaxx,
194 const unsigned int& lmaxy,
195 const std::string& lSRS_WKT,
196 const double& lcellsize):
248 _exhandler->raisefromcatch(
"",
"FMTlayer::swap", __LINE__, __FILE__);
259 this->maxx = rhs.
maxx;
260 this->maxy = rhs.
maxy;
268 template<
typename newtype>
349 std::vector<T>unique_attributes;
350 for(
typename std::map<FMTcoordinate,T>::const_iterator it =
mapping.begin();it !=
mapping.end(); it++)
352 if (std::find(unique_attributes.begin(),unique_attributes.end(),it->second)==unique_attributes.end())
354 unique_attributes.push_back(it->second);
357 return unique_attributes;
371 void replace(
typename std::map<FMTcoordinate,T>::const_iterator first,
typename std::map<FMTcoordinate,T>::const_iterator last)
375 typename std::map<FMTcoordinate,T>::iterator it =
mapping.find(first->first);
378 it->second = first->second;
387 std::map<FMTcoordinate, std::string>new_mapping;
388 for (std::map<FMTcoordinate, std::string>::const_iterator mit = mapping.begin(); mit != mapping.end(); mit++)
390 std::map<FMTcoordinate, std::string>::const_iterator rhsit = rhs.
mapping.find(mit->first);
391 if (rhsit != rhs.
mapping.end())
393 new_mapping[mit->first] = (mit->second +
"-" + rhsit->second);
396 mapping = new_mapping;
Definition: FMTobject.hpp:50
FMTobject & operator=(const FMTobject &rhs)
static std::shared_ptr< Exception::FMTexceptionhandler > _exhandler
A shared pointer to the exception handler.
Definition: FMTobject.hpp:66
Definition: FMTcoordinate.hpp:25
Definition: FMTlayer.hpp:29
virtual ~FMTlayer()=default
std::map< FMTcoordinate, T > mapping
std::map keeping the information of each pixel.
Definition: FMTlayer.hpp:64
std::string SRS_WKT
Projection string of the raster (see GDAL for more information about Geotransform)
Definition: FMTlayer.hpp:58
size_t size() const
Definition: FMTlayer.hpp:363
double cellsize
Size of the pixel in the unit used by the map (SRS_WKT)
Definition: FMTlayer.hpp:61
iterator find(const FMTcoordinate &coordinate)
Definition: FMTlayer.hpp:143
void setextentfrom(const FMTlayer< T > &rhs)
Definition: FMTlayer.hpp:256
void replace(typename std::map< FMTcoordinate, T >::const_iterator first, typename std::map< FMTcoordinate, T >::const_iterator last)
Definition: FMTlayer.hpp:371
FMTlayer()
Definition: FMTlayer.hpp:151
void swap(FMTlayer< T > &rhs)
Definition: FMTlayer.hpp:237
FMTlayer< T > & operator+=(const FMTlayer< T > &rhs)
Definition: FMTlayer.hpp:283
std::vector< double > geotransform
Geotransform of the map (see GDAL for more information about Geotransform)
Definition: FMTlayer.hpp:49
unsigned int GetXSize() const
Definition: FMTlayer.hpp:291
const_iterator begin() const
Definition: FMTlayer.hpp:111
unsigned int GetYSize() const
Definition: FMTlayer.hpp:299
FMTlayer(const std::vector< double > &lgeotransform, const unsigned int &lmaxx, const unsigned int &lmaxy, const std::string &lSRS_WKT, const double &lcellsize)
Definition: FMTlayer.hpp:176
unsigned int maxx
Maximal x value in the map.
Definition: FMTlayer.hpp:52
const_iterator find(const FMTcoordinate &coordinate) const
Definition: FMTlayer.hpp:135
const T & at(const FMTcoordinate &coordinate) const
Definition: FMTlayer.hpp:87
FMTlayer(const std::map< FMTcoordinate, T > &lmapping, const std::vector< double > &lgeotransform, const unsigned int &lmaxx, const unsigned int &lmaxy, const std::string &lSRS_WKT, const double &lcellsize)
Definition: FMTlayer.hpp:191
std::map< FMTcoordinate, T > getmapping() const
Definition: FMTlayer.hpp:323
std::vector< T > getattributes() const
Definition: FMTlayer.hpp:347
std::map< FMTcoordinate, T >::const_iterator const_iterator
Const_Iterator typedef of the FMTlist.
Definition: FMTlayer.hpp:74
std::map< FMTcoordinate, T >::iterator iterator
Iterator typedef of the FMTlayer.
Definition: FMTlayer.hpp:71
FMTlayer(FMTlayer &&rhs) noexcept
Definition: FMTlayer.hpp:161
unsigned int maxy
Maximal y value in the map.
Definition: FMTlayer.hpp:55
FMTlayer< T > & operator=(const FMTlayer< T > &rhs)
Definition: FMTlayer.hpp:219
FMTlayer< newtype > copyextent() const
Definition: FMTlayer.hpp:269
T & operator[](const FMTcoordinate &coordinate)
Definition: FMTlayer.hpp:79
std::vector< double > getgeotransform() const
Definition: FMTlayer.hpp:307
iterator end()
Definition: FMTlayer.hpp:119
friend class boost::serialization::access
Definition: FMTlayer.hpp:30
const_iterator end() const
Definition: FMTlayer.hpp:127
std::map< FMTcoordinate, T >::value_type value_type
Value typedef of the FMTlayer.
Definition: FMTlayer.hpp:68
iterator begin()
Definition: FMTlayer.hpp:103
std::string getprojection() const
Definition: FMTlayer.hpp:315
FMTlayer(const FMTlayer &rhs)
Definition: FMTlayer.hpp:208
double area() const
Definition: FMTlayer.hpp:331
bool empty() const
Definition: FMTlayer.hpp:95
double getcellsize() const
Definition: FMTlayer.hpp:339
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
The spatial namespace provides classes for spatialy explicit simulation/optimization based on raster ...
Definition: FMTareaparser.hpp:36