PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ mvt_iterate_clip_by_box_geos()

static LWGEOM * mvt_iterate_clip_by_box_geos ( LWGEOM lwgeom,
GBOX clip_gbox,
uint8_t  basic_type 
)
static

Clips the geometry using GEOSIntersection in a "safe way", cleaning the input if necessary and clipping MULTIPOLYGONs separately to reduce the impact of using invalid input in GEOS Might return NULL.

Definition at line 962 of file mvt.c.

963{
964 if (basic_type != POLYGONTYPE)
965 {
966 return mvt_unsafe_clip_by_box(lwgeom, clip_gbox);
967 }
968
969 if (lwgeom->type != MULTIPOLYGONTYPE || ((LWMPOLY *)lwgeom)->ngeoms == 1)
970 {
971 return mvt_safe_clip_polygon_by_box(lwgeom, clip_gbox);
972 }
973 else
974 {
975 GBOX geom_box;
976 uint32_t i;
977 LWCOLLECTION *lwmg;
979
980 gbox_init(&geom_box);
981 FLAGS_SET_GEODETIC(geom_box.flags, 0);
982 lwgeom_calculate_gbox(lwgeom, &geom_box);
983
984 lwmg = ((LWCOLLECTION *)lwgeom);
986 MULTIPOLYGONTYPE, lwgeom->srid, FLAGS_GET_Z(lwgeom->flags), FLAGS_GET_M(lwgeom->flags));
987 for (i = 0; i < lwmg->ngeoms; i++)
988 {
989 LWGEOM *clipped = mvt_safe_clip_polygon_by_box(lwcollection_getsubgeom(lwmg, i), clip_gbox);
990 if (clipped)
991 {
992 clipped = lwgeom_to_basic_type(clipped, POLYGONTYPE);
993 if (!lwgeom_is_empty(clipped) &&
994 (clipped->type == POLYGONTYPE || clipped->type == MULTIPOLYGONTYPE))
995 {
996 if (!lwgeom_is_collection(clipped))
997 {
998 lwcollection_add_lwgeom(res, clipped);
999 }
1000 else
1001 {
1002 uint32_t j;
1003 for (j = 0; j < ((LWCOLLECTION *)clipped)->ngeoms; j++)
1005 res, lwcollection_getsubgeom((LWCOLLECTION *)clipped, j));
1006 }
1007 }
1008 }
1009 }
1010 return lwcollection_as_lwgeom(res);
1011 }
1012}
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition gbox.c:40
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
#define MULTIPOLYGONTYPE
Definition liblwgeom.h:121
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
Definition lwgeom.c:1079
#define POLYGONTYPE
Definition liblwgeom.h:118
#define FLAGS_GET_M(flags)
Definition liblwgeom.h:180
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
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
#define FLAGS_SET_GEODETIC(flags, value)
Definition liblwgeom.h:189
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
Definition lwgeom.c:291
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
static LWGEOM * mvt_safe_clip_polygon_by_box(LWGEOM *lwg_in, GBOX *clip_box)
Clips an input geometry using GEOSIntersection It used to try to use GEOSClipByRect (as mvt_unsafe_cl...
Definition mvt.c:883
static LWGEOM * lwgeom_to_basic_type(LWGEOM *geom, uint8 original_type)
In place process a collection to find a concrete geometry object and expose that as the actual object...
Definition mvt.c:823
static LWGEOM * mvt_unsafe_clip_by_box(LWGEOM *lwg_in, GBOX *clip_box)
Definition mvt.c:848
tuple res
Definition window.py:79
lwflags_t flags
Definition liblwgeom.h:339
uint32_t ngeoms
Definition liblwgeom.h:566
uint8_t type
Definition liblwgeom.h:448
lwflags_t flags
Definition liblwgeom.h:549
int32_t srid
Definition liblwgeom.h:548

References GBOX::flags, LWGEOM::flags, FLAGS_GET_M, FLAGS_GET_Z, FLAGS_SET_GEODETIC, gbox_init(), lwcollection_add_lwgeom(), lwcollection_as_lwgeom(), lwcollection_construct_empty(), lwcollection_getsubgeom(), lwgeom_calculate_gbox(), lwgeom_is_collection(), lwgeom_is_empty(), lwgeom_to_basic_type(), MULTIPOLYGONTYPE, mvt_safe_clip_polygon_by_box(), mvt_unsafe_clip_by_box(), LWCOLLECTION::ngeoms, POLYGONTYPE, LWGEOM::srid, and LWGEOM::type.

Referenced by mvt_clip_and_validate_geos().

Here is the call graph for this function:
Here is the caller graph for this function: