PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ path_to_geometry()

Datum path_to_geometry ( PG_FUNCTION_ARGS  )

Definition at line 156 of file geometry_inout.c.

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

Referenced by geometry_to_path().

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 }
double x
Definition: liblwgeom.h:352
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:76
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:298
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, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_FALSE
Definition: liblwgeom.h:77
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
double y
Definition: liblwgeom.h:352
Here is the call graph for this function:
Here is the caller graph for this function: