PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 571 of file lwgeom_box3d.c.

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

Referenced by BOX3D_combine_BOX3D().

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