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

◆ LWGEOM_startpoint_linestring()

Datum LWGEOM_startpoint_linestring ( PG_FUNCTION_ARGS  )

Definition at line 682 of file lwgeom_ogc.c.

683{
684 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P(0);
685 LWGEOM *lwgeom = lwgeom_from_gserialized(geom);
686 LWPOINT *lwpoint = NULL;
687 int type = lwgeom->type;
688
689 if ( type == LINETYPE || type == CIRCSTRINGTYPE )
690 {
691 lwpoint = lwline_get_lwpoint((LWLINE*)lwgeom, 0);
692 }
693 else if ( type == COMPOUNDTYPE )
694 {
695 lwpoint = lwcompound_get_startpoint((LWCOMPOUND*)lwgeom);
696 }
697
698 lwgeom_free(lwgeom);
699 PG_FREE_IF_COPY(geom, 0);
700
701 if ( ! lwpoint )
702 PG_RETURN_NULL();
703
704 PG_RETURN_POINTER(geometry_serialize(lwpoint_as_lwgeom(lwpoint)));
705}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
Definition lwgeom.c:326
#define COMPOUNDTYPE
Definition liblwgeom.h:124
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
Definition lwline.c:309
#define LINETYPE
Definition liblwgeom.h:117
LWPOINT * lwcompound_get_startpoint(const LWCOMPOUND *lwcmp)
Definition lwcompound.c:248
#define CIRCSTRINGTYPE
Definition liblwgeom.h:123
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
uint8_t type
Definition liblwgeom.h:448

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

Here is the call graph for this function: