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 _geo_constraint_h
00027 #define _geo_constraint_h 1
00028
00029 #include <string>
00030 #include <sstream>
00031 #include <set>
00032
00033 #ifndef _basetype_h
00034 #include "BaseType.h"
00035 #endif
00036
00037 #ifndef _array_h
00038 #include "Array.h"
00039 #endif
00040
00041 #ifndef _grid_h
00042 #include "Grid.h"
00043 #endif
00044
00100 class GeoConstraint
00101 {
00102 public:
00106 enum Notation {
00107 unknown_notation,
00108 pos,
00109 neg_pos
00110 };
00111
00115 enum LatitudeSense {
00116 unknown_sense,
00117 normal,
00118 inverted
00119 };
00120
00121 private:
00122 const string &d_dataset;
00123
00124 char *d_array_data;
00125 int d_array_data_size;
00126
00127 double *d_lat;
00128 double *d_lon;
00129 int d_lat_length;
00130 int d_lon_length;
00131
00132
00133 int d_latitude_index_top;
00134 int d_latitude_index_bottom;
00135 int d_longitude_index_left;
00136 int d_longitude_index_right;
00137
00138 bool d_bounding_box_set;
00139 bool d_longitude_rightmost;
00140
00141 Notation d_longitude_notation;
00142 LatitudeSense d_latitude_sense;
00143
00144 Array::Dim_iter d_lon_dim;
00145 Array::Dim_iter d_lat_dim;
00146
00147
00148 set<string> d_coards_lat_units;
00149 set<string> d_coards_lon_units;
00150
00151 set<string> d_lat_names;
00152 set<string> d_lon_names;
00153
00154
00155 GeoConstraint();
00156 GeoConstraint(const GeoConstraint ¶m);
00157 GeoConstraint &operator=(GeoConstraint &rhs);
00158
00159 protected:
00168 virtual bool build_lat_lon_maps() = 0;
00169
00180 virtual bool lat_lon_dimensions_ok() = 0;
00181
00182 Notation categorize_notation(double left, double right) const;
00183 void transform_constraint_to_pos_notation(double &left, double &right) const;
00184 virtual void transform_longitude_to_pos_notation();
00185 virtual void transform_longitude_to_neg_pos_notation();
00186 virtual bool is_bounding_box_valid(double left, double top, double right,
00187 double bottom) const;
00188 void find_longitude_indeces(double left, double right,
00189 int &longitude_index_left,
00190 int &longitude_index_right) const;
00191 #if 0
00192 virtual void set_bounding_box_longitude(double left, double right) ;
00193 #endif
00194 virtual void reorder_longitude_map(int longitude_index_left);
00195
00196 virtual LatitudeSense categorize_latitude() const;
00197 void find_latitude_indeces(double top, double bottom, LatitudeSense sense,
00198 int &latitude_index_top,
00199 int &latitude_index_bottom) const;
00200 #if 0
00201 virtual void set_bounding_box_latitude(double top, double bottom) ;
00202 #endif
00203 virtual void reorder_data_longitude_axis(Array &a);
00204
00205
00206 friend class GridGeoConstraintTest;
00207
00208 public:
00211 GeoConstraint(const string &ds_name);
00213
00214 virtual ~GeoConstraint()
00215 {
00216 delete [] d_lat;
00217 delete [] d_lon;
00218 delete [] d_array_data; d_array_data = 0;
00219 }
00220
00223 string get_dataset() const
00224 {
00225 return d_dataset;
00226 }
00227
00228
00229 char *get_array_data() const
00230 {
00231 return d_array_data;
00232 }
00233 int get_array_data_size() const
00234 {
00235 return d_array_data_size;
00236 }
00237
00238 double *get_lat() const
00239 {
00240 return d_lat;
00241 }
00242 double *get_lon() const
00243 {
00244 return d_lon;
00245 }
00246 void set_lat(double *lat)
00247 {
00248 d_lat = lat;
00249 }
00250 void set_lon(double *lon)
00251 {
00252 d_lon = lon;
00253 }
00254
00255 int get_lat_length() const
00256 {
00257 return d_lat_length;
00258 }
00259 int get_lon_length() const
00260 {
00261 return d_lon_length;
00262 }
00263 void set_lat_length(int len)
00264 {
00265 d_lat_length = len;
00266 }
00267 void set_lon_length(int len)
00268 {
00269 d_lon_length = len;
00270 }
00271
00272 Array::Dim_iter get_lon_dim() const
00273 {
00274 return d_lon_dim;
00275 }
00276 Array::Dim_iter get_lat_dim() const
00277 {
00278 return d_lat_dim;
00279 }
00280 void set_lon_dim(Array::Dim_iter lon)
00281 {
00282 d_lon_dim = lon;
00283 }
00284 void set_lat_dim(Array::Dim_iter lat)
00285 {
00286 d_lat_dim = lat;
00287 }
00288
00289
00290 int get_latitude_index_top() const
00291 {
00292 return d_latitude_index_top;
00293 }
00294 int get_latitude_index_bottom() const
00295 {
00296 return d_latitude_index_bottom;
00297 }
00298 void set_latitude_index_top(int top)
00299 {
00300 d_latitude_index_top = top;
00301 }
00302 void set_latitude_index_bottom(int bottom)
00303 {
00304 d_latitude_index_bottom = bottom;
00305 }
00306
00307 int get_longitude_index_left() const
00308 {
00309 return d_longitude_index_left;
00310 }
00311 int get_longitude_index_right() const
00312 {
00313 return d_longitude_index_right;
00314 }
00315 void set_longitude_index_left(int left)
00316 {
00317 d_longitude_index_left = left;
00318 }
00319 void set_longitude_index_right(int right)
00320 {
00321 d_longitude_index_right = right;
00322 }
00323
00324 bool get_bounding_box_set() const
00325 {
00326 return d_bounding_box_set;
00327 }
00328 bool get_longitude_rightmost() const
00329 {
00330 return d_longitude_rightmost;
00331 }
00332 void set_longitude_rightmost(bool state)
00333 {
00334 d_longitude_rightmost = state;
00335 }
00336
00337 Notation get_longitude_notation() const
00338 {
00339 return d_longitude_notation;
00340 }
00341 LatitudeSense get_latitude_sense() const
00342 {
00343 return d_latitude_sense;
00344 }
00345 void set_longitude_notation(Notation n)
00346 {
00347 d_longitude_notation = n;
00348 }
00349 void set_latitude_sense(LatitudeSense l)
00350 {
00351 d_latitude_sense = l;
00352 }
00353
00354 set<string> get_coards_lat_units() const
00355 {
00356 return d_coards_lat_units;
00357 }
00358 set<string> get_coards_lon_units() const
00359 {
00360 return d_coards_lon_units;
00361 }
00362
00363 set<string> get_lat_names() const
00364 {
00365 return d_lat_names;
00366 }
00367 set<string> get_lon_names() const
00368 {
00369 return d_lon_names;
00370 }
00372
00373 void set_bounding_box(double left, double top, double right, double bottom);
00374
00377 virtual void apply_constraint_to_data() = 0;
00378 };
00379
00380 #endif // _geo_constraint_h
00381