bes  Updated for version 3.20.5
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 // Added hrg 3/20/19
38 bool FONgRequestHandler::d_use_byte_for_geotiff_bands = true;
39 
49  BESRequestHandler(name)
50 {
53 
54  FONgRequestHandler::d_use_byte_for_geotiff_bands = TheBESKeys::TheKeys()->read_bool_key("FONg.GeoTiff.band.type.byte", true);
55 
56  GDALAllRegister();
57  CPLSetErrorHandler(CPLQuietErrorHandler);
58 }
59 
63 {
64 }
65 
78 {
79  BESResponseObject *response = dhi.response_handler->get_response_object();
80  BESInfo *info = dynamic_cast<BESInfo *>(response);
81  if (!info)
82  throw BESInternalError("cast error", __FILE__, __LINE__);
83 
84  bool found = false;
85  string key = "FONg.Reference";
86  string ref;
87  TheBESKeys::TheKeys()->get_value(key, ref, found);
88  if (ref.empty())
89  ref = "http://docs.opendap.org/index.php/BES_-_Modules_-_FileOut_GDAL";
90 
91  map<string, string> attrs;
92  attrs["name"] = MODULE_NAME ;
93  attrs["version"] = MODULE_VERSION ;
94 
95  attrs["reference"] = ref;
96  info->begin_tag("module", &attrs);
97  info->end_tag("module");
98 
99  return true;
100 }
101 
110 {
111  BESResponseObject *response = dhi.response_handler->get_response_object();
112  BESVersionInfo *info = dynamic_cast<BESVersionInfo *>(response);
113  if (!info)
114  throw BESInternalError("cast error", __FILE__, __LINE__);
115 
116  info->add_module(MODULE_NAME, MODULE_VERSION);
117 
118  return true;
119 }
120 
127 void FONgRequestHandler::dump(ostream &strm) const
128 {
129  strm << BESIndent::LMarg << "FONgRequestHandler::dump - (" << (void *) this << ")" << endl;
130  BESIndent::Indent();
132  BESIndent::UnIndent();
133 }
134 
static bool build_help(BESDataHandlerInterface &dhi)
adds help information for FileOut GDAL to a help request
exception thrown if inernal error encountered
FONgRequestHandler(const string &name)
Constructor for FileOut GDAL module.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
Definition: TheBESKeys.cc:420
virtual bool add_method(const 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
static bool build_version(BESDataHandlerInterface &dhi)
add version information to a version response
virtual ~FONgRequestHandler(void)
Any cleanup that needs to take place.
informational response object
Definition: BESInfo.h:68
virtual BESResponseObject * get_response_object()
return the current response object
static TheBESKeys * TheKeys()
Definition: TheBESKeys.cc:61
bool read_bool_key(const std::string &key, bool default_value)
Read a boolean-valued key from the bes.conf file.
Definition: TheBESKeys.cc:474
Represents a specific data type request handler.
virtual void dump(ostream &strm) const
dumps information about this object
Structure storing information used by the BES to handle the request.
virtual void dump(ostream &strm) const
dumps information about this object
Abstract base class representing a specific set of information in response to a request to the BES.