FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
RexportParser.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 REXPORTParser_H_INCLUDED
9#define REXPORTParser_H_INCLUDED
10
11#include "FMTObject.h"
12#include "FMTParser.h"
13#include "FMTLandscapeParser.h"
14#include "FMTConstantParser.h"
15#include "FMTLifespanParser.h"
16#include "FMTYieldParser.h"
17#include "FMTAreaParser.h"
18#include "FMTActionParser.h"
19#include "FMTTransitionParser.h"
20#include "FMTOutputParser.h"
21#include "FMTScheduleParser.h"
23#include "FMTModelParser.h"
24#include <Rcpp.h>
25#include <string>
26#include "Rdefinitions.h"
27
32//RCPP_DEFINEMAP(std::string, std::string); //map of string definition
53
54
55
56namespace R
57{
59 {
60 // writeForest est surchargé (worker chemins explicites vs. version dossier) : on fixe la surcharge
61 // à exposer (le worker à 6 args) via un pointeur typé, sinon &FMTAreaParser::writeForest est ambigu.
62 bool (Parser::FMTAreaParser::*writeForestPtr)(
63 const Spatial::FMTForest&, const std::vector<Core::FMTTheme>&,
64 const std::vector<std::string>&, const std::string&, const std::string&,
65 std::vector<std::map<std::string, std::string>>) const = &Parser::FMTAreaParser::writeForest;
66
67 Rcpp::class_<Parser::FMTParser>("FMTparser", "@DocString(FMTParser)")
68 .derives<Core::FMTObject>("FMTobject")
69 .constructor("@DocString(FMTParser())");
70 Rcpp::class_<Parser::FMTAreaParser>("FMTareaparser", "@DocString(FMTAreaParser)")
71 .derives<Parser::FMTParser>("FMTparser")
72 .constructor("@DocString(FMTAreaParser())")
73 .method("read", &Parser::FMTAreaParser::read,
74 "@DocString(FMTAreaParser::read)")
75 #ifdef FMTWITHGDAL
76 .method("readvectors", &Parser::FMTAreaParser::readVectors,
77 "@DocString(FMTAreaParser::readvectors)")
78 .method("readrasters", &Parser::FMTAreaParser::readRasters,
79 "@DocString(FMTAreaParser::readrasters)")
80 .method("vectormaptoFMTforest", &Parser::FMTAreaParser::vectormaptoFMTforest,
81 "@DocString(FMTAreaParser::vectormaptoFMTforest)")
82 .method("vectorfieldtoraster", &Parser::FMTAreaParser::vectorFieldToRaster,
83 "@DocString(FMTAreaParser::vectorfieldtoraster)")
84 .method("writeforest",writeForestPtr,
85 "@DocString(FMTAreaParser::writeforest)")
86 .method("writedisturbances",&Parser::FMTAreaParser::writeDisturbances,
87 "@DocString(FMTAreaParser::writedisturbances)")
88 #ifdef FMTWITHOSI
89 .method("getschemeneighbors",&Parser::FMTAreaParser::getSchemeNeighbors,
90 "@DocString(FMTAreaParser::getschemeneighbors)")
91 .method("getclusters",&Parser::FMTAreaParser::getClusters,
92 "@DocString(FMTAreaParser::getclusters)")
93 #endif
94 #endif
95 .method("write", &Parser::FMTAreaParser::write,
96 "@DocString(FMTAreaParser::write)");
97 Rcpp::class_<Parser::FMTLandscapeParser>("FMTlandscapeparser","@DocString(FMTLandscapeParser)")
98 .constructor("@DocString(FMTLandscapeParser())")
99 .derives<Parser::FMTParser>("FMTparser")
100 .method("read",&Parser::FMTLandscapeParser::read,
101 "@DocString(FMTLandscapeParser::read)")
102 #ifdef FMTWITHGDAL
103 .method("readvectors", &Parser::FMTLandscapeParser::readVectors,
104 "@DocString(FMTLandscapeParser::readvectors)")
105 .method("readrasters",&Parser::FMTLandscapeParser::readRasters,
106 "@DocString(FMTLandscapeParser::readrasters)")
107 #endif
108 .method("write",&Parser::FMTLandscapeParser::write,
109 "@DocString(FMTLandscapeParser::write)");
110 Rcpp::class_<Parser::FMTActionParser>("FMTactionparser", "@DocString(FMTActionParser)")
111 .derives<Parser::FMTParser>("FMTparser")
112 .constructor("@DocString(FMTActionParser())")
113 .method("read",&Parser::FMTActionParser::read,
114 "@DocString(FMTActionParser::read)")
115 .method("write",&Parser::FMTActionParser::write,
116 "@DocString(FMTActionParser::write)");
117 Rcpp::class_<Parser::FMTTransitionParser>("FMTtransitionparser", "@DocString(FMTTransitionParser)")
118 .derives<Parser::FMTParser>("FMTparser")
119 .constructor("@DocString(FMTTransitionParser())")
120 .method("read",&Parser::FMTTransitionParser::read,
121 "@DocString(FMTTransitionParser::read)")
122 .method("write",&Parser::FMTTransitionParser::write,
123 "@DocString(FMTTransitionParser::write)");
124 Rcpp::class_<Parser::FMTConstantParser>("FMTconstantparser", "@DocString(FMTConstantParser)")
125 .derives<Parser::FMTParser>("FMTparser")
126 .constructor("@DocString(FMTConstantParser())")
127 .method("read",&Parser::FMTConstantParser::read,
128 "@DocString(FMTConstantParser::read)")
129 .method("write",&Parser::FMTConstantParser::write,
130 "@DocString(FMTConstantParser::write)");
131 Rcpp::class_<Parser::FMTLifespanParser>("FMTlifespanparser", "@DocString(FMTLifespanParser)")
132 .derives<Parser::FMTParser>("FMTparser")
133 .constructor("@DocString(FMTLifespanParser())")
134 .method("read",&Parser::FMTLifespanParser::read,
135 "@DocString(FMTLifespanParser::read)")
136 .method("write",&Parser::FMTLifespanParser::write,
137 "@DocString(FMTLifespanParser::write)");
138 Rcpp::class_<Parser::FMTYieldParser>("FMTyieldparser", "@DocString(FMTYieldParser)")
139 .derives<Parser::FMTParser>("FMTparser")
140 .constructor("@DocString(FMTYieldParser())")
141 .method("read",&Parser::FMTYieldParser::read,
142 "@DocString(FMTYieldParser::read)")
143 .method("write",&Parser::FMTYieldParser::write,
144 "@DocString(FMTYieldParser::write)");
145 Rcpp::class_<Parser::FMTOutputParser>("FMToutputparser", "@DocString(FMTOutputParser)")
146 .derives<Parser::FMTParser>("FMTparser")
147 .constructor("@DocString(FMTOutputParser())")
148 .method("read",&Parser::FMTOutputParser::read,
149 "@DocString(FMTOutputParser::read)")
150 .method("addoutputs",&Parser::FMTOutputParser::addOutputs,
151 "@DocString(FMTOutputParser::addoutputs)")
152 .method("write",&Parser::FMTOutputParser::write,
153 "@DocString(FMTOutputParser::write)");
154 Rcpp::class_<Parser::FMTOptimizationParser>("FMToptimizationparser", "@DocString(FMTOptimizationParser)")
155 .derives<Parser::FMTParser>("FMTparser")
156 .constructor("@DocString(FMTOptimizationParser())")
158 "@DocString(FMTOptimizationParser::read)")
159 .method("write", &Parser::FMTOptimizationParser::write,
160 "@DocString(FMTOptimizationParser::write)");
161 Rcpp::class_<Parser::FMTModelParser>("FMTmodelparser", "@DocString(FMTModelParser)")
162 .derives<Parser::FMTParser>("FMTparser")
163 .constructor("@DocString(FMTModelParser())")
164 .method("read",&Parser::FMTModelParser::read,
165 "@DocString(FMTModelParser::read)")
166 .method("readproject", &Parser::FMTModelParser::readproject,
167 "@DocString(FMTModelParser::readproject)")
168 .method("readschedules", &Parser::FMTModelParser::readSchedules,
169 "@DocString(FMTModelParser::readSchedules)")
170 .method("write",&Parser::FMTModelParser::write,
171 "@DocString(FMTModelParser::write)");
172 Rcpp::class_<Parser::FMTScheduleParser>("FMTscheduleparser", "@DocString(FMTScheduleParser)")
173 .derives<Parser::FMTParser>("FMTparser")
174 .constructor("@DocString(FMTScheduleParser())")
175 .method("read",&Parser::FMTScheduleParser::read,
176 "@DocString(FMTScheduleParser::read)")
177 .method("write",&Parser::FMTScheduleParser::write,
178 "@DocString(FMTScheduleParser::write)");
179 }
180
181}
182
183#endif // PYEXPORTParser_H_INCLUDED
RCPP_EXPOSED_WRAP(Parser::FMTParser)
RCPP_EXPOSED_AS(Parser::FMTParser)
Base class of multiple FMT classes holding a shared exception handler pointer and logger.
Definition: FMTObject.h:49
Parser reading and writing actions from or into action files, also used by the model parser.
Definition: FMTActionParser.h:33
std::vector< Core::FMTAction > read(const std::vector< Core::FMTTheme > &themes, const Core::FMTYields &yields, const Core::FMTConstants &constants, const std::string &location)
Read actions from an action file.
void write(const std::vector< Core::FMTAction > &actions, const std::string &location, bool withgcbmagg=false) const
Write actions to an action file.
Parser dealing with the spatial aspects used in multiple FMTModel children, reading and writing the a...
Definition: FMTAreaParser.h:67
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
Return the operating area schemes with their neighbors filled from a vector file.
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
Return the actual developments present in a vector file.
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
Rasterize a vector file and return the corresponding forest.
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
Write the disturbances into a raster file and return the corresponding GCBM transitions for the perio...
void vectorFieldToRaster(const std::string &data_vectors, const std::string &tifpathandname, const int &resolution, const std::string &field, bool fittoforel=true) const
Create a raster file of a given resolution from a vector file field.
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
Write a forest into multiple raster files.
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
Generate a FMTForest layer from raster files.
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
Return the operating area clusters with their linker mask from a vector file.
std::vector< Core::FMTActualDevelopment > read(const std::vector< Core::FMTTheme > &themes, const Core::FMTConstants &constants, const std::string &location)
Read a regular area section and return the actual developments.
void write(const std::vector< Core::FMTActualDevelopment > &areas, const std::string &location) const
Write an area section from a vector of actual developments.
Parser reading and writing constants, used by the model parser.
Definition: FMTConstantParser.h:26
void write(const Core::FMTConstants &constants, const std::string &location) const
Write constants to a file.
Core::FMTConstants read(const std::string &location)
Read a constants file.
Parser reading and writing the landscape section, and generating themes from vector or raster files.
Definition: FMTLandscapeParser.h:34
std::vector< Core::FMTTheme > readRasters(const std::vector< std::string > &locations)
Return the themes present in a vector of raster files, one theme per raster.
std::vector< Core::FMTTheme > readVectors(const std::string &location)
Return the themes present in a spatial vector file.
std::vector< Core::FMTTheme > read(const Core::FMTConstants &constants, const std::string &location)
Read the landscape section and return the themes.
void write(const std::vector< Core::FMTTheme > &themes, const std::string &location) const
Write a landscape section from a vector of themes.
Parser reading and writing the lifespan section of the model.
Definition: FMTLifespanParser.h:29
void write(const Core::FMTLifespans &lifespan, const std::string &location) const
Write the lifespan section.
Core::FMTLifespans read(const std::vector< Core::FMTTheme > &themes, const Core::FMTConstants &constants, const std::string &location)
Read the lifespan section.
Main parser reading and writing model files, for single or multiple scenarios, using all the other FM...
Definition: FMTModelParser.h:48
std::vector< std::vector< Core::FMTSchedule > > readSchedules(const std::string &primarym_location, const std::vector< Models::FMTModel > &models)
Read the schedule files of the models based on a primary file.
void write(const Models::FMTModel &model, const std::string &folder) const
Write a model into a folder, naming the files based on the model name.
Models::FMTModel read(const std::string &con, const std::string &lan, const std::string &lif, const std::string &are, const std::string &yld, const std::string &act, const std::string &tr, const std::string &out, std::string opt=std::string())
Read a single model and return it as a FMTModel.
std::vector< Models::FMTModel > readproject(const std::string &primarym_location, std::vector< std::string >scenarios=std::vector< std::string >(), bool readarea=true, bool readoutputs=true, bool readoptimize=true)
Read multiple scenarios based on a primary file location.
Parser reading and writing optimization sections into constraints and objectives.
Definition: FMTOptimizationParser.h:53
std::vector< Core::FMTConstraint > read(const std::vector< Core::FMTTheme > &p_themes, const std::vector< Core::FMTAction > &p_actions, const Core::FMTConstants &p_constants, const std::vector< Core::FMTOutput > &p_outputs, const Core::FMTYields &p_yields, std::vector< Core::FMTAction > &p_excluded, const std::string &pm_location)
Read an optimization file.
void write(const std::vector< Core::FMTConstraint > &p_constraints, const std::string &pm_location) const
Write the constraints into an optimization file.
Parser reading and writing a vector of FMTOutput from or into a file.
Definition: FMTOutputParser.h:35
std::vector< Core::FMTOutput > addOutputs(const std::vector< Core::FMTOutput > oldoutputs, const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const Core::FMTYields &ylds, const Core::FMTConstants &constants, const std::string &location, std::vector< std::string > outputsnames=std::vector< std::string >())
Read an output file and add the desired outputs to a vector of outputs.
std::vector< Core::FMTOutput > read(const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const Core::FMTYields &ylds, const Core::FMTConstants &constants, const std::string &location)
Read an output file.
void write(const std::vector< Core::FMTOutput > &outputs, const std::string &location) const
Write a vector of outputs to a file.
Main parent class of all the parsers in FMT.
Definition: FMTParser.h:72
Parser reading and writing vectors of schedules, also used by the model parser.
Definition: FMTScheduleParser.h:29
void write(const std::vector< Core::FMTSchedule > &schedules, const std::string &location, bool append=false) const
Write a vector of schedules to a schedule file.
std::vector< Core::FMTSchedule > read(const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const std::string &location, double tolerance=FMT_DBL_TOLERANCE)
Read a schedule section and turn it into a vector of schedules.
Parser reading and writing transition sections into a vector of FMTTransition.
Definition: FMTTransitionParser.h:35
void write(const std::vector< Core::FMTTransition > &transitions, const std::string &location) const
Write a vector of transitions to a file.
std::vector< Core::FMTTransition > read(const std::vector< Core::FMTTheme > &themes, const std::vector< Core::FMTAction > &actions, const Core::FMTYields &ylds, const Core::FMTConstants &constants, const std::string &location)
Read a vector of transitions.
Parser reading and writing yield sections into a FMTYields object.
Definition: FMTYieldParser.h:39
Core::FMTYields read(const std::vector< Core::FMTTheme > &themes, const Core::FMTConstants &constants, const std::string &location)
Read a yield file into a FMTYields object.
void write(const Core::FMTYields &yields, const std::string &location) const
Write a FMTYields object to a file.
Spatially referenced layer of Core::FMTDevelopment representing the forest.
Definition: FMTForest.h:33
Definition: RexportCore.h:153
void exportParser()
Definition: RexportParser.h:58