PostGIS  3.0.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 848 of file mvt.c.

849 {
850  LWGEOM *geom_clipped;
851  GBOX geom_box;
852 
853  gbox_init(&geom_box);
854  FLAGS_SET_GEODETIC(geom_box.flags, 0);
855  lwgeom_calculate_gbox(lwg_in, &geom_box);
856 
857  if (!gbox_overlaps_2d(&geom_box, clip_box))
858  {
859  POSTGIS_DEBUG(3, "mvt_geom: geometry outside clip box");
860  return NULL;
861  }
862 
863  if (gbox_contains_2d(clip_box, &geom_box))
864  {
865  POSTGIS_DEBUG(3, "mvt_geom: geometry contained fully inside the box");
866  return lwg_in;
867  }
868 
869  geom_clipped = lwgeom_clip_by_rect(lwg_in, clip_box->xmin, clip_box->ymin, clip_box->xmax, clip_box->ymax);
870  if (!geom_clipped || lwgeom_is_empty(geom_clipped))
871  return NULL;
872  return geom_clipped;
873 }
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:737
#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:193
double ymax
Definition: liblwgeom.h:343
double xmax
Definition: liblwgeom.h:341
double ymin
Definition: liblwgeom.h:342
double xmin
Definition: liblwgeom.h:340
lwflags_t flags
Definition: liblwgeom.h:339

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: