PostGIS  2.1.10dev-r@@SVN_REVISION@@
double gbox_angular_height ( const GBOX gbox)

Returns the angular height (latitudinal span) of the box in radians.

GBOX utility functions to figure out coverage/location on the globe.

Definition at line 165 of file lwgeodetic.c.

References MAXFLOAT, normalize(), POINT3D::x, GBOX::xmin, POINT3D::y, and POINT3D::z.

Referenced by geography_bestsrid(), and test_gbox_utils().

166 {
167  double d[6];
168  int i;
169  double zmin = MAXFLOAT;
170  double zmax = -1 * MAXFLOAT;
171  POINT3D pt;
172 
173  /* Take a copy of the box corners so we can treat them as a list */
174  /* Elements are xmin, xmax, ymin, ymax, zmin, zmax */
175  memcpy(d, &(gbox->xmin), 6*sizeof(double));
176 
177  /* Generate all 8 corner vectors of the box */
178  for ( i = 0; i < 8; i++ )
179  {
180  pt.x = d[i / 4];
181  pt.y = d[2 + (i % 4) / 2];
182  pt.z = d[4 + (i % 2)];
183  normalize(&pt);
184  if ( pt.z < zmin ) zmin = pt.z;
185  if ( pt.z > zmax ) zmax = pt.z;
186  }
187  return asin(zmax) - asin(zmin);
188 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:564
double y
Definition: liblwgeom.h:296
double x
Definition: liblwgeom.h:296
double z
Definition: liblwgeom.h:296
double xmin
Definition: liblwgeom.h:248
#define MAXFLOAT
Largest float value.

Here is the call graph for this function:

Here is the caller graph for this function: