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

Definition at line 414 of file lwgeom_box3d.c.

References error_if_srid_mismatch(), getPoint3dz_p(), lwgeom_from_gserialized(), POINTTYPE, result, 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.

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

Here is the call graph for this function: