PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwmpoint_extract_points_3d()

static POINT3D* lwmpoint_extract_points_3d ( const LWMPOINT g,
uint32_t ngeoms 
)
static

Definition at line 134 of file lwgeom_median.c.

References getPoint3dz_p(), lwalloc(), lwcollection_getsubgeom(), lwgeom_has_z(), lwgeom_is_empty(), and POINT3D::z.

Referenced by lwmpoint_median().

135 {
136  uint32_t i;
137  uint32_t n = 0;
138  int is_3d = lwgeom_has_z((LWGEOM*) g);
139 
140  POINT3D* points = lwalloc(g->ngeoms * sizeof(POINT3D));
141  for (i = 0; i < g->ngeoms; i++)
142  {
144  if (!lwgeom_is_empty(subg))
145  {
146  getPoint3dz_p(((LWPOINT*) subg)->point, 0, (POINT3DZ*) &points[n++]);
147  if (!is_3d)
148  points[n-1].z = 0.0; /* in case the getPoint functions return NaN in the future for 2d */
149  }
150  }
151 
152  if (ngeoms != NULL)
153  *ngeoms = n;
154 
155  return points;
156 }
LWGEOM * lwcollection_getsubgeom(LWCOLLECTION *col, int gnum)
Definition: lwcollection.c:113
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
Definition: lwgeom.c:885
double z
Definition: liblwgeom.h:340
unsigned int uint32_t
Definition: uthash.h:78
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
Definition: lwgeom_api.c:214
void * lwalloc(size_t size)
Definition: lwutil.c:229
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
Definition: lwgeom.c:1346
int ngeoms
Definition: liblwgeom.h:468
Here is the call graph for this function:
Here is the caller graph for this function: