PostGIS  2.5.0dev-r@@SVN_REVISION@@
static GEOSGeometry* _lwt_EdgeMotionArea ( LWLINE geom,
int  isclosed 
)
static

Definition at line 3275 of file lwgeom_topo.c.

References getPoint4d_p(), LW_FAILURE, LW_TRUE, lwalloc(), lwerror(), lwfree(), LWGEOM2GEOS(), lwgeom_free(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwgeom_make_valid(), lwnotice(), lwpoly_as_lwgeom(), lwpoly_construct(), lwpoly_free(), LWLINE::points, ptarray_append_point(), ptarray_clone_deep(), and ptarray_free().

Referenced by lwt_ChangeEdgeGeom().

3276 {
3277  GEOSGeometry *gg;
3278  POINT4D p4d;
3279  POINTARRAY *pa;
3280  POINTARRAY **pas;
3281  LWPOLY *poly;
3282  LWGEOM *g;
3283 
3284  pas = lwalloc(sizeof(POINTARRAY*));
3285 
3286  initGEOS(lwnotice, lwgeom_geos_error);
3287 
3288  if ( isclosed )
3289  {
3290  pas[0] = ptarray_clone_deep( geom->points );
3291  poly = lwpoly_construct(0, 0, 1, pas);
3292  gg = LWGEOM2GEOS( lwpoly_as_lwgeom(poly), 0 );
3293  lwpoly_free(poly); /* should also delete the pointarrays */
3294  }
3295  else
3296  {
3297  pa = geom->points;
3298  getPoint4d_p(pa, 0, &p4d);
3299  pas[0] = ptarray_clone_deep( pa );
3300  /* don't bother dup check */
3301  if ( LW_FAILURE == ptarray_append_point(pas[0], &p4d, LW_TRUE) )
3302  {
3303  ptarray_free(pas[0]);
3304  lwfree(pas);
3305  lwerror("Could not append point to pointarray");
3306  return NULL;
3307  }
3308  poly = lwpoly_construct(0, NULL, 1, pas);
3309  /* make valid, in case the edge self-intersects on its first-last
3310  * vertex segment */
3312  lwpoly_free(poly); /* should also delete the pointarrays */
3313  if ( ! g )
3314  {
3315  lwerror("Could not make edge motion area valid");
3316  return NULL;
3317  }
3318  gg = LWGEOM2GEOS(g, 0);
3319  lwgeom_free(g);
3320  }
3321  if ( ! gg )
3322  {
3323  lwerror("Could not convert old edge area geometry to GEOS: %s",
3325  return NULL;
3326  }
3327  return gg;
3328 }
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
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:328
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:319
#define LW_FAILURE
Definition: liblwgeom.h:78
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE, then a duplicate point will not be added.
Definition: ptarray.c:156
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
void lwgeom_geos_error(const char *fmt,...)
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition: lwpoly.c:43
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:173
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
Definition: ptarray.c:628
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:113
void * lwalloc(size_t size)
Definition: lwutil.c:229
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: