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

◆ lwcollection_wrapx()

static LWCOLLECTION * lwcollection_wrapx ( const LWCOLLECTION lwcoll_in,
double  cutx,
double  amount 
)
static

Definition at line 121 of file lwgeom_wrapx.c.

122{
123 LWGEOM** wrap_geoms;
124 LWCOLLECTION* out;
125 uint32_t i;
126 int outtype = lwcoll_in->type;
127
128 wrap_geoms = lwalloc(lwcoll_in->ngeoms * sizeof(LWGEOM*));
129 if ( ! wrap_geoms )
130 {
131 lwerror("Out of virtual memory");
132 return NULL;
133 }
134
135 for (i=0; i<lwcoll_in->ngeoms; ++i)
136 {
137 LWDEBUGF(3, "Wrapping collection element %d", i);
138 wrap_geoms[i] = lwgeom_wrapx(lwcoll_in->geoms[i], cutx, amount);
139 /* an exception should prevent this from ever returning NULL */
140 if ( ! wrap_geoms[i] ) {
141 uint32_t j;
142 lwnotice("Error wrapping geometry, cleaning up");
143 for (j = 0; j < i; j++)
144 {
145 lwnotice("cleaning geometry %d (%p)", j, (void *) wrap_geoms[j]);
146 lwgeom_free(wrap_geoms[j]);
147 }
148 lwfree(wrap_geoms);
149 lwnotice("cleanup complete");
150 return NULL;
151 }
152 if ( outtype != COLLECTIONTYPE ) {
153 if ( MULTITYPE[wrap_geoms[i]->type] != outtype )
154 {
155 outtype = COLLECTIONTYPE;
156 }
157 }
158 }
159
160 /* Now wrap_geoms has wrap_geoms_size geometries */
161 out = lwcollection_construct(outtype, lwcoll_in->srid, NULL,
162 lwcoll_in->ngeoms, wrap_geoms);
163
164 return out;
165}
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define COLLECTIONTYPE
Definition liblwgeom.h:108
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
void * lwalloc(size_t size)
Definition lwutil.c:227
void lwfree(void *mem)
Definition lwutil.c:248
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
Definition lwgeom.c:382
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void lwnotice(const char *fmt,...) __attribute__((format(printf
Write a notice out to the notice handler.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom_in, double cutx, double amount)
wrap geometry on given cut x value
uint32_t ngeoms
Definition liblwgeom.h:580
uint8_t type
Definition liblwgeom.h:578
LWGEOM ** geoms
Definition liblwgeom.h:575
int32_t srid
Definition liblwgeom.h:576

References COLLECTIONTYPE, LWCOLLECTION::geoms, lwalloc(), lwcollection_construct(), LWDEBUGF, lwerror(), lwfree(), lwgeom_free(), lwgeom_wrapx(), lwnotice(), MULTITYPE, LWCOLLECTION::ngeoms, LWCOLLECTION::srid, and LWCOLLECTION::type.

Referenced by lwgeom_split_wrapx(), and lwgeom_wrapx().

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