PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ create_linestring()

static SHPObject * create_linestring ( SHPDUMPERSTATE state,
LWLINE lwlinestring 
)
static

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

350 {
351  SHPObject *obj;
352  POINT4D p4d;
353  uint32_t i;
354 
355  double *xpts, *ypts, *zpts, *mpts;
356 
357  /* Allocate storage for points */
358  xpts = malloc(sizeof(double) * lwlinestring->points->npoints);
359  ypts = malloc(sizeof(double) * lwlinestring->points->npoints);
360  zpts = malloc(sizeof(double) * lwlinestring->points->npoints);
361  mpts = malloc(sizeof(double) * lwlinestring->points->npoints);
362 
363  /* Grab the points: note getPoint4d will correctly handle
364  the case where the POINTs don't contain Z or M coordinates */
365  for (i = 0; i < lwlinestring->points->npoints; i++)
366  {
367  p4d = getPoint4d(lwlinestring->points, i);
368 
369  xpts[i] = p4d.x;
370  ypts[i] = p4d.y;
371  zpts[i] = p4d.z;
372  mpts[i] = p4d.m;
373 
374  LWDEBUGF(4, "Linestring - Point: %g %g %g %g", i, xpts[i], ypts[i], zpts[i], mpts[i]);
375  }
376 
377  obj = SHPCreateObject(state->outshptype, -1, 0, NULL, NULL, lwlinestring->points->npoints, xpts, ypts, zpts, mpts);
378 
379  free(xpts);
380  free(ypts);
381  free(zpts);
382  free(mpts);
383 
384  return obj;
385 }
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
Definition: lwgeom_api.c:106
#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:425
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374
unsigned int uint32_t
Definition: uthash.h:78

References free(), getPoint4d(), LWDEBUGF, POINT4D::m, malloc(), 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: