bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
FoCovJsonRequestHandler.cc
1// -*- mode: c++; c-basic-offset:4 -*-
2//
3// FoCovJsonRequestHandler.cc
4//
5// This file is part of BES CovJSON File Out Module
6//
7// Copyright (c) 2018 OPeNDAP, Inc.
8// Author: Corey Hemphill <hemphilc@oregonstate.edu>
9// Author: River Hendriksen <hendriri@oregonstate.edu>
10// Author: Riley Rimer <rrimer@oregonstate.edu>
11//
12// Adapted from the File Out JSON module implemented by Nathan Potter
13//
14// This library is free software; you can redistribute it and/or
15// modify it under the terms of the GNU Lesser General Public
16// License as published by the Free Software Foundation; either
17// version 2.1 of the License, or (at your option) any later version.
18//
19// This library is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22// Lesser General Public License for more details.
23//
24// You should have received a copy of the GNU Lesser General Public
25// License along with this library; if not, write to the Free Software
26// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27//
28
29#include "FoCovJsonRequestHandler.h"
30#include <BESResponseHandler.h>
31#include <BESResponseNames.h>
32#include <BESVersionInfo.h>
33#include <BESDataNames.h>
34#include <BESDataNames.h>
35#include <TheBESKeys.h>
36#include "config.h"
37
38using std::endl;
39using std::ostream;
40using std::string;
41using std::map;
42
43bool FoCovJsonRequestHandler::_may_ignore_z_axis = true;
44bool FoCovJsonRequestHandler::_simple_geo = true;
45
46// Borrow from the HDF5 handler
47bool FoCovJsonRequestHandler::obtain_beskeys_info(const string & key, bool &has_key) {
48
49 bool ret_value = false;
50 string doset ="";
51 TheBESKeys::TheKeys()->get_value( key, doset, has_key ) ;
52 if(has_key) {
53 const string dosettrue ="true";
54 const string dosetyes = "yes";
55 doset = BESUtil::lowercase(doset) ;
56 ret_value = (dosettrue == doset || dosetyes == doset);
57 }
58 return ret_value;
59
60}
61
71 BESRequestHandler(name)
72{
75 bool has_key = false;
76 bool key_value = obtain_beskeys_info("FoCovJson.MAY_IGNORE_Z_AXIS",has_key);
77 if (has_key)
78 _may_ignore_z_axis = key_value;
79 key_value = obtain_beskeys_info("FoCovJson.SIMPLE_GEO",has_key);
80 if (has_key)
81 _simple_geo = key_value;
82
83#if 0
84if(_may_ignore_z_axis == true)
85std::cerr<<"IGNORE mode "<<endl;
86else
87std::cerr<<"Strict mode "<<endl;
88#endif
89}
90
96
109{
110 BESResponseObject *response = dhi.response_handler->get_response_object();
111 BESInfo *info = dynamic_cast<BESInfo *>(response);
112 if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
113
114 bool found = false;
115 string key = "FoCovJson.Reference";
116 string ref;
117 TheBESKeys::TheKeys()->get_value(key, ref, found);
118 if (ref.empty()) ref = "https://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_COVJSON";
119 map<string, string, std::less<>> attrs;
120 attrs["name"] = MODULE_NAME;
121 attrs["version"] = MODULE_VERSION;
122
123 attrs["reference"] = ref;
124 info->begin_tag("module", &attrs);
125 info->end_tag("module");
126
127 return true;
128}
129
138{
139 BESResponseObject *response = dhi.response_handler->get_response_object();
140 BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
141 if (!info) throw BESInternalError("cast error", __FILE__, __LINE__);
142
143 info->add_module(MODULE_NAME, MODULE_VERSION);
144
145 return true;
146}
147
154void FoCovJsonRequestHandler::dump(ostream &strm) const
155{
156 strm << BESIndent::LMarg << "FoCovJsonRequestHandler::dump - (" << (void *) this << ")" << endl;
157 BESIndent::Indent();
159 BESIndent::UnIndent();
160}
161
Structure storing information used by the BES to handle the request.
informational response object
Definition BESInfo.h:63
exception thrown if internal error encountered
virtual bool add_handler(const std::string &name, p_request_handler_method method)
Backward compatibility with the older version of this class.
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual BESResponseObject * get_response_object()
return the current response object
Abstract base class representing a specific set of information in response to a request to the BES.
static std::string lowercase(const std::string &s)
Definition BESUtil.cc:257
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
FoCovJsonRequestHandler(const std::string &name)
Constructor for FileOut Coverage JSON module.
virtual ~FoCovJsonRequestHandler(void)
Any cleanup that needs to take place.
virtual void dump(std::ostream &strm) const
dumps information about this object
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut Coverage JSON to a help request
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()
Access to the singleton.
Definition TheBESKeys.cc:85