FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
PYexportSpatial.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 PYEXPORTSPATIAL_H_INCLUDED
9#define PYEXPORTSPATIAL_H_INCLUDED
10
11#include "FMTcoordinate.hpp"
12#include "FMTforest.hpp"
13//#include "FMTspatialschedule.hpp"
14//#include "FMTspatialaction.hpp"
15#include "FMTeventcontainer.hpp"
16//#include "FMTsaschedule.hpp"
17#include "FMTgraph.hpp"
18//#include "FMTsasolution.hpp"
19#include "boost/python.hpp"
20
21namespace Python
22{
23BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getforestperiod_overloads, getforestperiod, 1, 2)
24BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getconstraintevaluation_overloads,getconstraintevaluation,2,2)
25BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(getobjectivevalue_overloads,getobjectivevalue,2,2)
27 {
28 namespace bp = boost::python;
29 bp::object SpatialModule(bp::handle<>(bp::borrowed(PyImport_AddModule("FMT.Spatial"))));
30 bp::scope().attr("Spatial") = SpatialModule;
31 bp::scope Spatial_scope = SpatialModule;
32 bp::scope().attr("__doc__") = ".. module:: Spatial\n"
33 "\n"
34 " :platform: Unix, Windows\n"
35 " :synopsis: Spatial module used for Simulation.\n"
36 "\n";
37
38 bp::class_<Spatial::FMTcoordinate>("FMTcoordinate", "@DocString(FMTcoordinate)")
39 .def(bp::init<unsigned int,unsigned int>())
40 .def("__lt__",&Spatial::FMTcoordinate::operator <,
41 "@DocString(FMTcoordinate::operator<)")
43 "@DocString(FMTcoordinate::getx)")
45 "@DocString(FMTcoordinate::gety)")
46 .def("getSpatialCoordinate",&Spatial::FMTcoordinate::getSpatialCoordinate,
47 "@DocString(FMTcoordinate::getSpatialCoordinate)")
48 .setattr("__hash__",&boost::pyhash<Spatial::FMTcoordinate>);
49
50 define_FMTlayer<Core::FMTdevelopment>();
51 //Mainly to iter over FMTforest
52 define_pypair<Spatial::FMTcoordinate,Core::FMTdevelopment>();
53 define_pypair<Spatial::FMTcoordinate const,Core::FMTdevelopment>();
54 define_pypair<Spatial::FMTcoordinate,Graph::FMTlinegraph>();
55 define_pypair<Spatial::FMTcoordinate const,Graph::FMTlinegraph>();
56
57
58
59 bp::class_<Spatial::FMTforest, bp::bases<Spatial::FMTlayer<Core::FMTdevelopment>>>("FMTforest", "@DocString(FMTforest)")
60 .def(bp::init<Spatial::FMTforest>())
61 .def("getarea",&Spatial::FMTforest::getarea,
62 "@DocString(FMTforest::getarea)")
63 .def("grow",&Spatial::FMTforest::grow,
64 "@DocString(FMTforest::grow)")
65 .def("getage",&Spatial::FMTforest::getage,
66 "@DocString(FMTforest::getage)")
67 .def("setperiod",&Spatial::FMTforest::setperiod,
68 "@DocString(FMTforest::setperiod)");
69
70
71 define_pylist<Spatial::FMTforest>();
72
73 bp::class_<Spatial::FMTeventcontainer>("FMTeventcontainer", "@DocString(FMTeventcontainer)")
74 .def(bp::init<Spatial::FMTeventcontainer>());
75
76 define_pylist<Spatial::FMTeventcontainer>();
77
78 /*
79 bp::class_<Spatial::FMTspatialaction, bp::bases<Core::FMTaction>>("FMTspatialaction", "@DocString(FMTspatialaction)")
80 .def(bp::init<Core::FMTaction>())
81 .add_property("neighbors", bp::make_getter(&Spatial::FMTspatialaction::neighbors, bp::return_value_policy<bp::return_by_value>()),
82 make_setter(&Spatial::FMTspatialaction::neighbors, bp::return_value_policy<bp::return_by_value>()))
83 .def_readwrite("green_up",&Spatial::FMTspatialaction::green_up,
84 "@DocString(FMTspatialaction::green_up)")
85 .def_readwrite("adjacency",&Spatial::FMTspatialaction::adjacency,
86 "@DocString(FMTspatialaction::adjacency)")
87 .def_readwrite("minimal_size",&Spatial::FMTspatialaction::minimal_size,
88 "@DocString(FMTspatialaction::minimal_size)")
89 .def_readwrite("maximal_size",&Spatial::FMTspatialaction::maximal_size,
90 "@DocString(FMTspatialaction::maximal_size)")
91 .def_readwrite("neighbors_size",&Spatial::FMTspatialaction::neighbors_size,
92 "@DocString(FMTspatialaction::neighbors_size)")
93 .def_readwrite("greenup_weight",&Spatial::FMTspatialaction::greenup_weight,
94 "@DocString(FMTspatialaction::greenup_weight)")
95 .def_readwrite("adjacency_weight",&Spatial::FMTspatialaction::adjacency_weight,
96 "@DocString(FMTspatialaction::adjacency_weight)")
97 .def_readwrite("size_weight",&Spatial::FMTspatialaction::size_weight,
98 "@DocString(FMTspatialaction::size_weight)");
99 define_pylist<Spatial::FMTspatialaction>();*/
100
101
102 //bp::class_<Spatial::FMTsaschedule, boost::noncopyable>("Abstract_FMTsaschedule","@DocString(FMTsaschedule)", bp::no_init);
103
104
105 //bp::class_<Spatial::FMTexponentialschedule, bp::bases<Spatial::FMTsaschedule>>("FMTexponentialschedule", "@DocString(FMTexponentialschedule)")
106 // .def(bp::init<double>());
107
108 /*bp::enum_<Spatial::FMTsamovetype>("FMTsamovetype")
109 .value("shotgun", Spatial::FMTsamovetype::shotgun)
110 .value("cluster", Spatial::FMTsamovetype::cluster)
111 .value("opt1", Spatial::FMTsamovetype::opt1);
112
113 bp::class_<Spatial::FMTsasolution, bp::bases<Spatial::FMTlayer<Graph::FMTlinegraph>>>("FMTsasolution", "@DocString(FMTsasolution)")
114 .def("get_stats",&Spatial::FMTsasolution::getsolution_stats, "@DocString(FMTsasolution::getsolution_stats)")
115 .def("getobjfvalue",&Spatial::FMTsasolution::getobjfvalue, "@DocString(FMTsasolution::getobjfvalue)")
116 .def("get_forest_at_period",&Spatial::FMTsasolution::getforestperiod, "@DocString(FMTsasolution::getforestperiod)")
117 .def("get_graphs_outputs", &Spatial::FMTsasolution::getgraphsoutputs);
118
119 define_pylist<Spatial::FMTsasolution>();
120 */
121
122 define_FMTlayer<Graph::FMTlinegraph>();
123
124 bp::class_<Spatial::FMTspatialschedule, bp::bases<Spatial::FMTlayer<Graph::FMTlinegraph>>>("FMTspatialschedule", "@DocString(FMTspatialschedule)")
125 .def(bp::init<Spatial::FMTspatialschedule>())
126 .def("getforestperiod", &Spatial::FMTspatialschedule::getforestperiod, getforestperiod_overloads(bp::args("period","periodstart"),"@DocString(FMTspatialschedule::getforestperiod)"))
127 .def("getoutputbycoordinate", &Spatial::FMTspatialschedule::getoutputbycoordinate, "@DocString(FMTspatialschedule::getoutputbycoordinate)")
128 .def("getbindingactions", &Spatial::FMTspatialschedule::getbindingactions, "@DocString(FMTspatialschedule::getbindingactions)")
129 .def("operatecoord", &Spatial::FMTspatialschedule::operatecoord, "@DocString(FMTspatialschedule::operatecoord)")
130 .def("getconstraintevaluation", &Spatial::FMTspatialschedule::getconstraintevaluation, getconstraintevaluation_overloads(bp::args("constraint","model"),"@DocString(FMTspatialschedule::getconstraintevaluation)"))
131 .def("grow", &Spatial::FMTspatialschedule::grow, "@DocString(FMTspatialschedule::grow)");
132 define_pylist<Spatial::FMTspatialschedule>();
133
134 bp::class_<Spatial::FMTbindingspatialaction>("FMTbindingspatialaction", "@DocString(FMTbindingspatialaction)")
135 .def("getminimaladjacency", &Spatial::FMTbindingspatialaction::getminimaladjacency,boost::python::return_value_policy<boost::python::copy_const_reference>(),"@DocString(FMTspatialschedule::getminimaladjacency)")
136 .def("getminimalsize",&Spatial::FMTbindingspatialaction::getminimalsize,boost::python::return_value_policy<boost::python::copy_const_reference>(),"@DocString(FMTspatialschedule::getminimalsize)")
137 .def("getmaximalsize",&Spatial::FMTbindingspatialaction::getmaximalsize,boost::python::return_value_policy<boost::python::copy_const_reference>(), "@DocString(FMTspatialschedule::getmaximalsize)");
138
139 define_pylist<Spatial::FMTbindingspatialaction>();
140
141 }
142}
143
144#endif // PYEXPORTSPATIAL_H_INCLUDED
const size_t & getmaximalsize() const
Definition: FMTbindingspatialaction.hpp:67
const size_t & getminimaladjacency() const
Definition: FMTbindingspatialaction.hpp:55
const size_t & getminimalsize() const
Definition: FMTbindingspatialaction.hpp:63
const std::vector< double > getSpatialCoordinate(std::vector< double > geoTransform) const
unsigned int getx() const
unsigned int gety() const
std::vector< Core::FMTactualdevelopment > getarea() const
void setperiod(int period)
FMTforest grow() const
FMTlayer< int > getage() const
std::vector< Spatial::FMTbindingspatialaction > getbindingactions(const Models::FMTmodel &model, const int &period) const
void operatecoord(const FMTcoordinate &coord, const Core::FMTaction &action, const int &action_id, const FMTbindingspatialaction &bindingspaction, const Core::FMTtransition &Transition, const Core::FMTyields &ylds, const std::vector< Core::FMTtheme > &themes)
FMTforest getforestperiod(const int &period, bool periodstart=false) const
std::vector< std::pair< FMTcoordinate, double > > getoutputbycoordinate(const Models::FMTmodel &model, const Core::FMToutput &output, const int &period) const
double getconstraintevaluation(const Core::FMTconstraint &constraint, const Models::FMTmodel &model, const FMTspatialschedule *friendlysolution=nullptr) const
Definition: PYdefinitions.hpp:14
void exportSpatial()
Definition: PYexportSpatial.hpp:26