FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
PYexportParser.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 PYEXPORTParser_H_INCLUDED
9#define PYEXPORTParser_H_INCLUDED
10
12#include "FMTconstantparser.hpp"
13#include "FMTyieldparser.hpp"
14#include "FMTareaparser.hpp"
15#include "FMTactionparser.hpp"
17#include "FMToutputparser.hpp"
19#include "FMTscheduleparser.hpp"
20#include "FMTmodelparser.hpp"
21#include "boost/python.hpp"
22#include "FMTlifespanparser.hpp"
23
24namespace Python
25{
26BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readrasters_overloads,readrasters, 3, 6)
27BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readvectors_overloads,readvectors, 4, 8)
28BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getschemeneighbors_overloads, getschemeneighbors, 5, 10)
29BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getclusters_overloads,getclusters,6, 11)
30BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(addoutputs_overloads,addoutputs,6, 7)
31BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(vectormaptoFMTforest_overloads,vectormaptoFMTforest,5,11)
32BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(vectorfieldtoraster_overloads, vectorfieldtoraster,4,5)
33
34
35BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writeforest_overloads,writeforest, 5, 6)
36//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writedisturbances_overloads,writedisturbances, 5, 6)
37BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writepredictors_overloads,writepredictors, 5, 7)
38
39BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readmodel_overloads, read, 8, 9)
40BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getconstraintsfromstring_overloads,getconstraintsfromstring,2,3)
41
42
43BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(readproject_overloads, readproject,1,5)
44BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(writeresults_overloads, writeresults, 5, 7)
45
46
48 {
49 namespace bp = boost::python;
50 bp::object ParserModule(bp::handle<>(bp::borrowed(PyImport_AddModule("FMT.Parser"))));
51 bp::scope().attr("Parser") = ParserModule;
52 bp::scope Parser_scope = ParserModule;
53 bp::scope().attr("__doc__") = ".. module:: Parser\n"
54 "\n"
55 " :platform: Unix, Windows\n"
56 " :synopsis: Module used to import Woodstock models.\n"
57 "\n";
58
59 bp::class_<Parser::FMTparser, bp::bases<Core::FMTobject>>("FMTparser", "@DocString(FMTparser)");
60
61 define_pydict<std::string,std::string>();
62
63 bp::class_<Parser::FMTareaparser, bp::bases<Parser::FMTparser>>("FMTareaparser", "@DocString(FMTareaparser)")
64 .def("read", &Parser::FMTareaparser::read, "@DocString(FMTareaparser::read)")
65 #ifdef FMTWITHGDAL
66 .def("readvectors", &Parser::FMTareaparser::readvectors,readvectors_overloads(bp::args("themes", "data_vectors", "agefield", "areafield", "areafactor", "lockfield","minimalarea"), "@DocString(FMTareaparser::readvectors)"))
67 .def("readrasters", &Parser::FMTareaparser::readrasters,readrasters_overloads(bp::args("themes","data_rasters","age","agefactor","areafactor","lock"), "@DocString(FMTareaparser::readrasters)"))
68 .def("writeforest",&Parser::FMTareaparser::writeforest,writeforest_overloads(bp::args("for_layer", "themes", "data_rasters", "age", "lock", "mapping"), "@DocString(FMTareaparser::writeforest)"))
69 //.def("writedisturbances",&Parser::FMTareaparser::writedisturbances,writedisturbances_overloads(bp::args("location", "spatialschedule", "for_layer", "out_layer", "themes", "mapping"), "@DocString(FMTareaparser::writedisturbances)"))
70 .def("writedisturbances", &Parser::FMTareaparser::writedisturbances)
71 .def("writepredictors", &Parser::FMTareaparser::writepredictors,writepredictors_overloads(bp::args("location", "spatialsolution", "yieldnames", "model", "period", "withGCBMid"), "@DocString(FMTareaparser::writepredictors)"))
72 .def("vectormaptoFMTforest", &Parser::FMTareaparser::vectormaptoFMTforest,vectormaptoFMTforest_overloads(bp::args("data_vectors","resolution","themes","agefield","areafield","agefactor","areafactor","lockfield","minimalarea","writeforestfolder","fittoforel"),"@DocString(FMTareaparser::vectormaptoFMTforest)"))
73 .def("vectorfieldtoraster", &Parser::FMTareaparser::vectorfieldtoraster, vectorfieldtoraster_overloads(bp::args("data_vectors", "tifpathandname", "resolution", "field", "fittoforel"), "@DocString(FMTareaparser::vectorfieldtoraster)"))
74 #ifdef FMTWITHOSI
75 .def("getschemeneighbors",&Parser::FMTareaparser::getschemeneighbors, getschemeneighbors_overloads(bp::args("operatingareaparameters", "themes", "data_vectors", "agefield", "areafield", "agefactor","areafractor","lockfield","minimal_area","buffersize"), "@DocString(FMTareaparser::getschemeneighbors)"))
76 .def("getclusters",&Parser::FMTareaparser::getclusters,getclusters_overloads(bp::args("operatingareaparameters", "themes", "data_vectors", "agefield", "areafield","maximaldistance","agefactor","areafractor","lockfield","minimal_area","buffersize"),"@DocString(FMTareaparser::getclusters)"))
77 #endif
78 #endif
79 .def("write", &Parser::FMTareaparser::write,
80 "@DocString(FMTareaparser::write)");
81 bp::class_<Parser::FMTlandscapeparser, bp::bases<Parser::FMTparser>>("FMTlandscapeparser", "@DocString(FMTlandscapeparser)")
83 "@DocString(FMTlandscapeparser::read)")
84 #ifdef FMTWITHGDAL
85 .def("readvectors", &Parser::FMTlandscapeparser::readvectors,
86 "@DocString(FMTlandscapeparser::readvectors)")
88 "@DocString(FMTlandscapeparser::readrasters)")
89 #endif
91 "@DocString(FMTlandscapeparser::write)");
92 bp::class_<Parser::FMTactionparser, bp::bases<Parser::FMTparser>>("FMTactionparser", "@DocString(FMTactionparser)")
94 "@DocString(FMTactionparser::read)")
96 "@DocString(FMTactionparser::write)");
97 bp::class_<Parser::FMTtransitionparser, bp::bases<Parser::FMTparser>>("FMTtransitionparser", "@DocString(FMTtransitionparser)")
99 "@DocString(FMTtransitionparser::read)")
101 "@DocString(FMTtransitionparser::write)")
103 "@DocString(FMTtransitionparser::readGCBM)")
105 "@DocString(FMTtransitionparser::writeGCBM)");
106 bp::class_<Parser::FMTconstantparser, bp::bases<Parser::FMTparser>>("FMTconstantparser", "@DocString(FMTconstantparser)")
108 "@DocString(FMTconstantparser::read)")
110 "@DocString(FMTconstantparser::write)");
111 bp::class_<Parser::FMTlifespanparser, bp::bases<Parser::FMTparser>>("FMTlifespanparser", "@DocString(FMTlifespanparser)")
113 "@DocString(FMTlifespanparser::read)")
115 "@DocString(FMTlifespanparser::write)");
116 bp::class_<Parser::FMTyieldparser, bp::bases<Parser::FMTparser>>("FMTyieldparser", "@DocString(FMTyieldparser)")
117 .def("read",&Parser::FMTyieldparser::read,
118 "@DocString(FMTyieldparser::read)")
119 .def("write",&Parser::FMTyieldparser::write,
120 "@DocString(FMTyieldparser::write)");
121 bp::class_<Parser::FMToutputparser, bp::bases<Parser::FMTparser>>("FMToutputparser", "@DocString(FMToutputparser)")
123 "@DocString(FMToutputparser::read)")
124 .def("addoutputs",&Parser::FMToutputparser::addoutputs,addoutputs_overloads(bp::args("oldoutputs","themes","actions","ylds","constants","location","outputsname"),"@DocString(FMToutputparser::addoutputs)"))
125 .def("write",&Parser::FMToutputparser::write,
126 "@DocString(FMToutputparser::write)");
127 bp::class_<Parser::FMToptimizationparser, bp::bases<Parser::FMTparser>>("FMToptimizationparser", "@DocString(FMToptimizationparser)")
129 "@DocString(FMToptimizationparser::read)")
131 "@DocString(FMToptimizationparser::write)");
132 bp::class_<Parser::FMTmodelparser, bp::bases<Parser::FMTparser>>("FMTmodelparser", "@DocString(FMTmodelparser)")
133 .def("read",&Parser::FMTmodelparser::read, readmodel_overloads(bp::args("con","lan","lif","are","yld","act","tr","out","opt"), "@DocString(FMTmodel::read)"))
134 .def("readproject", &Parser::FMTmodelparser::readproject, readproject_overloads(bp::args("primary_location","scenarios","readarea","readoutputs","readoptimize"), "@DocString(FMTmodel::readproject)"))
135 .def("getconstraintsfromstring",&Parser::FMTmodelparser::getconstraintsfromstring, getconstraintsfromstring_overloads(bp::args("constraintstr", "model", "constants"), "@DocString(FMTmodel::getconstraintsfromstring)"))
136 .def("readschedules", &Parser::FMTmodelparser::readschedules,
137 "@DocString(FMTmodelparser::readschedules)")
138 #ifdef FMTWITHGDAL
139 .def("writeresults", &Parser::FMTmodelparser::writeresults,
140 writeresults_overloads(bp::args("model", "theoutputs", "firstperiod", "lastperiod", "outlocation", "outputlevel", "gdaldrivername"),
141 "@DocString(FMTmodelparser::writeresults)"))
142 #endif
143 .def("write",&Parser::FMTmodelparser::write,
144 "@DocString(FMTmodelparser::write)");
145 bp::class_<Parser::FMTscheduleparser, bp::bases<Parser::FMTparser>>("FMTscheduleparser", "@DocString(FMTscheduleparser)")
147 "@DocString(FMTscheduleparser::read)")
149 "@DocString(FMTscheduleparser::write)");
150 }
151
152}
153
154#endif // PYEXPORTParser_H_INCLUDED
std::vector< Core::FMTaction > read(const std::vector< Core::FMTtheme > &themes, const Core::FMTyields &yields, const Core::FMTconstants &constants, const std::string &location)
void write(const std::vector< Core::FMTaction > &actions, const std::string &location, bool withgcbmagg=false) const
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
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
std::vector< Core::FMTactualdevelopment > read(const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &constants, const std::string &location)
void write(const std::vector< Core::FMTactualdevelopment > &areas, const std::string &location) const
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
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< 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
Core::FMTconstants read(const std::string &location)
void write(const Core::FMTconstants &constants, const std::string &location) const
std::vector< Core::FMTtheme > readrasters(const std::vector< std::string > &locations)
std::vector< Core::FMTtheme > readvectors(const std::string &location)
void write(const std::vector< Core::FMTtheme > &themes, const std::string &location) const
std::vector< Core::FMTtheme > read(const Core::FMTconstants &constants, const std::string &location)
void write(const Core::FMTlifespans &lifespan, const std::string &location) const
Core::FMTlifespans read(const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &constants, const std::string &location)
void write(const Models::FMTmodel &model, const std::string &folder) const
std::vector< Core::FMTconstraint > getconstraintsfromstring(std::string constraintstr, const Models::FMTmodel &model, Core::FMTconstants constants=Core::FMTconstants())
void writeresults(const Models::FMTmodel &model, const std::vector< Core::FMToutput > &theoutputs, const int &firstperiod, const int &lastperiod, const std::string &location, Core::FMToutputlevel level=Core::FMToutputlevel::standard, std::string gdaldrivername="CSV") const
std::vector< Models::FMTmodel > readproject(const std::string &primary_location, std::vector< std::string >scenarios=std::vector< std::string >(), bool readarea=true, bool readoutputs=true, bool readoptimize=true)
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())
std::vector< std::vector< Core::FMTschedule > > readschedules(const std::string &primary_location, const std::vector< Models::FMTmodel > &models)
std::vector< Core::FMTconstraint > read(const std::vector< Core::FMTtheme > &themes, const std::vector< Core::FMTaction > &actions, const Core::FMTconstants &constants, const std::vector< Core::FMToutput > &outputs, std::vector< Core::FMTaction > &excluded, const std::string &location)
void write(const std::vector< Core::FMTconstraint > &constraints, const std::string &location) const
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 >())
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)
void write(const std::vector< Core::FMToutput > &outputs, const std::string &location) const
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)
void write(const std::vector< Core::FMTschedule > &schedules, const std::string &location) const
void writeGCBM(const std::vector< Core::FMTGCBMtransition > &transitions, const std::string &location) const
void write(const std::vector< Core::FMTtransition > &transitions, const std::string &location) const
std::vector< Core::FMTGCBMtransition > readGCBM(const std::string &location) const
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)
void write(const Core::FMTyields &yields, const std::string &location) const
Core::FMTyields read(const std::vector< Core::FMTtheme > &themes, const Core::FMTconstants &constants, const std::string &location)
Definition: PYdefinitions.hpp:14
void exportParser()
Definition: PYexportParser.hpp:47