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

◆ geom_from_gml()

Datum geom_from_gml ( PG_FUNCTION_ARGS  )

Definition at line 98 of file lwgeom_in_gml.c.

99{
100 GSERIALIZED *geom;
101 text *xml_input;
102 LWGEOM *lwgeom;
103 char *xml;
104 int root_srid=SRID_UNKNOWN;
105 int xml_size;
106
107 /* Get the GML stream */
108 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
109 xml_input = PG_GETARG_TEXT_P(0);
110 xml = text_to_cstring(xml_input);
111 xml_size = VARSIZE_ANY_EXHDR(xml_input);
112
113 /* Zero for undefined */
114 root_srid = PG_GETARG_INT32(1);
115
116#if POSTGIS_PROJ_VERSION < 60
117 /* Internally lwgeom_from_gml calls gml_reproject_pa which, for PROJ before 6, called GetProj4String.
118 * That function requires access to spatial_ref_sys, so in order to have it ready we need to ensure
119 * the internal cache is initialized
120 */
121 postgis_initialize_cache(fcinfo);
122#endif
123 lwgeom = lwgeom_from_gml(xml, xml_size);
124 if ( root_srid != SRID_UNKNOWN )
125 lwgeom->srid = root_srid;
126
127 geom = geometry_serialize(lwgeom);
128 lwgeom_free(lwgeom);
129
130 PG_RETURN_POINTER(geom);
131}
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1138
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:229
static LWGEOM * lwgeom_from_gml(const char *wkt, int xml_size)
Read GML.
char * text_to_cstring(const text *textptr)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
int32_t srid
Definition liblwgeom.h:446

References geometry_serialize(), lwgeom_free(), lwgeom_from_gml(), LWGEOM::srid, SRID_UNKNOWN, and text_to_cstring().

Here is the call graph for this function: