PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwgeom_clip_by_rect()

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

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

938 {
939  LWGEOM *result;
940  GEOSGeometry *g1, *g3;
941  int is3d;
942 
943  /* A.Intersection(Empty) == Empty */
944  if ( lwgeom_is_empty(geom1) )
945  return lwgeom_clone_deep(geom1);
946 
947  is3d = FLAGS_GET_Z(geom1->flags);
948 
949  initGEOS(lwnotice, lwgeom_geos_error);
950 
951  if (!(g1 = LWGEOM2GEOS(geom1, AUTOFIX)))
952  GEOS_FAIL_DEBUG();
953 
954  if (!(g3 = GEOSClipByRect(g1, x1, y1, x2, y2)))
956 
957  GEOS_FREE(g1);
958  result = GEOS2LWGEOM(g3, is3d);
959  GEOS_FREE(g3);
960 
961  if (!result)
962  GEOS_FAIL_DEBUG();
963 
964  result->srid = geom1->srid;
965 
966  return result;
967 }
#define GEOS_FREE(...)
#define AUTOFIX
#define GEOS_FREE_AND_FAIL_DEBUG(...)
#define GEOS_FAIL_DEBUG()
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, uint8_t want3d)
void lwgeom_geos_error(const char *fmt,...)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
Definition: lwgeom.c:511
#define FLAGS_GET_Z(flags)
Definition: liblwgeom.h:179
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
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
int32_t srid
Definition: liblwgeom.h:446
lwflags_t flags
Definition: liblwgeom.h:447

References AUTOFIX, LWGEOM::flags, FLAGS_GET_Z, GEOS2LWGEOM(), GEOS_FAIL_DEBUG, GEOS_FREE, GEOS_FREE_AND_FAIL_DEBUG, LWGEOM2GEOS(), lwgeom_clone_deep(), lwgeom_geos_error(), lwgeom_is_empty(), lwnotice(), 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: