34 #include <mime_util.h>
35 #include <D4BaseTypeFactory.h>
55 #include <InternalErr.h>
56 #include <Ancillary.h>
60 #include "gridfields_functions.h"
67 bool NCRequestHandler::_show_shared_dims =
true;
68 bool NCRequestHandler::_show_shared_dims_set =
false;
70 bool NCRequestHandler::_ignore_unknown_types =
false;
71 bool NCRequestHandler::_ignore_unknown_types_set =
false;
73 bool NCRequestHandler::_promote_byte_to_short =
false;
74 bool NCRequestHandler::_promote_byte_to_short_set =
false;
85 static bool version_ge(
const string &version,
float value)
89 istringstream iss(version);
104 BESDEBUG(
"nc",
"In NCRequestHandler::NCRequestHandler" << endl);
117 if (NCRequestHandler::_show_shared_dims_set ==
false) {
118 bool key_found =
false;
123 NCRequestHandler::_show_shared_dims_set =
true;
126 if (doset ==
"true" || doset ==
"yes") {
127 NCRequestHandler::_show_shared_dims =
true;
130 NCRequestHandler::_show_shared_dims =
false;
134 if (NCRequestHandler::_ignore_unknown_types_set ==
false) {
135 bool key_found =
false;
140 if (doset ==
"true" || doset ==
"yes")
141 NCRequestHandler::_ignore_unknown_types =
true;
143 NCRequestHandler::_ignore_unknown_types =
false;
145 NCRequestHandler::_ignore_unknown_types_set =
true;
149 if (NCRequestHandler::_promote_byte_to_short_set ==
false) {
150 bool key_found =
false;
155 if (doset ==
"true" || doset ==
"yes")
156 NCRequestHandler::_promote_byte_to_short =
true;
158 NCRequestHandler::_promote_byte_to_short =
false;
160 NCRequestHandler::_promote_byte_to_short_set =
true;
164 BESDEBUG(
"nc",
"Exiting NCRequestHandler::NCRequestHandler" << endl);
173 BESDEBUG(
"nc",
"In NCRequestHandler::nc_build_das" << endl);
184 Ancillary::read_ancillary_das(*das, accessed);
190 catch (InternalErr & e) {
191 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
195 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
198 catch (std::exception &e) {
199 string s = string(
"C++ Exception: ") + e.what();
204 string s =
"unknown exception caught building DAS";
209 BESDEBUG(
"nc",
"Exiting NCRequestHandler::nc_build_das" << endl);
224 if (NCRequestHandler::_show_shared_dims_set ==
false) {
225 bool context_found =
false;
228 BESDEBUG(
"nc",
"xdap_accept: " << context_value << endl);
229 if (version_ge(context_value, 3.2))
230 NCRequestHandler::_show_shared_dims =
false;
232 NCRequestHandler::_show_shared_dims =
true;
239 dds->filename(accessed);
243 BESDEBUG(
"nc",
"NCRequestHandler::nc_build_dds, accessed: " << accessed << endl);
245 Ancillary::read_ancillary_dds(*dds, accessed);
252 Ancillary::read_ancillary_das(*das, accessed);
254 BESDEBUG(
"nc",
"Prior to dds->transfer_attributes" << endl);
256 dds->transfer_attributes(das);
259 ConstraintEvaluator & ce = bdds->
get_ce();
260 ce.add_function(
"ugrid_restrict", function_ugrid_restrict);
270 catch (InternalErr & e) {
271 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
275 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
278 catch (std::exception &e) {
279 string s = string(
"C++ Exception: ") + e.what();
284 string s =
"unknown exception caught building DDS";
300 if (NCRequestHandler::_show_shared_dims_set ==
false) {
301 bool context_found =
false;
304 BESDEBUG(
"nc",
"xdap_accept: " << context_value << endl);
305 if (version_ge(context_value, 3.2))
306 NCRequestHandler::_show_shared_dims =
false;
308 NCRequestHandler::_show_shared_dims =
true;
313 DataDDS *dds = bdds->
get_dds();
315 dds->filename(accessed);
320 Ancillary::read_ancillary_dds(*dds, accessed);
326 Ancillary::read_ancillary_das(*das, accessed);
328 dds->transfer_attributes(das);
331 ConstraintEvaluator & ce = bdds->
get_ce();
332 ce.add_function(
"ugrid_restrict", function_ugrid_restrict);
341 catch (InternalErr & e) {
342 BESDapError ex(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
346 BESDapError ex(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
349 catch (std::exception &e) {
350 string s = string(
"C++ Exception: ") + e.what();
355 string s =
"unknown exception caught building DAS";
370 BaseTypeFactory factory;
371 DDS dds(&factory, name_path(data_path),
"3.2");
372 dds.filename(data_path);
379 Ancillary::read_ancillary_das(das, data_path);
380 dds.transfer_attributes(&das);
382 catch (InternalErr &e) {
383 throw BESDapError(e.get_error_message(),
true, e.get_error_code(), __FILE__, __LINE__);
386 throw BESDapError(e.get_error_message(),
false, e.get_error_code(), __FILE__, __LINE__);
389 throw BESDapError(
"Caught unknown error build NC DMR response",
true, unknown_error, __FILE__, __LINE__);
401 dmr->set_factory(
new D4BaseTypeFactory);
402 dmr->build_using_dds(dds);
424 map < string, string > attrs;
425 attrs[
"name"] = MODULE_NAME ;
426 attrs[
"version"] = MODULE_VERSION ;
431 list < string > services;
433 if (services.size() > 0) {
435 attrs[
"handles"] = handles;
453 info->
add_module(MODULE_NAME, MODULE_VERSION);
static bool nc_build_version(BESDataHandlerInterface &dhi)
virtual ~NCRequestHandler(void)
brief represents simple text information in a response object, such as version and help inforamtion...
#define DAP4DATA_RESPONSE
exception thrown if an internal error is found and is fatal to the BES
exception thrown if inernal error encountered
ConstraintEvaluator & get_ce()
string get_symbolic_name() const
retrieve the symbolic name for this container
static string lowercase(const string &s)
Convert a string to all lower case.
Represents an OPeNDAP DDS DAP2 data object within the BES.
virtual void clear_container()
clear the container in the DAP response object
virtual void set_dap4_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
static bool nc_build_dds(BESDataHandlerInterface &dhi)
virtual string get_context(const string &name, bool &found)
retrieve the value of the specified context from the BES
static bool nc_build_das(BESDataHandlerInterface &dhi)
void nc_read_dataset_attributes(DAS &das, const string &filename)
Given a reference to an instance of class DAS and a filename that refers to a netcdf file...
static class NCMLUtil overview
virtual string access()=0
returns the true name of this container
virtual void clear_container()
clear the container in the DAP response object
void nc_read_dataset_variables(DDS &dds, const string &filename)
Given a reference to an instance of class DDS and a filename that refers to a netcdf file...
virtual void set_dap4_function(BESDataHandlerInterface &dhi)
set the constraint depending on the context
informational response object
static string implode(const list< string > &values, char delim)
implode a list of values into a single string delimited by delim
virtual BESResponseObject * get_response_object()
return the current response object
Abstract exception class for the BES with basic string message.
static BESServiceRegistry * TheRegistry()
BESResponseHandler * response_handler
virtual void set_constraint(BESDataHandlerInterface &dhi)
set the constraint depending on the context
virtual void begin_tag(const string &tag_name, map< string, string > *attrs=0)
Represents an OPeNDAP DMR DAP4 data object within the BES.
virtual void set_container(const string &cn)
set the container in the DAP response object
error object created from libdap error objects and can handle those errors
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
virtual void clear_container()
clear the container in the DAP response object
Represents a specific data type request handler.
static BESContextManager * TheManager()
NCRequestHandler(const string &name)
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
static bool nc_build_dmr(BESDataHandlerInterface &dhi)
ConstraintEvaluator & get_ce()
Structure storing information used by the BES to handle the request.
static bool nc_build_data(BESDataHandlerInterface &dhi)
static bool nc_build_help(BESDataHandlerInterface &dhi)
virtual void set_container(const string &cn)
set the container in the DAP response object
virtual bool add_handler(const string &handler_name, p_request_handler handler_method)
add a handler method to the request handler that knows how to fill in a specific response object ...
Represents an OPeNDAP DAS DAP2 data object within the BES.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
static BESKeys * TheKeys()
virtual void set_container(const string &cn)
set the container in the DAP response object
virtual void add_module(const string &n, const string &v)
Abstract base class representing a specific set of information in response to a request to the BES...
BESContainer * container
pointer to current container in this interface
virtual void end_tag(const string &tag_name)
virtual void services_handled(const string &handler, list< string > &services)
returns the list of servies provided by the handler in question