PostGIS  2.3.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 307 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().

308 {
309  int rv = LW_FALSE;
310  LWDEBUG(4, "checking poles");
311  LWDEBUGF(4, "gbox %s", gbox_to_string(gbox));
312  /* Z axis */
313  if ( gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
314  gbox->ymin < 0.0 && gbox->ymax > 0.0 )
315  {
316  if ( (gbox->zmin + gbox->zmax) > 0.0 )
317  {
318  LWDEBUG(4, "enclosed positive z axis");
319  gbox->zmax = 1.0;
320  }
321  else
322  {
323  LWDEBUG(4, "enclosed negative z axis");
324  gbox->zmin = -1.0;
325  }
326  rv = LW_TRUE;
327  }
328 
329  /* Y axis */
330  if ( gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
331  gbox->zmin < 0.0 && gbox->zmax > 0.0 )
332  {
333  if ( gbox->ymin + gbox->ymax > 0.0 )
334  {
335  LWDEBUG(4, "enclosed positive y axis");
336  gbox->ymax = 1.0;
337  }
338  else
339  {
340  LWDEBUG(4, "enclosed negative y axis");
341  gbox->ymin = -1.0;
342  }
343  rv = LW_TRUE;
344  }
345 
346  /* X axis */
347  if ( gbox->ymin < 0.0 && gbox->ymax > 0.0 &&
348  gbox->zmin < 0.0 && gbox->zmax > 0.0 )
349  {
350  if ( gbox->xmin + gbox->xmax > 0.0 )
351  {
352  LWDEBUG(4, "enclosed positive x axis");
353  gbox->xmax = 1.0;
354  }
355  else
356  {
357  LWDEBUG(4, "enclosed negative x axis");
358  gbox->xmin = -1.0;
359  }
360  rv = LW_TRUE;
361  }
362 
363  return rv;
364 }
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:404
double xmax
Definition: liblwgeom.h:292
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
double zmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:293
double xmin
Definition: liblwgeom.h:291
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
double ymax
Definition: liblwgeom.h:294
double zmin
Definition: liblwgeom.h:295
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the call graph for this function:
Here is the caller graph for this function: