PostGIS  2.2.7dev-r@@SVN_REVISION@@
Datum path_to_geometry ( PG_FUNCTION_ARGS  )

Definition at line 132 of file geometry_inout.c.

References geometry_serialize(), LW_FALSE, lwline_as_lwgeom(), lwline_construct(), lwline_free(), ptarray_append_point(), ptarray_construct_empty(), SRID_UNKNOWN, struct_point::x, POINT4D::x, struct_point::y, and POINT4D::y.

133 {
134  PATH *path;
135  LWLINE *lwline;
136  POINTARRAY *pa;
137  GSERIALIZED *geom;
138  POINT4D pt;
139  Point p;
140  int i;
141 
142  POSTGIS_DEBUG(2, "path_to_geometry called");
143 
144  if ( PG_ARGISNULL(0) )
145  PG_RETURN_NULL();
146 
147  path = PG_GETARG_PATH_P(0);
148 
149  if ( ! path )
150  PG_RETURN_NULL();
151 
152  pa = ptarray_construct_empty(0, 0, path->npts);
153  for ( i = 0; i < path->npts; i++ )
154  {
155  p = path->p[i];
156  pt.x = p.x;
157  pt.y = p.y;
158  ptarray_append_point(pa, &pt, LW_FALSE);
159  }
160  lwline = lwline_construct(SRID_UNKNOWN, NULL, pa);
161  geom = geometry_serialize(lwline_as_lwgeom(lwline));
162  lwline_free(lwline);
163 
164  PG_RETURN_POINTER(geom);
165 }
double x
Definition: liblwgeom.h:336
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
void lwline_free(LWLINE *line)
Definition: lwline.c:63
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_TRUE, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:62
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:29
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
double y
Definition: liblwgeom.h:336

Here is the call graph for this function: