268 double *xpts, *ypts, *zpts, *mpts;
270 int *shpparts, shppointtotal = 0, shppoint = 0, shpringtotal = 0, shpring = 0;
275 for (i = 0; i < lwmultipolygon->
ngeoms; i++)
277 for (j = 0; j < lwmultipolygon->
geoms[i]->
nrings; j++)
285 shpparts =
malloc(
sizeof(
int) * shpringtotal);
288 xpts =
malloc(
sizeof(
double) * shppointtotal);
289 ypts =
malloc(
sizeof(
double) * shppointtotal);
290 zpts =
malloc(
sizeof(
double) * shppointtotal);
291 mpts =
malloc(
sizeof(
double) * shppointtotal);
293 LWDEBUGF(4,
"Total number of rings: %d Total number of points: %d", shpringtotal, shppointtotal);
296 for (i = 0; i < lwmultipolygon->
ngeoms; i++)
298 for (j = 0; j < lwmultipolygon->
geoms[i]->
nrings; j++)
301 shpparts[shpring] = shppoint;
303 LWDEBUGF(4,
"Ring offset: %d", shpring);
309 xpts[shppoint] = p4d.
x;
310 ypts[shppoint] = p4d.
y;
311 zpts[shppoint] = p4d.
z;
312 mpts[shppoint] = p4d.
m;
314 LWDEBUGF(4,
"MultiPolygon %d Polygon Ring %d - Point: %g %g %g %g", i, j, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
327 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]], NULL) )
329 LWDEBUG(4,
"Outer ring not clockwise, forcing clockwise\n");
332 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]],
333 &zpts[shpparts[shpring]], &mpts[shpparts[shpring]]);
339 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]], NULL) )
341 LWDEBUGF(4,
"Inner ring %d not counter-clockwise, forcing counter-clockwise\n", i);
344 &xpts[shpparts[shpring]], &ypts[shpparts[shpring]],
345 &zpts[shpparts[shpring]], &mpts[shpparts[shpring]]);
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
static int reverse_points(int num_points, double *x, double *y, double *z, double *m)
static int is_clockwise(int num_points, double *x, double *y, double *z)
SHPObject SHPAPI_CALL1 * SHPCreateObject(int nSHPType, int nShapeId, int nParts, const int *panPartStart, const int *panPartType, int nVertices, const double *padfX, const double *padfY, const double *padfZ, const double *padfM);SHPObject SHPAPI_CALL1(*) SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ