50 #include <libxml/tree.h>
51 #include <libxml/parser.h>
52 #include <libxml/xpath.h>
53 #include <libxml/xpathInternals.h>
56 #include "executor/spi.h"
57 #include "utils/builtins.h"
59 #include "../postgis_config.h"
60 #include "lwgeom_pg.h"
62 #include "lwgeom_transform.h"
76 #define XLINK_NS ((char *) "http://www.w3.org/1999/xlink")
77 #define GML_NS ((char *) "http://www.opengis.net/gml")
78 #define GML32_NS ((char *) "http://www.opengis.net/gml/3.2")
84 POSTGIS_DEBUGF(3,
"ST_GeomFromGML ERROR %i", error_code);
108 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
109 xml_input = PG_GETARG_TEXT_P(0);
111 xml_size = VARSIZE_ANY_EXHDR(xml_input);
114 root_srid = PG_GETARG_INT32(1);
116 #if POSTGIS_PROJ_VERSION < 60
121 postgis_initialize_cache(fcinfo);
125 lwgeom->
srid = root_srid;
130 PG_RETURN_POINTER(geom);
141 if (!xn || xn->type != XML_ELEMENT_NODE)
147 node_name = (
char*)xn->name;
148 colon_pos = strchr(node_name,
':');
150 node_name = colon_pos + 1;
152 return strcmp(node_name, gml_name) == 0;
164 ns = xmlGetNsList(xnode->doc, xnode);
170 if (ns == NULL) {
return !is_strict; }
177 for (p=ns ; *p ; p++)
179 if ((*p)->href == NULL || (*p)->prefix == NULL ||
180 xnode->ns == NULL || xnode->ns->prefix == NULL)
continue;
182 if (!xmlStrcmp(xnode->ns->prefix, (*p)->prefix))
184 if ( !strcmp((
char *) (*p)->href,
GML_NS)
185 || !strcmp((
char *) (*p)->href,
GML32_NS))
205 static xmlChar *
gmlGetProp(xmlNodePtr xnode,
const char *charProp)
208 xmlChar *prop = (xmlChar*)charProp;
211 return xmlGetProp(xnode, prop);
217 value = xmlGetNsProp(xnode, prop, (xmlChar *)
GML_NS);
221 if (
value == NULL)
value = xmlGetNoNsProp(xnode, prop);
235 prop = xmlGetNsProp(node, (xmlChar *)
"type", (xmlChar *)
XLINK_NS);
236 if (prop == NULL)
return false;
237 if (strcmp((
char *) prop,
"simple"))
243 prop = xmlGetNsProp(node, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
244 if (prop == NULL)
return false;
263 xmlXPathContext *ctx;
264 xmlXPathObject *xpath;
265 xmlNodePtr node, ret_node;
266 xmlChar *href, *p, *node_id;
268 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
269 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name)
270 + xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
275 sprintf(
id,
"//%s:%s[@%s:id='%s']", (
char *) xnode->ns->prefix,
276 (
char *) xnode->name,
277 (
char *) xnode->ns->prefix,
280 ctx = xmlXPathNewContext(xnode->doc);
289 ns = xmlGetNsList(xnode->doc, xnode);
290 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
294 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
296 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
299 xmlXPathFreeObject(xpath);
300 xmlXPathFreeContext(ctx);
303 ret_node = xpath->nodesetval->nodeTab[0];
304 xmlXPathFreeObject(xpath);
305 xmlXPathFreeContext(ctx);
308 for (node = xnode ; node != NULL ; node = node->parent)
310 if (node->type != XML_ELEMENT_NODE)
continue;
314 if (!xmlStrcmp(node_id, p))
330 #if POSTGIS_PROJ_VERSION < 60
336 char *text_in, *text_out;
341 text_in = GetProj4String(srid_in);
342 text_out = GetProj4String(srid_out);
344 pj.pj_from = projpj_from_string(text_in);
345 pj.pj_to = projpj_from_string(text_out);
352 elog(ERROR,
"gml_reproject_pa: reprojection failed");
383 snprintf(text_in, 16,
"EPSG:%d", epsg_in);
384 snprintf(text_out, 16,
"EPSG:%d", epsg_out);
385 pj = proj_create_crs_to_crs(NULL, text_in, text_out, NULL);
398 elog(ERROR,
"gml_reproject_pa: reprojection failed");
420 if (SPI_OK_CONNECT != SPI_connect ())
421 lwpgerror(
"gml_is_srid_planar: could not connect to SPI manager");
424 sprintf(query,
"SELECT position('+units=m ' in proj4text) \
425 FROM spatial_ref_sys WHERE srid='%d'", srid);
427 err = SPI_exec(query, 1);
428 if (err < 0) lwpgerror(
"gml_is_srid_planar: error executing query %d", err);
431 if (SPI_processed <= 0)
437 result = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
438 is_planar = atoi(result);
462 if (node->parent == NULL)
489 if (!strncmp((
char *) srsname,
"EPSG:", 5))
494 else if (!strncmp((
char *) srsname,
"urn:ogc:def:crs:EPSG:", 21)
495 || !strncmp((
char *) srsname,
"urn:x-ogc:def:crs:EPSG:", 23)
496 || !strncmp((
char *) srsname,
"urn:EPSG:geographicCRS:", 23))
501 else if (!strncmp((
char *) srsname,
502 "http://www.opengis.net/gml/srs/epsg.xml#", 40))
510 for (p = (
char *) srsname ; *p ; p++);
511 for (--p ; *p != sep ; p--)
512 if (!isdigit(*p))
gml_lwpgerror(
"unknown spatial reference system", 5);
514 srs->
srid = atoi(++p);
557 if (space_before)
while (isspace(*d)) d++;
558 for (st = INIT, p = d ; *p ; p++)
563 if (st == INIT || st == NEED_DIG) st = DIG;
564 else if (st == NEED_DIG_DEC) st = DIG_DEC;
565 else if (st == NEED_DIG_EXP || st == EXP) st = DIG_EXP;
566 else if (st == DIG || st == DIG_DEC || st == DIG_EXP);
571 if (st == DIG) st = NEED_DIG_DEC;
574 else if (*p ==
'-' || *p ==
'+')
576 if (st == INIT) st = NEED_DIG;
577 else if (st == EXP) st = NEED_DIG_EXP;
580 else if (*p ==
'e' || *p ==
'E')
582 if (st == DIG || st == DIG_DEC) st = EXP;
585 else if (isspace(*p))
587 if (!space_after)
gml_lwpgerror(
"invalid GML representation", 11);
588 if (st == DIG || st == DIG_DEC || st == DIG_EXP)st = END;
589 else if (st == NEED_DIG_DEC) st = END;
596 if (st != DIG && st != NEED_DIG_DEC && st != DIG_DEC && st != DIG_EXP && st != END)
608 xmlChar *gml_coord, *gml_ts, *gml_cs, *gml_dec;
617 gml_coord = xmlNodeGetContent(xnode);
618 p = (
char *) gml_coord;
628 if (gml_ts == NULL) ts =
' ';
631 if (xmlStrlen(gml_ts) > 1 || isdigit(gml_ts[0]))
639 if (gml_cs == NULL) cs =
',';
642 if (xmlStrlen(gml_cs) > 1 || isdigit(gml_cs[0]))
650 if (gml_dec == NULL) dec =
'.';
653 if (xmlStrlen(gml_dec) > 1 || isdigit(gml_dec[0]))
659 if (cs == ts || cs == dec || ts == dec)
665 while (isspace(*p)) p++;
666 for (q = p, gml_dims=0, digit =
false ; *p ; p++)
669 if (isdigit(*p)) digit =
true;
677 if (*(p+1) ==
'\0')
gml_lwpgerror(
"invalid GML representation", 19);
686 else if (digit && (*p == ts || *(p+1) ==
'\0'))
688 if (*p == ts) *p =
'\0';
691 if (gml_dims < 2 || gml_dims > 3)
710 else if (*p == dec && dec !=
'.') *p =
'.';
734 for (xyz = xnode->children ; xyz != NULL ; xyz = xyz->next)
736 if (xyz->type != XML_ELEMENT_NODE)
continue;
742 c = xmlNodeGetContent(xyz);
750 c = xmlNodeGetContent(xyz);
758 c = xmlNodeGetContent(xyz);
766 if (!z) *hasz =
false;
779 xmlChar *dimension, *gmlpos;
789 dimension =
gmlGetProp(xnode,
"srsDimension");
790 if (dimension == NULL)
792 if (dimension == NULL) dim = 2;
795 dim = atoi((
char *) dimension);
797 if (dim < 2 || dim > 3)
800 if (dim == 2) *hasz =
false;
803 gmlpos = xmlNodeGetContent(xnode);
804 pos = (
char *) gmlpos;
805 while (isspace(*pos)) pos++;
810 for (p=pos, gml_dim=0, digit=
false ; *pos ; pos++)
812 if (isdigit(*pos)) digit =
true;
813 if (digit && (*pos ==
' ' || *(pos+1) ==
'\0'))
815 if (*pos ==
' ') *pos =
'\0';
819 else if (gml_dim == 2)
821 else if (gml_dim == 3)
831 if (gml_dim == 2) *hasz =
false;
832 if (gml_dim < 2 || gml_dim > 3 || gml_dim != dim)
846 xmlChar *dimension, *gmlposlist;
854 dimension =
gmlGetProp(xnode,
"srsDimension");
855 if (dimension == NULL)
857 if (dimension == NULL) dim = 2;
860 dim = atoi((
char *) dimension);
862 if (dim < 2 || dim > 3)
gml_lwpgerror(
"invalid GML representation", 27);
864 if (dim == 2) *hasz =
false;
867 gmlposlist = xmlNodeGetContent(xnode);
868 poslist = (
char *) gmlposlist;
876 while (isspace(*poslist)) poslist++;
877 for (p=poslist, gml_dim=0, digit=
false ; *poslist ; poslist++)
879 if (isdigit(*poslist)) digit =
true;
880 if (digit && (*poslist ==
' ' || *(poslist+1) ==
'\0'))
882 if (*poslist ==
' ') *poslist =
'\0';
892 pt.
x = pt.
y = pt.
z = pt.
m = 0.0;
895 else if (*(poslist+1) ==
'\0')
930 for (xa = xnode ; xa != NULL ; xa = xa->next)
932 if (xa->type != XML_ELEMENT_NODE)
continue;
934 if (xa->name == NULL)
continue;
939 if (pa == NULL) pa = tmp_pa;
946 if (pa == NULL) pa = tmp_pa;
953 if (pa == NULL) pa = tmp_pa;
960 if (pa == NULL) pa = tmp_pa;
968 for (xb = xa->children ; xb != NULL ; xb = xb->next)
970 if (xb->type != XML_ELEMENT_NODE)
continue;
978 if (!found || xb == NULL)
982 if (xb == NULL || xb->children == NULL)
986 if (tmp_pa->npoints != 1)
992 else if (srs.
srid != *root_srid)
994 if (pa == NULL) pa = tmp_pa;
999 if (pa == NULL)
gml_lwpgerror(
"invalid GML representation", 32);
1016 if (xnode->children == NULL)
1026 *root_srid = srs.
srid;
1031 if (srs.
srid != *root_srid)
1051 if (xnode->children == NULL)
1061 *root_srid = srs.
srid;
1066 if (srs.
srid != *root_srid)
1088 xmlChar *interpolation=NULL;
1093 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1095 if (xa->type != XML_ELEMENT_NODE)
continue;
1103 if (!found)
gml_lwpgerror(
"invalid GML representation", 37);
1108 for (xa = xa->children, lss=0; xa != NULL ; xa = xa->next)
1110 if (xa->type != XML_ELEMENT_NODE)
continue;
1116 interpolation =
gmlGetProp(xa,
"interpolation");
1117 if (interpolation != NULL)
1119 if (strcmp((
char *) interpolation,
"linear"))
1121 xmlFree(interpolation);
1129 if (ppa[lss]->npoints < 2)
1133 if (lss == 0)
gml_lwpgerror(
"invalid GML representation", 40);
1136 if (lss == 1) pa = ppa[0];
1148 size_t cp_point_size =
sizeof(
POINT3D);
1149 size_t final_point_size = *hasz ?
sizeof(
POINT3D) :
sizeof(
POINT2D);
1161 for (
size_t i = 1; i < lss; i++)
1168 cp_point_size * (ppa[i]->npoints - 1));
1170 npoints += ppa[i]->
npoints - 1;
1202 if (ppa[0]->npoints < 4
1232 if (xnode->children == NULL)
1237 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1241 if (xa->type != XML_ELEMENT_NODE)
continue;
1247 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1249 if (xb->type != XML_ELEMENT_NODE)
continue;
1256 if (ppa[0]->npoints < 4
1269 for (ring=1, xa = xnode->children ; xa != NULL ; xa = xa->next)
1273 if (xa->type != XML_ELEMENT_NODE)
continue;
1279 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1281 if (xb->type != XML_ELEMENT_NODE)
continue;
1289 if (ppa[ring]->npoints < 4
1300 if (ppa == NULL || ppa[0] == NULL)
gml_lwpgerror(
"invalid GML representation", 44);
1304 for (i=0 ; i < ring ; i++)
1322 xmlChar *interpolation=NULL;
1326 if (xnode->children == NULL)
1332 interpolation =
gmlGetProp(xnode,
"interpolation");
1333 if (interpolation != NULL)
1335 if (strcmp((
char *) interpolation,
"planar"))
1337 xmlFree(interpolation);
1342 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1345 if (xa->type != XML_ELEMENT_NODE)
continue;
1349 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1352 if (xb->type != XML_ELEMENT_NODE)
continue;
1369 if (pa == NULL)
gml_lwpgerror(
"invalid GML representation", 47);
1385 xmlChar *interpolation=NULL;
1397 interpolation =
gmlGetProp(xnode,
"interpolation");
1398 if (interpolation != NULL)
1400 if (strcmp((
char *) interpolation,
"planar"))
1402 xmlFree(interpolation);
1408 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1414 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1416 if (xb->type != XML_ELEMENT_NODE)
continue;
1423 if (ppa[0]->npoints < 4
1438 for (ring=1, xa = xnode->children ; xa != NULL ; xa = xa->next)
1440 if (xa->type != XML_ELEMENT_NODE)
continue;
1445 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1447 if (xb->type != XML_ELEMENT_NODE)
continue;
1454 if (ppa[ring]->npoints < 4
1467 if (ppa == NULL || ppa[0] == NULL)
gml_lwpgerror(
"invalid GML representation", 50);
1471 for (i=0 ; i < ring ; i++)
1493 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1495 if (xa->type != XML_ELEMENT_NODE)
continue;
1503 if (!found)
gml_lwpgerror(
"invalid GML representation", 51);
1506 for (patch=0, xa = xa->children ; xa != NULL ; xa = xa->next)
1508 if (xa->type != XML_ELEMENT_NODE)
continue;
1515 if (patch > 1)
gml_lwpgerror(
"invalid GML representation", 52);
1520 if (!patch)
gml_lwpgerror(
"invalid GML representation", 53);
1546 *root_srid = srs.
srid;
1550 if (xnode->children == NULL)
1554 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1556 if (xa->type != XML_ELEMENT_NODE)
continue;
1565 if (!found)
return geom;
1568 for (xa = xa->children ; xa != NULL ; xa = xa->next)
1570 if (xa->type != XML_ELEMENT_NODE)
continue;
1574 if (xa->children != NULL)
1596 *root_srid = srs.
srid;
1600 if (xnode->children == NULL)
1603 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1606 if (xa->type != XML_ELEMENT_NODE)
continue;
1610 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1619 if (xa->children != NULL)
1642 *root_srid = srs.
srid;
1646 if (xnode->children == NULL)
1649 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1652 if (xa->type != XML_ELEMENT_NODE)
continue;
1655 if (xa->children != NULL)
1677 *root_srid = srs.
srid;
1681 if (xnode->children == NULL)
1684 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1688 if (xa->type != XML_ELEMENT_NODE)
continue;
1692 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1701 if (xa->children != NULL)
1724 *root_srid = srs.
srid;
1728 if (xnode->children == NULL)
1731 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1734 if (xa->type != XML_ELEMENT_NODE)
continue;
1737 if (xa->children != NULL)
1759 *root_srid = srs.
srid;
1763 if (xnode->children == NULL)
1766 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1769 if (xa->type != XML_ELEMENT_NODE)
continue;
1773 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1782 if (xa->children != NULL)
1807 *root_srid = srs.
srid;
1811 if (xnode->children == NULL)
1815 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1817 if (xa->type != XML_ELEMENT_NODE)
continue;
1825 if (!found)
return geom;
1827 for (xa = xa->children ; xa != NULL ; xa = xa->next)
1830 if (xa->type != XML_ELEMENT_NODE)
continue;
1855 *root_srid = srs.
srid;
1859 if (xnode->children == NULL)
1862 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1864 if (xa->type != XML_ELEMENT_NODE)
continue;
1877 if (xa->children == NULL)
break;
1879 parse_gml(xa->children, hasz, root_srid));
1893 xmlNodePtr xmlroot=NULL;
1901 xmldoc = xmlReadMemory(xml, xml_size, NULL, NULL, 0);
1909 xmlroot = xmlDocGetRootElement(xmldoc);
1918 lwgeom =
parse_gml(xmlroot, &hasz, &root_srid);
1925 lwgeom->
srid = root_srid;
1950 xmlNodePtr xa = xnode;
1954 while (xa != NULL &&
1960 if (xa == NULL)
gml_lwpgerror(
"invalid GML representation", 55);
1965 *root_srid = srs.
srid;
LWPOINT * lwpoint_construct_empty(int32_t srid, char hasz, char hasm)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
int ptarray_transform(POINTARRAY *pa, LWPROJ *pj)
void lwgeom_free(LWGEOM *geom)
int ptarray_is_closed_3d(const POINTARRAY *pa)
LWTIN * lwtin_add_lwtriangle(LWTIN *mobj, const LWTRIANGLE *obj)
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWTRIANGLE * lwtriangle_construct_empty(int32_t srid, char hasz, char hasm)
LWMPOINT * lwmpoint_add_lwpoint(LWMPOINT *mobj, const LWPOINT *obj)
LWMPOLY * lwmpoly_add_lwpoly(LWMPOLY *mobj, const LWPOLY *obj)
LWPSURFACE * lwpsurface_add_lwpoly(LWPSURFACE *mobj, const LWPOLY *obj)
void * lwrealloc(void *mem, size_t size)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
#define POLYHEDRALSURFACETYPE
LWPROJ * lwproj_from_PJ(PJ *pj, int8_t extra_geography_data)
Allocate a new LWPROJ containing the reference to the PROJ's PJ If extra_geography_data is true,...
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
LWCOLLECTION * lwcollection_construct_empty(uint8_t type, int32_t srid, char hasz, char hasm)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
void * lwalloc(size_t size)
int ptarray_is_closed_2d(const POINTARRAY *pa)
LWGEOM * lwtriangle_as_lwgeom(const LWTRIANGLE *obj)
#define LW_TRUE
Return types for functions with status returns.
#define SRID_UNKNOWN
Unknown SRID value.
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
LWLINE * lwline_construct_empty(int32_t srid, char hasz, char hasm)
LWTRIANGLE * lwtriangle_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
LWGEOM * lwgeom_force_2d(const LWGEOM *geom)
Strip out the Z/M components of an LWGEOM.
This library is the generic geometry handling section of PostGIS.
static LWGEOM * parse_gml_surface(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML Surface (3.1.1)
struct struct_gmlSrs gmlSrs
static xmlNodePtr get_xlink_node(xmlNodePtr xnode)
Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise.
static POINTARRAY * parse_gml_pos(xmlNodePtr xnode, bool *hasz)
Parse gml:pos.
PG_FUNCTION_INFO_V1(geom_from_gml)
Ability to parse GML geometry fragment and to return an LWGEOM or an error message.
static bool is_xlink(xmlNodePtr node)
Return true if current node contains a simple XLink Return false otherwise.
static LWGEOM * parse_gml_patch(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML PolygonPatch (3.1.1)
static LWGEOM * parse_gml_msurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML MultiSurface (3.1.1)
static LWGEOM * parse_gml(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML.
static LWGEOM * parse_gml_psurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML PolyhedralSurface (3.1.1) Nota: It's not part of SF-2.
static LWGEOM * parse_gml_coll(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML MultiGeometry (2.1.2, 3.1.1)
static POINTARRAY * gml_reproject_pa(POINTARRAY *pa, int32_t epsg_in, int32_t epsg_out)
Use Proj to reproject a given POINTARRAY.
static double parse_gml_double(char *d, bool space_before, bool space_after)
Parse a string supposed to be a double.
static LWGEOM * parse_gml_mcurve(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML MultiCurve (3.1.1)
Datum geom_from_gml(PG_FUNCTION_ARGS)
static LWGEOM * lwgeom_from_gml(const char *wkt, int xml_size)
Read GML.
static xmlChar * gmlGetProp(xmlNodePtr xnode, const char *charProp)
Retrieve a GML property from a node or NULL otherwise Respect namespaces if presents in the node elem...
static bool is_gml_namespace(xmlNodePtr xnode, bool is_strict)
Return false if current element namespace is not a GML one Return true otherwise.
static void parse_gml_srs(xmlNodePtr xnode, gmlSrs *srs)
Parse gml srsName attribute.
static LWGEOM * parse_gml_polygon(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML Polygon (2.1.2, 3.1.1)
static POINTARRAY * parse_gml_coordinates(xmlNodePtr xnode, bool *hasz)
Parse gml:coordinates.
static LWGEOM * parse_gml_line(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML lineString (2.1.2, 3.1.1)
static POINTARRAY * parse_gml_data(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse data coordinates.
static LWGEOM * parse_gml_mpoly(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML MultiPolygon (2.1.2, 3.1.1)
static POINTARRAY * parse_gml_coord(xmlNodePtr xnode, bool *hasz)
Parse gml:coord.
static LWGEOM * parse_gml_curve(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML Curve (3.1.1)
static void gml_lwpgerror(char *msg, __attribute__((__unused__)) int error_code)
static LWGEOM * parse_gml_mpoint(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse gml:MultiPoint (2.1.2, 3.1.1)
static LWGEOM * parse_gml_point(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML point (2.1.2, 3.1.1)
static LWGEOM * parse_gml_tin(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML Tin (and TriangulatedSurface) (3.1.1)
static LWGEOM * parse_gml_triangle(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML Triangle (3.1.1)
static LWGEOM * parse_gml_mline(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse gml:MultiLineString (2.1.2, 3.1.1)
static int gml_is_srid_planar(int32_t srid)
Return 1 if given srid is planar (0 otherwise, i.e geocentric srid) Return -1 if srid is not in spati...
static POINTARRAY * parse_gml_poslist(xmlNodePtr xnode, bool *hasz)
Parse gml:posList.
static bool is_gml_element(xmlNodePtr xn, const char *gml_name)
static LWGEOM * parse_gml_linearring(xmlNodePtr xnode, bool *hasz, int *root_srid)
Parse GML LinearRing (3.1.1)
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
char * text_to_cstring(const text *textptr)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)