PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 551 of file lwgeom_box3d.c.

552{
553 GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
554 GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
555 BOX3D *result = palloc(sizeof(BOX3D));
556 LWGEOM *minpoint, *maxpoint;
557 POINT3DZ minp, maxp;
558
559 minpoint = lwgeom_from_gserialized(min);
560 maxpoint = lwgeom_from_gserialized(max);
561
562 if (minpoint->type != POINTTYPE || maxpoint->type != POINTTYPE)
563 {
564 elog(ERROR, "BOX3D_construct: args must be points");
565 PG_RETURN_NULL();
566 }
567
568 if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
569 elog(ERROR, "BOX3D_construct: args can not be empty points");
570 PG_RETURN_NULL();
571 }
572
573 gserialized_error_if_srid_mismatch(min, max, __func__);
574
575 getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
576 getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
577
578 result->xmax = maxp.x;
579 result->ymax = maxp.y;
580 result->zmax = maxp.z;
581
582 result->xmin = minp.x;
583 result->ymin = minp.y;
584 result->zmin = minp.z;
585
586 result->srid = minpoint->srid;
587
588 PG_RETURN_POINTER(result);
589}
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:116
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition lwgeom_api.c:215
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:193
double xmax
Definition liblwgeom.h:326
double zmin
Definition liblwgeom.h:325
double ymax
Definition liblwgeom.h:326
double ymin
Definition liblwgeom.h:325
double zmax
Definition liblwgeom.h:326
double xmin
Definition liblwgeom.h:325
int32_t srid
Definition liblwgeom.h:327
uint8_t type
Definition liblwgeom.h:448
int32_t srid
Definition liblwgeom.h:446
double z
Definition liblwgeom.h:382
double x
Definition liblwgeom.h:382
double y
Definition liblwgeom.h:382

References getPoint3dz_p(), gserialized_error_if_srid_mismatch(), lwgeom_from_gserialized(), lwgeom_is_empty(), 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.

Here is the call graph for this function: