PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ mvt_unsafe_clip_by_box()

static LWGEOM* mvt_unsafe_clip_by_box ( LWGEOM lwg_in,
GBOX clip_box 
)
static

Definition at line 840 of file mvt.c.

841 {
842  LWGEOM *geom_clipped;
843  GBOX geom_box;
844 
845  gbox_init(&geom_box);
846  FLAGS_SET_GEODETIC(geom_box.flags, 0);
847  lwgeom_calculate_gbox(lwg_in, &geom_box);
848 
849  if (!gbox_overlaps_2d(&geom_box, clip_box))
850  {
851  POSTGIS_DEBUG(3, "mvt_geom: geometry outside clip box");
852  return NULL;
853  }
854 
855  if (gbox_contains_2d(clip_box, &geom_box))
856  {
857  POSTGIS_DEBUG(3, "mvt_geom: geometry contained fully inside the box");
858  return lwg_in;
859  }
860 
861  geom_clipped = lwgeom_clip_by_rect(lwg_in, clip_box->xmin, clip_box->ymin, clip_box->xmax, clip_box->ymax);
862  if (!geom_clipped || lwgeom_is_empty(geom_clipped))
863  return NULL;
864  return geom_clipped;
865 }
int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise.
Definition: gbox.c:323
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: gbox.c:40
int gbox_contains_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the first GBOX contains the second on the 2d plane, LW_FALSE otherwise.
Definition: gbox.c:339
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
Definition: lwgeom.c:755
#define FLAGS_SET_GEODETIC(flags, value)
Definition: liblwgeom.h:175
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
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:203
double ymax
Definition: liblwgeom.h:357
double xmax
Definition: liblwgeom.h:355
double ymin
Definition: liblwgeom.h:356
double xmin
Definition: liblwgeom.h:354
lwflags_t flags
Definition: liblwgeom.h:353

References GBOX::flags, FLAGS_SET_GEODETIC, gbox_contains_2d(), gbox_init(), gbox_overlaps_2d(), lwgeom_calculate_gbox(), lwgeom_clip_by_rect(), lwgeom_is_empty(), GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Referenced by mvt_clip_and_validate_geos().

Here is the call graph for this function:
Here is the caller graph for this function: