PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_startpoint_linestring()

Datum LWGEOM_startpoint_linestring ( PG_FUNCTION_ARGS  )

Definition at line 720 of file lwgeom_ogc.c.

721 {
722  GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
723  LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
724  LWPOINT *lwpoint = NULL;
725  int type = lwgeom->type;
726 
727  if ( type == LINETYPE || type == CIRCSTRINGTYPE )
728  {
729  lwpoint = lwline_get_lwpoint((LWLINE*)lwgeom, 0);
730  }
731  else if ( type == COMPOUNDTYPE )
732  {
733  lwpoint = lwcompound_get_startpoint((LWCOMPOUND*)lwgeom);
734  }
735 
736  lwgeom_free(lwgeom);
737  PG_FREE_IF_COPY(geom, 0);
738 
739  if ( ! lwpoint )
740  PG_RETURN_NULL();
741 
742  PG_RETURN_POINTER(geometry_serialize(lwpoint_as_lwgeom(lwpoint)));
743 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define COMPOUNDTYPE
Definition: liblwgeom.h:93
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define LINETYPE
Definition: liblwgeom.h:86
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
Definition: lwcompound.c:248
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition: lwgeom.c:335
#define CIRCSTRINGTYPE
Definition: liblwgeom.h:92
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition: lwline.c:318
type
Definition: ovdump.py:41
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
uint8_t type
Definition: liblwgeom.h:399

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

Here is the call graph for this function: