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

◆ create_linestring()

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

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

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