PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ LWGEOM_asEncodedPolyline()

Datum LWGEOM_asEncodedPolyline ( PG_FUNCTION_ARGS  )

Definition at line 660 of file lwgeom_export.c.

661 {
662  GSERIALIZED *geom;
663  LWGEOM *lwgeom;
664  char *encodedpolyline;
665  int precision = 5;
666  text *result;
667 
668  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
669 
670  geom = PG_GETARG_GSERIALIZED_P(0);
671  if (gserialized_get_srid(geom) != 4326) {
672  PG_FREE_IF_COPY(geom, 0);
673  elog(ERROR, "Only SRID 4326 is supported.");
674  PG_RETURN_NULL();
675  }
676  lwgeom = lwgeom_from_gserialized(geom);
677 
678  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
679  {
680  precision = PG_GETARG_INT32(1);
681  if ( precision < 0 ) precision = 5;
682  }
683 
684  encodedpolyline = lwgeom_to_encoded_polyline(lwgeom, precision);
685  lwgeom_free(lwgeom);
686  PG_FREE_IF_COPY(geom, 0);
687 
688  result = cstring_to_text(encodedpolyline);
689  lwfree(encodedpolyline);
690 
691  PG_RETURN_TEXT_P(result);
692 }
static uint8_t precision
Definition: cu_in_twkb.c:25
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:100
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
void lwfree(void *mem)
Definition: lwutil.c:244
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)

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

Here is the call graph for this function: