PostGIS  2.5.7dev-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 796 of file mvt.c.

797 {
798  LWGEOM *geom_clipped;
799  GBOX geom_box;
800 
801  gbox_init(&geom_box);
802  FLAGS_SET_GEODETIC(geom_box.flags, 0);
803  lwgeom_calculate_gbox(lwg_in, &geom_box);
804 
805  if (!gbox_overlaps_2d(&geom_box, clip_box))
806  {
807  POSTGIS_DEBUG(3, "mvt_geom: geometry outside clip box");
808  return NULL;
809  }
810 
811  if (gbox_contains_2d(clip_box, &geom_box))
812  {
813  POSTGIS_DEBUG(3, "mvt_geom: geometry contained fully inside the box");
814  return lwg_in;
815  }
816 
817  geom_clipped = lwgeom_clip_by_rect(lwg_in, clip_box->xmin, clip_box->ymin, clip_box->xmax, clip_box->ymax);
818  if (!geom_clipped || lwgeom_is_empty(geom_clipped))
819  return NULL;
820  return geom_clipped;
821 }
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: g_box.c:330
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:47
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: g_box.c:346
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwgeom.c:1393
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:746
#define FLAGS_SET_GEODETIC(flags, value)
Definition: liblwgeom.h:149
LWGEOM * lwgeom_clip_by_rect(const LWGEOM *geom1, double x0, double y0, double x1, double y1)
double ymax
Definition: liblwgeom.h:298
double xmax
Definition: liblwgeom.h:296
double ymin
Definition: liblwgeom.h:297
double xmin
Definition: liblwgeom.h:295
uint8_t flags
Definition: liblwgeom.h:294

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: