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

Definition at line 413 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.

414 {
415  GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
416  GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
417  BOX3D *result = palloc(sizeof(BOX3D));
418  LWGEOM *minpoint, *maxpoint;
419  POINT3DZ minp, maxp;
420 
421  minpoint = lwgeom_from_gserialized(min);
422  maxpoint = lwgeom_from_gserialized(max);
423 
424  if ( minpoint->type != POINTTYPE ||
425  maxpoint->type != POINTTYPE )
426  {
427  elog(ERROR, "BOX3D_construct: args must be points");
428  PG_RETURN_NULL();
429  }
430 
431  error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
432 
433  getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
434  getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
435 
436  result->xmax = maxp.x;
437  result->ymax = maxp.y;
438  result->zmax = maxp.z;
439 
440  result->xmin = minp.x;
441  result->ymin = minp.y;
442  result->zmin = minp.z;
443 
444  result->srid = minpoint->srid;
445 
446  PG_RETURN_POINTER(result);
447 }
int32_t srid
Definition: liblwgeom.h:263
double z
Definition: liblwgeom.h:318
double y
Definition: liblwgeom.h:318
double x
Definition: liblwgeom.h:318
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
double ymin
Definition: liblwgeom.h:261
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
int32_t srid
Definition: liblwgeom.h:383
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:319
double xmin
Definition: liblwgeom.h:261
double xmax
Definition: liblwgeom.h:262
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
uint8_t type
Definition: liblwgeom.h:380
double ymax
Definition: liblwgeom.h:262
double zmax
Definition: liblwgeom.h:262
double zmin
Definition: liblwgeom.h:261

Here is the call graph for this function: