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

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 594 of file lwgeom_box3d.c.

595{
596 GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
597 GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
598 BOX3D *result = palloc(sizeof(BOX3D));
599 LWGEOM *minpoint, *maxpoint;
600 POINT3DZ minp, maxp;
601
602 minpoint = lwgeom_from_gserialized(min);
603 maxpoint = lwgeom_from_gserialized(max);
604
605 if (minpoint->type != POINTTYPE || maxpoint->type != POINTTYPE)
606 {
607 elog(ERROR, "BOX3D_construct: args must be points");
608 PG_RETURN_NULL();
609 }
610
611 if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
612 elog(ERROR, "BOX3D_construct: args can not be empty points");
613 PG_RETURN_NULL();
614 }
615
616 gserialized_error_if_srid_mismatch(min, max, __func__);
617
618 getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
619 getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
620
621 result->xmax = maxp.x;
622 result->ymax = maxp.y;
623 result->zmax = maxp.z;
624
625 result->xmin = minp.x;
626 result->ymin = minp.y;
627 result->zmin = minp.z;
628
629 result->srid = minpoint->srid;
630
631 PG_RETURN_POINTER(result);
632}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
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:102
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:199
uint8_t type
Definition liblwgeom.h:462
int32_t srid
Definition liblwgeom.h:460
double z
Definition liblwgeom.h:396
double x
Definition liblwgeom.h:396
double y
Definition liblwgeom.h:396

References getPoint3dz_p(), gserialized_error_if_srid_mismatch(), lwgeom_from_gserialized(), lwgeom_is_empty(), POINTTYPE, result, LWGEOM::srid, LWGEOM::type, POINT3DZ::x, POINT3DZ::y, and POINT3DZ::z.

Here is the call graph for this function: