PostGIS  2.1.10dev-r@@SVN_REVISION@@
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 293 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().

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