PostGIS  3.1.6dev-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 812 of file mvt.c.

813 {
814  LWGEOM *geom_clipped;
815  GBOX geom_box;
816 
817  gbox_init(&geom_box);
818  FLAGS_SET_GEODETIC(geom_box.flags, 0);
819  lwgeom_calculate_gbox(lwg_in, &geom_box);
820 
821  if (!gbox_overlaps_2d(&geom_box, clip_box))
822  {
823  POSTGIS_DEBUG(3, "mvt_geom: geometry outside clip box");
824  return NULL;
825  }
826 
827  if (gbox_contains_2d(clip_box, &geom_box))
828  {
829  POSTGIS_DEBUG(3, "mvt_geom: geometry contained fully inside the box");
830  return lwg_in;
831  }
832 
833  geom_clipped = lwgeom_clip_by_rect(lwg_in, clip_box->xmin, clip_box->ymin, clip_box->xmax, clip_box->ymax);
834  if (!geom_clipped || lwgeom_is_empty(geom_clipped))
835  return NULL;
836  return geom_clipped;
837 }
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:738
#define FLAGS_SET_GEODETIC(flags, value)
Definition: liblwgeom.h:189
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:371
double xmax
Definition: liblwgeom.h:369
double ymin
Definition: liblwgeom.h:370
double xmin
Definition: liblwgeom.h:368
lwflags_t flags
Definition: liblwgeom.h:367

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_iterate_clip_by_box_geos().

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