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.
849 LWGEOM *geom_clipped, *envelope;
851 GEOSGeometry *geos_input, *geos_box, *geos_result;
859 POSTGIS_DEBUG(3,
"mvt_geom: geometry outside clip box");
865 POSTGIS_DEBUG(3,
"mvt_geom: geometry contained fully inside the box");
879 GEOSGeom_destroy(geos_input);
883 geos_result = GEOSIntersection(geos_input, geos_box);
886 POSTGIS_DEBUG(3,
"mvt_geom: no geometry after intersection. Retrying after validation");
887 GEOSGeom_destroy(geos_input);
891 GEOSGeom_destroy(geos_box);
894 geos_result = GEOSIntersection(geos_input, geos_box);
897 GEOSGeom_destroy(geos_box);
898 GEOSGeom_destroy(geos_input);
903 GEOSSetSRID(geos_result, lwg_in->
srid);
906 GEOSGeom_destroy(geos_box);
907 GEOSGeom_destroy(geos_input);
908 GEOSGeom_destroy(geos_result);
912 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)