PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ST_RemoveRepeatedPoints()

Datum ST_RemoveRepeatedPoints ( PG_FUNCTION_ARGS  )

Definition at line 2631 of file lwgeom_functions_basic.c.

References LWGEOM::bbox, geometry_serialize(), gserialized_get_type(), lwgeom_add_bbox(), lwgeom_drop_bbox(), lwgeom_free(), lwgeom_from_gserialized(), lwgeom_remove_repeated_points(), PG_FUNCTION_INFO_V1(), POINTTYPE, ST_FlipCoordinates(), and ovdump::type.

Referenced by ST_CollectionHomogenize().

2632 {
2633  GSERIALIZED *g_in = PG_GETARG_GSERIALIZED_P(0);
2634  int type = gserialized_get_type(g_in);
2635  GSERIALIZED *g_out;
2636  LWGEOM *lwgeom_in = NULL;
2637  LWGEOM *lwgeom_out = NULL;
2638  double tolerance = 0.0;
2639 
2640  /* Don't even start to think about points */
2641  if ( type == POINTTYPE )
2642  PG_RETURN_POINTER(g_in);
2643 
2644  if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
2645  tolerance = PG_GETARG_FLOAT8(1);
2646 
2647  lwgeom_in = lwgeom_from_gserialized(g_in);
2648  lwgeom_out = lwgeom_remove_repeated_points(lwgeom_in, tolerance);
2649 
2650  /* COMPUTE_BBOX TAINTING */
2651  if (lwgeom_in->bbox)
2652  {
2653  lwgeom_drop_bbox(lwgeom_out);
2654  lwgeom_add_bbox(lwgeom_out);
2655  }
2656 
2657  g_out = geometry_serialize(lwgeom_out);
2658 
2659  if ( lwgeom_out != lwgeom_in )
2660  {
2661  lwgeom_free(lwgeom_out);
2662  }
2663 
2664  lwgeom_free(lwgeom_in);
2665 
2666  PG_FREE_IF_COPY(g_in, 0);
2667  PG_RETURN_POINTER(g_out);
2668 }
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
GBOX * bbox
Definition: liblwgeom.h:398
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
Definition: lwgeom.c:635
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
Definition: lwgeom.c:648
type
Definition: ovdump.py:41
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
Remove repeated points!
Definition: lwgeom.c:1456
Here is the call graph for this function:
Here is the caller graph for this function: