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

◆ lwcompound_get_lwpoint()

LWPOINT * lwcompound_get_lwpoint ( const LWCOMPOUND lwcmp,
uint32_t  where 
)

Definition at line 241 of file lwcompound.c.

242{
243 uint32_t i;
244 uint32_t count = 0;
245 uint32_t npoints = 0;
246 if ( lwgeom_is_empty((LWGEOM*)lwcmp) )
247 return NULL;
248
249 npoints = lwgeom_count_vertices((LWGEOM*)lwcmp);
250 if ( where >= npoints )
251 {
252 lwerror("%s: index %d is not in range of number of vertices (%d) in input", __func__, where, npoints);
253 return NULL;
254 }
255
256 for ( i = 0; i < lwcmp->ngeoms; i++ )
257 {
258 LWGEOM* part = lwcmp->geoms[i];
259 uint32_t npoints_part = lwgeom_count_vertices(part);
260 if ( where >= count && where < count + npoints_part )
261 {
262 return lwline_get_lwpoint((LWLINE*)part, where - count);
263 }
264 else
265 {
266 count += npoints_part;
267 }
268 }
269
270 return NULL;
271}
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition lwline.c:319
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition lwgeom.c:1337
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
int count
Definition genraster.py:57

References LWCOMPOUND::geoms, lwerror(), lwgeom_count_vertices(), lwgeom_is_empty(), lwline_get_lwpoint(), and LWCOMPOUND::ngeoms.

Referenced by lwcompound_get_startpoint(), and LWGEOM_pointn_linestring().

Here is the call graph for this function:
Here is the caller graph for this function: