PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ST_GeomFromMARC21()

Datum ST_GeomFromMARC21 ( PG_FUNCTION_ARGS  )

Definition at line 51 of file lwgeom_in_marc21.c.

51  {
52  GSERIALIZED *geom;
53  LWGEOM *lwgeom;
54  xmlDocPtr xmldoc;
55  text *xml_input;
56  int xml_size;
57  char *xml;
58  xmlNodePtr xmlroot = NULL;
59 
60  if (PG_ARGISNULL(0)) PG_RETURN_NULL();
61 
62  xml_input = PG_GETARG_TEXT_P(0);
63  xml = text_to_cstring(xml_input);
64  xml_size = VARSIZE_ANY_EXHDR(xml_input);
65 
66  xmlInitParser();
67  xmldoc = xmlReadMemory(xml, xml_size, NULL, NULL, XML_PARSE_SAX1);
68 
69  if (!xmldoc || (xmlroot = xmlDocGetRootElement(xmldoc)) == NULL) {
70  xmlFreeDoc(xmldoc);
71  xmlCleanupParser();
72  lwpgerror("invalid MARC21/XML document.");
73  }
74 
75  lwgeom = parse_marc21(xmlroot);
76 
77  xmlFreeDoc(xmldoc);
78  xmlCleanupParser();
79 
80  if (lwgeom == NULL) {
81 
82  //lwgeom_free(lwgeom);
83  PG_RETURN_NULL();
84 
85  }
86 
87  geom = geometry_serialize(lwgeom);
88 
89  lwgeom_free(lwgeom);
90 
91  PG_RETURN_POINTER(geom);
92 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1155
static LWGEOM * parse_marc21(xmlNodePtr xnode)

References lwgeom_free(), and parse_marc21().

Here is the call graph for this function: