PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ create_linestring()

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

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

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().

339 {
340  SHPObject *obj;
341  POINT4D p4d;
342  int i;
343 
344  double *xpts, *ypts, *zpts, *mpts;
345 
346  /* Allocate storage for points */
347  xpts = malloc(sizeof(double) * lwlinestring->points->npoints);
348  ypts = malloc(sizeof(double) * lwlinestring->points->npoints);
349  zpts = malloc(sizeof(double) * lwlinestring->points->npoints);
350  mpts = malloc(sizeof(double) * lwlinestring->points->npoints);
351 
352  /* Grab the points: note getPoint4d will correctly handle
353  the case where the POINTs don't contain Z or M coordinates */
354  for (i = 0; i < lwlinestring->points->npoints; i++)
355  {
356  p4d = getPoint4d(lwlinestring->points, i);
357 
358  xpts[i] = p4d.x;
359  ypts[i] = p4d.y;
360  zpts[i] = p4d.z;
361  mpts[i] = p4d.m;
362 
363  LWDEBUGF(4, "Linestring - Point: %g %g %g %g", i, xpts[i], ypts[i], zpts[i], mpts[i]);
364  }
365 
366  obj = SHPCreateObject(state->outshptype, -1, 0, NULL, NULL, lwlinestring->points->npoints, xpts, ypts, zpts, mpts);
367 
368  free(xpts);
369  free(ypts);
370  free(zpts);
371  free(mpts);
372 
373  return obj;
374 }
double x
Definition: liblwgeom.h:351
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
double m
Definition: liblwgeom.h:351
int npoints
Definition: liblwgeom.h:370
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:229
double z
Definition: liblwgeom.h:351
void free(void *)
void * malloc(YYSIZE_T)
double y
Definition: liblwgeom.h:351
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
POINTARRAY * points
Definition: liblwgeom.h:421
Here is the call graph for this function:
Here is the caller graph for this function: