bes  Updated for version 3.20.6
FONgRequestHandler.cc
1 // FONgRequestHandler.cc
2 
3 // This file is part of BES GDAL File Out Module
4 
5 // Copyright (c) 2012 OPeNDAP, Inc.
6 // Author: James Gallagher <jgallagher@opendap.org>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact University Corporation for Atmospheric Research at
23 // 3080 Center Green Drive, Boulder, CO 80301
24 
25 #include <gdal.h>
26 
27 #include <BESResponseHandler.h>
28 #include <BESResponseNames.h>
29 #include <BESVersionInfo.h>
30 
31 #include <TheBESKeys.h>
32 
33 #include "config.h"
34 
35 #include "FONgRequestHandler.h"
36 
37 using std::endl;
38 using std::ostream;
39 using std::string;
40 using std::map;
41 
42 // Added hrg 3/20/19
43 bool FONgRequestHandler::d_use_byte_for_geotiff_bands = true;
44 
54  BESRequestHandler(name)
55 {
58 
59  FONgRequestHandler::d_use_byte_for_geotiff_bands = TheBESKeys::TheKeys()->read_bool_key("FONg.GeoTiff.band.type.byte", true);
60 
61  GDALAllRegister();
62  CPLSetErrorHandler(CPLQuietErrorHandler);
63 }
64 
68 {
69 }
70 
83 {
84  BESResponseObject *response = dhi.response_handler->get_response_object();
85  BESInfo *info = dynamic_cast<BESInfo *>(response);
86  if (!info)
87  throw BESInternalError("cast error", __FILE__, __LINE__);
88 
89  bool found = false;
90  string key = "FONg.Reference";
91  string ref;
92  TheBESKeys::TheKeys()->get_value(key, ref, found);
93  if (ref.empty())
94  ref = "http://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_GDAL";
95 
96  map<string, string> attrs;
97  attrs["name"] = MODULE_NAME ;
98  attrs["version"] = MODULE_VERSION ;
99 
100  attrs["reference"] = ref;
101  info->begin_tag("module", &attrs);
102  info->end_tag("module");
103 
104  return true;
105 }
106 
115 {
116  BESResponseObject *response = dhi.response_handler->get_response_object();
117  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
118  if (!info)
119  throw BESInternalError("cast error", __FILE__, __LINE__);
120 
121  info->add_module(MODULE_NAME, MODULE_VERSION);
122 
123  return true;
124 }
125 
132 void FONgRequestHandler::dump(ostream &strm) const
133 {
134  strm << BESIndent::LMarg << "FONgRequestHandler::dump - (" << (void *) this << ")" << endl;
135  BESIndent::Indent();
137  BESIndent::UnIndent();
138 }
139 
BESRequestHandler
Represents a specific data type request handler.
Definition: BESRequestHandler.h:74
FONgRequestHandler::build_help
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut GDAL to a help request
Definition: FONgRequestHandler.cc:82
BESInfo
informational response object
Definition: BESInfo.h:63
BESRequestHandler::add_method
virtual bool add_method(const std::string &name, p_request_handler_method method)
add a handler method to the request handler that knows how to fill in a specific response object
Definition: BESRequestHandler.cc:58
TheBESKeys::read_bool_key
bool read_bool_key(const std::string &key, bool default_value)
Read a boolean-valued key from the bes.conf file.
Definition: TheBESKeys.cc:326
TheBESKeys::TheKeys
static TheBESKeys * TheKeys()
Definition: TheBESKeys.cc:62
BESResponseHandler::get_response_object
virtual BESResponseObject * get_response_object()
return the current response object
Definition: BESResponseHandler.cc:82
BESVersionInfo
Definition: BESVersionInfo.h:47
BESInternalError
exception thrown if internal error encountered
Definition: BESInternalError.h:43
FONgRequestHandler::FONgRequestHandler
FONgRequestHandler(const std::string &name)
Constructor for FileOut GDAL module.
Definition: FONgRequestHandler.cc:53
TheBESKeys::get_value
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
Definition: TheBESKeys.cc:272
BESRequestHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESRequestHandler.cc:163
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56
FONgRequestHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: FONgRequestHandler.cc:132
FONgRequestHandler::build_version
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
Definition: FONgRequestHandler.cc:114
FONgRequestHandler::~FONgRequestHandler
virtual ~FONgRequestHandler(void)
Any cleanup that needs to take place.
Definition: FONgRequestHandler.cc:67
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:45