178{
181 uint32_t i, j;
182
183 double *xpts, *ypts, *zpts, *mpts;
184
185 int *shpparts, shppointtotal = 0, shppoint = 0;
186
187
189
190
191 for (i = 0; i < lwpolygon->
nrings; i++)
193
194
195 xpts =
malloc(
sizeof(
double) * shppointtotal);
196 ypts =
malloc(
sizeof(
double) * shppointtotal);
197 zpts =
malloc(
sizeof(
double) * shppointtotal);
198 mpts =
malloc(
sizeof(
double) * shppointtotal);
199
200 LWDEBUGF(4,
"Total number of points: %d", shppointtotal);
201
202
203 for (i = 0; i < lwpolygon->
nrings; i++)
204 {
205
206 shpparts[i] = shppoint;
207
209 {
211
212 xpts[shppoint] = p4d.
x;
213 ypts[shppoint] = p4d.
y;
214 zpts[shppoint] = p4d.
z;
215 mpts[shppoint] = p4d.
m;
216
217 LWDEBUGF(4,
"Polygon Ring %d - Point: %g %g %g %g", i, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
218
219
220 shppoint++;
221 }
222
223
224
225
226
227 if ( i == 0 )
228 {
230 &xpts[shpparts[i]], &ypts[shpparts[i]], NULL) )
231 {
232 LWDEBUG(4,
"Outer ring not clockwise, forcing clockwise\n");
233
235 &xpts[shpparts[i]], &ypts[shpparts[i]],
236 &zpts[shpparts[i]], &mpts[shpparts[i]]);
237 }
238 }
239 else
240 {
242 &xpts[shpparts[i]], &ypts[shpparts[i]], NULL) )
243 {
244 LWDEBUGF(4,
"Inner ring %d not counter-clockwise, forcing counter-clockwise\n", i);
245
247 &xpts[shpparts[i]], &ypts[shpparts[i]],
248 &zpts[shpparts[i]], &mpts[shpparts[i]]);
249 }
250 }
251 }
252
254
260
261 return obj;
262}
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