25 #include "../postgis_config.h"
58 LWDEBUGF(2,
"BOX X range is %g..%g, cutx:%g, amount:%g", box_in->
xmin, box_in->
xmax, cutx, amount);
61 if ( ( amount < 0 && box_in->xmin >= cutx ) || ( amount > 0 && box_in->
xmax <= cutx ) )
65 LWDEBUGG(2, split,
"returning the translated geometry");
70 if ( ( amount < 0 && box_in->xmax <= cutx ) || ( amount > 0 && box_in->
xmin >= cutx ) )
73 LWDEBUGG(2, split,
"returning the cloned geometry");
82 pt.
y = box_in->
ymin - 1;
84 pt.
y = box_in->
ymax + 1;
88 LWDEBUG(2,
"splitting the geometry");
97 LWDEBUGG(2, split,
"split geometry");
104 lwnotice(
"WARNING: unexpected lack of split in lwgeom_split_wrapx");
112 LWDEBUGF(2,
"col_out:%p, unaryunion_out:%p", col_out, out);
126 int outtype = lwcoll_in->
type;
131 lwerror(
"Out of virtual memory");
135 for (i=0; i<lwcoll_in->
ngeoms; ++i)
137 LWDEBUGF(3,
"Wrapping collection element %d", i);
140 if ( ! wrap_geoms[i] ) {
142 lwnotice(
"Error wrapping geometry, cleaning up");
143 for (j = 0; j < i; j++)
145 lwnotice(
"cleaning geometry %d (%p)", j, wrap_geoms[j]);
162 lwcoll_in->
ngeoms, wrap_geoms);
174 LWDEBUG(2,
"geom is empty, cloning");
181 LWDEBUG(2,
"amount is zero, cloning");
185 switch (lwgeom_in->
type)
189 LWDEBUG(2,
"split-wrapping line or polygon");
198 LWDEBUGF(2,
"POINT X is %g, cutx:%g, amount:%g", pt4d.
x, cutx, amount);
200 if ( ( amount < 0 && pt4d.x > cutx ) || ( amount > 0 && pt4d.
x < cutx ) )
212 LWDEBUG(2,
"collection-wrapping multi");
218 lwerror(
"Wrapping of %s geometries is unsupported",
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_split(const LWGEOM *lwgeom_in, const LWGEOM *blade_in)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
void lwgeom_affine(LWGEOM *geom, const AFFINE *affine)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
void lwcollection_free(LWCOLLECTION *col)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
void * lwalloc(size_t size)
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
#define LWDEBUGG(level, geom, msg)
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom_in, double cutx, double amount)
wrap geometry on given cut x value
static LWGEOM * lwgeom_split_wrapx(const LWGEOM *geom_in, double cutx, double amount)
static LWCOLLECTION * lwcollection_wrapx(const LWCOLLECTION *lwcoll_in, double cutx, double amount)