BMPArealSourceFactory.h
Go to the documentation of this file.
1/*!
2 * \file BMPArealSourceFactory.h
3 * \brief Areal source pollution and BMP factory
4 *
5 * Changelog:
6 * - 1. 2016-04-12 - lj - Code reformat.
7 *
8 * \author Liang-Jun Zhu
9 * \date Aug 2016
10 */
11#ifndef SEIMS_BMP_AREALSOURCE_H
12#define SEIMS_BMP_AREALSOURCE_H
13
14#include "basic.h"
15#include "data_raster.hpp"
16#include "BMPFactory.h"
17
18using namespace ccgl;
19using namespace data_raster;
20using namespace bmps;
21
22namespace bmps {
23/*!
24 * \class bmps::ArealSourceLocations
25 * \brief Base class of point BMP, mainly store location related parameters
26 *
27 */
29public:
30 /*!
31 * \brief Constructor, read and calculate areal BMP locations related parameters from Raster
32 */
33 ArealSourceLocations(const bson_t*& bsonTable, bson_iter_t& iter);
34
35 /// load valid cells index
36 void SetValidCells(int n, int* mgtFieldIDs);
37
38 /// Output
39 void Dump(std::ostream* fs);
40
41 /// Get point source ID
42 int GetArealSourceID() { return m_arealSrcID; }
43
44 /// name
45 string GetArealSourceName() { return m_name; }
46
47 /// index of valid cells
48 vector<int>& GetCellsIndex() { return m_cellsIndex; }
49
50 /// Located subbasin ID
51 int GetValidCells() { return m_nCells; }
52
53 /// size
54 FLTPT GetSize() { return m_size; }
55
56private:
57 /// ID of point source
58 int m_arealSrcID;
59 /// name
60 string m_name;
61 /// valid cell number
62 int m_nCells;
63 /// index of valid cells
64 vector<int> m_cellsIndex;
65 /// size, used to calculate amount of pollutants
66 FLTPT m_size;
67};
68
69/*!
70 * \class bmps::ArealSourceMgtParams
71 * \brief Point source management parameters
72 *
73 */
75public:
76 /*!
77 * \brief Constructor, parse areal source management parameters from bson object
78 * \param[in] bsonTable Query result from MongoDB
79 * \param[in] iter Iterator of bsonTab
80 */
81 ArealSourceMgtParams(const bson_t*& bsonTable, bson_iter_t& iter);
82
83 /// Destructor
84 //~ArealSourceMgtParams() = default;
85
86 /// Output
87 void Dump(std::ostream* fs);
88
89 /// Get start date of the current management operation
90 time_t GetStartDate() { return m_startDate; }
91
92 /// Get end date
93 time_t GetEndDate() { return m_endDate; }
94
95 /// Get sequence number
96 int GetSequence() { return m_seqence; }
97
98 /// Get subScenario name
99 string GetSubScenarioName() { return m_name; }
100
101 /// Get water volume
102 FLTPT GetWaterVolume() { return m_waterVolume; }
103
104 /// Get sediment concentration
105 FLTPT GetSedment() { return m_sedimentConc; }
106
107 /// Get sediment concentration
108 FLTPT GetTN() { return m_TNConc; }
109
110 /// Get NO3 concentration
111 FLTPT GetNO3() { return m_NO3Conc; }
112
113 /// Get NH4 concentration
114 FLTPT GetNH4() { return m_NH4Conc; }
115
116 /// Get OrgN concentration
117 FLTPT GetOrgN() { return m_OrgNConc; }
118
119 /// Get TP concentration
120 FLTPT GetTP() { return m_TPConc; }
121
122 /// Get MinP concentration
123 FLTPT GetMinP() { return m_SolPConc; }
124
125 /// Get OrgP concentration
126 FLTPT GetOrgP() { return m_OrgPConc; }
127
128 /// Get COD concentration
129 FLTPT GetCOD() { return m_COD; }
130
131private:
132 /// subSecenario name
133 string m_name;
134 /// Sequence number of management
135 int m_seqence;
136 /// Start date
137 time_t m_startDate;
138 /// End date
139 time_t m_endDate;
140 /// Q Water volume m3/'size'/day ('Size' may be one chicken or so, depends on ARSRC code)
141 FLTPT m_waterVolume;
142 /// Sed Sediment concentration kg/'size'/day
143 FLTPT m_sedimentConc;
144 /// TN Total Nitrogen concentration kg/'size'/day
145 FLTPT m_TNConc;
146 /// NO3 Nitrate Nitrogen concentration kg/'size'/day
147 FLTPT m_NO3Conc;
148 /// NH4 Ammonium Nitrogen concentration kg/'size'/day
149 FLTPT m_NH4Conc;
150 /// ORGN Organic Nitrogen concentration kg/'size'/day
151 FLTPT m_OrgNConc;
152 /// TP Total phosphorus concentration kg/'size'/day
153 FLTPT m_TPConc;
154 /// MINP Mineral phosphorus concentration kg/'size'/day
155 FLTPT m_SolPConc;
156 /// ORGP Organic phosphorus concentration kg/'size'/day
157 FLTPT m_OrgPConc;
158 /// cod
159 FLTPT m_COD;
160};
161
162/*!
163 * \class bmps::BMPArealSrcFactory
164 * \brief Base class of areal source BMPs.
165 * Such as chicken farm
166 *
167 */
169public:
170 /// Constructor
171 BMPArealSrcFactory(int scenarioId, int bmpId, int subScenario,
172 int bmpType, int bmpPriority, vector<string>& distribution,
173 const string& collection, const string& location);
174
175 /// Destructor
177
178 /// Load BMP parameters from MongoDB
179 void loadBMP(MongoClient* conn, const string& bmpDBName) OVERRIDE;
180
181 /// Output
182 void Dump(std::ostream* fs) OVERRIDE;
183
184 /*!
185 * \brief Load areal BMP location related parameters from MongoDB
186 * \param[in] conn MongoClient instance
187 * \param[in] bmpDBName BMP Scenario database
188 */
189 void ReadArealSourceManagements(MongoClient* conn, const string& bmpDBName);
190
191 /*!
192 * \brief Load areal BMP location related parameters from MongoDB
193 * \param[in] conn MongoClient instance
194 * \param[in] bmpDBName BMP Scenario database
195 */
196 void ReadArealSourceLocations(MongoClient* conn, const string& bmpDBName);
197
198 /// Set raster data if needed
199 void setRasterData(map<string, IntRaster*>& sceneRsMap) OVERRIDE;
200
201 /// Get management fields data
202 int* GetRasterData() OVERRIDE { return m_mgtFieldsRs; }
203
204 string GetArealSrcDistName() { return m_arealSrcDistName; }
205
206 vector<int>& GetArealSrcMgtSeqs() { return m_arealSrcMgtSeqs; }
207
208 map<int, ArealSourceMgtParams*>& GetArealSrcMgtMap() { return m_arealSrcMgtMap; }
209
210 vector<int>& GetArealSrcIDs() { return m_arealSrcIDs; }
211
212 bool GetLocationLoadStatus() { return m_loadedMgtFieldIDs; }
213
214 void SetArealSrcLocsMap(int n, int* mgtField);
215
216 map<int, ArealSourceLocations*>& GetArealSrcLocsMap() { return m_arealSrcLocsMap; }
217
218private:
219 /// areal source code
220 int m_arealSrc;
221 /// Collection of point source management parameters
222 string m_arealSrcMgtTab;
223 /// Sequences of point source managements
224 vector<int> m_arealSrcMgtSeqs;
225 /* Map of areal source management parameters
226 * Key: Scheduled sequence number, unique
227 * Value: Pointer of ArealSourceMgtParams instance
228 */
229 map<int, ArealSourceMgtParams*> m_arealSrcMgtMap;
230 /// core file name of areal source locations, such as MGT_FIELDS
231 string m_arealSrcDistName;
232 /// distribution data of areal source locations
233 int* m_mgtFieldsRs;
234 /// areal source distribution table
235 string m_arealSrcDistTab;
236 /// Field IDs of areal source of current subScenario
237 vector<int> m_arealSrcIDs;
238 /// flag
239 bool m_loadedMgtFieldIDs;
240 /* Map of areal source location related parameters
241 * Key: ARSRCID, unique
242 * Value: Pointer of ArealBMPLocations instance
243 */
244 map<int, ArealSourceLocations*> m_arealSrcLocsMap;
245};
246}
247#endif /* SEIMS_BMP_AREALSOURCE_H */
Base namespace for implementation of BMP configuration.
Basic definitions.
#define OVERRIDE
A compatible reference to override or blank if not supported by the compiler.
Definition: basic.h:160
Base class of point BMP, mainly store location related parameters.
Definition: BMPArealSourceFactory.h:28
int GetArealSourceID()
Get point source ID.
Definition: BMPArealSourceFactory.h:42
ArealSourceLocations(const bson_t *&bsonTable, bson_iter_t &iter)
Constructor, read and calculate areal BMP locations related parameters from Raster.
FLTPT GetSize()
size
Definition: BMPArealSourceFactory.h:54
int GetValidCells()
Located subbasin ID.
Definition: BMPArealSourceFactory.h:51
void SetValidCells(int n, int *mgtFieldIDs)
load valid cells index
vector< int > & GetCellsIndex()
index of valid cells
Definition: BMPArealSourceFactory.h:48
void Dump(std::ostream *fs)
Output.
string GetArealSourceName()
name
Definition: BMPArealSourceFactory.h:45
Point source management parameters.
Definition: BMPArealSourceFactory.h:74
FLTPT GetTP()
Get TP concentration.
Definition: BMPArealSourceFactory.h:120
int GetSequence()
Get sequence number.
Definition: BMPArealSourceFactory.h:96
FLTPT GetNO3()
Get NO3 concentration.
Definition: BMPArealSourceFactory.h:111
FLTPT GetOrgN()
Get OrgN concentration.
Definition: BMPArealSourceFactory.h:117
time_t GetEndDate()
Get end date.
Definition: BMPArealSourceFactory.h:93
FLTPT GetWaterVolume()
Get water volume.
Definition: BMPArealSourceFactory.h:102
FLTPT GetOrgP()
Get OrgP concentration.
Definition: BMPArealSourceFactory.h:126
FLTPT GetTN()
Get sediment concentration.
Definition: BMPArealSourceFactory.h:108
ArealSourceMgtParams(const bson_t *&bsonTable, bson_iter_t &iter)
Constructor, parse areal source management parameters from bson object.
time_t GetStartDate()
Get start date of the current management operation.
Definition: BMPArealSourceFactory.h:90
FLTPT GetMinP()
Get MinP concentration.
Definition: BMPArealSourceFactory.h:123
FLTPT GetCOD()
Get COD concentration.
Definition: BMPArealSourceFactory.h:129
FLTPT GetNH4()
Get NH4 concentration.
Definition: BMPArealSourceFactory.h:114
void Dump(std::ostream *fs)
Destructor.
string GetSubScenarioName()
Get subScenario name.
Definition: BMPArealSourceFactory.h:99
FLTPT GetSedment()
Get sediment concentration.
Definition: BMPArealSourceFactory.h:105
Base class of areal source BMPs.
Definition: BMPArealSourceFactory.h:168
void ReadArealSourceManagements(MongoClient *conn, const string &bmpDBName)
Load areal BMP location related parameters from MongoDB.
int * GetRasterData() OVERRIDE
Get management fields data.
Definition: BMPArealSourceFactory.h:202
virtual ~BMPArealSrcFactory()
Destructor.
void loadBMP(MongoClient *conn, const string &bmpDBName) OVERRIDE
Load BMP parameters from MongoDB.
BMPArealSrcFactory(int scenarioId, int bmpId, int subScenario, int bmpType, int bmpPriority, vector< string > &distribution, const string &collection, const string &location)
Constructor.
void setRasterData(map< string, IntRaster * > &sceneRsMap) OVERRIDE
Set raster data if needed.
void ReadArealSourceLocations(MongoClient *conn, const string &bmpDBName)
Load areal BMP location related parameters from MongoDB.
void Dump(std::ostream *fs) OVERRIDE
Output.
Base class of all kind of BMPs Factory.
Definition: BMPFactory.h:33
int bmpType()
Get BMP type 1 - reach BMPs which are attached to specific reaches and will change the character of t...
int bmpPriority()
Get BMP priority.
Base type of all interfaces.
Definition: basic.h:407
A simple wrapper of the class of MongoDB Client mongoc_client_t.
Definition: db_mongoc.h:46
All BMPs scenario related data, classes, and functions.
Definition: BMPArealSourceFactory.h:22
Common Cross-platform Geographic Library (CCGL)