PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ line_from_encoded_polyline()

Datum line_from_encoded_polyline ( PG_FUNCTION_ARGS  )

Definition at line 37 of file lwgeom_in_encoded_polyline.c.

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

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