PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ gbox_angular_height()

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 179 of file lwgeodetic.c.

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

Referenced by geography_bestsrid(), and test_gbox_utils().

180 {
181  double d[6];
182  int i;
183  double zmin = FLT_MAX;
184  double zmax = -1 * FLT_MAX;
185  POINT3D pt;
186 
187  /* Take a copy of the box corners so we can treat them as a list */
188  /* Elements are xmin, xmax, ymin, ymax, zmin, zmax */
189  memcpy(d, &(gbox->xmin), 6*sizeof(double));
190 
191  /* Generate all 8 corner vectors of the box */
192  for ( i = 0; i < 8; i++ )
193  {
194  pt.x = d[i / 4];
195  pt.y = d[2 + (i % 4) / 2];
196  pt.z = d[4 + (i % 2)];
197  normalize(&pt);
198  if ( pt.z < zmin ) zmin = pt.z;
199  if ( pt.z > zmax ) zmax = pt.z;
200  }
201  return asin(zmax) - asin(zmin);
202 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:584
double y
Definition: liblwgeom.h:342
double x
Definition: liblwgeom.h:342
double z
Definition: liblwgeom.h:342
double xmin
Definition: liblwgeom.h:294
Here is the call graph for this function:
Here is the caller graph for this function: