bes  Updated for version 3.20.6
CmrApi.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of cmr_module, A C++ MODULE that can be loaded in to
4 // the OPeNDAP Back-End Server (BES) and is able to handle remote requests.
5 
6 // Copyright (c) 2015 OPeNDAP, Inc.
7 // Author: Nathan Potter <ndp@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 /*
26  * CmrApi.h
27  *
28  * Created on: July, 13 2018
29  * Author: ndp
30  */
31 
32 #ifndef MODULES_CMR_MODULE_CMRAPI_H_
33 #define MODULES_CMR_MODULE_CMRAPI_H_
34 
35 #include <string>
36 #include <vector>
37 #include "rapidjson/document.h"
38 #include "BESCatalogUtils.h"
39 
40 #include "Granule.h"
41 
42 namespace cmr {
43 
44 
45 class CmrApi {
46 private:
47  std::string cmr_search_endpoint_url;
48 
49  const rapidjson::Value& get_temporal_group(const rapidjson::Document &cmr_doc);
50  const rapidjson::Value& get_year_group(const rapidjson::Document &cmr_doc);
51  const rapidjson::Value& get_month_group(const std::string year, const rapidjson::Document &cmr_doc);
52  const rapidjson::Value& get_month(const std::string r_month, const std::string r_year, const rapidjson::Document &cmr_doc);
53  const rapidjson::Value& get_day_group(const std::string r_month, const std::string year, const rapidjson::Document &cmr_doc);
54  const rapidjson::Value& get_children(const rapidjson::Value& obj);
55  const rapidjson::Value& get_feed(const rapidjson::Document &cmr_doc);
56  const rapidjson::Value& get_entries(const rapidjson::Document &cmr_doc);
57  void granule_search(std::string collection_name, std::string r_year, std::string r_month, std::string r_day,rapidjson::Document &result_doc);
58 
59 
60 public:
61  CmrApi() : cmr_search_endpoint_url("https://cmr.earthdata.nasa.gov/search") {}
62 
63  void get_years(std::string collection_name, std::vector<std::string> &years_result);
64  void get_months(std::string collection_name, std::string year, std::vector<std::string> &months_result);
65  void get_days(std::string collection_name, std::string r_year, std::string r_month, std::vector<std::string> &days_result);
66  void get_granule_ids(std::string collection_name, std::string r_year, std::string r_month, std::string r_day, std::vector<std::string> &granules_result);
67  void get_granule_ids(std::string collection_name, std::string r_year, std::string r_month, std::vector<std::string> &granules_result);
68  void get_granules(std::string collection_name, std::string r_year, std::string r_month, std::string r_day, std::vector<cmr::Granule *> &granules);
69  void get_collection_ids(std::vector<std::string> &collection_ids);
70  unsigned long granule_count(std::string collection_name,std:: string r_year, std::string r_month, std::string r_day);
71  cmr::Granule *get_granule(const std::string path);
72  cmr::Granule *get_granule(std::string collection_name, std::string r_year, std::string r_month, std::string r_day, std::string granule_id);
73 };
74 
75 
76 
77 } // namespace cmr
78 
79 #endif /* MODULES_CMR_MODULE_CMRAPI_H_ */
Document
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: cmr_module/rapidjson/document.h:2402
cmr::CmrApi::get_days
void get_days(std::string collection_name, std::string r_year, std::string r_month, std::vector< std::string > &days_result)
Definition: CmrApi.cc:425
cmr::CmrApi::get_months
void get_months(std::string collection_name, std::string year, std::vector< std::string > &months_result)
Definition: CmrApi.cc:362
cmr::Granule
Definition: Granule.h:43
Value
GenericValue< UTF8<> > Value
GenericValue with UTF8 encoding.
Definition: cmr_module/rapidjson/document.h:2010
cmr::CmrApi
Definition: CmrApi.h:45
cmr::CmrApi::get_granules
void get_granules(std::string collection_name, std::string r_year, std::string r_month, std::string r_day, std::vector< cmr::Granule * > &granules)
Definition: CmrApi.cc:516
cmr::CmrApi::get_years
void get_years(std::string collection_name, std::vector< std::string > &years_result)
Definition: CmrApi.cc:334