97{
100 xmlDocPtr xmldoc;
101 text *xml_input;
102 int xml_size;
103 char *xml;
104 bool hasz=true;
105 xmlNodePtr xmlroot=NULL;
106
107
108 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
109 xml_input = PG_GETARG_TEXT_P(0);
111 xml_size = VARSIZE_ANY_EXHDR(xml_input);
112
113
114 xmlInitParser();
115 xmldoc = xmlReadMemory(xml, xml_size, NULL, NULL, 0);
116
117 if (!xmldoc || (xmlroot = xmlDocGetRootElement(xmldoc)) == NULL)
118 {
119 xmlFreeDoc(xmldoc);
120 xmlCleanupParser();
121 lwpgerror("invalid KML representation");
122 }
123
125
126
128 {
131 lwgeom = hlwgeom;
132 }
133
135
136
137
138
139
140
141
142 if (!hasz)
143 {
146 lwgeom = tmp;
147 }
148
151
152 xmlFreeDoc(xmldoc);
153 xmlCleanupParser();
154
155 PG_RETURN_POINTER(geom);
156}
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
LWGEOM * lwgeom_homogenize(const LWGEOM *geom)
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
static LWGEOM * parse_kml(xmlNodePtr xnode, bool *hasz)
Parse KML.
char * text_to_cstring(const text *textptr)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)