PostGIS  2.2.7dev-r@@SVN_REVISION@@
LWGEOM* lwgeom_offsetcurve ( const LWLINE lwline,
double  size,
int  quadsegs,
int  joinStyle,
double  mitreLimit 
)

Definition at line 1545 of file liblwgeom/lwgeom_geos.c.

References GEOS2LWGEOM(), LWDEBUGF, lwerror(), LWGEOM2GEOS(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwgeom_get_srid(), lwgeom_has_z(), lwline_as_lwgeom(), and lwnotice().

Referenced by lwgeom_clip_to_ordinate_range(), and ST_OffsetCurve().

1546 {
1547 #if POSTGIS_GEOS_VERSION < 32
1548  lwerror("lwgeom_offsetcurve: GEOS 3.2 or higher required");
1549 #else
1550  GEOSGeometry *g1, *g3;
1551  LWGEOM *lwgeom_result;
1552  LWGEOM *lwgeom_in = lwline_as_lwgeom(lwline);
1553 
1554  initGEOS(lwnotice, lwgeom_geos_error);
1555 
1556  g1 = (GEOSGeometry *)LWGEOM2GEOS(lwgeom_in, 0);
1557  if ( ! g1 )
1558  {
1559  lwerror("lwgeom_offsetcurve: Geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1560  return NULL;
1561  }
1562 
1563 #if POSTGIS_GEOS_VERSION < 33
1564  /* Size is always positive for GEOSSingleSidedBuffer, and a flag determines left/right */
1565  g3 = GEOSSingleSidedBuffer(g1, size < 0 ? -size : size,
1566  quadsegs, joinStyle, mitreLimit,
1567  size < 0 ? 0 : 1);
1568 #else
1569  g3 = GEOSOffsetCurve(g1, size, quadsegs, joinStyle, mitreLimit);
1570 #endif
1571  /* Don't need input geometry anymore */
1572  GEOSGeom_destroy(g1);
1573 
1574  if (g3 == NULL)
1575  {
1576  lwerror("GEOSOffsetCurve: %s", lwgeom_geos_errmsg);
1577  return NULL;
1578  }
1579 
1580  LWDEBUGF(3, "result: %s", GEOSGeomToWKT(g3));
1581 
1582  GEOSSetSRID(g3, lwgeom_get_srid(lwgeom_in));
1583  lwgeom_result = GEOS2LWGEOM(g3, lwgeom_has_z(lwgeom_in));
1584  GEOSGeom_destroy(g3);
1585 
1586  if (lwgeom_result == NULL)
1587  {
1588  lwerror("lwgeom_offsetcurve: GEOS2LWGEOM returned null");
1589  return NULL;
1590  }
1591 
1592  return lwgeom_result;
1593 
1594 #endif /* POSTGIS_GEOS_VERSION < 32 */
1595 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:61
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:822
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:836
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
void lwgeom_geos_error(const char *fmt,...)
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:74

Here is the call graph for this function:

Here is the caller graph for this function: