PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ create_multipoint()

static SHPObject * create_multipoint ( SHPDUMPERSTATE state,
LWMPOINT lwmultipoint 
)
static

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

References free(), LWMPOINT::geoms, getPoint4d(), LWDEBUGF, POINT4D::m, malloc(), LWMPOINT::ngeoms, shp_dumper_state::outshptype, LWPOINT::point, SHPCreateObject(), POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by ShpLoaderGenerateShapeRow().

108 {
109  SHPObject *obj;
110  POINT4D p4d;
111  int i;
112 
113  double *xpts, *ypts, *zpts, *mpts;
114 
115  /* Allocate storage for points */
116  xpts = malloc(sizeof(double) * lwmultipoint->ngeoms);
117  ypts = malloc(sizeof(double) * lwmultipoint->ngeoms);
118  zpts = malloc(sizeof(double) * lwmultipoint->ngeoms);
119  mpts = malloc(sizeof(double) * lwmultipoint->ngeoms);
120 
121  /* Grab the points: note getPoint4d will correctly handle
122  the case where the POINTs don't contain Z or M coordinates */
123  for (i = 0; i < lwmultipoint->ngeoms; i++)
124  {
125  p4d = getPoint4d(lwmultipoint->geoms[i]->point, 0);
126 
127  xpts[i] = p4d.x;
128  ypts[i] = p4d.y;
129  zpts[i] = p4d.z;
130  mpts[i] = p4d.m;
131 
132  LWDEBUGF(4, "MultiPoint %d - Point: %g %g %g %g", i, xpts[i], ypts[i], zpts[i], mpts[i]);
133  }
134 
135  obj = SHPCreateObject(state->outshptype, -1, 0, NULL, NULL, lwmultipoint->ngeoms, xpts, ypts, zpts, mpts);
136 
137  free(xpts);
138  free(ypts);
139  free(zpts);
140  free(mpts);
141 
142  return obj;
143 }
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
POINTARRAY * point
Definition: liblwgeom.h:410
POINT4D getPoint4d(const POINTARRAY *pa, int n)
Definition: lwgeom_api.c:229
LWPOINT ** geoms
Definition: liblwgeom.h:469
double z
Definition: liblwgeom.h:351
void free(void *)
void * malloc(YYSIZE_T)
double y
Definition: liblwgeom.h:351
int ngeoms
Definition: liblwgeom.h:467
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the call graph for this function:
Here is the caller graph for this function: