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.
885 LWGEOM *geom_clipped, *envelope;
887 GEOSGeometry *geos_input, *geos_box, *geos_result;
895 POSTGIS_DEBUG(3,
"mvt_geom: geometry outside clip box");
901 POSTGIS_DEBUG(3,
"mvt_geom: geometry contained fully inside the box");
915 GEOSGeom_destroy(geos_input);
919 geos_result = GEOSIntersection(geos_input, geos_box);
922 POSTGIS_DEBUG(3,
"mvt_geom: no geometry after intersection. Retrying after validation");
923 GEOSGeom_destroy(geos_input);
927 GEOSGeom_destroy(geos_box);
930 geos_result = GEOSIntersection(geos_input, geos_box);
933 GEOSGeom_destroy(geos_box);
934 GEOSGeom_destroy(geos_input);
939 GEOSSetSRID(geos_result, lwg_in->
srid);
942 GEOSGeom_destroy(geos_box);
943 GEOSGeom_destroy(geos_input);
944 GEOSGeom_destroy(geos_result);
948 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)
LWPOLY * lwpoly_construct_envelope(int32_t srid, double x1, double y1, double x2, double y2)
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)
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.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)