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

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 559 of file lwgeom_box3d.c.

560{
561 GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
562 GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
563 BOX3D *result = palloc(sizeof(BOX3D));
564 LWGEOM *minpoint, *maxpoint;
565 POINT3DZ minp, maxp;
566
567 minpoint = lwgeom_from_gserialized(min);
568 maxpoint = lwgeom_from_gserialized(max);
569
570 if (minpoint->type != POINTTYPE || maxpoint->type != POINTTYPE)
571 {
572 elog(ERROR, "BOX3D_construct: args must be points");
573 PG_RETURN_NULL();
574 }
575
576 if (lwgeom_is_empty(minpoint) || lwgeom_is_empty(maxpoint) ){
577 elog(ERROR, "BOX3D_construct: args can not be empty points");
578 PG_RETURN_NULL();
579 }
580
581 gserialized_error_if_srid_mismatch(min, max, __func__);
582
583 getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
584 getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
585
586 result->xmax = maxp.x;
587 result->ymax = maxp.y;
588 result->zmax = maxp.z;
589
590 result->xmin = minp.x;
591 result->ymin = minp.y;
592 result->zmin = minp.z;
593
594 result->srid = minpoint->srid;
595
596 PG_RETURN_POINTER(result);
597}
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: