108{
109 PATH *path;
114 uint32_t i;
116 size_t size;
117
118 POSTGIS_DEBUG(2, "geometry_to_path called");
119
120 if ( PG_ARGISNULL(0) )
121 PG_RETURN_NULL();
122
123 geom = PG_GETARG_GSERIALIZED_P(0);
124
126 elog(ERROR, "geometry_to_path only accepts LineStrings");
127
130 PG_RETURN_NULL();
132
134 size = offsetof(PATH, p[0]) +
sizeof(path->p[0]) * pa->
npoints;
135 path = (PATH*)palloc(size);
136 SET_VARSIZE(path, size);
138 path->closed = 0;
139 path->dummy = 0;
140
141 for ( i = 0; i < pa->
npoints; i++ )
142 {
144 (path->p[i]).x = pt->
x;
145 (path->p[i]).y = pt->
y;
146 }
147
149 PG_FREE_IF_COPY(geom,0);
150
151 PG_RETURN_PATH_P(path);
152}
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
void lwgeom_free(LWGEOM *geom)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.