PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ BOX3D_construct()

Datum BOX3D_construct ( PG_FUNCTION_ARGS  )

Definition at line 551 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().

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  error_if_srid_mismatch(minpoint->srid, maxpoint->srid);
569 
570  getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
571  getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
572 
573  result->xmax = maxp.x;
574  result->ymax = maxp.y;
575  result->zmax = maxp.z;
576 
577  result->xmin = minp.x;
578  result->ymin = minp.y;
579  result->zmin = minp.z;
580 
581  result->srid = minpoint->srid;
582 
583  PG_RETURN_POINTER(result);
584 }
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:338
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:215
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: