PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ create_multilinestring()

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

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

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