PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ lwgeom_offsetcurve()

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

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

1649 {
1650  int32_t srid = RESULT_SRID(geom);
1651  LWGEOM *result = NULL;
1652  LWGEOM *noded = NULL;
1653  if (srid == SRID_INVALID) return NULL;
1654 
1655  if (lwgeom_dimension(geom) != 1)
1656  {
1657  lwerror("%s: input is not linear", __func__, lwtype_name(geom->type));
1658  return NULL;
1659  }
1660 
1661  while (!result)
1662  {
1663  switch (geom->type)
1664  {
1665  case LINETYPE:
1666  result = lwline_offsetcurve(lwgeom_as_lwline(geom), size, quadsegs, joinStyle, mitreLimit);
1667  break;
1668  case COLLECTIONTYPE:
1669  case MULTILINETYPE:
1670  result = lwcollection_offsetcurve(lwgeom_as_lwcollection(geom), size, quadsegs, joinStyle, mitreLimit);
1671  break;
1672  default:
1673  lwerror("%s: unsupported geometry type: %s", __func__, lwtype_name(geom->type));
1674  return NULL;
1675  }
1676 
1677  if (result)
1678  {
1679  if (noded) lwgeom_free(noded);
1680  return result;
1681  }
1682  else if (!noded)
1683  {
1684  noded = lwgeom_node(geom);
1685  if (!noded)
1686  {
1687  lwerror("lwgeom_offsetcurve: cannot node input");
1688  return NULL;
1689  }
1690  geom = noded;
1691  }
1692  else
1693  {
1694  lwgeom_free(noded);
1695  lwerror("lwgeom_offsetcurve: noded geometry cannot be offset");
1696  return NULL;
1697  }
1698  }
1699 
1700  return result;
1701 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
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:1155
#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:1298
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 lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
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: