244 const char *default_prefix =
"";
246 const char *prefix = default_prefix;
248 const int32_t srid_to = 4326;
251 GSERIALIZED *geom = PG_GETARG_GSERIALIZED_P_COPY(0);
253 text *prefix_text = PG_GETARG_TEXT_P(2);
258 PG_FREE_IF_COPY(geom, 0);
259 elog(ERROR,
"ST_AsKML: Input geometry has unknown (%d) SRID",
SRID_UNKNOWN);
267 if (VARSIZE_ANY_EXHDR(prefix_text) > 0)
270 prefixbuf = palloc(VARSIZE_ANY_EXHDR(prefix_text)+2);
271 memcpy(prefixbuf, VARDATA(prefix_text),
272 VARSIZE_ANY_EXHDR(prefix_text));
274 prefixbuf[VARSIZE_ANY_EXHDR(prefix_text)] =
':';
275 prefixbuf[VARSIZE_ANY_EXHDR(prefix_text)+1] =
'\0';
281 if (srid_from != srid_to)
284 if (lwproj_lookup(srid_from, srid_to, &pj) ==
LW_FAILURE)
286 PG_FREE_IF_COPY(geom, 0);
287 elog(ERROR,
"ST_AsKML: Failure reading projections from spatial_ref_sys.");
295 PG_RETURN_TEXT_P(kml);
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.
lwvarlena_t * lwgeom_to_kml2(const LWGEOM *geom, int precision, const char *prefix)
int lwgeom_transform(LWGEOM *geom, LWPROJ *pj)
Transform (reproject) a geometry in-place.
#define SRID_UNKNOWN
Unknown SRID value.