PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ ST_AsMARC21()

Datum ST_AsMARC21 ( PG_FUNCTION_ARGS  )

Definition at line 51 of file lwgeom_out_marc21.c.

51 {
52 lwvarlena_t *marc21;
53 int32_t srid;
54 LWPROJ *lwproj;
55 LWGEOM *lwgeom;
56 //uint8_t is_latlong;
57 GSERIALIZED *gs = PG_GETARG_GSERIALIZED_P(0);
58 text *format_text_input = PG_GETARG_TEXT_P(1);
59 const char *format = text_to_cstring(format_text_input);
60
61 srid = gserialized_get_srid(gs);
62
63 if (srid == SRID_UNKNOWN) {
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
87 lwgeom = lwgeom_from_gserialized(gs);
88 marc21 = lwgeom_to_marc21(lwgeom, format);
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 LW_FAILURE
Definition liblwgeom.h:96
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:215
lwvarlena_t * lwgeom_to_marc21(const LWGEOM *geom, const char *format)

References gserialized_get_srid(), LW_FAILURE, lwgeom_from_gserialized(), lwgeom_to_marc21(), and SRID_UNKNOWN.

Here is the call graph for this function: