PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ geom_from_gml()

Datum geom_from_gml ( PG_FUNCTION_ARGS  )

Definition at line 97 of file lwgeom_in_gml.c.

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

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

Here is the call graph for this function: