215 static const char *default_prefix =
"gml:";
216 const char *prefix = default_prefix;
217 char *prefix_buf =
"";
218 text *prefix_text, *id_text = NULL;
219 const char *
id = NULL;
228 Oid first_type = get_fn_expr_argtype(fcinfo->flinfo, 0);
230 if (first_type != INT4OID)
237 version = PG_GETARG_INT32(argnum++);
238 if (version != 2 && version != 3)
240 elog(ERROR,
"Only GML 2 and GML 3 are supported");
246 g = PG_GETARG_GSERIALIZED_P(argnum++);
248 option = PG_GETARG_INT32(argnum++);
249 prefix_text = PG_GETARG_TEXT_P(argnum++);
250 id_text = PG_GETARG_TEXT_P(argnum++);
256 if (VARSIZE_ANY_EXHDR(prefix_text) > 0)
259 prefix_buf = palloc(VARSIZE_ANY_EXHDR(prefix_text)+2);
260 memcpy(prefix_buf, VARDATA_ANY(prefix_text),
261 VARSIZE_ANY_EXHDR(prefix_text));
263 prefix_buf[VARSIZE_ANY_EXHDR(prefix_text)] =
':';
264 prefix_buf[VARSIZE_ANY_EXHDR(prefix_text)+1] =
'\0';
272 if (VARSIZE_ANY_EXHDR(id_text) > 0)
274 id_buf = palloc(VARSIZE_ANY_EXHDR(id_text)+2);
275 memcpy(id_buf, VARDATA(id_text), VARSIZE_ANY_EXHDR(id_text));
276 id_buf[VARSIZE_ANY_EXHDR(id_text)+1] =
'\0';
281 srs = GetSRSCacheBySRID(fcinfo, srid,
false);
283 srs = GetSRSCacheBySRID(fcinfo, srid,
true);
286 elog(ERROR,
"SRID %d unknown in spatial_ref_sys table",
SRID_DEFAULT);
296 "Options %d passed to ST_AsGML(geography) sets "
297 "unsupported value 8",
301 if ((option & 4) || (option & 16) || (option & 32))
304 "Options %d passed to ST_AsGML(geography) but are only "
305 "applicable to ST_AsGML(geometry)",
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define LW_GML_IS_DEGREE
For GML3 only, declare that datas are lat/lon.
lwvarlena_t * lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
#define LW_GML_IS_DIMS
Macros for specifying GML options.
lwvarlena_t * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)