PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ _lwt_EdgeMotionArea()

static GEOSGeometry* _lwt_EdgeMotionArea ( LWLINE geom,
int  isclosed 
)
static

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

3213 {
3214  GEOSGeometry *gg;
3215  POINT4D p4d;
3216  POINTARRAY *pa;
3217  POINTARRAY **pas;
3218  LWPOLY *poly;
3219  LWGEOM *g;
3220 
3221  pas = lwalloc(sizeof(POINTARRAY*));
3222 
3223  initGEOS(lwnotice, lwgeom_geos_error);
3224 
3225  if ( isclosed )
3226  {
3227  pas[0] = ptarray_clone_deep( geom->points );
3228  poly = lwpoly_construct(0, 0, 1, pas);
3229  gg = LWGEOM2GEOS( lwpoly_as_lwgeom(poly), 0 );
3230  lwpoly_free(poly); /* should also delete the pointarrays */
3231  }
3232  else
3233  {
3234  pa = geom->points;
3235  getPoint4d_p(pa, 0, &p4d);
3236  pas[0] = ptarray_clone_deep( pa );
3237  /* don't bother dup check */
3238  if ( LW_FAILURE == ptarray_append_point(pas[0], &p4d, LW_TRUE) )
3239  {
3240  ptarray_free(pas[0]);
3241  lwfree(pas);
3242  lwerror("Could not append point to pointarray");
3243  return NULL;
3244  }
3245  poly = lwpoly_construct(0, NULL, 1, pas);
3246  /* make valid, in case the edge self-intersects on its first-last
3247  * vertex segment */
3249  lwpoly_free(poly); /* should also delete the pointarrays */
3250  if ( ! g )
3251  {
3252  lwerror("Could not make edge motion area valid");
3253  return NULL;
3254  }
3255  gg = LWGEOM2GEOS(g, 0);
3256  lwgeom_free(g);
3257  }
3258  if ( ! gg )
3259  {
3260  lwerror("Could not convert old edge area geometry to GEOS: %s",
3262  return NULL;
3263  }
3264  return gg;
3265 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:61
void lwfree(void *mem)
Definition: lwutil.c:214
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
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:239
#define LW_FAILURE
Definition: liblwgeom.h:64
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_TRUE, 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:29
void lwpoly_free(LWPOLY *poly)
Definition: lwpoly.c:79
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:61
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:199
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
Definition: lwgeom_api.c:231
POINTARRAY * points
Definition: liblwgeom.h:406
Here is the call graph for this function:
Here is the caller graph for this function: