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

◆ create_multilinestring()

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

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

409{
410 SHPObject *obj;
411 POINT4D p4d;
412 uint32_t i, j;
413
414 double *xpts, *ypts, *zpts, *mpts;
415
416 int *shpparts, shppointtotal = 0, shppoint = 0;
417
418 /* Allocate storage for ring pointers */
419 shpparts = malloc(sizeof(int) * lwmultilinestring->ngeoms);
420
421 /* First count through all the points in each linestring so we now how much memory is required */
422 for (i = 0; i < lwmultilinestring->ngeoms; i++)
423 shppointtotal += lwmultilinestring->geoms[i]->points->npoints;
424
425 LWDEBUGF(3, "Total number of points: %d", shppointtotal);
426
427 /* Allocate storage for points */
428 xpts = malloc(sizeof(double) * shppointtotal);
429 ypts = malloc(sizeof(double) * shppointtotal);
430 zpts = malloc(sizeof(double) * shppointtotal);
431 mpts = malloc(sizeof(double) * shppointtotal);
432
433 /* Iterate through each linestring setting up shpparts to point to the beginning of each line */
434 for (i = 0; i < lwmultilinestring->ngeoms; i++)
435 {
436 /* For each linestring, store the integer coordinate offset for the start of each line */
437 shpparts[i] = shppoint;
438
439 for (j = 0; j < lwmultilinestring->geoms[i]->points->npoints; j++)
440 {
441 p4d = getPoint4d(lwmultilinestring->geoms[i]->points, j);
442
443 xpts[shppoint] = p4d.x;
444 ypts[shppoint] = p4d.y;
445 zpts[shppoint] = p4d.z;
446 mpts[shppoint] = p4d.m;
447
448 LWDEBUGF(4, "Linestring %d - Point: %g %g %g %g", i, xpts[shppoint], ypts[shppoint], zpts[shppoint], mpts[shppoint]);
449
450 /* Increment the point counter */
451 shppoint++;
452 }
453 }
454
455 obj = SHPCreateObject(state->outshptype, -1, lwmultilinestring->ngeoms, shpparts, NULL, shppoint, xpts, ypts, zpts, mpts);
456
457 free(shpparts);
458 free(xpts);
459 free(ypts);
460 free(zpts);
461 free(mpts);
462
463 return obj;
464}
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition lwgeom_api.c:107
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
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:483
LWLINE ** geoms
Definition liblwgeom.h:547
uint32_t ngeoms
Definition liblwgeom.h:552
double m
Definition liblwgeom.h:414
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414
uint32_t npoints
Definition liblwgeom.h:427

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: