PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwgeom_offsetcurve()

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

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

1431 {
1432  int32_t srid = RESULT_SRID(geom);
1433  LWGEOM *result = NULL;
1434  LWGEOM *noded = NULL;
1435  if (srid == SRID_INVALID) return NULL;
1436 
1437  if (lwgeom_dimension(geom) != 1)
1438  {
1439  lwerror("%s: input is not linear", __func__, lwtype_name(geom->type));
1440  return NULL;
1441  }
1442 
1443  while (!result)
1444  {
1445  switch (geom->type)
1446  {
1447  case LINETYPE:
1448  result = lwline_offsetcurve(lwgeom_as_lwline(geom), size, quadsegs, joinStyle, mitreLimit);
1449  break;
1450  case COLLECTIONTYPE:
1451  case MULTILINETYPE:
1452  result = lwcollection_offsetcurve(lwgeom_as_lwcollection(geom), size, quadsegs, joinStyle, mitreLimit);
1453  break;
1454  default:
1455  lwerror("%s: unsupported geometry type: %s", __func__, lwtype_name(geom->type));
1456  return NULL;
1457  }
1458 
1459  if (result)
1460  {
1461  if (noded) lwgeom_free(noded);
1462  return result;
1463  }
1464  else if (!noded)
1465  {
1466  noded = lwgeom_node(geom);
1467  if (!noded)
1468  {
1469  lwerror("lwgeom_offsetcurve: cannot node input");
1470  return NULL;
1471  }
1472  geom = noded;
1473  }
1474  else
1475  {
1476  lwgeom_free(noded);
1477  lwerror("lwgeom_offsetcurve: noded geometry cannot be offset");
1478  return NULL;
1479  }
1480  }
1481 
1482  return result;
1483 }
static LWGEOM * lwcollection_offsetcurve(const LWCOLLECTION *col, double size, int quadsegs, int joinStyle, double mitreLimit)
static LWGEOM * lwline_offsetcurve(const LWLINE *lwline, double size, int quadsegs, int joinStyle, double mitreLimit)
#define RESULT_SRID(...)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:170
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
#define SRID_INVALID
Definition: liblwgeom.h:192
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LINETYPE
Definition: liblwgeom.h:86
int lwgeom_dimension(const LWGEOM *geom)
For an LWGEOM, returns 0 for points, 1 for lines, 2 for polygons, 3 for volume, and the max dimension...
Definition: lwgeom.c:1287
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:224
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
uint8_t type
Definition: liblwgeom.h:399

References COLLECTIONTYPE, LINETYPE, lwcollection_offsetcurve(), lwerror(), lwgeom_as_lwcollection(), lwgeom_as_lwline(), lwgeom_dimension(), lwgeom_free(), lwgeom_node(), lwline_offsetcurve(), lwtype_name(), MULTILINETYPE, RESULT_SRID, SRID_INVALID, and LWGEOM::type.

Referenced by lwcollection_offsetcurve(), lwgeom_clip_to_ordinate_range(), ST_OffsetCurve(), test_geos_offsetcurve(), and test_geos_offsetcurve_crash().

Here is the call graph for this function:
Here is the caller graph for this function: