PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum ST_RemoveRepeatedPoints ( PG_FUNCTION_ARGS  )

Definition at line 2756 of file lwgeom_functions_basic.c.

References geometry_serialize(), gserialized_get_type(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_remove_repeated_points(), and POINTTYPE.

2757 {
2758  GSERIALIZED *g_in = PG_GETARG_GSERIALIZED_P(0);
2759  int type = gserialized_get_type(g_in);
2760  GSERIALIZED *g_out;
2761  LWGEOM *lwgeom_in = NULL;
2762  LWGEOM *lwgeom_out = NULL;
2763  double tolerance = 0.0;
2764 
2765  /* Don't even start to think about points */
2766  if ( type == POINTTYPE )
2767  PG_RETURN_POINTER(g_in);
2768 
2769  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
2770  tolerance = PG_GETARG_FLOAT8(1);
2771 
2772  lwgeom_in = lwgeom_from_gserialized(g_in);
2773  lwgeom_out = lwgeom_remove_repeated_points(lwgeom_in, tolerance);
2774  g_out = geometry_serialize(lwgeom_out);
2775 
2776  if ( lwgeom_out != lwgeom_in )
2777  {
2778  lwgeom_free(lwgeom_out);
2779  }
2780 
2781  lwgeom_free(lwgeom_in);
2782 
2783  PG_FREE_IF_COPY(g_in, 0);
2784  PG_RETURN_POINTER(g_out);
2785 }
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
Definition: g_serialized.c:86
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
Definition: lwgeom.c:1496

Here is the call graph for this function: