173{
174 uint32_t n = 0;
177
178 for (uint32_t i = 0; i < g->
ngeoms; i++)
179 {
182 {
185 {
186 lwerror(
"Geometric median: getPoint4d_p reported failure on point (POINT(%g %g %g %g), number %d of %d in input).", points[n].x, points[n].y, points[n].z, points[n].m, i, g->
ngeoms);
188 return NULL;
189 }
190 if (has_m)
191 {
192
193
194
195
196
197
198
199
200
201 if (points[n].m < 0)
202 {
203 lwerror(
"Geometric median input contains points with negative weights (POINT(%g %g %g %g), number %d of %d in input). Implementation can't guarantee global minimum convergence.", points[n].x, points[n].y, points[n].z, points[n].m, i, g->
ngeoms);
205 return NULL;
206 }
207
208
209 if (points[n].m > DBL_EPSILON) n++;
210 }
211 else
212 {
214 n++;
215 }
216 }
217 }
218
219#ifndef NDEBUG
220
222 for (uint32_t i = 0; i < n; i++)
223 assert(points[i].z == 0);
224#endif
225
226 *npoints = n;
227 return points;
228}
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
void * lwalloc(size_t size)
const LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, uint32_t gnum)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)