PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ gbox_check_poles()

static int gbox_check_poles ( GBOX gbox)
static

Check to see if this geocentric gbox is wrapped around a pole.

Only makes sense if this gbox originated from a polygon, as it's assuming the box is generated from external edges and there's an "interior" which contains the pole.

This function is overdetermined, for very large polygons it might add an unwarranted pole. STILL NEEDS WORK!

Definition at line 292 of file lwgeodetic.c.

References gbox_to_string(), LW_FALSE, LW_TRUE, LWDEBUG, LWDEBUGF, GBOX::xmax, GBOX::xmin, GBOX::ymax, GBOX::ymin, GBOX::zmax, and GBOX::zmin.

Referenced by lwpolygon_calculate_gbox_geodetic().

293 {
294  int rv = LW_FALSE;
295  LWDEBUG(4, "checking poles");
296  LWDEBUGF(4, "gbox %s", gbox_to_string(gbox));
297  /* Z axis */
298  if ( gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
299  gbox->ymin < 0.0 && gbox->ymax > 0.0 )
300  {
301  if ( (gbox->zmin + gbox->zmax) > 0.0 )
302  {
303  LWDEBUG(4, "enclosed positive z axis");
304  gbox->zmax = 1.0;
305  }
306  else
307  {
308  LWDEBUG(4, "enclosed negative z axis");
309  gbox->zmin = -1.0;
310  }
311  rv = LW_TRUE;
312  }
313 
314  /* Y axis */
315  if ( gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
316  gbox->zmin < 0.0 && gbox->zmax > 0.0 )
317  {
318  if ( gbox->ymin + gbox->ymax > 0.0 )
319  {
320  LWDEBUG(4, "enclosed positive y axis");
321  gbox->ymax = 1.0;
322  }
323  else
324  {
325  LWDEBUG(4, "enclosed negative y axis");
326  gbox->ymin = -1.0;
327  }
328  rv = LW_TRUE;
329  }
330 
331  /* X axis */
332  if ( gbox->ymin < 0.0 && gbox->ymax > 0.0 &&
333  gbox->zmin < 0.0 && gbox->zmax > 0.0 )
334  {
335  if ( gbox->xmin + gbox->xmax > 0.0 )
336  {
337  LWDEBUG(4, "enclosed positive x axis");
338  gbox->xmax = 1.0;
339  }
340  else
341  {
342  LWDEBUG(4, "enclosed negative x axis");
343  gbox->xmin = -1.0;
344  }
345  rv = LW_TRUE;
346  }
347 
348  return rv;
349 }
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:369
double xmax
Definition: liblwgeom.h:277
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
double zmax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:278
double xmin
Definition: liblwgeom.h:276
#define LW_FALSE
Definition: liblwgeom.h:62
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
double ymax
Definition: liblwgeom.h:279
double zmin
Definition: liblwgeom.h:280
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
Here is the call graph for this function:
Here is the caller graph for this function: