572 static const char* default_defid =
"x3d:";
574 const char* defid = default_defid;
578 version = PG_GETARG_INT32(0);
581 elog(ERROR,
"Only X3D version 3 are supported");
586 if ( PG_ARGISNULL(1) ) PG_RETURN_NULL();
587 geom = PG_GETARG_GSERIALIZED_P(1);
590 if (PG_NARGS() >2 && !PG_ARGISNULL(2))
600 if (PG_NARGS() >3 && !PG_ARGISNULL(3))
601 option = PG_GETARG_INT32(3);
606 if (PG_NARGS() >4 && !PG_ARGISNULL(4))
608 defid_text = PG_GETARG_TEXT_P(4);
609 if ( VARSIZE(defid_text)-VARHDRSZ == 0 )
616 defidbuf = palloc(VARSIZE(defid_text)-VARHDRSZ+2);
617 memcpy(defidbuf, VARDATA(defid_text),
618 VARSIZE(defid_text)-VARHDRSZ);
620 defidbuf[VARSIZE(defid_text)-VARHDRSZ] =
':';
621 defidbuf[VARSIZE(defid_text)-VARHDRSZ+1] =
'\0';
636 PG_FREE_IF_COPY(geom, 0);
639 elog(ERROR,
"Only SRID 4326 is supported for geocoordinates.");
648 PG_FREE_IF_COPY(geom, 1);
650 result = cstring_to_text(x3d);
653 PG_RETURN_TEXT_P(result);
int32_t gserialized_get_srid(const GSERIALIZED *s)
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, int srid, bool short_crs)