PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_asEncodedPolyline()

Datum LWGEOM_asEncodedPolyline ( PG_FUNCTION_ARGS  )

Definition at line 606 of file lwgeom_export.c.

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

Referenced by LWGEOM_asX3D().

607 {
608  GSERIALIZED *geom;
609  LWGEOM *lwgeom;
610  char *encodedpolyline;
611  int precision = 5;
612  text *result;
613 
614  if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
615 
616  geom = PG_GETARG_GSERIALIZED_P(0);
617  if (gserialized_get_srid(geom) != 4326) {
618  PG_FREE_IF_COPY(geom, 0);
619  elog(ERROR, "Only SRID 4326 is supported.");
620  PG_RETURN_NULL();
621  }
622  lwgeom = lwgeom_from_gserialized(geom);
623  PG_FREE_IF_COPY(geom, 0);
624 
625  if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
626  {
627  precision = PG_GETARG_INT32(1);
628  if ( precision < 0 ) precision = 5;
629  }
630 
631  encodedpolyline = lwgeom_to_encoded_polyline(lwgeom, precision);
632  lwgeom_free(lwgeom);
633 
634  result = cstring2text(encodedpolyline);
635  lwfree(encodedpolyline);
636 
637  PG_RETURN_TEXT_P(result);
638 }
void lwfree(void *mem)
Definition: lwutil.c:214
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
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:69
Here is the call graph for this function:
Here is the caller graph for this function: