00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00042 extern void remove_quotes(string & value);
00043 extern bool unit_or_name_match(set < string > units, set < string > names,
00044 const string & var_units, const string & var_name);
00045
00053 class ArrayGeoConstraint : public GeoConstraint
00054 {
00055
00056 private:
00057 struct Extent
00058 {
00059 double d_left;
00060 double d_top;
00061 double d_right;
00062 double d_bottom;
00063
00064 Extent()
00065 {}
00066 Extent(double l, double t, double r, double b)
00067 : d_left(l), d_top(t), d_right(r), d_bottom(b)
00068 {}
00069 };
00070
00071 struct Projection
00072 {
00073 string d_name;
00074 string d_datum;
00075
00076 Projection()
00077 {}
00078 Projection(const string &n, const string &d)
00079 : d_name(n), d_datum(d)
00080 {
00081 downcase(d_name);
00082 if (d_name != "plat-carre")
00083 throw Error(
00084 "geoarray(): Only the Plat-Carre projection is supported by this version of\n\
00085 geoarray().");
00086 downcase(d_datum);
00087 if (d_datum != "wgs84")
00088 throw Error(
00089 "geoarray(): Only the wgs84 datum is supported by this version of geoarray().");
00090 }
00091 };
00092
00093 Array *d_array;
00094
00095 Extent d_extent;
00096 Projection d_projection;
00097
00098 bool build_lat_lon_maps();
00099 bool lat_lon_dimensions_ok();
00100
00101 void m_init();
00102
00103 friend class ArrayGeoConstraintTest;
00104
00105 public:
00108 ArrayGeoConstraint(Array *, const string &ds_name)
00109 : GeoConstraint(ds_name)
00110 {
00111 throw Error(
00112 "Bummer. The five-argument version of geoarray() is not currently implemented.");
00113 }
00114
00115 ArrayGeoConstraint(Array *array, const string &ds_name,
00116 double left, double top, double right, double bottom);
00117
00118 ArrayGeoConstraint(Array *array, const string &ds_name,
00119 double left, double top, double right, double bottom,
00120 const string &projection, const string &datum);
00122
00123 virtual ~ArrayGeoConstraint()
00124 {}
00125
00126 virtual void apply_constraint_to_data();
00127
00128 virtual Array *get_constrained_array() const
00129 {
00130 return d_array;
00131 }
00132 };
00133
00134 #endif // _array_geo_constraint_h