FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTareaparser.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 FMTareaparser_H_INCLUDED
9#define FMTareaparser_H_INCLUDED
10
11#include "FMTparser.hpp"
12#include <iterator>
13#include <map>
14#include <string>
15#include <vector>
16#include "FMTutility.hpp"
17#include <boost/regex.hpp>
18
19
20class OGRPolygon;
21class OGRMultiPolygon;
22class OGRFeature;
23
24namespace Core
25{
26 class FMTdevelopment;
27 class FMTactualdevelopment;
28 class FMTGCBMtransition;
29}
30namespace Graph
31{
32 class FMTpredictor;
33}
34
35namespace Spatial
36{
37 class FMTforest;
39 class FMTsasolution;
40}
41
42namespace Heuristics
43{
46 class FMToperatingarea;
47}
48
49namespace Models
50{
51 class FMTmodel;
52}
53
54
55namespace Parser
56{
57// DocString: FMTareaparser
64 {
65 public:
66#ifdef FMTWITHGDAL
67 // DocString: FMTareaparser::readrasters
73 Spatial::FMTforest readrasters(const std::vector<Core::FMTtheme>& themes, const std::vector<std::string>& data_rasters,
74 const std::string& age, double agefactor = 1.0, double areafactor = 0.0001, std::string lock = "") const;
75 // DocString: FMTareaparser::writelayer
80 template<typename T>
81 bool writelayer(const Spatial::FMTlayer<T>& layer, std::string location, const std::map<T, std::string>& mapping, std::string format = "GTiff") const;
82 // DocString: FMTareaparser::writelayer
87 bool writelayer(const Spatial::FMTlayer<double>& layer, std::string location, std::string format = "GTiff") const;
88 // DocString: FMTareaparser::writeforest
95 bool writeforest(const Spatial::FMTforest& for_layer,
96 const std::vector<Core::FMTtheme>& themes,
97 const std::vector<std::string>& data_rasters,
98 const std::string& age,
99 const std::string& lock,
100 std::vector<std::map<std::string, std::string>> mapping = std::vector<std::map<std::string, std::string>>()) const;
101 // DocString: FMTareaparser::writeforesttheme
106 const Spatial::FMTforest& for_layer,
107 const Core::FMTtheme& theme,
108 const std::string& location,
109 const std::map<std::string, std::string>& mapping,
110 std::string format = "GTiff") const;
111 // DocString: FMTareaparser::writedisturbances
118 std::vector<Core::FMTGCBMtransition> writedisturbances(const std::string& location,
119 const Spatial::FMTspatialschedule& disturbances,
120 const std::vector<Core::FMTaction>& actions,
121 const std::vector<Core::FMTtheme>& themes,
122 const int& period) const;
123 // DocString: FMTareaparser::writepredictors()
130 std::vector<std::vector<Graph::FMTpredictor>> writepredictors(const std::string& location,
131 const Spatial::FMTspatialschedule& spatialsolution,
132 const std::vector<std::string>& yieldnames,
133 const Models::FMTmodel& model,
134 const int& period,
135 bool periodonevalues = false,
136 bool withGCBMid = true) const;
137 // DocString: FMTareaparser::writesasolution
141 /*bool writesasolution(const std::string location,
142 const Spatial::FMTsasolution& solution,
143 const std::vector<Core::FMTtheme>& themes,
144 const std::vector<Core::FMTaction>& actions,
145 const bool& writeevents = true,
146 int periodstart=-1,
147 int periodstop=-1) const;*/
148 #ifdef FMTWITHOSI
149 // DocString: FMTareaparser::getschemeneighbors
156 std::vector<Heuristics::FMToperatingareascheme> getschemeneighbors(std::vector<Heuristics::FMToperatingareascheme> operatingareaparameters,
157 const std::vector<Core::FMTtheme>& themes, const std::string& data_vectors,
158 const std::string& agefield, const std::string& areafield, double agefactor = 1.0,
159 double areafactor = 1, std::string lockfield = "",
160 double minimal_area = 0.0, double buffersize = 100) const;
161 // DocString: FMTareaparser::getclusters
168 std::vector<Heuristics::FMToperatingareacluster> getclusters(const std::vector<Heuristics::FMToperatingarea>& operatingareas,
169 const std::vector<Core::FMTtheme>& themes, const std::string& data_vectors,
170 const std::string& agefield, const std::string& areafield, const double& maximaldistance,
171 double agefactor = 1.0, double areafactor = 1, std::string lockfield = "",
172 double minimal_area = 0.0, double buffersize = 100) const;
173 std::vector<Heuristics::FMToperatingareascheme> getOperatingArea(const std::string& fichierShp, const std::vector<Core::FMTtheme>& themes, const int& numeroTheme, const int& startingperiod, const std::string& nomChampAge, const std::string& nomChampSuperficie, const std::string& nomChampStanlock, const std::string& fichierParam) const;
174 // DocString: FMTareaparser::readOAschedulerparameters
180 std::vector<Heuristics::FMToperatingareascheme> readOAschedulerparameters(const std::string& location, const std::vector<Core::FMTtheme>& modelthemes, const int& themetarget, const int& startingperiod) const;
181 // DocString: FMTareaparser::writeOAschedulerparameters
186 void writeOAschedulerparameters(const std::string& location, const std::vector<Heuristics::FMToperatingareascheme>& OAschemes,
187 std::vector<std::string> creationoptions = std::vector<std::string>()) const;
188#endif
189 // DocString: FMTareaparser::readvectors
195 std::vector<Core::FMTactualdevelopment>readvectors(const std::vector<Core::FMTtheme>& themes, const std::string& data_vectors,
196 const std::string& agefield, const std::string& areafield, double agefactor = 1.0,
197 double areafactor = 1, std::string lockfield = "",
198 double minimalarea = 0.0) const;
199 // DocString: FMTareaparser::vectormaptoFMTforest
203 Spatial::FMTforest vectormaptoFMTforest(const std::string& data_vectors,
204 const int& resolution, const std::vector<Core::FMTtheme>& themes,
205 const std::string& agefield, const std::string& areafield, double agefactor = 1.0,
206 double areafactor = 1, std::string lockfield = "",
207 double minimalarea = 0.0, const std::string& writeforestfolder = "",
208 const bool& fittoforel = true) const;
209 // DocString: FMTareaparser::vectormaptoFMTforest
213 void vectorfieldtoraster(const std::string& data_vectors,
214 const std::string& tifpathandname,
215 const int& resolution,
216 const std::string& field,
217 bool fittoforel = true) const;
218 // DocString: FMTareaparser::OGRlayertoRaster
226 GDALDataset* OGRlayertoRaster(OGRLayer* layer, const std::string& fieldname, const std::string& outfilename, const int& resolution, const bool& fittoforel) const;
227#endif
228 // DocString: FMTareaparser()
233 // DocString: ~FMTareaparser()
237 ~FMTareaparser() = default;
238 // DocString: FMTareaparser(const FMTareaparser&)
242 FMTareaparser(const FMTareaparser& rhs) = default;
243 // DocString: FMTareaparser::operator=
247 FMTareaparser& operator = (const FMTareaparser& rhs) = default;
248 // DocString: FMTareaparser::read
253 std::vector<Core::FMTactualdevelopment>read(const std::vector<Core::FMTtheme>& themes, const Core::FMTconstants& constants, const std::string& location);
254 // DocString: FMTareaparser::write
259 void write(const std::vector<Core::FMTactualdevelopment>& areas, const std::string& location) const;
260 private:
261 // DocString: FMTareaparser::rxcleanarea
263 const static boost::regex rxcleanarea;
264 // DocString: FMTareaparser::getperiodpathname
269 std::string getperiodpathname(const std::string& location, const int& period,const std::string& name) const;
270 // DocString: FMTareaparser::getGCBMtransitions
276 std::vector<Core::FMTGCBMtransition> getGCBMtransitions(const Spatial::FMTlayer<std::string>& stacked_actions,
277 const Spatial::FMTlayer<int>& ages,
278 const Spatial::FMTforest& newfor,
279 const std::vector<Core::FMTtheme>& themes) const;
280 #ifdef FMTWITHGDAL
281 // DocString: FMTareaparser::writeband
285 template<typename T,typename outT>
286 void writeband(const Spatial::FMTlayer<T>& layer, GDALRasterBand* wband, const std::map<T, std::string>& mapping) const;
287 // DocString: FMTareaparser::getunion
292 std::vector<OGRPolygon*> getunion(const std::vector<OGRMultiPolygon>& multipartpolygons) const;
293 // DocString: FMTareaparser::destroypolygons
297 void destroypolygons(std::vector<OGRPolygon*>& polygonstodestroy) const;
298 // DocString: FMTareaparser::getfeaturetodevelopment
305 Core::FMTactualdevelopment getfeaturetodevelopment(const OGRFeature* feature,
306 const std::vector<Core::FMTtheme>& themes,
307 const std::map<int, int>& themes_fields,
308 const int& age_field,
309 const int& lock_field,
310 const int& area_field,
311 const double& agefactor,
312 const double& areafactor,
313 const double& minimalarea) const;
314 // DocString: FMTareaparser::validate_raster
320 void validate_raster(const std::vector<std::string>&data_rasters) const;
321 // DocString: FMTareaparser::openvectorfile
327 GDALDataset* openvectorfile(std::map<int, int>&themes_fields, int& age_field, int& lock_field, int& area_field,
328 const std::string& data_vectors, const std::string& agefield, const std::string& areafield, const std::string& lockfield,
329 const std::vector<Core::FMTtheme>& themes) const;
330 #ifdef FMTWITHOSI
331 // DocString: FMTareaparser::getmultipolygons
337 std::vector<OGRMultiPolygon>getmultipolygons(const std::vector<Heuristics::FMToperatingarea>& operatingareas,
338 const std::vector<Core::FMTtheme>& themes, const std::string& data_vectors,
339 const std::string& agefield, const std::string& areafield, double agefactor = 1.0,
340 double areafactor = 1, std::string lockfield = "",
341 double minimal_area = 0.0) const;
342 // DocString: FMTareaparser::getneighborsfrompolygons
349 std::vector<Heuristics::FMToperatingarea> getneighborsfrompolygons(const std::vector<OGRPolygon*>&polygons,
350 std::vector<Heuristics::FMToperatingarea> operatingareas,
351 const double& buffersize) const;
352
353 // DocString: FMTareaparser::getclustersfrompolygons
358 std::vector<Heuristics::FMToperatingareacluster> getclustersfrompolygons(const std::vector<OGRPolygon*>&polygons,
359 const std::vector<Heuristics::FMToperatingarea>& operatingareas,
360 const double& maximaldistance) const;
361 #endif
362 // DocString: FMTareaparser::getFMTforestfromlayer
369 Spatial::FMTforest getFMTforestfromlayer(OGRLayer* layer,const std::vector<Core::FMTactualdevelopment>& actualdevs, const std::string& devidfield, const int& resolution, const double& areafactor,const bool& fittoforel) const;
370 // DocString: FMTareaparser::subsetlayer
376 OGRLayer* subsetlayer(OGRLayer*layer, const std::vector<Core::FMTtheme>& themes,
377 const std::string& agefield, const std::string& areafield) const;
378 #endif
379
380 };
381}
382#endif // FMTareaparser_H_INCLUDED
383
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTactualdevelopment.hpp:25
Definition: FMTconstants.hpp:29
Definition: FMTtheme.hpp:47
Definition: FMTpredictor.hpp:29
Definition: FMToperatingarea.hpp:29
Definition: FMToperatingareacluster.hpp:28
Definition: FMToperatingareascheme.hpp:44
Definition: FMTmodel.hpp:60
Definition: FMTareaparser.hpp:64
std::vector< Heuristics::FMToperatingareascheme > getschemeneighbors(std::vector< Heuristics::FMToperatingareascheme > operatingareaparameters, const std::vector< Core::FMTtheme > &themes, const std::string &data_vectors, const std::string &agefield, const std::string &areafield, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimal_area=0.0, double buffersize=100) const
Spatial::FMTforest readrasters(const std::vector< Core::FMTtheme > &themes, const std::vector< std::string > &data_rasters, const std::string &age, double agefactor=1.0, double areafactor=0.0001, std::string lock="") const
std::vector< Heuristics::FMToperatingareascheme > getOperatingArea(const std::string &fichierShp, const std::vector< Core::FMTtheme > &themes, const int &numeroTheme, const int &startingperiod, const std::string &nomChampAge, const std::string &nomChampSuperficie, const std::string &nomChampStanlock, const std::string &fichierParam) const
Spatial::FMTforest vectormaptoFMTforest(const std::string &data_vectors, const int &resolution, const std::vector< Core::FMTtheme > &themes, const std::string &agefield, const std::string &areafield, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimalarea=0.0, const std::string &writeforestfolder="", const bool &fittoforel=true) const
bool writeforest(const Spatial::FMTforest &for_layer, const std::vector< Core::FMTtheme > &themes, const std::vector< std::string > &data_rasters, const std::string &age, const std::string &lock, std::vector< std::map< std::string, std::string > > mapping=std::vector< std::map< std::string, std::string > >()) const
std::vector< Heuristics::FMToperatingareacluster > getclusters(const std::vector< Heuristics::FMToperatingarea > &operatingareas, const std::vector< Core::FMTtheme > &themes, const std::string &data_vectors, const std::string &agefield, const std::string &areafield, const double &maximaldistance, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimal_area=0.0, double buffersize=100) const
void writeOAschedulerparameters(const std::string &location, const std::vector< Heuristics::FMToperatingareascheme > &OAschemes, std::vector< std::string > creationoptions=std::vector< std::string >()) const
std::vector< Core::FMTactualdevelopment > read(const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &constants, const std::string &location)
bool writelayer(const Spatial::FMTlayer< double > &layer, std::string location, std::string format="GTiff") const
void write(const std::vector< Core::FMTactualdevelopment > &areas, const std::string &location) const
FMTareaparser(const FMTareaparser &rhs)=default
void vectorfieldtoraster(const std::string &data_vectors, const std::string &tifpathandname, const int &resolution, const std::string &field, bool fittoforel=true) const
std::vector< std::vector< Graph::FMTpredictor > > writepredictors(const std::string &location, const Spatial::FMTspatialschedule &spatialsolution, const std::vector< std::string > &yieldnames, const Models::FMTmodel &model, const int &period, bool periodonevalues=false, bool withGCBMid=true) const
bool writelayer(const Spatial::FMTlayer< T > &layer, std::string location, const std::map< T, std::string > &mapping, std::string format="GTiff") const
bool writeforesttheme(const Spatial::FMTforest &for_layer, const Core::FMTtheme &theme, const std::string &location, const std::map< std::string, std::string > &mapping, std::string format="GTiff") const
GDALDataset * OGRlayertoRaster(OGRLayer *layer, const std::string &fieldname, const std::string &outfilename, const int &resolution, const bool &fittoforel) const
std::vector< Core::FMTactualdevelopment > readvectors(const std::vector< Core::FMTtheme > &themes, const std::string &data_vectors, const std::string &agefield, const std::string &areafield, double agefactor=1.0, double areafactor=1, std::string lockfield="", double minimalarea=0.0) const
std::vector< Heuristics::FMToperatingareascheme > readOAschedulerparameters(const std::string &location, const std::vector< Core::FMTtheme > &modelthemes, const int &themetarget, const int &startingperiod) const
std::vector< Core::FMTGCBMtransition > writedisturbances(const std::string &location, const Spatial::FMTspatialschedule &disturbances, const std::vector< Core::FMTaction > &actions, const std::vector< Core::FMTtheme > &themes, const int &period) const
Definition: FMTparser.hpp:66
Definition: FMTforest.hpp:27
Definition: FMTlayer.hpp:29
Definition: FMTspatialschedule.hpp:44
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace for using/building unidirectional graphs in FMT.
Definition: FMTareaparser.hpp:31
Namespace regrouping all tools for solving LP/MIP problems using an heuristic.
Definition: FMTareaparser.hpp:43
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTareaparser.hpp:50
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTactionparser.hpp:26
The spatial namespace provides classes for spatialy explicit simulation/optimization based on raster ...
Definition: FMTareaparser.hpp:36