Clips an input geometry using GEOSIntersection It used to try to use GEOSClipByRect (as mvt_unsafe_clip_by_box) but since that produces invalid output when an invalid geometry is given and detecting it resulted to be impossible, we use intersection instead and, upon error, force validation of the input and retry.
833 LWGEOM *geom_clipped, *envelope;
835 GEOSGeometry *geos_input, *geos_box, *geos_result;
843 POSTGIS_DEBUG(3,
"mvt_geom: geometry outside clip box");
849 POSTGIS_DEBUG(3,
"mvt_geom: geometry contained fully inside the box");
863 GEOSGeom_destroy(geos_input);
867 geos_result = GEOSIntersection(geos_input, geos_box);
870 POSTGIS_DEBUG(3,
"mvt_geom: no geometry after intersection. Retrying after validation");
871 GEOSGeom_destroy(geos_input);
875 GEOSGeom_destroy(geos_box);
878 geos_result = GEOSIntersection(geos_input, geos_box);
881 GEOSGeom_destroy(geos_box);
882 GEOSGeom_destroy(geos_input);
887 GEOSSetSRID(geos_result, lwg_in->
srid);
890 GEOSGeom_destroy(geos_box);
891 GEOSGeom_destroy(geos_input);
892 GEOSGeom_destroy(geos_result);
896 POSTGIS_DEBUG(3,
"mvt_geom: no geometry after clipping");
int gbox_overlaps_2d(const GBOX *g1, const GBOX *g2)
Return LW_TRUE if the GBOX overlaps on the 2d plane, LW_FALSE otherwise.
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
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.
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
void lwgeom_free(LWGEOM *geom)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
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...
#define FLAGS_SET_GEODETIC(flags, value)
LWPOLY * lwpoly_construct_envelope(int srid, double x1, double y1, double x2, double y2)
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.