533 static const char* default_defid =
"x3d:";
535 const char* defid = default_defid;
539 version = PG_GETARG_INT32(0);
542 elog(ERROR,
"Only X3D version 3 are supported");
547 if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
548 geom = PG_GETARG_GSERIALIZED_P(1);
551 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
561 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
562 option = PG_GETARG_INT32(3);
567 if (PG_NARGS() >4 && !PG_ARGISNULL(4))
569 defid_text = PG_GETARG_TEXT_P(4);
570 if ( VARSIZE_ANY_EXHDR(defid_text) == 0 )
577 defidbuf = palloc(VARSIZE_ANY_EXHDR(defid_text)+2);
578 memcpy(defidbuf, VARDATA(defid_text),
579 VARSIZE_ANY_EXHDR(defid_text));
581 defidbuf[VARSIZE_ANY_EXHDR(defid_text)] =
':';
582 defidbuf[VARSIZE_ANY_EXHDR(defid_text)+1] =
'\0';
597 PG_FREE_IF_COPY(geom, 0);
600 elog(ERROR,
"Only SRID 4326 is supported for geocoordinates.");
609 PG_FREE_IF_COPY(geom, 1);
611 result = cstring_to_text(x3d);
614 PG_RETURN_TEXT_P(result);
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.
void lwgeom_free(LWGEOM *geom)
char * lwgeom_to_x3d3(const LWGEOM *geom, char *srs, int precision, int opts, const char *defid)
#define SRID_UNKNOWN
Unknown SRID value.
#define LW_X3D_USE_GEOCOORDS
char * getSRSbySRID(FunctionCallInfo fcinfo, int32_t srid, bool short_crs)