PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ ptarray_calculate_gbox_cartesian()

int ptarray_calculate_gbox_cartesian ( const POINTARRAY pa,
GBOX gbox 
)

Calculate box (x/y) and add values to gbox.

Return LW_SUCCESS on success.

Definition at line 601 of file gbox.c.

602 {
603  if (!pa || pa->npoints == 0)
604  return LW_FAILURE;
605  if (!gbox)
606  return LW_FAILURE;
607 
608  int has_z = FLAGS_GET_Z(pa->flags);
609  int has_m = FLAGS_GET_M(pa->flags);
610  gbox->flags = lwflags(has_z, has_m, 0);
611  LWDEBUGF(4, "ptarray_calculate_gbox Z: %d M: %d", has_z, has_m);
612  int coordinates = 2 + has_z + has_m;
613 
614  switch (coordinates)
615  {
616  case 2:
617  {
619  break;
620  }
621  case 3:
622  {
623  if (has_z)
624  {
626  }
627  else
628  {
629  double zmin = gbox->zmin;
630  double zmax = gbox->zmax;
632  gbox->mmin = gbox->zmin;
633  gbox->mmax = gbox->zmax;
634  gbox->zmin = zmin;
635  gbox->zmax = zmax;
636  }
637  break;
638  }
639  default:
640  {
642  break;
643  }
644  }
645  return LW_SUCCESS;
646 }
static void ptarray_calculate_gbox_cartesian_2d(const POINTARRAY *pa, GBOX *gbox)
Definition: gbox.c:537
static void ptarray_calculate_gbox_cartesian_3d(const POINTARRAY *pa, GBOX *gbox)
Definition: gbox.c:556
static void ptarray_calculate_gbox_cartesian_4d(const POINTARRAY *pa, GBOX *gbox)
Definition: gbox.c:577
#define LW_FAILURE
Definition: liblwgeom.h:110
#define LW_SUCCESS
Definition: liblwgeom.h:111
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:180
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
Definition: lwutil.c:471
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
double zmax
Definition: liblwgeom.h:345
double zmin
Definition: liblwgeom.h:344
double mmax
Definition: liblwgeom.h:347
double mmin
Definition: liblwgeom.h:346
lwflags_t flags
Definition: liblwgeom.h:339
lwflags_t flags
Definition: liblwgeom.h:417
uint32_t npoints
Definition: liblwgeom.h:413

References GBOX::flags, POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, LW_FAILURE, LW_SUCCESS, LWDEBUGF, lwflags(), GBOX::mmax, GBOX::mmin, POINTARRAY::npoints, ptarray_calculate_gbox_cartesian_2d(), ptarray_calculate_gbox_cartesian_3d(), ptarray_calculate_gbox_cartesian_4d(), GBOX::zmax, and GBOX::zmin.

Referenced by LWGEOM_interiorringn_polygon(), lwline_calculate_gbox_cartesian(), lwpoint_calculate_gbox_cartesian(), lwpoly_calculate_gbox_cartesian(), and lwtriangle_calculate_gbox_cartesian().

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