PostGIS  2.3.7dev-r@@SVN_REVISION@@
LWGEOM* lwmpoint_remove_repeated_points ( const LWMPOINT mpoint,
double  tolerance 
)

Definition at line 92 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().

93 {
94  uint32_t nnewgeoms;
95  uint32_t i, j;
96  LWGEOM **newgeoms;
97 
98  newgeoms = lwalloc(sizeof(LWGEOM *)*mpoint->ngeoms);
99  nnewgeoms = 0;
100  for (i=0; i<mpoint->ngeoms; ++i)
101  {
102  /* Brute force, may be optimized by building an index */
103  int seen=0;
104  for (j=0; j<nnewgeoms; ++j)
105  {
106  if ( lwpoint_same((LWPOINT*)newgeoms[j],
107  (LWPOINT*)mpoint->geoms[i]) )
108  {
109  seen=1;
110  break;
111  }
112  }
113  if ( seen ) continue;
114  newgeoms[nnewgeoms++] = (LWGEOM*)lwpoint_clone(mpoint->geoms[i]);
115  }
116 
117  return (LWGEOM*)lwcollection_construct(mpoint->type,
118  mpoint->srid, mpoint->bbox ? gbox_copy(mpoint->bbox) : NULL,
119  nnewgeoms, newgeoms);
120 
121 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:438
char lwpoint_same(const LWPOINT *p1, const LWPOINT *p2)
Definition: lwpoint.c:246
GBOX * bbox
Definition: liblwgeom.h:465
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
uint8_t type
Definition: liblwgeom.h:463
LWPOINT * lwpoint_clone(const LWPOINT *lwgeom)
Definition: lwpoint.c:221
LWPOINT ** geoms
Definition: liblwgeom.h:469
void * lwalloc(size_t size)
Definition: lwutil.c:227
int ngeoms
Definition: liblwgeom.h:467
int32_t srid
Definition: liblwgeom.h:466

Here is the call graph for this function:

Here is the caller graph for this function: