51 {
53 int32_t srid;
56
58 text *format_text_input = PG_GETARG_TEXT_P(1);
59 const char *format = text_to_cstring(format_text_input);
60
62
64
65 PG_FREE_IF_COPY(gs, 0);
66 lwpgerror("ST_AsMARC21: Input geometry has unknown (%d) SRID", srid);
67 PG_RETURN_NULL();
68
69 }
70
71 if (lwproj_lookup(srid, srid, &lwproj) ==
LW_FAILURE) {
72
73 PG_FREE_IF_COPY(gs, 0);
74 lwpgerror("ST_AsMARC21: Failure reading projections from spatial_ref_sys.");
75 PG_RETURN_NULL();
76
77 }
78
79 if (!lwproj_is_latlong(lwproj)) {
80
81 PG_FREE_IF_COPY(gs, 0);
82 lwpgerror("ST_AsMARC21: Unsupported SRID (%d). Only lon/lat coordinate systems are supported in MARC21/XML Documents.", srid);
83 PG_RETURN_NULL();
84 }
85
86
89
90 if (marc21) PG_RETURN_TEXT_P(marc21);
91
92 PG_RETURN_NULL();
93}
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.
#define SRID_UNKNOWN
Unknown SRID value.
lwvarlena_t * lwgeom_to_marc21(const LWGEOM *geom, const char *format)