PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ lwgeom_collect_endpoints()

static void lwgeom_collect_endpoints ( const LWGEOM lwg,
LWMPOINT col 
)
static

Definition at line 50 of file lwgeom_geos_node.c.

References LINETYPE, lwerror(), lwgeom_ngeoms(), lwgeom_subgeom(), lwline_get_lwpoint(), lwmpoint_add_lwpoint(), lwtype_name(), MULTILINETYPE, POINTARRAY::npoints, LWLINE::points, and LWGEOM::type.

Referenced by lwgeom_extract_endpoints().

51 {
52  int i, n;
53  LWLINE* l;
54 
55  switch (lwg->type)
56  {
57  case MULTILINETYPE:
58  for ( i = 0,
59  n = lwgeom_ngeoms(lwg);
60  i < n; ++i )
61  {
63  lwgeom_subgeom(lwg, i),
64  col);
65  }
66  break;
67  case LINETYPE:
68  l = (LWLINE*)lwg;
69  col = lwmpoint_add_lwpoint(col,
70  lwline_get_lwpoint(l, 0));
71  col = lwmpoint_add_lwpoint(col,
73  break;
74  default:
75  lwerror("lwgeom_collect_endpoints: invalid type %s",
76  lwtype_name(lwg->type));
77  break;
78  }
79 }
#define LINETYPE
Definition: liblwgeom.h:86
int npoints
Definition: liblwgeom.h:371
static int lwgeom_ngeoms(const LWGEOM *n)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:218
static const LWGEOM * lwgeom_subgeom(const LWGEOM *g, int n)
static void lwgeom_collect_endpoints(const LWGEOM *lwg, LWMPOINT *col)
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
Definition: lwmpoint.c:45
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:324
uint8_t type
Definition: liblwgeom.h:396
#define MULTILINETYPE
Definition: liblwgeom.h:89
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: