PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwcollection_wrapx()

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

Definition at line 121 of file lwgeom_wrapx.c.

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

Referenced by lwgeom_split_wrapx(), and lwgeom_wrapx().

122 {
123  LWGEOM** wrap_geoms;
124  LWCOLLECTION* out;
125  int 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  lwnotice("Error wrapping geometry, cleaning up");
142  while ((--i)>=0) {
143  lwnotice("cleaning geometry %d (%p)", i, wrap_geoms[i]);
144  lwgeom_free(wrap_geoms[i]);
145  }
146  lwfree(wrap_geoms);
147  lwnotice("cleanup complete");
148  return NULL;
149  }
150  if ( outtype != COLLECTIONTYPE ) {
151  if ( MULTITYPE[wrap_geoms[i]->type] != outtype )
152  {
153  outtype = COLLECTIONTYPE;
154  }
155  }
156  }
157 
158  /* Now wrap_geoms has wrap_geoms_size geometries */
159  out = lwcollection_construct(outtype, lwcoll_in->srid, NULL,
160  lwcoll_in->ngeoms, wrap_geoms);
161 
162  return out;
163 }
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
void lwfree(void *mem)
Definition: lwutil.c:244
uint8_t type
Definition: liblwgeom.h:503
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
LWGEOM ** geoms
Definition: liblwgeom.h:509
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom_in, double cutx, double amount)
wrap geometry on given cut x value
Definition: lwgeom_wrapx.c:167
int32_t srid
Definition: liblwgeom.h:506
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
Definition: lwgeom.c:313
type
Definition: ovdump.py:41
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: