PostGIS  2.5.7dev-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 542 of file g_box.c.

543 {
544  uint32_t i;
545  POINT4D p;
546  int has_z, has_m;
547 
548  if ( ! pa ) return LW_FAILURE;
549  if ( ! gbox ) return LW_FAILURE;
550  if ( pa->npoints < 1 ) return LW_FAILURE;
551 
552  has_z = FLAGS_GET_Z(pa->flags);
553  has_m = FLAGS_GET_M(pa->flags);
554  gbox->flags = gflags(has_z, has_m, 0);
555  LWDEBUGF(4, "ptarray_calculate_gbox Z: %d M: %d", has_z, has_m);
556 
557  getPoint4d_p(pa, 0, &p);
558  gbox->xmin = gbox->xmax = p.x;
559  gbox->ymin = gbox->ymax = p.y;
560  if ( has_z )
561  gbox->zmin = gbox->zmax = p.z;
562  if ( has_m )
563  gbox->mmin = gbox->mmax = p.m;
564 
565  for ( i = 1 ; i < pa->npoints; i++ )
566  {
567  getPoint4d_p(pa, i, &p);
568  gbox->xmin = FP_MIN(gbox->xmin, p.x);
569  gbox->xmax = FP_MAX(gbox->xmax, p.x);
570  gbox->ymin = FP_MIN(gbox->ymin, p.y);
571  gbox->ymax = FP_MAX(gbox->ymax, p.y);
572  if ( has_z )
573  {
574  gbox->zmin = FP_MIN(gbox->zmin, p.z);
575  gbox->zmax = FP_MAX(gbox->zmax, p.z);
576  }
577  if ( has_m )
578  {
579  gbox->mmin = FP_MIN(gbox->mmin, p.m);
580  gbox->mmax = FP_MAX(gbox->mmax, p.m);
581  }
582  }
583  return LW_SUCCESS;
584 }
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
Definition: g_util.c:145
#define LW_FAILURE
Definition: liblwgeom.h:79
#define LW_SUCCESS
Definition: liblwgeom.h:80
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
Definition: liblwgeom.h:140
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:141
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:123
#define FP_MAX(A, B)
#define FP_MIN(A, B)
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
double ymax
Definition: liblwgeom.h:298
double zmax
Definition: liblwgeom.h:300
double xmax
Definition: liblwgeom.h:296
double zmin
Definition: liblwgeom.h:299
double mmax
Definition: liblwgeom.h:302
double ymin
Definition: liblwgeom.h:297
double xmin
Definition: liblwgeom.h:295
double mmin
Definition: liblwgeom.h:301
uint8_t flags
Definition: liblwgeom.h:294
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374
uint8_t flags
Definition: liblwgeom.h:372
unsigned int uint32_t
Definition: uthash.h:78

References GBOX::flags, POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, FP_MAX, FP_MIN, getPoint4d_p(), gflags(), LW_FAILURE, LW_SUCCESS, LWDEBUGF, POINT4D::m, GBOX::mmax, GBOX::mmin, POINTARRAY::npoints, POINT4D::x, GBOX::xmax, GBOX::xmin, POINT4D::y, GBOX::ymax, GBOX::ymin, POINT4D::z, GBOX::zmax, and GBOX::zmin.

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

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