PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwgeom_offsetcurve()

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

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

1348 {
1349  int32_t srid = RESULT_SRID(geom);
1350  LWGEOM *result = NULL;
1351  LWGEOM *noded = NULL;
1352  if (srid == SRID_INVALID) return NULL;
1353 
1354  if (lwgeom_dimension(geom) != 1)
1355  {
1356  lwerror("%s: input is not linear (type %s)", __func__, lwtype_name(geom->type));
1357  return NULL;
1358  }
1359 
1360  while (!result)
1361  {
1362  switch (geom->type)
1363  {
1364  case LINETYPE:
1365  result = lwline_offsetcurve(lwgeom_as_lwline(geom), size, quadsegs, joinStyle, mitreLimit);
1366  break;
1367  case COLLECTIONTYPE:
1368  case MULTILINETYPE:
1369  result = lwcollection_offsetcurve(lwgeom_as_lwcollection(geom), size, quadsegs, joinStyle, mitreLimit);
1370  break;
1371  default:
1372  lwerror("%s: unsupported geometry type: %s", __func__, lwtype_name(geom->type));
1373  return NULL;
1374  }
1375 
1376  if (result)
1377  {
1378  if (noded) lwgeom_free(noded);
1379  return result;
1380  }
1381  else if (!noded)
1382  {
1383  noded = lwgeom_node(geom);
1384  if (!noded)
1385  {
1386  lwerror("lwgeom_offsetcurve: cannot node input");
1387  return NULL;
1388  }
1389  geom = noded;
1390  }
1391  else
1392  {
1393  lwgeom_free(noded);
1394  lwerror("lwgeom_offsetcurve: noded geometry cannot be offset");
1395  return NULL;
1396  }
1397  }
1398 
1399  return result;
1400 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:267
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:179
#define COLLECTIONTYPE
Definition: liblwgeom.h:108
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
#define SRID_INVALID
Definition: liblwgeom.h:219
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1218
#define MULTILINETYPE
Definition: liblwgeom.h:106
#define LINETYPE
Definition: liblwgeom.h:103
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:1361
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
Definition: lwgeom.c:233
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
uint8_t type
Definition: liblwgeom.h:462

References COLLECTIONTYPE, LINETYPE, lwcollection_offsetcurve(), lwerror(), lwgeom_as_lwcollection(), lwgeom_as_lwline(), lwgeom_dimension(), lwgeom_free(), lwgeom_node(), lwline_offsetcurve(), lwtype_name(), MULTILINETYPE, result, 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: