libdap++ Updated for version 3.8.2
|
00001 00002 // -*- mode: c++; c-basic-offset:4 -*- 00003 00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00005 // Access Protocol. 00006 00007 // Copyright (c) 2006 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // 00010 // This library is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU Lesser General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2.1 of the License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 // 00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00025 00026 #ifndef _array_geo_constraint_h 00027 #define _array_geo_constraint_h 1 00028 00029 #include <string> 00030 #include <sstream> 00031 #include <set> 00032 00033 #ifndef _geo_constraint_h 00034 #include "GeoConstraint.h" 00035 #endif 00036 00037 #ifndef _util_h 00038 #include "util.h" 00039 #endif 00040 00041 namespace libdap 00042 { 00043 00044 extern bool unit_or_name_match(set < string > units, set < string > names, 00045 const string & var_units, 00046 const string & var_name); 00047 00055 class ArrayGeoConstraint : public GeoConstraint 00056 { 00057 00058 private: 00059 struct Extent 00060 { 00061 double d_left; 00062 double d_top; 00063 double d_right; 00064 double d_bottom; 00065 00066 Extent() 00067 {} 00068 Extent(double t, double l, double b, double r) 00069 : d_left(l), d_top(t), d_right(r), d_bottom(b) 00070 {} 00071 }; 00072 00073 struct Projection 00074 { 00075 string d_name; 00076 string d_datum; 00077 00078 Projection() 00079 {} 00080 Projection(const string &n, const string &d) 00081 : d_name(n), d_datum(d) 00082 { 00083 downcase(d_name); 00084 if (d_name != "plat-carre") 00085 throw Error( 00086 "geoarray(): Only the Plat-Carre projection is supported by this version of\n\ 00087 geoarray()."); 00088 downcase(d_datum); 00089 if (d_datum != "wgs84") 00090 throw Error( 00091 "geoarray(): Only the wgs84 datum is supported by this version of geoarray()."); 00092 } 00093 }; 00094 00095 Array *d_array; 00096 00097 Extent d_extent; 00098 Projection d_projection; 00099 00100 bool build_lat_lon_maps(); 00101 bool lat_lon_dimensions_ok(); 00102 00103 void m_init(); 00104 00105 friend class ArrayGeoConstraintTest; // Unit tests 00106 00107 public: 00110 ArrayGeoConstraint(Array *) 00111 : GeoConstraint() 00112 { 00113 // See ce_finctions.cc:function_geoarray() to put this message in 00114 // context. 00115 throw Error( 00116 "Bummer. The five-argument version of geoarray() is not currently implemented."); 00117 } 00118 00119 ArrayGeoConstraint(Array *array, 00120 double left, double top, double right, double bottom); 00121 00122 ArrayGeoConstraint(Array *array, 00123 double left, double top, double right, double bottom, 00124 const string &projection, const string &datum); 00126 00127 virtual ~ArrayGeoConstraint() 00128 {} 00129 00130 virtual void apply_constraint_to_data(); 00131 00132 virtual Array *get_constrained_array() const 00133 { 00134 return d_array; 00135 } 00136 }; 00137 00138 } // namespace libdap 00139 00140 #endif // _array_geo_constraint_h