PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_asEncodedPolyline()

Datum LWGEOM_asEncodedPolyline ( PG_FUNCTION_ARGS  )

Definition at line 621 of file lwgeom_export.c.

622{
623 GSERIALIZED *geom;
624 LWGEOM *lwgeom;
625 char *encodedpolyline;
626 int precision = 5;
627 text *result;
628
629 if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
630
631 geom = PG_GETARG_GSERIALIZED_P(0);
632 if (gserialized_get_srid(geom) != 4326) {
633 PG_FREE_IF_COPY(geom, 0);
634 elog(ERROR, "Only SRID 4326 is supported.");
635 PG_RETURN_NULL();
636 }
637 lwgeom = lwgeom_from_gserialized(geom);
638
639 if (PG_NARGS() > 1 && !PG_ARGISNULL(1))
640 {
641 precision = PG_GETARG_INT32(1);
642 if ( precision < 0 ) precision = 5;
643 }
644
645 encodedpolyline = lwgeom_to_encoded_polyline(lwgeom, precision);
646 lwgeom_free(lwgeom);
647 PG_FREE_IF_COPY(geom, 0);
648
649 result = cstring_to_text(encodedpolyline);
650 lwfree(encodedpolyline);
651
652 PG_RETURN_TEXT_P(result);
653}
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)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
char * lwgeom_to_encoded_polyline(const LWGEOM *geom, int precision)
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
void lwfree(void *mem)
Definition lwutil.c:242

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

Here is the call graph for this function: