PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gbox_angular_height()

double gbox_angular_height ( const GBOX gbox)

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

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

Definition at line 164 of file lwgeodetic.c.

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

Referenced by geography_bestsrid(), and test_gbox_utils().

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