PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_offsetcurve()

LWGEOM* lwgeom_offsetcurve ( const LWLINE lwline,
double  size,
int  quadsegs,
int  joinStyle,
double  mitreLimit 
)

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

1637 {
1638  GEOSGeometry *g1, *g3;
1639  LWGEOM *lwgeom_result;
1640  LWGEOM *lwgeom_in = lwline_as_lwgeom(lwline);
1641 
1642  initGEOS(lwnotice, lwgeom_geos_error);
1643 
1644  g1 = (GEOSGeometry *)LWGEOM2GEOS(lwgeom_in, 0);
1645  if ( ! g1 )
1646  {
1647  lwerror("lwgeom_offsetcurve: Geometry could not be converted to GEOS: %s", lwgeom_geos_errmsg);
1648  return NULL;
1649  }
1650 
1651  g3 = GEOSOffsetCurve(g1, size, quadsegs, joinStyle, mitreLimit);
1652 
1653  /* Don't need input geometry anymore */
1654  GEOSGeom_destroy(g1);
1655 
1656  if (g3 == NULL)
1657  {
1658  lwerror("GEOSOffsetCurve: %s", lwgeom_geos_errmsg);
1659  return NULL;
1660  }
1661 
1662  LWDEBUGF(3, "result: %s", GEOSGeomToWKT(g3));
1663 
1664  GEOSSetSRID(g3, lwgeom_get_srid(lwgeom_in));
1665  lwgeom_result = GEOS2LWGEOM(g3, lwgeom_has_z(lwgeom_in));
1666  GEOSGeom_destroy(g3);
1667 
1668  if (lwgeom_result == NULL)
1669  {
1670  lwerror("lwgeom_offsetcurve: GEOS2LWGEOM returned null");
1671  return NULL;
1672  }
1673 
1674  return lwgeom_result;
1675 }
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:871
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:885
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:298
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:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
Here is the call graph for this function:
Here is the caller graph for this function: