Cell2Fire
A large-scale forest fire simulator.
Loading...
Searching...
No Matches
ReadCSV.h
1#ifndef READCSV
2#define READCSV
3
4#include "Cells.h"
5#include "DataGenerator.h"
6#include "ReadArgs.h"
7
8#include "tiffio.h"
9#include <algorithm>
10#include <boost/algorithm/string.hpp>
11#include <fstream>
12#include <iostream>
13#include <iterator>
14#include <string>
15#include <unordered_map>
16#include <unordered_set>
17#include <vector>
18
19/*
20 * Forest structure
21 */
22typedef struct
23{
24 int cellside, rows, cols;
25 double xllcorner, yllcorner;
26 // std::vector<std::unordered_map<std::string, int>> adjCells;
27 std::vector<std::vector<int>> coordCells;
28} forestDF;
29
30/*
31 * A class to read data from a csv file.
32 */
34{
35 public:
36 // inmutable
37 std::string fileName;
38 std::string delimeter;
39
40 // Constructor
41 CSVReader(std::string filename, std::string delm = ",");
42
43 // Function to fetch data from a CSV File
44 std::vector<std::vector<std::string>> getData();
45
46 // Print data to console (Debug)
47 void printData(std::vector<std::vector<std::string>>& DF);
48
49 // Populate DF (Spanish version)
50 void parseDF(inputs* df_ptr, std::vector<std::vector<std::string>>& DF, arguments* args_ptr, int NCells);
51
52 // Populate NFtypes (Spanish version)
53 void parseNDF(std::vector<int>& NFTypes, std::vector<std::vector<std::string>>& DF, int NCells);
54
55 // Populate Probabilities
56 void parsePROB(std::vector<float>& probabilities, std::vector<std::vector<std::string>>& DF, int NCells);
57
58 // Populate Weather DF (Spanish version)
59 void
60 parseWeatherDF(weatherDF* wt_ptr, arguments* args_ptr, std::vector<std::vector<std::string>>& DF, int WPeriods);
61
62 // Populate Ignition Points
63 void parseIgnitionDF(std::vector<int>& ig, std::vector<std::vector<std::string>>& DF, int IgPeriods);
64
65 // Populates ForestDF
66 void parseForestDF(forestDF* frt_ptr, std::vector<std::vector<std::string>>& DF);
67
68 // Populate Harvested Cells
69 void parseHarvestedDF(std::unordered_map<int, std::vector<int>>& hc,
70 std::vector<std::vector<std::string>>& DF,
71 int HPeriods);
72
73 // Populate BBO Factors
74 void parseBBODF(std::unordered_map<int, std::vector<float>>& bbo,
75 std::vector<std::vector<std::string>>& DF,
76 int NFTypes);
77
78 // Prints individual cell info
79 void printDF(inputs df);
80
81 // Prints individual weather row info
82 void printWeatherDF(weatherDF wdf);
83};
84
85#endif
Definition ReadCSV.h:34
void parseNDF(std::vector< int > &NFTypes, std::vector< std::vector< std::string > > &DF, int NCells)
Populates a vector of size NCells with fuel type number per cell.
Definition ReadCSV.cpp:422
void parsePROB(std::vector< float > &probabilities, std::vector< std::vector< std::string > > &DF, int NCells)
Not currently supported. Populates a vector of size NCells with ignition probability per cell.
Definition ReadCSV.cpp:454
void printData(std::vector< std::vector< std::string > > &DF)
print data contained in 2D vector to console row by row
Definition ReadCSV.cpp:213
std::vector< std::vector< std::string > > getData()
Reads and parses data from a CSV, ASCII or TIFF file into a 2D vector.
Definition ReadCSV.cpp:46
void parseDF(inputs *df_ptr, std::vector< std::vector< std::string > > &DF, arguments *args_ptr, int NCells)
Populates an instance of inputs using information contained in a 2D vector.
Definition ReadCSV.cpp:243
Definition ReadArgs.h:16
Definition ReadCSV.h:23
Definition Cells.h:29
Definition Cells.h:22