PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum LWGEOM_asEncodedPolyline ( PG_FUNCTION_ARGS  )

Definition at line 632 of file lwgeom_export.c.

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

633 {
634  GSERIALIZED *geom;
635  LWGEOM *lwgeom;
636  char *encodedpolyline;
637  int precision = 5;
638  text *result;
639 
640  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
641 
642  geom = PG_GETARG_GSERIALIZED_P(0);
643  if (gserialized_get_srid(geom) != 4326) {
644  PG_FREE_IF_COPY(geom, 0);
645  elog(ERROR, "Only SRID 4326 is supported.");
646  PG_RETURN_NULL();
647  }
648  lwgeom = lwgeom_from_gserialized(geom);
649 
650  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
651  {
652  precision = PG_GETARG_INT32(1);
653  if ( precision < 0 ) precision = 5;
654  }
655 
656  encodedpolyline = lwgeom_to_encoded_polyline(lwgeom, precision);
657  lwgeom_free(lwgeom);
658  PG_FREE_IF_COPY(geom, 0);
659 
660  result = cstring2text(encodedpolyline);
661  lwfree(encodedpolyline);
662 
663  PG_RETURN_TEXT_P(result);
664 }
void lwfree(void *mem)
Definition: lwutil.c:244
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
LWGEOM * geom
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:99

Here is the call graph for this function: