InputStation.h
Go to the documentation of this file.
1/*!
2 * \file InputStation.h
3 * \brief HydroClimate site information
4 * \author Junzhi Liu, LiangJun Zhu
5 * \version 1.2
6 * \date Aug., 2022
7 */
8#ifndef SEIMS_CLIMATE_STATION_H
9#define SEIMS_CLIMATE_STATION_H
10
11#include <map>
12
13#include "basic.h"
14#include "db_mongoc.h"
15
16#include "Measurement.h"
17#include <seims.h>
18
19using namespace ccgl;
20using namespace db_mongoc;
21using std::map;
22
23/*!
24 * \ingroup data
25 * \class InputStation
26 * \brief HydroClimate sites information
27 */
29public:
30 //! Constructor
31 InputStation(MongoClient* conn, time_t dtHillslope, time_t dtChannel);
32
33 //! Destructor
35
36 //! Get site number of given site type
37 bool NumberOfSites(const char* site_type, int& site_count);
38
39 //! Get elevations of given site type
40 bool GetElevation(const char* site_type, FLTPT*& site_elevs);
41
42 //! Get latitudes of given site type
43 bool GetLatitude(const char* site_type, FLTPT*& site_lats);
44
45 /*!
46 * \brief Get time series data
47 *
48 * \param[in] time data time
49 * \param[in] type data type
50 * \param[out] nRow data item number
51 * \param[out] data time series data
52 */
53 void GetTimeSeriesData(time_t time, const string& type, int* nRow, FLTPT** data);
54
55 /*!
56 * \brief Read data of each site type
57 *
58 * \param[in] hydroDBName HydroClimate database which contains "DataValues" collection
59 * \param[in] sitesList \a string, site ID string derived from model database (e.g., model_dianbu30m_longterm)
60 * \param[in] siteType site type
61 * \param[in] startDate start date
62 * \param[in] endDate end date
63 * \param[in] stormMode \a bool, false by default
64 */
65 void ReadSitesData(const string& hydroDBName, const string& sitesList, const string& siteType,
66 time_t startDate, time_t endDate, bool stormMode = false);
67
68private:
69 /*!
70 * \brief build BSON query sentences for MongoDB
71 *
72 * \param[in] nSites site number
73 * \param[in] siteIDList site ID list
74 * \param[in] siteType site type, "P" or "M"
75 * \param[in] query \a bson_t
76 */
77 void build_query_bson(int nSites, const vector<int>& siteIDList, const string& siteType, bson_t* query);
78
79 /*!
80 * \brief Read HydroClimate sites information from HydroClimateDB (MongoDB)
81 *
82 * \param[in] siteType site type, "P", "M" or others
83 * \param[in] hydroDBName HydroClimate database which contains "Sites" collection
84 * \param[in] sitesList \a string, site ID string derived from model database (e.g., model_dianbu30m_longterm)
85 */
86 void ReadSitesInfo(const string& siteType, const string& hydroDBName, const string& sitesList);
87
88private:
89 //! MongoDB client object
90 MongoClient* m_conn;
91 //! Channel scale time interval
92 time_t m_dtCh;
93 //! Hillslope scale time interval
94 time_t m_dtHs;
95 //! Measurement object of each data type
96 map<string, Measurement *> m_measurement;
97 //! Site ID: elevation
98 map<string, FLTPT*> m_elevation;
99 //! Site ID: latitude
100 map<string, FLTPT*> m_latitude;
101 //! site numbers of each site type
102 map<string, int> m_numSites;
103};
104#endif /* SEIMS_CLIMATE_STATION_H */
Measurement class to store HydroClimate site data.
Basic definitions.
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
Simple wrappers of the API of MongoDB C driver mongo-c-driver, see MongoDB C Driver for more informat...
bool GetLatitude(const char *site_type, FLTPT *&site_lats)
Get latitudes of given site type.
bool NumberOfSites(const char *site_type, int &site_count)
Get site number of given site type.
~InputStation()
Destructor.
void ReadSitesData(const string &hydroDBName, const string &sitesList, const string &siteType, time_t startDate, time_t endDate, bool stormMode=false)
Read data of each site type.
bool GetElevation(const char *site_type, FLTPT *&site_elevs)
Get elevations of given site type.
InputStation(MongoClient *conn, time_t dtHillslope, time_t dtChannel)
Constructor.
void GetTimeSeriesData(time_t time, const string &type, int *nRow, FLTPT **data)
Get time series data.
HydroClimate sites information.
Definition: InputStation.h:28
Common Cross-platform Geographic Library (CCGL)
The SEIMS related definitions and utilities header.