PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ create_multipoint()

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

Definition at line 106 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().

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