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

Definition at line 3242 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().

3243 {
3244  GEOSGeometry *gg;
3245  POINT4D p4d;
3246  POINTARRAY *pa;
3247  POINTARRAY **pas;
3248  LWPOLY *poly;
3249  LWGEOM *g;
3250 
3251  pas = lwalloc(sizeof(POINTARRAY*));
3252 
3253  initGEOS(lwnotice, lwgeom_geos_error);
3254 
3255  if ( isclosed )
3256  {
3257  pas[0] = ptarray_clone_deep( geom->points );
3258  poly = lwpoly_construct(0, 0, 1, pas);
3259  gg = LWGEOM2GEOS( lwpoly_as_lwgeom(poly), 0 );
3260  lwpoly_free(poly); /* should also delete the pointarrays */
3261  }
3262  else
3263  {
3264  pa = geom->points;
3265  getPoint4d_p(pa, 0, &p4d);
3266  pas[0] = ptarray_clone_deep( pa );
3267  /* don't bother dup check */
3268  if ( LW_FAILURE == ptarray_append_point(pas[0], &p4d, LW_TRUE) )
3269  {
3270  ptarray_free(pas[0]);
3271  lwfree(pas);
3272  lwerror("Could not append point to pointarray");
3273  return NULL;
3274  }
3275  poly = lwpoly_construct(0, NULL, 1, pas);
3276  /* make valid, in case the edge self-intersects on its first-last
3277  * vertex segment */
3279  lwpoly_free(poly); /* should also delete the pointarrays */
3280  if ( ! g )
3281  {
3282  lwerror("Could not make edge motion area valid");
3283  return NULL;
3284  }
3285  gg = LWGEOM2GEOS(g, 0);
3286  lwgeom_free(g);
3287  }
3288  if ( ! gg )
3289  {
3290  lwerror("Could not convert old edge area geometry to GEOS: %s",
3292  return NULL;
3293  }
3294  return gg;
3295 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:89
void lwfree(void *mem)
Definition: lwutil.c:242
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1063
void ptarray_free(POINTARRAY *pa)
Definition: ptarray.c:330
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition: lwgeom.c:252
#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:150
#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:634
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
void * lwalloc(size_t size)
Definition: lwutil.c:227
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:102
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:244
POINTARRAY * points
Definition: liblwgeom.h:421

Here is the call graph for this function:

Here is the caller graph for this function: