PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 551 of file lwgeom_box3d.c.

552 {
553  GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
554  GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
555  BOX3D *result = palloc(sizeof(BOX3D));
556  LWGEOM *minpoint, *maxpoint;
557  POINT3DZ minp, maxp;
558 
559  minpoint = lwgeom_from_gserialized(min);
560  maxpoint = lwgeom_from_gserialized(max);
561 
562  if (minpoint->type != POINTTYPE || maxpoint->type != POINTTYPE)
563  {
564  elog(ERROR, "BOX3D_construct: args must be points");
565  PG_RETURN_NULL();
566  }
567 
568  error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
569 
570  getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
571  getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
572 
573  result->xmax = maxp.x;
574  result->ymax = maxp.y;
575  result->zmax = maxp.z;
576 
577  result->xmin = minp.x;
578  result->ymin = minp.y;
579  result->zmin = minp.z;
580 
581  result->srid = minpoint->srid;
582 
583  PG_RETURN_POINTER(result);
584 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:215
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
double xmax
Definition: liblwgeom.h:281
double zmin
Definition: liblwgeom.h:280
double ymax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:280
double zmax
Definition: liblwgeom.h:281
double xmin
Definition: liblwgeom.h:280
int32_t srid
Definition: liblwgeom.h:282
uint8_t type
Definition: liblwgeom.h:399
int32_t srid
Definition: liblwgeom.h:402
double z
Definition: liblwgeom.h:337
double x
Definition: liblwgeom.h:337
double y
Definition: liblwgeom.h:337

References error_if_srid_mismatch(), getPoint3dz_p(), lwgeom_from_gserialized(), POINTTYPE, BOX3D::srid, LWGEOM::srid, LWGEOM::type, POINT3DZ::x, BOX3D::xmax, BOX3D::xmin, POINT3DZ::y, BOX3D::ymax, BOX3D::ymin, POINT3DZ::z, BOX3D::zmax, and BOX3D::zmin.

Here is the call graph for this function: