PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ 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 
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 
112  /* Zero for undefined */
113  root_srid = PG_GETARG_INT32(1);
114 
115  /* Internally lwgeom_from_gml calls gml_reproject_pa which, for PROJ before 6, called GetProj4String.
116  * That function requires access to spatial_ref_sys, so in order to have it ready we need to ensure
117  * the internal cache is initialized
118  */
119  postgis_initialize_cache(fcinfo);
120  lwgeom = lwgeom_from_gml(xml);
121 
122  if ( root_srid != SRID_UNKNOWN )
123  lwgeom->srid = root_srid;
124 
125  geom = geometry_serialize(lwgeom);
126  lwgeom_free(lwgeom);
127 
128  PG_RETURN_POINTER(geom);
129 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
static LWGEOM * lwgeom_from_gml(const char *wkt)
Read GML.
char * text_to_cstring(const text *textptr)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
int32_t srid
Definition: liblwgeom.h:402

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

Here is the call graph for this function: