PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ create_linestring()

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

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

364 {
365  SHPObject *obj;
366  POINT4D p4d;
367  uint32_t i;
368 
369  double *xpts, *ypts, *zpts, *mpts;
370 
371  /* Allocate storage for points */
372  xpts = malloc(sizeof(double) * lwlinestring->points->npoints);
373  ypts = malloc(sizeof(double) * lwlinestring->points->npoints);
374  zpts = malloc(sizeof(double) * lwlinestring->points->npoints);
375  mpts = malloc(sizeof(double) * lwlinestring->points->npoints);
376 
377  /* Grab the points: note getPoint4d will correctly handle
378  the case where the POINTs don't contain Z or M coordinates */
379  for (i = 0; i < lwlinestring->points->npoints; i++)
380  {
381  p4d = getPoint4d(lwlinestring->points, i);
382 
383  xpts[i] = p4d.x;
384  ypts[i] = p4d.y;
385  zpts[i] = p4d.z;
386  mpts[i] = p4d.m;
387 
388  LWDEBUGF(4, "Linestring - Point: %g %g %g %g", i, xpts[i], ypts[i], zpts[i], mpts[i]);
389  }
390 
391  obj = SHPCreateObject(state->outshptype, -1, 0, NULL, NULL, lwlinestring->points->npoints, xpts, ypts, zpts, mpts);
392 
393  free(xpts);
394  free(ypts);
395  free(zpts);
396  free(mpts);
397 
398  return obj;
399 }
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:498
double m
Definition: liblwgeom.h:429
double x
Definition: liblwgeom.h:429
double z
Definition: liblwgeom.h:429
double y
Definition: liblwgeom.h:429
uint32_t npoints
Definition: liblwgeom.h:442

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: