8#ifndef FMTareaparser_Hm_included
9#define FMTareaparser_Hm_included
17#include <boost/regex.hpp>
20class OGRGeometryCollection;
28 class FMTActualDevelopment;
29 class FMTGCBMTransition;
82 const std::string& age,
double agefactor = 1.0,
double areafactor = 0.0001, std::string lock =
"")
const;
116 const std::vector<Core::FMTTheme>& themes,
117 const std::vector<std::string>& data_rasters,
118 const std::string& age,
119 const std::string& lock,
120 std::vector<std::map<std::string, std::string>> mapping = std::vector<std::map<std::string, std::string>>())
const;
131 const std::vector<Core::FMTTheme>& p_themes,
132 const std::string& p_folder,
133 std::vector<std::map<std::string, std::string>> p_mapping = std::vector<std::map<std::string, std::string>>())
const;
147 const std::string& location,
148 const std::map<std::string, std::string>& mapping,
149 std::string format =
"GTiff")
const;
162 const std::vector<Core::FMTAction>& actions,
163 const std::vector<Core::FMTTheme>& themes,
164 const int& period)
const;
177 std::vector<std::vector<Graph::FMTPredictor>>
writePredictors(
const std::string& location,
179 const std::vector<std::string>& yieldnames,
182 bool periodonevalues =
false,
183 bool withGCBMid =
true)
const;
211 std::vector<Heuristics::FMTOperatingAreaScheme>
getSchemeNeighbors(std::vector<Heuristics::FMTOperatingAreaScheme> operatingareaparameters,
212 const std::vector<Core::FMTTheme>& themes,
const std::string& data_vectors,
213 const std::string& agefield,
const std::string& areafield,
double agefactor = 1.0,
214 double areafactor = 1, std::string lockfield =
"",
215 double minimal_area = 0.0,
double buffersize = 100)
const;
232 std::vector<Heuristics::FMTOperatingAreaCluster>
getClusters(
const std::vector<Heuristics::FMTOperatingArea>& operatingareas,
233 const std::vector<Core::FMTTheme>& themes,
const std::string& data_vectors,
234 const std::string& agefield,
const std::string& areafield,
const double& maximaldistance,
235 double agefactor = 1.0,
double areafactor = 1, std::string lockfield =
"",
236 double minimal_area = 0.0,
double buffersize = 100)
const;
250 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;
260 std::vector<Heuristics::FMTOperatingAreaScheme>
readOaSchedulerParameters(
const std::string& location,
const std::vector<Core::FMTTheme>& modelthemes,
const int& themetarget,
const int& startingperiod)
const;
269 std::vector<std::string> creationoptions = std::vector<std::string>())
const;
284 std::vector<Core::FMTActualDevelopment>
readVectors(
const std::vector<Core::FMTTheme>& themes,
const std::string& data_vectors,
285 const std::string& agefield,
const std::string& areafield,
double agefactor = 1.0,
286 double areafactor = 1, std::string lockfield =
"",
287 double minimalarea = 0.0)
const;
305 const int& resolution,
const std::vector<Core::FMTTheme>& themes,
306 const std::string& agefield,
const std::string& areafield,
double agefactor = 1.0,
307 double areafactor = 1, std::string lockfield =
"",
308 double minimalarea = 0.0,
const std::string& writeforestfolder =
"",
309 const bool& fittoforel =
true)
const;
320 const std::string& tifpathandname,
321 const int& resolution,
322 const std::string& field,
323 bool fittoforel =
true)
const;
334 GDALDataset*
ogrLayerToRaster(OGRLayer* layer,
const std::string& fieldname,
const std::string& outfilename,
const int& resolution,
const bool& fittoforel)
const;
346 const std::vector<Core::FMTTheme> p_themes,
347 const std::vector<Core::FMTActualDevelopment>& p_area,
348 const std::string& p_folder)
const;
382 std::vector<Core::FMTActualDevelopment>
read(
const std::vector<Core::FMTTheme>& themes,
const Core::FMTConstants& constants,
const std::string& location);
389 void write(
const std::vector<Core::FMTActualDevelopment>& areas,
const std::string& location)
const;
393 const static boost::regex m_rxcleanarea;
396 const static boost::regex m_RxExclude;
399 const static boost::regex m_RxExcludeSpec;
406 bool _isExclude(
const std::string& pm_line)
const;
413 std::string _getExcludeValue(
const std::string& pm_line)
const;
422 std::pair<Core::FMTMask, Core::FMTSpec> _getExcludedSpec(
const std::vector<Core::FMTTheme>& p_themes,
424 const std::string& p_value)
const;
434 bool _gotNewExclude(
const std::vector<Core::FMTTheme>& p_themes,
436 const std::string& p_value,
446 std::string _getPeriodPathName(
const std::string& location,
const int& period,
const std::string& name)
const;
459 const std::vector<Core::FMTTheme>& themes)
const;
471 template<
typename T,
typename outT>
472 bool _writeBand(
const Spatial::FMTLayer<T>& layer, GDALRasterBand* wband,
const std::map<T, std::string>& mapping)
const;
486 std::vector<OGRGeometry*> _getUnion(
const std::vector<OGRMultiPolygon>& p_collections)
const;
497 void _destroyGeometries(std::vector<OGRGeometry*>& p_geometires)
const;
513 const std::vector<Core::FMTTheme>& themes,
514 const std::map<int, int>& themes_fields,
515 const int& age_field,
516 const int& lock_field,
517 const int& area_field,
518 const double& agefactor,
519 const double& areafactor,
520 const double& minimalarea)
const;
526 void _validateRaster(
const std::vector<std::string>&data_rasters)
const;
541 GDALDataset* _openVectorFile(std::map<int, int>&themes_fields,
int& age_field,
int& lock_field,
int& area_field,
542 const std::string& data_vectors,
const std::string& agefield,
const std::string& areafield,
const std::string& lockfield,
543 const std::vector<Core::FMTTheme>& themes)
const;
564 std::vector<OGRMultiPolygon> _getMultiPolygons(
const std::vector<Heuristics::FMTOperatingArea>& operatingareas,
565 const std::vector<Core::FMTTheme>& themes,
const std::string& data_vectors,
566 const std::string& agefield,
const std::string& areafield,
double agefactor = 1.0,
567 double areafactor = 1, std::string lockfield =
"",
568 double minimal_area = 0.0)
const;
585 std::vector<Heuristics::FMTOperatingArea> _getNeighborsFromPolygons(
const std::vector<OGRGeometry*>& polygons,
586 std::vector<Heuristics::FMTOperatingArea> operatingareas,
587 const double& buffersize)
const;
597 std::vector<Heuristics::FMTOperatingAreaCluster> _getClustersFromPolygons(
const std::vector<OGRGeometry*>&polygons,
598 const std::vector<Heuristics::FMTOperatingArea>& operatingareas,
const double& maximaldistance)
const;
606 bool _isMapWithSameThemes(
const std::vector<Core::FMTTheme>& p_themes,
607 const std::string& p_VectorsMap)
const;
615 static double _GetGeometryArea(
const OGRGeometry* p_geometry);
628 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;
638 OGRLayer* _subsetLayer(OGRLayer*layer,
const std::vector<Core::FMTTheme>& themes,
639 const std::string& agefield,
const std::string& areafield)
const;
#define FMTEXPORT
Definition: FMTutility.h:125
Child class of FMTDevelopment representing an actual forest stand, holding the area of the stand.
Definition: FMTActualDevelopment.h:24
Class holding the constants defined in the constants section of a model, used by the parsers.
Definition: FMTConstants.h:28
Definition: FMTAreaParser.h:32
Class holding the attributes and aggregates of a single theme, describing a part of a FMTMask.
Definition: FMTTheme.h:47
Predictor gathering the source and target ages, yields, distances and disturbances of a graph transit...
Definition: FMTPredictor.h:33
Potential cluster of multiple operating areas.
Definition: FMTOperatingAreaCluster.h:27
Operating area scheme giving information about its opening time, green up and return time.
Definition: FMTOperatingAreaScheme.h:42
Operating area giving information about its mask, neighbors and neighbors perimeter.
Definition: FMTOperatingArea.h:29
Base class for the different models in FMT.
Definition: FMTModel.h:62
Parser dealing with the spatial aspects used in multiple FMTModel children, reading and writing the a...
Definition: FMTAreaParser.h:67
bool writeLayer(const Spatial::FMTLayer< T > &layer, std::string location, const std::map< T, std::string > &mapping, std::string format="GTiff") const
Write a layer into a raster file, with a mapping for categorical variables.
bool writeForest(const Spatial::FMTForest &p_for_layer, const std::vector< Core::FMTTheme > &p_themes, const std::string &p_folder, std::vector< std::map< std::string, std::string > > p_mapping=std::vector< std::map< std::string, std::string > >()) const
Write a forest into a folder.
bool writeLayer(const Spatial::FMTLayer< double > &layer, std::string location, std::string format="GTiff") const
Write a double layer into a raster file.
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
Write the predictor ids into a raster file and return the corresponding predictors for the period.
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.
GDALDataset * ogrLayerToRaster(OGRLayer *layer, const std::string &fieldname, const std::string &outfilename, const int &resolution, const bool &fittoforel) const
Rasterize a layer to 20x20 in memory then reproject it to the given resolution using MODE resampling.
std::vector< Heuristics::FMTOperatingAreaScheme > readOaSchedulerParameters(const std::string &location, const std::vector< Core::FMTTheme > &modelthemes, const int &themetarget, const int &startingperiod) const
Return the operating area schemes from a parameters file, for use in the operating area scheduler.
void writeForestExtended(Spatial::FMTForest &p_forest, const std::string &p_VectorFile, const std::vector< Core::FMTTheme > p_themes, const std::vector< Core::FMTActualDevelopment > &p_area, const std::string &p_folder) const
Write an extended forest to a folder using a vector file.
~FMTAreaParser()=default
Default destructor for FMTAreaParser.
void writeOaSchedulerParameters(const std::string &location, const std::vector< Heuristics::FMTOperatingAreaScheme > &OAschemes, std::vector< std::string > creationoptions=std::vector< std::string >()) const
Write a parameters file with the full mask in the OA column into a csv file.
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...
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
Write a forest theme into a raster file using a mapping.
FMTAreaParser(const FMTAreaParser &rhs)=default
Copy constructor for FMTAreaParser.
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::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
Return the operating area schemes from a shapefile.
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.
FMTAreaParser()
Default constructor for FMTAreaParser.
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.
Main parent class of all the parsers in FMT.
Definition: FMTParser.h:72
Spatially referenced layer of Core::FMTDevelopment representing the forest.
Definition: FMTForest.h:33
Definition: FMTParser.h:54
Map containing a line graph for each cell, representing the stand, the action and the transition at e...
Definition: FMTSpatialSchedule.h:50
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Definition: FMTAreaParser.h:35
Namespace regrouping all tools for solving LP/MIP problems using an heuristic.
Definition: FMTAreaParser.h:47
Namespace containing all enumerator and classes used to construct or manipulate the different type of...
Definition: FMTAreaParser.h:54
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTActionParser.h:27
Definition: FMTAreaParser.h:40