PostGIS  2.5.0beta1dev-r@@SVN_REVISION@@

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 569 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().

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