PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_remove_repeated_points()

LWGEOM* lwgeom_remove_repeated_points ( const LWGEOM in,
double  tolerance 
)

Remove repeated points!

Definition at line 1456 of file lwgeom.c.

References CIRCSTRINGTYPE, COLLECTIONTYPE, COMPOUNDTYPE, CURVEPOLYTYPE, LINETYPE, lwcollection_remove_repeated_points(), LWDEBUGF, lwgeom_clone_deep(), lwgeom_is_empty(), lwline_remove_repeated_points(), lwmpoint_remove_repeated_points(), lwnotice(), lwpoly_remove_repeated_points(), lwtype_name(), MULTICURVETYPE, MULTILINETYPE, MULTIPOINTTYPE, MULTIPOLYGONTYPE, MULTISURFACETYPE, POINTTYPE, POLYGONTYPE, POLYHEDRALSURFACETYPE, TINTYPE, TRIANGLETYPE, LWGEOM::type, and LWPOLY::type.

Referenced by _lwt_AddEdge(), _lwt_FindAdjacentEdges(), _lwt_toposnap(), lwcollection_remove_repeated_points(), and ST_RemoveRepeatedPoints().

1457 {
1458  LWDEBUGF(4, "lwgeom_remove_repeated_points got type %s",
1459  lwtype_name(in->type));
1460 
1461  if(lwgeom_is_empty(in))
1462  {
1463  return lwgeom_clone_deep(in);
1464  }
1465 
1466  switch (in->type)
1467  {
1468  case MULTIPOINTTYPE:
1469  return lwmpoint_remove_repeated_points((LWMPOINT*)in, tolerance);
1470  break;
1471  case LINETYPE:
1472  return lwline_remove_repeated_points((LWLINE*)in, tolerance);
1473 
1474  case MULTILINETYPE:
1475  case COLLECTIONTYPE:
1476  case MULTIPOLYGONTYPE:
1477  case POLYHEDRALSURFACETYPE:
1478  return lwcollection_remove_repeated_points((LWCOLLECTION *)in, tolerance);
1479 
1480  case POLYGONTYPE:
1481  return lwpoly_remove_repeated_points((LWPOLY *)in, tolerance);
1482  break;
1483 
1484  case POINTTYPE:
1485  case TRIANGLETYPE:
1486  case TINTYPE:
1487  /* No point is repeated for a single point, or for Triangle or TIN */
1488  return lwgeom_clone_deep(in);
1489 
1490  case CIRCSTRINGTYPE:
1491  case COMPOUNDTYPE:
1492  case MULTICURVETYPE:
1493  case CURVEPOLYTYPE:
1494  case MULTISURFACETYPE:
1495  /* Dunno how to handle these, will return untouched */
1496  return lwgeom_clone_deep(in);
1497 
1498  default:
1499  lwnotice("%s: unsupported geometry type: %s",
1500  __func__, lwtype_name(in->type));
1501  return lwgeom_clone_deep(in);
1502  break;
1503  }
1504  return 0;
1505 }
#define LINETYPE
Definition: liblwgeom.h:86
#define MULTICURVETYPE
Definition: liblwgeom.h:95
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
#define POLYGONTYPE
Definition: liblwgeom.h:87
#define CURVEPOLYTYPE
Definition: liblwgeom.h:94
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
#define MULTIPOINTTYPE
Definition: liblwgeom.h:88
#define TRIANGLETYPE
Definition: liblwgeom.h:98
LWGEOM * lwmpoint_remove_repeated_points(const LWMPOINT *in, double tolerance)
Definition: lwmpoint.c:92
#define POLYHEDRALSURFACETYPE
Definition: liblwgeom.h:97
LWGEOM * lwcollection_remove_repeated_points(const LWCOLLECTION *in, double tolerance)
Definition: lwcollection.c:460
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep-clone an LWGEOM object.
Definition: lwgeom.c:482
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
#define TINTYPE
Definition: liblwgeom.h:99
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
#define MULTIPOLYGONTYPE
Definition: liblwgeom.h:90
LWGEOM * lwline_remove_repeated_points(const LWLINE *in, double tolerance)
Definition: lwline.c:456
LWGEOM * lwpoly_remove_repeated_points(const LWPOLY *in, double tolerance)
Definition: lwpoly.c:402
#define MULTISURFACETYPE
Definition: liblwgeom.h:96
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
uint8_t type
Definition: liblwgeom.h:396
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
#define MULTILINETYPE
Definition: liblwgeom.h:89
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
#define COLLECTIONTYPE
Definition: liblwgeom.h:91
Here is the call graph for this function:
Here is the caller graph for this function: