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

◆ BOX2D_combine()

Datum BOX2D_combine ( PG_FUNCTION_ARGS  )

Definition at line 418 of file lwgeom_box.c.

419{
420 static const uint32_t box2d_idx = 0;
421 static const uint32_t geom_idx = 1;
422 GBOX *a,*b;
423 GBOX box, *result;
424
425 if (PG_ARGISNULL(box2d_idx) && PG_ARGISNULL(geom_idx))
426 {
427 PG_RETURN_NULL(); /* combine_box2d(null,null) => null */
428 }
429
430 result = (GBOX *)palloc(sizeof(GBOX));
431
432 if (PG_ARGISNULL(box2d_idx))
433 {
434 /* empty geom would make getbox2d_p return NULL */
435 if (!gserialized_datum_get_gbox_p(PG_GETARG_DATUM(geom_idx), &box))
436 PG_RETURN_NULL();
437 memcpy(result, &box, sizeof(GBOX));
438 PG_RETURN_POINTER(result);
439 }
440
441 /* combine_bbox(BOX3D, null) => BOX3D */
442 if (PG_ARGISNULL(geom_idx))
443 {
444 memcpy(result, (char *)PG_GETARG_DATUM(box2d_idx), sizeof(GBOX));
445 PG_RETURN_POINTER(result);
446 }
447
448 /*combine_bbox(BOX3D, geometry) => union(BOX3D, geometry->bvol) */
449
450 if (!gserialized_datum_get_gbox_p(PG_GETARG_DATUM(geom_idx), &box))
451 {
452 /* must be the empty geom */
453 memcpy(result, (char *)PG_GETARG_DATUM(box2d_idx), sizeof(GBOX));
454 PG_RETURN_POINTER(result);
455 }
456
457 a = (GBOX *)PG_GETARG_DATUM(box2d_idx);
458 b = &box;
459
460 result->xmax = Max(a->xmax, b->xmax);
461 result->ymax = Max(a->ymax, b->ymax);
462 result->xmin = Min(a->xmin, b->xmin);
463 result->ymin = Min(a->ymin, b->ymin);
464
465 PG_RETURN_POINTER(result);
466}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
int gserialized_datum_get_gbox_p(Datum gsdatum, GBOX *gbox)
Given a GSERIALIZED datum, as quickly as possible (peaking into the top of the memory) return the gbo...
double ymax
Definition liblwgeom.h:357
double xmax
Definition liblwgeom.h:355
double ymin
Definition liblwgeom.h:356
double xmin
Definition liblwgeom.h:354

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

Here is the call graph for this function: