PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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.

317{
318 int rv = LW_FALSE;
319#if POSTGIS_DEBUG_LEVEL >= 4
320 char *gbox_str = gbox_to_string(gbox);
321 LWDEBUG(4, "checking poles");
322 LWDEBUGF(4, "gbox %s", gbox_str);
323 lwfree(gbox_str);
324#endif
325 /* Z axis */
326 if (gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
327 gbox->ymin < 0.0 && gbox->ymax > 0.0)
328 {
329 /* Extrema lean positive */
330 if ((gbox->zmin > 0.0) && (gbox->zmax > 0.0))
331 {
332 LWDEBUG(4, "enclosed positive z axis");
333 gbox->zmax = 1.0;
334 }
335 /* Extrema lean negative */
336 else if ((gbox->zmin < 0.0) && (gbox->zmax < 0.0))
337 {
338 LWDEBUG(4, "enclosed negative z axis");
339 gbox->zmin = -1.0;
340 }
341 /* Extrema both sides! */
342 else
343 {
344 LWDEBUG(4, "enclosed both z axes");
345 gbox->zmin = -1.0;
346 gbox->zmax = 1.0;
347 }
348 rv = LW_TRUE;
349 }
350
351 /* Y axis */
352 if (gbox->xmin < 0.0 && gbox->xmax > 0.0 &&
353 gbox->zmin < 0.0 && gbox->zmax > 0.0)
354 {
355 if ((gbox->ymin > 0.0) && (gbox->ymax > 0.0))
356 {
357 LWDEBUG(4, "enclosed positive y axis");
358 gbox->ymax = 1.0;
359 }
360 else if ((gbox->ymin < 0.0) && (gbox->ymax < 0.0))
361 {
362 LWDEBUG(4, "enclosed negative y axis");
363 gbox->ymin = -1.0;
364 }
365 else
366 {
367 LWDEBUG(4, "enclosed both y axes");
368 gbox->ymax = 1.0;
369 gbox->ymin = -1.0;
370 }
371 rv = LW_TRUE;
372 }
373
374 /* X axis */
375 if (gbox->ymin < 0.0 && gbox->ymax > 0.0 &&
376 gbox->zmin < 0.0 && gbox->zmax > 0.0)
377 {
378 if ((gbox->xmin > 0.0) && (gbox->xmax > 0.0))
379 {
380 LWDEBUG(4, "enclosed positive x axis");
381 gbox->xmax = 1.0;
382 }
383 else if ((gbox->xmin < 0.0) && (gbox->xmax < 0.0))
384 {
385 LWDEBUG(4, "enclosed negative x axis");
386 gbox->xmin = -1.0;
387 }
388 else
389 {
390 LWDEBUG(4, "enclosed both x axes");
391 gbox->xmax = 1.0;
392 gbox->xmin = -1.0;
393 }
394
395 rv = LW_TRUE;
396 }
397
398 return rv;
399}
char * gbox_to_string(const GBOX *gbox)
Allocate a string representation of the GBOX, based on dimensionality of flags.
Definition gbox.c:404
#define LW_FALSE
Definition liblwgeom.h:94
void lwfree(void *mem)
Definition lwutil.c:248
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
double ymax
Definition liblwgeom.h:357
double zmax
Definition liblwgeom.h:359
double xmax
Definition liblwgeom.h:355
double zmin
Definition liblwgeom.h:358
double ymin
Definition liblwgeom.h:356
double xmin
Definition liblwgeom.h:354

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().

Here is the call graph for this function:
Here is the caller graph for this function: