PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 550 of file lwgeom_box3d.c.

References BOX3D_above_internal(), BOX3D_back_internal(), BOX3D_below_internal(), BOX3D_contained_internal(), BOX3D_contains_internal(), BOX3D_distance_internal(), BOX3D_front_internal(), BOX3D_left_internal(), BOX3D_overabove_internal(), BOX3D_overback_internal(), BOX3D_overbelow_internal(), BOX3D_overfront_internal(), BOX3D_overlaps_internal(), BOX3D_overleft_internal(), BOX3D_overright_internal(), BOX3D_right_internal(), BOX3D_same_internal(), error_if_srid_mismatch(), getPoint3dz_p(), lwgeom_from_gserialized(), PG_FUNCTION_INFO_V1(), POINTTYPE, BOX3D::srid, LWGEOM::srid, LWPOINT::srid, LWGEOM::type, POINT3DZ::x, BOX3D::xmax, BOX3D::xmin, POINT3DZ::y, BOX3D::ymax, BOX3D::ymin, POINT3DZ::z, BOX3D::zmax, and BOX3D::zmin.

Referenced by BOX3D_combine_BOX3D().

551 {
552  GSERIALIZED *min = PG_GETARG_GSERIALIZED_P(0);
553  GSERIALIZED *max = PG_GETARG_GSERIALIZED_P(1);
554  BOX3D *result = palloc(sizeof(BOX3D));
555  LWGEOM *minpoint, *maxpoint;
556  POINT3DZ minp, maxp;
557 
558  minpoint = lwgeom_from_gserialized(min);
559  maxpoint = lwgeom_from_gserialized(max);
560 
561  if (minpoint->type != POINTTYPE || maxpoint->type != POINTTYPE)
562  {
563  elog(ERROR, "BOX3D_construct: args must be points");
564  PG_RETURN_NULL();
565  }
566 
567  error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
568 
569  getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
570  getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
571 
572  result->xmax = maxp.x;
573  result->ymax = maxp.y;
574  result->zmax = maxp.z;
575 
576  result->xmin = minp.x;
577  result->ymin = minp.y;
578  result->zmin = minp.z;
579 
580  result->srid = minpoint->srid;
581 
582  PG_RETURN_POINTER(result);
583 }
int32_t srid
Definition: liblwgeom.h:281
double z
Definition: liblwgeom.h:336
double y
Definition: liblwgeom.h:336
double x
Definition: liblwgeom.h:336
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
double ymin
Definition: liblwgeom.h:279
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:336
int32_t srid
Definition: liblwgeom.h:401
double xmin
Definition: liblwgeom.h:279
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
Definition: lwgeom_api.c:204
double xmax
Definition: liblwgeom.h:280
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
uint8_t type
Definition: liblwgeom.h:398
double ymax
Definition: liblwgeom.h:280
double zmax
Definition: liblwgeom.h:280
double zmin
Definition: liblwgeom.h:279
Here is the call graph for this function:
Here is the caller graph for this function: