libdap++  Updated for version 3.8.2
ArrayGeoConstraint.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2006 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #ifndef _array_geo_constraint_h
27 #define _array_geo_constraint_h 1
28 
29 #include <string>
30 #include <sstream>
31 #include <set>
32 
33 #ifndef _geo_constraint_h
34 #include "GeoConstraint.h"
35 #endif
36 
37 #ifndef _util_h
38 #include "util.h"
39 #endif
40 
41 namespace libdap
42 {
43 
44 extern bool unit_or_name_match(set < string > units, set < string > names,
45  const string & var_units,
46  const string & var_name);
47 
56 {
57 
58 private:
59  struct Extent
60  {
61  double d_left;
62  double d_top;
63  double d_right;
64  double d_bottom;
65 
66  Extent()
67  {}
68  Extent(double t, double l, double b, double r)
69  : d_left(l), d_top(t), d_right(r), d_bottom(b)
70  {}
71  };
72 
73  struct Projection
74  {
75  string d_name;
76  string d_datum;
77 
78  Projection()
79  {}
80  Projection(const string &n, const string &d)
81  : d_name(n), d_datum(d)
82  {
83  downcase(d_name);
84  if (d_name != "plat-carre")
85  throw Error(
86  "geoarray(): Only the Plat-Carre projection is supported by this version of\n\
87  geoarray().");
88  downcase(d_datum);
89  if (d_datum != "wgs84")
90  throw Error(
91  "geoarray(): Only the wgs84 datum is supported by this version of geoarray().");
92  }
93  };
94 
95  Array *d_array;
96 
97  Extent d_extent;
98  Projection d_projection;
99 
100  bool build_lat_lon_maps();
101  bool lat_lon_dimensions_ok();
102 
103  void m_init();
104 
105  friend class ArrayGeoConstraintTest; // Unit tests
106 
107 public:
111  : GeoConstraint()
112  {
113  // See ce_finctions.cc:function_geoarray() to put this message in
114  // context.
115  throw Error(
116  "Bummer. The five-argument version of geoarray() is not currently implemented.");
117  }
118 
120  double left, double top, double right, double bottom);
121 
122  ArrayGeoConstraint(Array *array,
123  double left, double top, double right, double bottom,
124  const string &projection, const string &datum);
126 
128  {}
129 
130  virtual void apply_constraint_to_data();
131 
132  virtual Array *get_constrained_array() const
133  {
134  return d_array;
135  }
136 };
137 
138 } // namespace libdap
139 
140 #endif // _array_geo_constraint_h
void downcase(string &s)
Definition: util.cc:367
bool unit_or_name_match(set< string > units, set< string > names, const string &var_units, const string &var_name)
A class for error processing.
Definition: Error.h:90
virtual Array * get_constrained_array() const
A multidimensional array of identical data types.
Definition: Array.h:101