PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ BOX2D_combine()

Datum BOX2D_combine ( PG_FUNCTION_ARGS  )

Definition at line 417 of file lwgeom_box.c.

418 {
419  Pointer box2d_ptr = PG_GETARG_POINTER(0);
420  Pointer geom_ptr = PG_GETARG_POINTER(1);
421  GBOX *a,*b;
422  GSERIALIZED *lwgeom;
423  GBOX box, *result;
424 
425  if ( (box2d_ptr == NULL) && (geom_ptr == NULL) )
426  {
427  PG_RETURN_NULL(); /* combine_box2d(null,null) => null */
428  }
429 
430  result = (GBOX *)palloc(sizeof(GBOX));
431 
432  if (box2d_ptr == NULL)
433  {
434  lwgeom = PG_GETARG_GSERIALIZED_P(1);
435  /* empty geom would make getbox2d_p return NULL */
436  if ( ! gserialized_get_gbox_p(lwgeom, &box) ) PG_RETURN_NULL();
437  memcpy(result, &box, sizeof(GBOX));
438  PG_RETURN_POINTER(result);
439  }
440 
441  /* combine_bbox(BOX3D, null) => BOX3D */
442  if (geom_ptr == NULL)
443  {
444  memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(GBOX));
445  PG_RETURN_POINTER(result);
446  }
447 
448  /*combine_bbox(BOX3D, geometry) => union(BOX3D, geometry->bvol) */
449 
450  lwgeom = PG_GETARG_GSERIALIZED_P(1);
451  if ( ! gserialized_get_gbox_p(lwgeom, &box) )
452  {
453  /* must be the empty geom */
454  memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(GBOX));
455  PG_RETURN_POINTER(result);
456  }
457 
458  a = (GBOX *)PG_GETARG_DATUM(0);
459  b = &box;
460 
461  result->xmax = Max(a->xmax, b->xmax);
462  result->ymax = Max(a->ymax, b->ymax);
463  result->xmin = Min(a->xmin, b->xmin);
464  result->ymin = Min(a->ymin, b->ymin);
465 
466  PG_RETURN_POINTER(result);
467 }
int gserialized_get_gbox_p(const GSERIALIZED *g, GBOX *box)
Read the bounding box off a serialization and calculate one if it is not already there.
Definition: g_serialized.c:640
double ymax
Definition: liblwgeom.h:298
double xmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:297
double xmin
Definition: liblwgeom.h:295

References gserialized_get_gbox_p(), GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Here is the call graph for this function: