PostGIS  2.5.7dev-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.

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, 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 }
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
void lwfree(void *mem)
Definition: lwutil.c:244
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
void * lwalloc(size_t size)
Definition: lwutil.c:229
uint8_t MULTITYPE[NUMTYPES]
Look-up for the correct MULTI* type promotion for singleton types.
Definition: lwgeom.c:345
#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
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
LWGEOM * lwgeom_wrapx(const LWGEOM *lwgeom_in, double cutx, double amount)
wrap geometry on given cut x value
Definition: lwgeom_wrapx.c:169
type
Definition: ovdump.py:41
uint32_t ngeoms
Definition: liblwgeom.h:510
uint8_t type
Definition: liblwgeom.h:506
LWGEOM ** geoms
Definition: liblwgeom.h:512
int32_t srid
Definition: liblwgeom.h:509
unsigned int uint32_t
Definition: uthash.h:78

References COLLECTIONTYPE, LWCOLLECTION::geoms, lwalloc(), lwcollection_construct(), LWDEBUGF, lwerror(), lwfree(), lwgeom_free(), lwgeom_wrapx(), lwnotice(), MULTITYPE, LWCOLLECTION::ngeoms, LWCOLLECTION::srid, LWCOLLECTION::type, and ovdump::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: