PostGIS  2.3.7dev-r@@SVN_REVISION@@
Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 573 of file lwgeom_box3d.c.

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.

574 {
575  GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
576  GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
577  BOX3D *result = palloc(sizeof(BOX3D));
578  LWGEOM *minpoint, *maxpoint;
579  POINT3DZ minp, maxp;
580 
581  minpoint = lwgeom_from_gserialized(min);
582  maxpoint = lwgeom_from_gserialized(max);
583 
584  if ( minpoint->type != POINTTYPE ||
585  maxpoint->type != POINTTYPE )
586  {
587  elog(ERROR, "BOX3D_construct: args must be points");
588  PG_RETURN_NULL();
589  }
590 
591  error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
592 
593  getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
594  getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
595 
596  result->xmax = maxp.x;
597  result->ymax = maxp.y;
598  result->zmax = maxp.z;
599 
600  result->xmin = minp.x;
601  result->ymin = minp.y;
602  result->zmin = minp.z;
603 
604  result->srid = minpoint->srid;
605 
606  PG_RETURN_POINTER(result);
607 }
int32_t srid
Definition: liblwgeom.h:278
double z
Definition: liblwgeom.h:333
double y
Definition: liblwgeom.h:333
double x
Definition: liblwgeom.h:333
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
double ymin
Definition: liblwgeom.h:276
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:369
int32_t srid
Definition: liblwgeom.h:398
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:332
double xmin
Definition: liblwgeom.h:276
double xmax
Definition: liblwgeom.h:277
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:395
double ymax
Definition: liblwgeom.h:277
double zmax
Definition: liblwgeom.h:277
double zmin
Definition: liblwgeom.h:276

Here is the call graph for this function: