PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ create_multilinestring()

static SHPObject * create_multilinestring ( SHPDUMPERSTATE state,
LWMLINE lwmultilinestring 
)
static

Definition at line 387 of file pgsql2shp-core.c.

388{
389 SHPObject *obj;
390 POINT4D p4d;
391 uint32_t i, j;
392
393 double *xpts, *ypts, *zpts, *mpts;
394
395 int *shpparts, shppointtotal = 0, shppoint = 0;
396
397 /* Allocate storage for ring pointers */
398 shpparts = malloc(sizeof(int) * lwmultilinestring->ngeoms);
399
400 /* First count through all the points in each linestring so we now how much memory is required */
401 for (i = 0; i < lwmultilinestring->ngeoms; i++)
402 shppointtotal += lwmultilinestring->geoms[i]->points->npoints;
403
404 LWDEBUGF(3, "Total number of points: %d", shppointtotal);
405
406 /* Allocate storage for points */
407 xpts = malloc(sizeof(double) * shppointtotal);
408 ypts = malloc(sizeof(double) * shppointtotal);
409 zpts = malloc(sizeof(double) * shppointtotal);
410 mpts = malloc(sizeof(double) * shppointtotal);
411
412 /* Iterate through each linestring setting up shpparts to point to the beginning of each line */
413 for (i = 0; i < lwmultilinestring->ngeoms; i++)
414 {
415 /* For each linestring, store the integer coordinate offset for the start of each line */
416 shpparts[i] = shppoint;
417
418 for (j = 0; j < lwmultilinestring->geoms[i]->points->npoints; j++)
419 {
420 p4d = getPoint4d(lwmultilinestring->geoms[i]->points, j);
421
422 xpts[shppoint] = p4d.x;
423 ypts[shppoint] = p4d.y;
424 zpts[shppoint] = p4d.z;
425 mpts[shppoint] = p4d.m;
426
427 LWDEBUGF(4, "Linestring %d - Point: %g %g %g %g", i, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
428
429 /* Increment the point counter */
430 shppoint++;
431 }
432 }
433
434 obj = SHPCreateObject(state->outshptype, -1, lwmultilinestring->ngeoms, shpparts, NULL, shppoint, xpts, ypts, zpts, mpts);
435
436 free(xpts);
437 free(ypts);
438 free(zpts);
439 free(mpts);
440
441 return obj;
442}
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition lwgeom_api.c:108
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:88
void * malloc(YYSIZE_T)
void free(void *)
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
POINTARRAY * points
Definition liblwgeom.h:469
LWLINE ** geoms
Definition liblwgeom.h:533
uint32_t ngeoms
Definition liblwgeom.h:538
double m
Definition liblwgeom.h:400
double x
Definition liblwgeom.h:400
double z
Definition liblwgeom.h:400
double y
Definition liblwgeom.h:400
uint32_t npoints
Definition liblwgeom.h:413

References free(), LWMLINE::geoms, getPoint4d(), LWDEBUGF, POINT4D::m, malloc(), LWMLINE::ngeoms, POINTARRAY::npoints, shp_dumper_state::outshptype, LWLINE::points, SHPCreateObject(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by ShpLoaderGenerateShapeRow().

Here is the call graph for this function:
Here is the caller graph for this function: