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

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

1269 {
1270 #if POSTGIS_GEOS_VERSION < 32
1271  lwerror("lwgeom_offsetcurve: GEOS 3.2 or higher required");
1272 #else
1273  GEOSGeometry *g1, *g3;
1274  LWGEOM *lwgeom_result;
1275  LWGEOM *lwgeom_in = lwline_as_lwgeom(lwline);
1276 
1277  initGEOS(lwnotice, lwgeom_geos_error);
1278 
1279  g1 = (GEOSGeometry *)LWGEOM2GEOS(lwgeom_in);
1280  if ( ! g1 )
1281  {
1282  lwerror("lwgeom_offsetcurve: Geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1283  return NULL;
1284  }
1285 
1286 #if POSTGIS_GEOS_VERSION < 33
1287  /* Size is always positive for GEOSSingleSidedBuffer, and a flag determines left/right */
1288  g3 = GEOSSingleSidedBuffer(g1, size < 0 ? -size : size,
1289  quadsegs, joinStyle, mitreLimit,
1290  size < 0 ? 0 : 1);
1291 #else
1292  g3 = GEOSOffsetCurve(g1, size, quadsegs, joinStyle, mitreLimit);
1293 #endif
1294  /* Don't need input geometry anymore */
1295  GEOSGeom_destroy(g1);
1296 
1297  if (g3 == NULL)
1298  {
1299  lwerror("GEOSOffsetCurve: %s", lwgeom_geos_errmsg);
1300  return NULL;
1301  }
1302 
1303  LWDEBUGF(3, "result: %s", GEOSGeomToWKT(g3));
1304 
1305  GEOSSetSRID(g3, lwgeom_get_srid(lwgeom_in));
1306  lwgeom_result = GEOS2LWGEOM(g3, lwgeom_has_z(lwgeom_in));
1307  GEOSGeom_destroy(g3);
1308 
1309  if (lwgeom_result == NULL)
1310  {
1311  lwerror("lwgeom_offsetcurve: GEOS2LWGEOM returned null");
1312  return NULL;
1313  }
1314 
1315  return lwgeom_result;
1316 
1317 #endif /* POSTGIS_GEOS_VERSION < 32 */
1318 }
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:778
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:792
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:67
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:54
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
void lwgeom_geos_error(const char *fmt,...)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:55

Here is the call graph for this function:

Here is the caller graph for this function: