PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ LWGEOM_asEncodedPolyline()

Datum LWGEOM_asEncodedPolyline ( PG_FUNCTION_ARGS  )

Definition at line 398 of file lwgeom_export.c.

399 {
400  GSERIALIZED *geom;
401  LWGEOM *lwgeom;
402  int precision = 5;
403 
404  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
405 
406  geom = PG_GETARG_GSERIALIZED_P(0);
407  if (gserialized_get_srid(geom) != 4326) {
408  PG_FREE_IF_COPY(geom, 0);
409  elog(ERROR, "Only SRID 4326 is supported.");
410  PG_RETURN_NULL();
411  }
412  lwgeom = lwgeom_from_gserialized(geom);
413 
414  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
415  {
416  precision = PG_GETARG_INT32(1);
417  if ( precision < 0 ) precision = 5;
418  }
419 
420  PG_RETURN_TEXT_P(lwgeom_to_encoded_polyline(lwgeom, precision));
421 }
static uint8_t precision
Definition: cu_in_twkb.c:25
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: gserialized.c:126
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
lwvarlena_t * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)

References gserialized_get_srid(), lwgeom_from_gserialized(), lwgeom_to_encoded_polyline(), and precision.

Here is the call graph for this function: