PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_startpoint_linestring ( PG_FUNCTION_ARGS  )

Definition at line 691 of file lwgeom_ogc.c.

References CIRCSTRINGTYPE, geometry_serialize(), LINETYPE, lwgeom_free(), lwgeom_from_gserialized(), lwline_get_lwpoint(), lwpoint_as_lwgeom(), and LWGEOM::type.

692 {
693  GSERIALIZED *geom = (GSERIALIZED*)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
694  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
695  LWPOINT *lwpoint = NULL;
696  int type = lwgeom->type;
697 
698  if ( type == LINETYPE || type == CIRCSTRINGTYPE )
699  {
700  lwpoint = lwline_get_lwpoint((LWLINE*)lwgeom, 0);
701  }
702 
703  lwgeom_free(lwgeom);
704  PG_FREE_IF_COPY(geom, 0);
705 
706  if ( ! lwpoint )
707  PG_RETURN_NULL();
708 
709  PG_RETURN_POINTER(geometry_serialize(lwpoint_as_lwgeom(lwpoint)));
710 }
#define LINETYPE
Definition: liblwgeom.h:61
LWPOINT * lwline_get_lwpoint(LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:294
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
LWGEOM * geom
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
uint8_t type
Definition: liblwgeom.h:352
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:254
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:67

Here is the call graph for this function: