215 GSERIALIZED *pg_lwgeom = PG_GETARG_GSERIALIZED_P(0);
216 text *format_text = PG_GETARG_TEXT_P(1);
219 char *format_str = NULL;
221 char * formatted_str;
222 text * formatted_text;
229 lwpgerror(
"Only points are supported, you tried type %s.",
lwtype_name(geom_type));
234 if (format_text == NULL) {
235 lwpgerror(
"ST_AsLatLonText: invalid format string (null");
240 lwpgerror(
"ST_AsLatLonText: invalid coordinate");
244 format_str = text_to_cstring(format_text);
245 assert(format_str != NULL);
249 tmp = (
char *)pg_do_encoding_conversion(
250 (uint8_t *)format_str, strlen(format_str), GetDatabaseEncoding(), PG_UTF8);
252 if ( tmp != format_str ) {
259 assert(formatted_str != NULL);
263 tmp = (
char *)pg_do_encoding_conversion(
264 (uint8_t *)formatted_str, strlen(formatted_str),
265 PG_UTF8, GetDatabaseEncoding());
267 if ( tmp != formatted_str) {
268 pfree(formatted_str);
273 formatted_text = cstring_to_text(formatted_str);
274 pfree(formatted_str);
276 PG_RETURN_POINTER(formatted_text);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
int lwgeom_isfinite(const LWGEOM *lwgeom)
Check if a LWGEOM has any non-finite (NaN or Inf) coordinates.
char * lwpoint_to_latlon(const LWPOINT *p, const char *format)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.