PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ ST_RemoveRepeatedPoints()

Datum ST_RemoveRepeatedPoints ( PG_FUNCTION_ARGS  )

Definition at line 2786 of file lwgeom_functions_basic.c.

2787 {
2788  GSERIALIZED *g_in = PG_GETARG_GSERIALIZED_P_COPY(0);
2789  uint32_t type = gserialized_get_type(g_in);
2790  GSERIALIZED *g_out;
2791  LWGEOM *lwgeom_in = NULL;
2792  double tolerance = 0.0;
2793  int modified = LW_FALSE;
2794 
2795  /* Don't even start to think about points */
2796  if (type == POINTTYPE)
2797  PG_RETURN_POINTER(g_in);
2798 
2799  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
2800  tolerance = PG_GETARG_FLOAT8(1);
2801 
2802  lwgeom_in = lwgeom_from_gserialized(g_in);
2803  modified = lwgeom_remove_repeated_points_in_place(lwgeom_in, tolerance);
2804  if (!modified)
2805  {
2806  /* Since there were no changes, we can return the input to avoid the serialization */
2807  PG_RETURN_POINTER(g_in);
2808  }
2809 
2810  g_out = geometry_serialize(lwgeom_in);
2811 
2812  pfree(g_in);
2813  PG_RETURN_POINTER(g_out);
2814 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
#define LW_FALSE
Definition: liblwgeom.h:108
int lwgeom_remove_repeated_points_in_place(LWGEOM *in, double tolerance)
Definition: lwgeom.c:1554
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:116
type
Definition: ovdump.py:42
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

References geometry_serialize(), gserialized_get_type(), LW_FALSE, lwgeom_from_gserialized(), lwgeom_remove_repeated_points_in_place(), POINTTYPE, and ovdump::type.

Here is the call graph for this function: