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

◆ lwgeom_clip_by_rect()

LWGEOM * lwgeom_clip_by_rect ( const LWGEOM geom1,
double  x1,
double  y1,
double  x2,
double  y2 
)

Definition at line 1090 of file liblwgeom/lwgeom_geos.c.

1091{
1092 LWGEOM *result;
1093 GEOSGeometry *g1, *g3;
1094 int is3d;
1095
1096 /* A.Intersection(Empty) == Empty */
1097 if ( lwgeom_is_empty(geom1) )
1098 return lwgeom_clone_deep(geom1);
1099
1100 is3d = FLAGS_GET_Z(geom1->flags);
1101
1102 initGEOS(lwnotice, lwgeom_geos_error);
1103
1104 if (!(g1 = LWGEOM2GEOS(geom1, AUTOFIX)))
1106
1107 if (!(g3 = GEOSClipByRect(g1, x1, y1, x2, y2)))
1109
1110 GEOS_FREE(g1);
1111 result = GEOS2LWGEOM(g3, is3d);
1112 GEOS_FREE(g3);
1113
1114 if (!result)
1116
1117 result->srid = geom1->srid;
1118
1119 return result;
1120}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
#define GEOS_FREE(...)
#define AUTOFIX
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
#define GEOS_FREE_AND_FAIL_DEBUG(...)
#define GEOS_FAIL_DEBUG()
void lwgeom_geos_error(const char *fmt,...)
void(*) LWGEOM GEOS2LWGEOM)(const GEOSGeometry *geom, uint8_t want3d)
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:165
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition lwgeom.c:557
void lwnotice(const char *fmt,...) __attribute__((format(printf
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)
Definition lwinline.h:199
int32_t srid
Definition liblwgeom.h:460
lwflags_t flags
Definition liblwgeom.h:461

References AUTOFIX, LWGEOM::flags, FLAGS_GET_Z, GEOS_FAIL_DEBUG, GEOS_FREE, GEOS_FREE_AND_FAIL_DEBUG, LWGEOM2GEOS(), lwgeom_clone_deep(), lwgeom_geos_error(), lwgeom_is_empty(), lwnotice(), result, and LWGEOM::srid.

Referenced by mvt_unsafe_clip_by_box(), ST_ClipByBox2d(), and test_lwgeom_clip_by_rect().

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