GridGeoConstraint Class Reference

#include <GridGeoConstraint.h>

Inheritance diagram for GridGeoConstraint:

Inheritance graph
[legend]
Collaboration diagram for GridGeoConstraint:

Collaboration graph
[legend]
List of all members.

Public Types

 inverted
enum  LatitudeSense { unknown_sense, normal, inverted }
 neg_pos
 normal
enum  Notation { unknown_notation, pos, neg_pos }
 pos
 unknown_notation
 unknown_sense

Public Member Functions

virtual void apply_constraint_to_data ()
virtual Gridget_constrained_grid () const
void set_bounding_box (double left, double top, double right, double bottom)
virtual ~GridGeoConstraint ()
Accessors/Mutators
char * get_array_data () const
int get_array_data_size () const
bool get_bounding_box_set () const
set< string > get_coards_lat_units () const
set< string > get_coards_lon_units () const
string get_dataset () const
double * get_lat () const
Array::Dim_iter get_lat_dim () const
int get_lat_length () const
set< string > get_lat_names () const
int get_latitude_index_bottom () const
int get_latitude_index_top () const
LatitudeSense get_latitude_sense () const
double * get_lon () const
Array::Dim_iter get_lon_dim () const
int get_lon_length () const
set< string > get_lon_names () const
int get_longitude_index_left () const
int get_longitude_index_right () const
Notation get_longitude_notation () const
bool get_longitude_rightmost () const
void set_lat (double *lat)
void set_lat_dim (Array::Dim_iter lat)
void set_lat_length (int len)
void set_latitude_index_bottom (int bottom)
void set_latitude_index_top (int top)
void set_latitude_sense (LatitudeSense l)
void set_lon (double *lon)
void set_lon_dim (Array::Dim_iter lon)
void set_lon_length (int len)
void set_longitude_index_left (int left)
void set_longitude_index_right (int right)
void set_longitude_notation (Notation n)
void set_longitude_rightmost (bool state)
Accessors/Mutators
char * get_array_data () const
int get_array_data_size () const
bool get_bounding_box_set () const
set< string > get_coards_lat_units () const
set< string > get_coards_lon_units () const
string get_dataset () const
double * get_lat () const
Array::Dim_iter get_lat_dim () const
int get_lat_length () const
set< string > get_lat_names () const
int get_latitude_index_bottom () const
int get_latitude_index_top () const
LatitudeSense get_latitude_sense () const
double * get_lon () const
Array::Dim_iter get_lon_dim () const
int get_lon_length () const
set< string > get_lon_names () const
int get_longitude_index_left () const
int get_longitude_index_right () const
Notation get_longitude_notation () const
bool get_longitude_rightmost () const
void set_lat (double *lat)
void set_lat_dim (Array::Dim_iter lat)
void set_lat_length (int len)
void set_latitude_index_bottom (int bottom)
void set_latitude_index_top (int top)
void set_latitude_sense (LatitudeSense l)
void set_lon (double *lon)
void set_lon_dim (Array::Dim_iter lon)
void set_lon_length (int len)
void set_longitude_index_left (int left)
void set_longitude_index_right (int right)
void set_longitude_notation (Notation n)
void set_longitude_rightmost (bool state)
Accessors/Mutators
char * get_array_data () const
int get_array_data_size () const
bool get_bounding_box_set () const
set< string > get_coards_lat_units () const
set< string > get_coards_lon_units () const
string get_dataset () const
double * get_lat () const
Array::Dim_iter get_lat_dim () const
int get_lat_length () const
set< string > get_lat_names () const
int get_latitude_index_bottom () const
int get_latitude_index_top () const
LatitudeSense get_latitude_sense () const
double * get_lon () const
Array::Dim_iter get_lon_dim () const
int get_lon_length () const
set< string > get_lon_names () const
int get_longitude_index_left () const
int get_longitude_index_right () const
Notation get_longitude_notation () const
bool get_longitude_rightmost () const
void set_lat (double *lat)
void set_lat_dim (Array::Dim_iter lat)
void set_lat_length (int len)
void set_latitude_index_bottom (int bottom)
void set_latitude_index_top (int top)
void set_latitude_sense (LatitudeSense l)
void set_lon (double *lon)
void set_lon_dim (Array::Dim_iter lon)
void set_lon_length (int len)
void set_longitude_index_left (int left)
void set_longitude_index_right (int right)
void set_longitude_notation (Notation n)
void set_longitude_rightmost (bool state)
Constructors
 GridGeoConstraint (Grid *grid, const string &ds_name)
 Initialize GeoConstraint with a Grid.

Protected Member Functions

virtual LatitudeSense categorize_latitude () const
Notation categorize_notation (double left, double right) const
void find_latitude_indeces (double top, double bottom, LatitudeSense sense, int &latitude_index_top, int &latitude_index_bottom) const
void find_longitude_indeces (double left, double right, int &longitude_index_left, int &longitude_index_right) const
virtual bool is_bounding_box_valid (double left, double top, double right, double bottom) const
virtual void reorder_data_longitude_axis (Array &a)
virtual void reorder_longitude_map (int longitude_index_left)
void transform_constraint_to_pos_notation (double &left, double &right) const
virtual void transform_longitude_to_neg_pos_notation ()
virtual void transform_longitude_to_pos_notation ()

Friends

class GridGeoConstraintTest

Detailed Description

Geographical constraint applied to a grid.
Author:
James Gallagher

Definition at line 45 of file GridGeoConstraint.h.


Member Enumeration Documentation

enum GeoConstraint::LatitudeSense [inherited]

Most of the time, latitude starts at the top of an array with positive values and ends up at the bottom with negative ones. But sometimes... the world is upside down.

Enumerator:
unknown_sense 
normal 
inverted 

Definition at line 115 of file GeoConstraint.h.

enum GeoConstraint::Notation [inherited]

The longitude extents of the constraint bounding box can be expressed two ways: using a 0/359 notation and using a -180/179 notation. I call the 0/359 notation 'pos' and the -180/179 notation 'neg_pos'.

Enumerator:
unknown_notation 
pos 
neg_pos 

Definition at line 106 of file GeoConstraint.h.


Constructor & Destructor Documentation

GridGeoConstraint::GridGeoConstraint ( Grid grid,
const string &  ds_name 
)

Parameters:
grid Set the GeoConstraint to use this Grid variable. It is the caller's responsibility to ensure that the value grid is a valid Grid variable.
ds_name The name of the dataset. Passed to BaseType::read().
dds Use this DDS to get global attributes.

Definition at line 63 of file GridGeoConstraint.cc.

References Array::dimensions(), Grid::get_array(), and BaseType::name().

Here is the call graph for this function:

virtual GridGeoConstraint::~GridGeoConstraint (  )  [inline, virtual]

Definition at line 66 of file GridGeoConstraint.h.


Member Function Documentation

void GridGeoConstraint::apply_constraint_to_data (  )  [virtual]

Once the bounding box is set use this method to apply the constraint. This modifies the data values in the Grid so that the software in Vector::serialize() will work correctly. Vector::serialize() assumes that the BaseType::read() method is called after the projection is applied to the data. That is, the projection is applied, then data are read. but geogrid() first reads all the data values and then computes the projection. To make Vector::serialize() work, this method uses the projection information recorded in the Grid by set_bounding_box() to arrange data so that the information to be sent is all that is held by the Grid. Call this after applying any 'Grid selection expressions' of the sort that can be passed to the grid() function.

Note:
Why do this here? The grid() function uses the standard logic in Vector and elsewhere to read data that's to be sent. The problem is that the data values need to be reordered using information only this object has. If this were implemented as a 'selection function' (i.e., if the code was run by ConstraintExpression::eval() then we might be able to better optimize how data are read, but in this case we have read all the data and may have alredy reorganized it. Set up the internal buffers so they hold the correct values and mark the Grid's array and lat/lon maps as read.

Implements GeoConstraint.

Definition at line 199 of file GridGeoConstraint.cc.

References Array::add_constraint(), Array::dim_begin(), Grid::get_array(), GeoConstraint::get_array_data(), GeoConstraint::get_array_data_size(), GeoConstraint::get_bounding_box_set(), GeoConstraint::get_dataset(), GeoConstraint::get_lat(), GeoConstraint::get_lat_dim(), GeoConstraint::get_latitude_index_bottom(), GeoConstraint::get_latitude_index_top(), GeoConstraint::get_latitude_sense(), GeoConstraint::get_lon(), GeoConstraint::get_lon_dim(), GeoConstraint::get_lon_length(), GeoConstraint::get_longitude_index_left(), GeoConstraint::get_longitude_index_right(), GeoConstraint::get_longitude_notation(), GeoConstraint::inverted, GeoConstraint::neg_pos, BaseType::read(), GeoConstraint::reorder_data_longitude_axis(), GeoConstraint::reorder_longitude_map(), libdap::set_array_using_double(), GeoConstraint::set_latitude_index_bottom(), GeoConstraint::set_latitude_index_top(), GeoConstraint::set_longitude_index_left(), GeoConstraint::set_longitude_index_right(), Grid::set_read_p(), GeoConstraint::transform_longitude_to_neg_pos_notation(), and Vector::val2buf().

Referenced by libdap::function_geogrid().

Here is the call graph for this function:

GeoConstraint::LatitudeSense GeoConstraint::categorize_latitude (  )  const [protected, virtual, inherited]

Take a look at the latitude vector values and record whether the world is normal or upside down.

Returns:
normal or inverted.

Definition at line 332 of file GeoConstraint.cc.

References GeoConstraint::inverted, and GeoConstraint::normal.

Referenced by GeoConstraint::set_bounding_box().

GeoConstraint::Notation GeoConstraint::categorize_notation ( double  left,
double  right 
) const [protected, inherited]

A private method that determines if the longitude part of the bounding box uses 0/359 or -180/179 notation. This class only supports latitude constriants which use 90/-90 notation, so there's no need to figure out what sort of notation they use.

Note:
This function assumes that if one of the two values is negative, then the notation is or the -180/179 form, otherwise not. If the user asks for 30 degrees to 50 degress (or 50 to 30, for that matter), there's no real way to tell which notation they are using.
Parameters:
left The left side of the bounding box, in degrees
right The right side of the boubding box
Returns:
The notation (pos or neg_pos)

Definition at line 128 of file GeoConstraint.cc.

References GeoConstraint::neg_pos, and GeoConstraint::pos.

Referenced by GeoConstraint::set_bounding_box().

void GeoConstraint::find_latitude_indeces ( double  top,
double  bottom,
LatitudeSense  sense,
int &  latitude_index_top,
int &  latitude_index_bottom 
) const [protected, inherited]

Scan from the top to the bottom, and the bottom to the top, looking for the top and bottom bounding box edges, respectively.

Parameters:
top The top edge of the bounding box
bottom The bottom edge
latitude_index_top Value-result parameter that holds the index in the grid's latitude map of the top bounding box edge. Uses a closed interval for the test.
latitude_index_bottom Value-result parameter for the bottom edge index.

Definition at line 289 of file GeoConstraint.cc.

References GeoConstraint::normal.

Referenced by GeoConstraint::set_bounding_box().

void GeoConstraint::find_longitude_indeces ( double  left,
double  right,
int &  longitude_index_left,
int &  longitude_index_right 
) const [protected, inherited]

Scan from the left to the right, and the right to the left, looking for the left and right bounding box edges, respectively.

Parameters:
left The left edge of the bounding box
right The right edge
d_longitude_index_left Value-result parameter that holds the index in the grid's longitude map of the left bounding box edge. Uses a closed interval for the test.
d_longitude_index_right Value-result parameter for the right edge index.

Definition at line 201 of file GeoConstraint.cc.

References DBG2.

Referenced by GeoConstraint::set_bounding_box().

char* GeoConstraint::get_array_data (  )  const [inline, inherited]

Definition at line 229 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

int GeoConstraint::get_array_data_size (  )  const [inline, inherited]

Definition at line 233 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

bool GeoConstraint::get_bounding_box_set (  )  const [inline, inherited]

Definition at line 324 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

set<string> GeoConstraint::get_coards_lat_units (  )  const [inline, inherited]

Definition at line 354 of file GeoConstraint.h.

set<string> GeoConstraint::get_coards_lon_units (  )  const [inline, inherited]

Definition at line 358 of file GeoConstraint.h.

virtual Grid* GridGeoConstraint::get_constrained_grid (  )  const [inline, virtual]

Definition at line 71 of file GridGeoConstraint.h.

Referenced by libdap::function_geogrid().

string GeoConstraint::get_dataset (  )  const [inline, inherited]

Definition at line 223 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), ArrayGeoConstraint::apply_constraint_to_data(), and GeoConstraint::reorder_data_longitude_axis().

double* GeoConstraint::get_lat (  )  const [inline, inherited]

Definition at line 238 of file GeoConstraint.h.

Referenced by apply_constraint_to_data().

Array::Dim_iter GeoConstraint::get_lat_dim (  )  const [inline, inherited]

Definition at line 276 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

int GeoConstraint::get_lat_length (  )  const [inline, inherited]

Definition at line 255 of file GeoConstraint.h.

set<string> GeoConstraint::get_lat_names (  )  const [inline, inherited]

Definition at line 363 of file GeoConstraint.h.

int GeoConstraint::get_latitude_index_bottom (  )  const [inline, inherited]

Definition at line 294 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

int GeoConstraint::get_latitude_index_top (  )  const [inline, inherited]

Definition at line 290 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

LatitudeSense GeoConstraint::get_latitude_sense (  )  const [inline, inherited]

Definition at line 341 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

double* GeoConstraint::get_lon (  )  const [inline, inherited]

Definition at line 242 of file GeoConstraint.h.

Referenced by apply_constraint_to_data().

Array::Dim_iter GeoConstraint::get_lon_dim (  )  const [inline, inherited]

Definition at line 272 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

int GeoConstraint::get_lon_length (  )  const [inline, inherited]

Definition at line 259 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), ArrayGeoConstraint::apply_constraint_to_data(), and GeoConstraint::reorder_data_longitude_axis().

set<string> GeoConstraint::get_lon_names (  )  const [inline, inherited]

Definition at line 367 of file GeoConstraint.h.

int GeoConstraint::get_longitude_index_left (  )  const [inline, inherited]

Definition at line 307 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), ArrayGeoConstraint::apply_constraint_to_data(), and GeoConstraint::reorder_data_longitude_axis().

int GeoConstraint::get_longitude_index_right (  )  const [inline, inherited]

Definition at line 311 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), ArrayGeoConstraint::apply_constraint_to_data(), and GeoConstraint::reorder_data_longitude_axis().

Notation GeoConstraint::get_longitude_notation (  )  const [inline, inherited]

Definition at line 337 of file GeoConstraint.h.

Referenced by apply_constraint_to_data().

bool GeoConstraint::get_longitude_rightmost (  )  const [inline, inherited]

Definition at line 328 of file GeoConstraint.h.

Referenced by GeoConstraint::reorder_data_longitude_axis().

bool GeoConstraint::is_bounding_box_valid ( double  left,
double  top,
double  right,
double  bottom 
) const [protected, virtual, inherited]

Definition at line 169 of file GeoConstraint.cc.

References GeoConstraint::normal.

Referenced by GeoConstraint::set_bounding_box().

void GeoConstraint::reorder_data_longitude_axis ( Array a  )  [protected, virtual, inherited]

Reorder the data values relative to the longitude axis so that the reordered longitude map (see GeoConstraint::reorder_longitude_map()) and the data values match.

Note:
This method should set the d_array_data and d_array_data_size fields. If those are set, apply_constraint_to_data() will use those values.

First set all the other constraints, including the latitude and then make this call. Other constraints, besides latitude, will be simple range constraints. Latitude might require that values be inverted, but that can be done _after_ the longitude reordering takes place. The latitude constraint can be imposed by inverting the top and bottom indices if the sense of the grid is inverted, before data are read in this method. Then apply the longitude constraint, then invert the result of the merge, if needed.

Todo:
Fix this code so that it works with latitude as the rightmost map

Definition at line 417 of file GeoConstraint.cc.

References Array::add_constraint(), Vector::buf2val(), DBG, DBG2, GeoConstraint::get_dataset(), GeoConstraint::get_lon_length(), GeoConstraint::get_longitude_index_left(), GeoConstraint::get_longitude_index_right(), GeoConstraint::get_longitude_rightmost(), Array::print_val(), BaseType::read(), Vector::set_read_p(), Vector::var(), and BaseType::width().

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

Here is the call graph for this function:

void GeoConstraint::reorder_longitude_map ( int  longitude_index_left  )  [protected, virtual, inherited]

Reorder the elements in the longitude map so that the longitude constraint no longer crosses the edge of the map's storage. The d_lon field is modified.

Note:
The d_lon vector always has double values regardless of the type of d_longitude.
Parameters:
d_longitude_index_left The left edge of the bounding box.

Definition at line 377 of file GeoConstraint.cc.

Referenced by apply_constraint_to_data().

void GeoConstraint::set_bounding_box ( double  left,
double  top,
double  right,
double  bottom 
) [inherited]

Set the bounding box for this constraint. After calling this method the object has values for the indexes for the latitude and longitude extent as well as the sense of the latitude (south pole at the top or bottom of the Array or Grid). These are used by the apply_constraint_to_data() method to actually constrain the data.

Parameters:
left The left side of the bounding box.
right The right side
top The top
bottom The bottom

Definition at line 560 of file GeoConstraint.cc.

References GeoConstraint::categorize_latitude(), GeoConstraint::categorize_notation(), DBG, double_to_string(), GeoConstraint::find_latitude_indeces(), GeoConstraint::find_longitude_indeces(), GeoConstraint::is_bounding_box_valid(), GeoConstraint::neg_pos, GeoConstraint::transform_constraint_to_pos_notation(), and GeoConstraint::transform_longitude_to_pos_notation().

Referenced by libdap::function_geoarray(), and libdap::function_geogrid().

Here is the call graph for this function:

void GeoConstraint::set_lat ( double *  lat  )  [inline, inherited]

Definition at line 246 of file GeoConstraint.h.

void GeoConstraint::set_lat_dim ( Array::Dim_iter  lat  )  [inline, inherited]

Definition at line 284 of file GeoConstraint.h.

void GeoConstraint::set_lat_length ( int  len  )  [inline, inherited]

Definition at line 263 of file GeoConstraint.h.

void GeoConstraint::set_latitude_index_bottom ( int  bottom  )  [inline, inherited]

Definition at line 302 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

void GeoConstraint::set_latitude_index_top ( int  top  )  [inline, inherited]

Definition at line 298 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

void GeoConstraint::set_latitude_sense ( LatitudeSense  l  )  [inline, inherited]

Definition at line 349 of file GeoConstraint.h.

void GeoConstraint::set_lon ( double *  lon  )  [inline, inherited]

Definition at line 250 of file GeoConstraint.h.

void GeoConstraint::set_lon_dim ( Array::Dim_iter  lon  )  [inline, inherited]

Definition at line 280 of file GeoConstraint.h.

void GeoConstraint::set_lon_length ( int  len  )  [inline, inherited]

Definition at line 267 of file GeoConstraint.h.

void GeoConstraint::set_longitude_index_left ( int  left  )  [inline, inherited]

Definition at line 315 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

void GeoConstraint::set_longitude_index_right ( int  right  )  [inline, inherited]

Definition at line 319 of file GeoConstraint.h.

Referenced by apply_constraint_to_data(), and ArrayGeoConstraint::apply_constraint_to_data().

void GeoConstraint::set_longitude_notation ( Notation  n  )  [inline, inherited]

Definition at line 345 of file GeoConstraint.h.

void GeoConstraint::set_longitude_rightmost ( bool  state  )  [inline, inherited]

Definition at line 332 of file GeoConstraint.h.

void GeoConstraint::transform_constraint_to_pos_notation ( double &  left,
double &  right 
) const [protected, inherited]

Definition at line 139 of file GeoConstraint.cc.

Referenced by GeoConstraint::set_bounding_box().

void GeoConstraint::transform_longitude_to_neg_pos_notation (  )  [protected, virtual, inherited]

Given that the Grid has a longitude map that uses the 'pos' notation, transform it to the 'neg_pos' notation. This method modifies the d_longitude Array.

Definition at line 163 of file GeoConstraint.cc.

Referenced by apply_constraint_to_data().

void GeoConstraint::transform_longitude_to_pos_notation (  )  [protected, virtual, inherited]

Given that the Grid has a longitude map that uses the 'neg_pos' notation, transform it to the 'pos' notation. This method modifies the d_longitude Array.

Definition at line 151 of file GeoConstraint.cc.

Referenced by GeoConstraint::set_bounding_box().


Friends And Related Function Documentation

friend class GridGeoConstraintTest [friend]

Reimplemented from GeoConstraint.

Definition at line 58 of file GridGeoConstraint.h.


The documentation for this class was generated from the following files:
Generated on Wed Jun 27 12:57:58 2007 for libdap++ by  doxygen 1.4.7