PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ lwmpoint_remove_repeated_points()

LWGEOM* lwmpoint_remove_repeated_points ( LWMPOINT mpoint,
double  tolerance 
)

Definition at line 79 of file lwmpoint.c.

References LWMPOINT::bbox, gbox_copy(), LWMPOINT::geoms, lwalloc(), lwcollection_construct(), lwpoint_clone(), lwpoint_same(), LWMPOINT::ngeoms, LWMPOINT::srid, and LWMPOINT::type.

Referenced by lwgeom_remove_repeated_points().

80 {
81  uint32_t nnewgeoms;
82  uint32_t i, j;
83  LWGEOM **newgeoms;
84 
85  newgeoms = lwalloc(sizeof(LWGEOM *)*mpoint->ngeoms);
86  nnewgeoms = 0;
87  for (i=0; i<mpoint->ngeoms; ++i)
88  {
89  /* Brute force, may be optimized by building an index */
90  int seen=0;
91  for (j=0; j<nnewgeoms; ++j)
92  {
93  if ( lwpoint_same((LWPOINT*)newgeoms[j],
94  (LWPOINT*)mpoint->geoms[i]) )
95  {
96  seen=1;
97  break;
98  }
99  }
100  if ( seen ) continue;
101  newgeoms[nnewgeoms++] = (LWGEOM*)lwpoint_clone(mpoint->geoms[i]);
102  }
103 
104  return (LWGEOM*)lwcollection_construct(mpoint->type,
105  mpoint->srid, mpoint->bbox ? gbox_copy(mpoint->bbox) : NULL,
106  nnewgeoms, newgeoms);
107 
108 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:403
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:233
GBOX * bbox
Definition: liblwgeom.h:450
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
uint8_t type
Definition: liblwgeom.h:448
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
Definition: lwpoint.c:208
LWPOINT ** geoms
Definition: liblwgeom.h:454
void * lwalloc(size_t size)
Definition: lwutil.c:199
int ngeoms
Definition: liblwgeom.h:452
int32_t srid
Definition: liblwgeom.h:451
Here is the call graph for this function:
Here is the caller graph for this function: