PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ lwcompound_get_lwpoint()

LWPOINT* lwcompound_get_lwpoint ( const LWCOMPOUND lwcmp,
uint32_t  where 
)

Definition at line 199 of file lwcompound.c.

200 {
201  uint32_t i;
202  uint32_t count = 0;
203  uint32_t npoints = 0;
204  if ( lwgeom_is_empty((LWGEOM*)lwcmp) )
205  return NULL;
206 
207  npoints = lwgeom_count_vertices((LWGEOM*)lwcmp);
208  if ( where >= npoints )
209  {
210  lwerror("%s: index %d is not in range of number of vertices (%d) in input", __func__, where, npoints);
211  return NULL;
212  }
213 
214  for ( i = 0; i < lwcmp->ngeoms; i++ )
215  {
216  LWGEOM* part = lwcmp->geoms[i];
217  uint32_t npoints_part = lwgeom_count_vertices(part);
218  if ( where >= count && where < count + npoints_part )
219  {
220  return lwline_get_lwpoint((LWLINE*)part, where - count);
221  }
222  else
223  {
224  count += npoints_part;
225  }
226  }
227 
228  return NULL;
229 }
uint32_t lwgeom_count_vertices(const LWGEOM *geom)
Count the total number of vertices in any LWGEOM.
Definition: lwgeom.c:1229
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:309
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
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:203
int count
Definition: genraster.py:57

References genraster::count, 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: