PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ path_to_geometry()

Datum path_to_geometry ( PG_FUNCTION_ARGS  )

Definition at line 156 of file geometry_inout.c.

157 {
158  PATH *path;
159  LWLINE *lwline;
160  POINTARRAY *pa;
161  GSERIALIZED *geom;
162  POINT4D pt;
163  Point p;
164  int i;
165 
166  POSTGIS_DEBUG(2, "path_to_geometry called");
167 
168  if ( PG_ARGISNULL(0) )
169  PG_RETURN_NULL();
170 
171  path = PG_GETARG_PATH_P(0);
172 
173  if ( ! path )
174  PG_RETURN_NULL();
175 
176  pa = ptarray_construct_empty(0, 0, path->npts);
177  for ( i = 0; i < path->npts; i++ )
178  {
179  p = path->p[i];
180  pt.x = p.x;
181  pt.y = p.y;
182  ptarray_append_point(pa, &pt, LW_FALSE);
183  }
184  lwline = lwline_construct(SRID_UNKNOWN, NULL, pa);
185  geom = geometry_serialize(lwline_as_lwgeom(lwline));
186  lwline_free(lwline);
187 
188  PG_RETURN_POINTER(geom);
189 }
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:330
#define LW_FALSE
Definition: liblwgeom.h:77
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
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_FALSE,...
Definition: ptarray.c:156
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
void lwline_free(LWLINE *line)
Definition: lwline.c:76
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
double x
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355

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

Here is the call graph for this function: