PostGIS  3.0.0dev-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, lwfree(), 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 #if POSTGIS_DEBUG_LEVEL >= 4
311  char *gbox_str = gbox_to_string(gbox);
312  LWDEBUG(4, "checking poles");
313  LWDEBUGF(4, "gbox %s", gbox_str);
314  lwfree(gbox_str);
315 #endif
316  /* Z axis */
317  if ( gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
318  gbox->ymin < 0.0 && gbox->ymax > 0.0 )
319  {
320  if ( (gbox->zmin + gbox->zmax) > 0.0 )
321  {
322  LWDEBUG(4, "enclosed positive z axis");
323  gbox->zmax = 1.0;
324  }
325  else
326  {
327  LWDEBUG(4, "enclosed negative z axis");
328  gbox->zmin = -1.0;
329  }
330  rv = LW_TRUE;
331  }
332 
333  /* Y axis */
334  if ( gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
335  gbox->zmin < 0.0 && gbox->zmax > 0.0 )
336  {
337  if ( gbox->ymin + gbox->ymax > 0.0 )
338  {
339  LWDEBUG(4, "enclosed positive y axis");
340  gbox->ymax = 1.0;
341  }
342  else
343  {
344  LWDEBUG(4, "enclosed negative y axis");
345  gbox->ymin = -1.0;
346  }
347  rv = LW_TRUE;
348  }
349 
350  /* X axis */
351  if ( gbox->ymin < 0.0 && gbox->ymax > 0.0 &&
352  gbox->zmin < 0.0 && gbox->zmax > 0.0 )
353  {
354  if ( gbox->xmin + gbox->xmax > 0.0 )
355  {
356  LWDEBUG(4, "enclosed positive x axis");
357  gbox->xmax = 1.0;
358  }
359  else
360  {
361  LWDEBUG(4, "enclosed negative x axis");
362  gbox->xmin = -1.0;
363  }
364  rv = LW_TRUE;
365  }
366 
367  return rv;
368 }
void lwfree(void *mem)
Definition: lwutil.c:242
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition: g_box.c:399
double xmax
Definition: liblwgeom.h:295
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
double zmax
Definition: liblwgeom.h:299
double ymin
Definition: liblwgeom.h:296
double xmin
Definition: liblwgeom.h:294
#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:297
double zmin
Definition: liblwgeom.h:298
#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: