#include <GridGeoConstraint.h>
|
virtual LatitudeSense | categorize_latitude () const |
|
Notation | categorize_notation (const double left, const 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 void | flip_latitude_within_array (libdap::Array &a, int lat_length, int lon_length) |
|
virtual bool | is_bounding_box_valid (const double left, const double top, const double right, const double bottom) const |
|
virtual void | reorder_data_longitude_axis (libdap::Array &a, libdap::Array::Dim_iter lon_dim) |
|
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 () |
|
virtual void | transpose_vector (double *src, const int length) |
|
Geographical constraint applied to a grid.
- Author
- James Gallagher
Definition at line 45 of file GridGeoConstraint.h.
◆ LatitudeSense
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 106 of file GeoConstraint.h.
◆ Notation
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 101 of file GeoConstraint.h.
◆ GridGeoConstraint() [1/2]
functions::GridGeoConstraint::GridGeoConstraint |
( |
libdap::Grid * | grid | ) |
|
◆ GridGeoConstraint() [2/2]
◆ ~GridGeoConstraint()
virtual functions::GridGeoConstraint::~GridGeoConstraint |
( |
| ) |
|
|
inlinevirtual |
◆ apply_constraint_to_data()
void functions::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 already 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 functions::GeoConstraint.
Definition at line 264 of file GridGeoConstraint.cc.
◆ categorize_latitude()
|
protectedvirtualinherited |
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 307 of file GeoConstraint.cc.
◆ categorize_notation()
GeoConstraint::Notation functions::GeoConstraint::categorize_notation |
( |
const double | left, |
|
|
const double | right ) const |
|
protectedinherited |
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 constraints 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 degrees (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 bounding box |
- Returns
- The notation (pos or neg_pos)
Definition at line 97 of file GeoConstraint.cc.
◆ find_latitude_indeces()
void functions::GeoConstraint::find_latitude_indeces |
( |
double | top, |
|
|
double | bottom, |
|
|
LatitudeSense | sense, |
|
|
int & | latitude_index_top, |
|
|
int & | latitude_index_bottom ) const |
|
protectedinherited |
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 |
sense | Does the array/grid store data with larger latitudes at the starting indices or are the latitude 'upside down?' |
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 261 of file GeoConstraint.cc.
◆ find_longitude_indeces()
void functions::GeoConstraint::find_longitude_indeces |
( |
double | left, |
|
|
double | right, |
|
|
int & | longitude_index_left, |
|
|
int & | longitude_index_right ) const |
|
protectedinherited |
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 |
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. |
longitude_index_right | Value-result parameter for the right edge index. |
Definition at line 184 of file GeoConstraint.cc.
◆ flip_latitude_within_array()
void functions::GeoConstraint::flip_latitude_within_array |
( |
libdap::Array & | a, |
|
|
int | lat_length, |
|
|
int | lon_length ) |
|
protectedvirtualinherited |
◆ get_array_data()
char * functions::GeoConstraint::get_array_data |
( |
| ) |
const |
|
inlineinherited |
◆ get_array_data_size()
int functions::GeoConstraint::get_array_data_size |
( |
| ) |
const |
|
inlineinherited |
◆ get_coards_lat_units()
set< string > functions::GeoConstraint::get_coards_lat_units |
( |
| ) |
const |
|
inlineinherited |
◆ get_coards_lon_units()
set< string > functions::GeoConstraint::get_coards_lon_units |
( |
| ) |
const |
|
inlineinherited |
◆ get_constrained_grid()
virtual libdap::Grid * functions::GridGeoConstraint::get_constrained_grid |
( |
| ) |
const |
|
inlinevirtual |
◆ get_lat()
double * functions::GeoConstraint::get_lat |
( |
| ) |
const |
|
inlineinherited |
◆ get_lat_dim()
◆ get_lat_length()
int functions::GeoConstraint::get_lat_length |
( |
| ) |
const |
|
inlineinherited |
◆ get_lat_names()
set< string > functions::GeoConstraint::get_lat_names |
( |
| ) |
const |
|
inlineinherited |
◆ get_latitude_index_bottom()
int functions::GeoConstraint::get_latitude_index_bottom |
( |
| ) |
const |
|
inlineinherited |
◆ get_latitude_index_top()
int functions::GeoConstraint::get_latitude_index_top |
( |
| ) |
const |
|
inlineinherited |
◆ get_latitude_sense()
LatitudeSense functions::GeoConstraint::get_latitude_sense |
( |
| ) |
const |
|
inlineinherited |
◆ get_lon()
double * functions::GeoConstraint::get_lon |
( |
| ) |
const |
|
inlineinherited |
◆ get_lon_dim()
◆ get_lon_length()
int functions::GeoConstraint::get_lon_length |
( |
| ) |
const |
|
inlineinherited |
◆ get_lon_names()
set< string > functions::GeoConstraint::get_lon_names |
( |
| ) |
const |
|
inlineinherited |
◆ get_longitude_index_left()
int functions::GeoConstraint::get_longitude_index_left |
( |
| ) |
const |
|
inlineinherited |
◆ get_longitude_index_right()
int functions::GeoConstraint::get_longitude_index_right |
( |
| ) |
const |
|
inlineinherited |
◆ get_longitude_notation()
Notation functions::GeoConstraint::get_longitude_notation |
( |
| ) |
const |
|
inlineinherited |
◆ is_bounding_box_set()
bool functions::GeoConstraint::is_bounding_box_set |
( |
| ) |
const |
|
inlineinherited |
◆ is_bounding_box_valid()
bool functions::GeoConstraint::is_bounding_box_valid |
( |
const double | left, |
|
|
const double | top, |
|
|
const double | right, |
|
|
const double | bottom ) const |
|
protectedvirtualinherited |
◆ is_longitude_rightmost()
bool functions::GeoConstraint::is_longitude_rightmost |
( |
| ) |
const |
|
inlineinherited |
◆ reorder_data_longitude_axis()
|
protectedvirtualinherited |
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 should be called with the Array that contains the d_lon_dim Array::Dim_iter.
-
This method must 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 flipped, but that can be done after the longitude reordering takes place.
- Todo
- Fix this code so that it works with latitude as the rightmost map
Definition at line 434 of file GeoConstraint.cc.
◆ reorder_longitude_map()
void functions::GeoConstraint::reorder_longitude_map |
( |
int | longitude_index_left | ) |
|
|
protectedvirtualinherited |
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
-
longitude_index_left | The left edge of the bounding box. |
Definition at line 399 of file GeoConstraint.cc.
◆ set_bounding_box()
void functions::GeoConstraint::set_bounding_box |
( |
double | top, |
|
|
double | left, |
|
|
double | bottom, |
|
|
double | right ) |
|
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 541 of file GeoConstraint.cc.
◆ set_lat()
void functions::GeoConstraint::set_lat |
( |
double * | lat | ) |
|
|
inlineinherited |
◆ set_lat_dim()
◆ set_lat_length()
void functions::GeoConstraint::set_lat_length |
( |
int | len | ) |
|
|
inlineinherited |
◆ set_latitude_index_bottom()
void functions::GeoConstraint::set_latitude_index_bottom |
( |
int | bottom | ) |
|
|
inlineinherited |
◆ set_latitude_index_top()
void functions::GeoConstraint::set_latitude_index_top |
( |
int | top | ) |
|
|
inlineinherited |
◆ set_latitude_sense()
void functions::GeoConstraint::set_latitude_sense |
( |
LatitudeSense | l | ) |
|
|
inlineinherited |
◆ set_lon()
void functions::GeoConstraint::set_lon |
( |
double * | lon | ) |
|
|
inlineinherited |
◆ set_lon_dim()
◆ set_lon_length()
void functions::GeoConstraint::set_lon_length |
( |
int | len | ) |
|
|
inlineinherited |
◆ set_longitude_index_left()
void functions::GeoConstraint::set_longitude_index_left |
( |
int | left | ) |
|
|
inlineinherited |
◆ set_longitude_index_right()
void functions::GeoConstraint::set_longitude_index_right |
( |
int | right | ) |
|
|
inlineinherited |
◆ set_longitude_notation()
void functions::GeoConstraint::set_longitude_notation |
( |
Notation | n | ) |
|
|
inlineinherited |
◆ set_longitude_rightmost()
void functions::GeoConstraint::set_longitude_rightmost |
( |
bool | state | ) |
|
|
inlineinherited |
◆ transform_constraint_to_pos_notation()
void functions::GeoConstraint::transform_constraint_to_pos_notation |
( |
double & | left, |
|
|
double & | right ) const |
|
protectedinherited |
◆ transform_longitude_to_neg_pos_notation()
void functions::GeoConstraint::transform_longitude_to_neg_pos_notation |
( |
| ) |
|
|
protectedvirtualinherited |
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_lon array.
- Note
- : About the two notations: 0 180 360 |------------------------—|----------------------—| 0 180,-180 0
Definition at line 149 of file GeoConstraint.cc.
◆ transform_longitude_to_pos_notation()
void functions::GeoConstraint::transform_longitude_to_pos_notation |
( |
| ) |
|
|
protectedvirtualinherited |
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_lon array.
- Note
- : About the two notations: 0 180 360 |------------------------—|----------------------—| 0 180,-180 0
Definition at line 131 of file GeoConstraint.cc.
◆ transpose_vector()
void functions::GeoConstraint::transpose_vector |
( |
double * | src, |
|
|
const int | length ) |
|
protectedvirtualinherited |
Given a vector of doubles, transpose the elements. Use this to flip the latitude vector for a Grid that stores the southern latitudes at the top instead of the bottom.
- Parameters
-
src | A pointer to the vector |
length | The number of elements in the vector |
Definition at line 335 of file GeoConstraint.cc.
◆ GridGeoConstraintTest
friend class GridGeoConstraintTest |
|
friend |
The documentation for this class was generated from the following files: