PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ line_from_encoded_polyline()

Datum line_from_encoded_polyline ( PG_FUNCTION_ARGS  )

Definition at line 38 of file lwgeom_in_encoded_polyline.c.

39 {
40  GSERIALIZED *geom;
41  LWGEOM *lwgeom;
42  text *encodedpolyline_input;
43  char *encodedpolyline;
44  int precision = 5;
45 
46  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
47 
48  encodedpolyline_input = PG_GETARG_TEXT_P(0);
49  encodedpolyline = text_to_cstring(encodedpolyline_input);
50 
51  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
52  {
53  precision = PG_GETARG_INT32(1);
54  if ( precision < 0 ) precision = 5;
55  }
56 
57  lwgeom = lwgeom_from_encoded_polyline(encodedpolyline, precision);
58  if ( ! lwgeom ) {
59  /* Shouldn't get here */
60  elog(ERROR, "lwgeom_from_encoded_polyline returned NULL");
61  PG_RETURN_NULL();
62  }
63  lwgeom_set_srid(lwgeom, 4326);
64 
65  geom = geometry_serialize(lwgeom);
66  lwgeom_free(lwgeom);
67  PG_RETURN_POINTER(geom);
68 }
static uint8_t precision
Definition: cu_in_twkb.c:25
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
Create an LWGEOM object from an Encoded Polyline representation.
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...
char * text_to_cstring(const text *textptr)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

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

Here is the call graph for this function: