PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ line_from_encoded_polyline()

Datum line_from_encoded_polyline ( PG_FUNCTION_ARGS  )

Definition at line 25 of file lwgeom_in_encoded_polyline.c.

References geometry_serialize(), lwgeom_free(), lwgeom_from_encoded_polyline(), lwgeom_set_srid(), precision, and text2cstring().

26 {
27  GSERIALIZED *geom;
28  LWGEOM *lwgeom;
29  text *encodedpolyline_input;
30  char *encodedpolyline;
31  int precision = 5;
32 
33  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
34 
35  encodedpolyline_input = PG_GETARG_TEXT_P(0);
36  encodedpolyline = text2cstring(encodedpolyline_input);
37 
38  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
39  {
40  precision = PG_GETARG_INT32(1);
41  if ( precision < 0 ) precision = 5;
42  }
43 
44  lwgeom = lwgeom_from_encoded_polyline(encodedpolyline, precision);
45  if ( ! lwgeom ) {
46  /* Shouldn't get here */
47  elog(ERROR, "lwgeom_from_encoded_polyline returned NULL");
48  PG_RETURN_NULL();
49  }
50  lwgeom_set_srid(lwgeom, 4326);
51 
52  geom = geometry_serialize(lwgeom);
53  lwgeom_free(lwgeom);
54  PG_RETURN_POINTER(geom);
55 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
char * text2cstring(const text *textptr)
uint8_t precision
Definition: cu_in_twkb.c:25
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...
Here is the call graph for this function: