PostGIS  2.4.9dev-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 316 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().

317 {
318  int rv = LW_FALSE;
319  LWDEBUG(4, "checking poles");
320  LWDEBUGF(4, "gbox %s", gbox_to_string(gbox));
321  /* Z axis */
322  if (gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
323  gbox->ymin < 0.0 && gbox->ymax > 0.0)
324  {
325  /* Extrema lean positive */
326  if ((gbox->zmin > 0.0) && (gbox->zmax > 0.0))
327  {
328  LWDEBUG(4, "enclosed positive z axis");
329  gbox->zmax = 1.0;
330  }
331  /* Extrema lean negative */
332  else if ((gbox->zmin < 0.0) && (gbox->zmax < 0.0))
333  {
334  LWDEBUG(4, "enclosed negative z axis");
335  gbox->zmin = -1.0;
336  }
337  /* Extrema both sides! */
338  else
339  {
340  LWDEBUG(4, "enclosed both z axes");
341  gbox->zmin = -1.0;
342  gbox->zmax = 1.0;
343  }
344  rv = LW_TRUE;
345  }
346 
347  /* Y axis */
348  if (gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
349  gbox->zmin < 0.0 && gbox->zmax > 0.0)
350  {
351  if ((gbox->ymin > 0.0) && (gbox->ymax > 0.0))
352  {
353  LWDEBUG(4, "enclosed positive y axis");
354  gbox->ymax = 1.0;
355  }
356  else if ((gbox->ymin < 0.0) && (gbox->ymax < 0.0))
357  {
358  LWDEBUG(4, "enclosed negative y axis");
359  gbox->ymax = -1.0;
360  }
361  else
362  {
363  LWDEBUG(4, "enclosed both y axes");
364  gbox->ymax = 1.0;
365  gbox->ymin = -1.0;
366  }
367  rv = LW_TRUE;
368  }
369 
370  /* X axis */
371  if (gbox->ymin < 0.0 && gbox->ymax > 0.0 &&
372  gbox->zmin < 0.0 && gbox->zmax > 0.0)
373  {
374  if ((gbox->xmin > 0.0) && (gbox->xmax > 0.0))
375  {
376  LWDEBUG(4, "enclosed positive x axis");
377  gbox->xmax = 1.0;
378  }
379  else if ((gbox->xmin < 0.0) && (gbox->xmax < 0.0))
380  {
381  LWDEBUG(4, "enclosed negative x axis");
382  gbox->xmin = -1.0;
383  }
384  else
385  {
386  LWDEBUG(4, "enclosed both x axes");
387  gbox->xmax = 1.0;
388  gbox->xmin = -1.0;
389  }
390 
391  rv = LW_TRUE;
392  }
393 
394  return rv;
395 }
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:293
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
double zmax
Definition: liblwgeom.h:297
double ymin
Definition: liblwgeom.h:294
double xmin
Definition: liblwgeom.h:292
#define LW_FALSE
Definition: liblwgeom.h:77
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
double ymax
Definition: liblwgeom.h:295
double zmin
Definition: liblwgeom.h:296
#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: