50 #include "executor/spi.h"
51 #include "utils/builtins.h"
53 #include <libxml/tree.h>
54 #include <libxml/parser.h>
55 #include <libxml/xpath.h>
56 #include <libxml/xpathInternals.h>
58 #include "../postgis_config.h"
59 #include "lwgeom_pg.h"
61 #include "lwgeom_transform.h"
75 #define XLINK_NS ((char *) "http://www.w3.org/1999/xlink")
76 #define GML_NS ((char *) "http://www.opengis.net/gml")
77 #define GML32_NS ((char *) "http://www.opengis.net/gml/3.2")
83 POSTGIS_DEBUGF(3,
"ST_GeomFromGML ERROR %i", error_code);
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);
113 root_srid = PG_GETARG_INT32(1);
117 lwgeom->
srid = root_srid;
119 geom = geometry_serialize(lwgeom);
122 PG_RETURN_POINTER(geom);
129 const char *colon_pos;
130 const char *node_name;
133 if (!xn || xn->type != XML_ELEMENT_NODE)
139 node_name = (
const char*)xn->name;
140 colon_pos = strchr(node_name,
':');
142 node_name = colon_pos + 1;
144 return strcmp(node_name, gml_name) == 0;
156 ns = xmlGetNsList(xnode->doc, xnode);
162 if (ns == NULL) {
return !is_strict; }
169 for (p=ns ; *p ; p++)
171 if ((*p)->href == NULL || (*p)->prefix == NULL ||
172 xnode->ns == NULL || xnode->ns->prefix == NULL)
continue;
174 if (!xmlStrcmp(xnode->ns->prefix, (*p)->prefix))
176 if ( !strcmp((
char *) (*p)->href,
GML_NS)
177 || !strcmp((
char *) (*p)->href,
GML32_NS))
197 static xmlChar *
gmlGetProp(xmlNodePtr xnode,
const char *charProp)
200 xmlChar *prop = (xmlChar*)charProp;
203 return xmlGetProp(xnode, prop);
209 value = xmlGetNsProp(xnode, prop, (xmlChar *)
GML_NS);
213 if (
value == NULL)
value = xmlGetNoNsProp(xnode, prop);
227 prop = xmlGetNsProp(node, (xmlChar *)
"type", (xmlChar *)
XLINK_NS);
228 if (prop == NULL)
return false;
229 if (strcmp((
char *) prop,
"simple"))
235 prop = xmlGetNsProp(node, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
236 if (prop == NULL)
return false;
255 xmlXPathContext *ctx;
256 xmlXPathObject *xpath;
257 xmlNodePtr node, ret_node;
258 xmlChar *href, *p, *node_id;
260 href = xmlGetNsProp(xnode, (xmlChar *)
"href", (xmlChar *)
XLINK_NS);
266 id =
lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name) +
267 xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
269 sprintf(
id,
"//%s:%s[@%s:id='%s']",
270 (
char *) xnode->ns->prefix,
271 (
char *) xnode->name,
272 (
char *) xnode->ns->prefix,
277 id =
lwalloc((xmlStrlen(xnode->name) +
278 xmlStrlen(href) +
sizeof(
"//:[@:id='']") + 1));
280 sprintf(
id,
"//%s[@id='%s']",
281 (
char *) xnode->name,
285 ctx = xmlXPathNewContext(xnode->doc);
294 ns = xmlGetNsList(xnode->doc, xnode);
295 for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href);
299 xpath = xmlXPathEvalExpression((xmlChar *)
id, ctx);
301 if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1)
304 xmlXPathFreeObject(xpath);
305 xmlXPathFreeContext(ctx);
308 ret_node = xpath->nodesetval->nodeTab[0];
309 xmlXPathFreeObject(xpath);
310 xmlXPathFreeContext(ctx);
313 for (node = xnode ; node != NULL ; node = node->parent)
315 if (node->type != XML_ELEMENT_NODE)
continue;
319 if (!xmlStrcmp(node_id, p))
351 snprintf(text_in, 16,
"EPSG:%d", epsg_in);
352 snprintf(text_out, 16,
"EPSG:%d", epsg_out);
364 elog(ERROR,
"gml_reproject_pa: reprojection failed");
367 proj_destroy(lwp->
pj);
383 int is_axis_order_gis_friendly, err;
385 if (SPI_OK_CONNECT != SPI_connect ())
386 lwpgerror(
"gml_is_srs_axis_order_gis_friendly: could not connect to SPI manager");
388 sprintf(query,
"SELECT srtext \
389 FROM spatial_ref_sys WHERE srid='%d'", srid);
391 err = SPI_exec(query, 1);
392 if (err < 0) lwpgerror(
"gml_is_srs_axis_order_gis_friendly: error executing query %d", err);
395 if (SPI_processed <= 0)
401 srtext = SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1);
403 is_axis_order_gis_friendly = 1;
404 if (srtext && srtext[0] !=
'\0')
407 char* srtext_horizontal = (
char*)
malloc(strlen(srtext) + 1);
408 strcpy(srtext_horizontal, srtext);
411 ptr = strstr(srtext_horizontal,
",VERT_CS[");
415 if( strstr(srtext_horizontal,
"AXIS[") == NULL &&
416 strstr(srtext_horizontal,
"GEOCCS[") == NULL )
421 is_axis_order_gis_friendly = 0;
423 else if( strstr(srtext_horizontal,
424 "AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST]") != NULL )
426 is_axis_order_gis_friendly = 0;
428 else if( strstr(srtext_horizontal,
429 "AXIS[\"Northing\",NORTH],AXIS[\"Easting\",EAST]") != NULL )
431 is_axis_order_gis_friendly = 0;
433 else if( strstr(srtext_horizontal,
434 "AXIS[\"geodetic latitude (Lat)\",north,ORDER[1]") != NULL )
436 is_axis_order_gis_friendly = 0;
439 free(srtext_horizontal);
443 return is_axis_order_gis_friendly;
453 int is_axis_order_gis_friendly;
456 bool honours_authority_axis_order =
false;
464 if (node->parent == NULL)
491 if (!strncmp((
char *) srsname,
"EPSG:", 5))
494 honours_authority_axis_order =
false;
496 else if (!strncmp((
char *) srsname,
"urn:ogc:def:crs:EPSG:", 21)
497 || !strncmp((
char *) srsname,
"urn:x-ogc:def:crs:EPSG:", 23)
498 || !strncmp((
char *) srsname,
"urn:EPSG:geographicCRS:", 23))
501 honours_authority_axis_order =
true;
503 else if (!strncmp((
char *) srsname,
504 "http://www.opengis.net/gml/srs/epsg.xml#", 40))
507 honours_authority_axis_order =
false;
512 for (p = (
char *) srsname ; *p ; p++);
513 for (--p ; *p != sep ; p--)
514 if (!isdigit(*p))
gml_lwpgerror(
"unknown spatial reference system", 5);
516 srs->
srid = atoi(++p);
526 srs->
reverse_axis = !is_axis_order_gis_friendly && honours_authority_axis_order;
561 if (space_before)
while (isspace(*d)) d++;
562 for (st = INIT, p = d ; *p ; p++)
567 if (st == INIT || st == NEED_DIG) st = DIG;
568 else if (st == NEED_DIG_DEC) st = DIG_DEC;
569 else if (st == NEED_DIG_EXP || st == EXP) st = DIG_EXP;
570 else if (st == DIG || st == DIG_DEC || st == DIG_EXP);
575 if (st == DIG) st = NEED_DIG_DEC;
578 else if (*p ==
'-' || *p ==
'+')
580 if (st == INIT) st = NEED_DIG;
581 else if (st == EXP) st = NEED_DIG_EXP;
584 else if (*p ==
'e' || *p ==
'E')
586 if (st == DIG || st == DIG_DEC) st = EXP;
589 else if (isspace(*p))
591 if (!space_after)
gml_lwpgerror(
"invalid GML representation", 11);
592 if (st == DIG || st == DIG_DEC || st == DIG_EXP)st = END;
593 else if (st == NEED_DIG_DEC) st = END;
600 if (st != DIG && st != NEED_DIG_DEC && st != DIG_DEC && st != DIG_EXP && st != END)
612 xmlChar *gml_coord, *gml_ts, *gml_cs, *gml_dec;
621 gml_coord = xmlNodeGetContent(xnode);
622 p = (
char *) gml_coord;
632 if (gml_ts == NULL) ts =
' ';
635 if (xmlStrlen(gml_ts) > 1 || isdigit(gml_ts[0]))
643 if (gml_cs == NULL) cs =
',';
646 if (xmlStrlen(gml_cs) > 1 || isdigit(gml_cs[0]))
654 if (gml_dec == NULL) dec =
'.';
657 if (xmlStrlen(gml_dec) > 1 || isdigit(gml_dec[0]))
663 if (cs == ts || cs == dec || ts == dec)
669 while (isspace(*p)) p++;
670 for (q = p, gml_dims=0, digit =
false ; *p ; p++)
673 if (isdigit(*p)) digit =
true;
681 if (*(p+1) ==
'\0')
gml_lwpgerror(
"invalid GML representation", 19);
690 else if (digit && (*p == ts || *(p+1) ==
'\0'))
692 if (*p == ts) *p =
'\0';
695 if (gml_dims < 2 || gml_dims > 3)
714 else if (*p == dec && dec !=
'.') *p =
'.';
738 for (xyz = xnode->children ; xyz != NULL ; xyz = xyz->next)
740 if (xyz->type != XML_ELEMENT_NODE)
continue;
746 c = xmlNodeGetContent(xyz);
754 c = xmlNodeGetContent(xyz);
762 c = xmlNodeGetContent(xyz);
770 if (!z) *hasz =
false;
783 xmlChar *dimension, *gmlpos;
793 dimension =
gmlGetProp(xnode,
"srsDimension");
794 if (dimension == NULL)
796 if (dimension == NULL) dim = 2;
799 dim = atoi((
char *) dimension);
801 if (dim < 2 || dim > 3)
804 if (dim == 2) *hasz =
false;
807 gmlpos = xmlNodeGetContent(xnode);
808 pos = (
char *) gmlpos;
809 while (isspace(*pos)) pos++;
814 for (p=pos, gml_dim=0, digit=
false ; *pos ; pos++)
816 if (isdigit(*pos)) digit =
true;
817 if (digit && (*pos ==
' ' || *(pos+1) ==
'\0'))
819 if (*pos ==
' ') *pos =
'\0';
823 else if (gml_dim == 2)
825 else if (gml_dim == 3)
835 if (gml_dim == 2) *hasz =
false;
836 if (gml_dim < 2 || gml_dim > 3 || gml_dim != dim)
850 xmlChar *dimension, *gmlposlist;
858 dimension =
gmlGetProp(xnode,
"srsDimension");
859 if (dimension == NULL)
861 if (dimension == NULL) dim = 2;
864 dim = atoi((
char *) dimension);
866 if (dim < 2 || dim > 3)
gml_lwpgerror(
"invalid GML representation", 27);
868 if (dim == 2) *hasz =
false;
871 gmlposlist = xmlNodeGetContent(xnode);
872 poslist = (
char *) gmlposlist;
880 while (isspace(*poslist)) poslist++;
881 for (p=poslist, gml_dim=0, digit=
false ; *poslist ; poslist++)
883 if (isdigit(*poslist)) digit =
true;
884 if (digit && (*poslist ==
' ' || *(poslist+1) ==
'\0'))
886 if (*poslist ==
' ') *poslist =
'\0';
897 pt.
x = pt.
y = pt.
z = pt.
m = 0.0;
900 else if (*(poslist+1) ==
'\0')
935 for (xa = xnode ; xa != NULL ; xa = xa->next)
937 if (xa->type != XML_ELEMENT_NODE)
continue;
939 if (xa->name == NULL)
continue;
944 if (pa == NULL) pa = tmp_pa;
951 if (pa == NULL) pa = tmp_pa;
958 if (pa == NULL) pa = tmp_pa;
965 if (pa == NULL) pa = tmp_pa;
973 for (xb = xa->children ; xb != NULL ; xb = xb->next)
975 if (xb->type != XML_ELEMENT_NODE)
continue;
983 if (!found || xb == NULL)
987 if (xb == NULL || xb->children == NULL)
991 if (tmp_pa->npoints != 1)
997 else if (srs.
srid != *root_srid)
999 if (pa == NULL) pa = tmp_pa;
1004 if (pa == NULL)
gml_lwpgerror(
"invalid GML representation", 32);
1023 if (xnode->children == NULL)
1033 *root_srid = srs.
srid;
1038 if (srs.
srid != *root_srid)
1060 if (xnode->children == NULL)
1070 *root_srid = srs.
srid;
1075 if (srs.
srid != *root_srid)
1097 xmlChar *interpolation=NULL;
1104 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1106 if (xa->type != XML_ELEMENT_NODE)
continue;
1114 if (!found)
gml_lwpgerror(
"invalid GML representation", 37);
1119 for (xa = xa->children, lss=0; xa != NULL ; xa = xa->next)
1121 if (xa->type != XML_ELEMENT_NODE)
continue;
1127 interpolation =
gmlGetProp(xa,
"interpolation");
1128 if (interpolation != NULL)
1130 if (strcmp((
char *) interpolation,
"linear"))
1132 xmlFree(interpolation);
1140 if (ppa[lss]->npoints < 2)
1144 if (lss == 0)
gml_lwpgerror(
"invalid GML representation", 40);
1147 if (lss == 1) pa = ppa[0];
1159 size_t cp_point_size =
sizeof(
POINT3D);
1160 size_t final_point_size = *hasz ?
sizeof(
POINT3D) :
sizeof(
POINT2D);
1172 for (
size_t i = 1; i < lss; i++)
1179 cp_point_size * (ppa[i]->npoints - 1));
1181 npoints += ppa[i]->
npoints - 1;
1215 if (ppa[0]->npoints < 4
1247 if (xnode->children == NULL)
1252 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1256 if (xa->type != XML_ELEMENT_NODE)
continue;
1262 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1264 if (xb->type != XML_ELEMENT_NODE)
continue;
1271 if (ppa[0]->npoints < 4
1284 for (ring=1, xa = xnode->children ; xa != NULL ; xa = xa->next)
1288 if (xa->type != XML_ELEMENT_NODE)
continue;
1294 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1296 if (xb->type != XML_ELEMENT_NODE)
continue;
1304 if (ppa[ring]->npoints < 4
1315 if (ppa == NULL || ppa[0] == NULL)
gml_lwpgerror(
"invalid GML representation", 44);
1319 for (i=0 ; i < ring ; i++)
1337 xmlChar *interpolation=NULL;
1343 if (xnode->children == NULL)
1349 interpolation =
gmlGetProp(xnode,
"interpolation");
1350 if (interpolation != NULL)
1352 if (strcmp((
char *) interpolation,
"planar"))
1354 xmlFree(interpolation);
1359 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1362 if (xa->type != XML_ELEMENT_NODE)
continue;
1366 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1369 if (xb->type != XML_ELEMENT_NODE)
continue;
1386 if (pa == NULL)
gml_lwpgerror(
"invalid GML representation", 47);
1402 xmlChar *interpolation=NULL;
1414 interpolation =
gmlGetProp(xnode,
"interpolation");
1415 if (interpolation != NULL)
1417 if (strcmp((
char *) interpolation,
"planar"))
1419 xmlFree(interpolation);
1425 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1431 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1433 if (xb->type != XML_ELEMENT_NODE)
continue;
1440 if (ppa[0]->npoints < 4
1455 for (ring=1, xa = xnode->children ; xa != NULL ; xa = xa->next)
1457 if (xa->type != XML_ELEMENT_NODE)
continue;
1462 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1464 if (xb->type != XML_ELEMENT_NODE)
continue;
1471 if (ppa[ring]->npoints < 4
1484 if (ppa == NULL || ppa[0] == NULL)
gml_lwpgerror(
"invalid GML representation", 50);
1488 for (i=0 ; i < ring ; i++)
1512 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1514 if (xa->type != XML_ELEMENT_NODE)
continue;
1522 if (!found)
gml_lwpgerror(
"invalid GML representation", 51);
1525 for (patch=0, xa = xa->children ; xa != NULL ; xa = xa->next)
1527 if (xa->type != XML_ELEMENT_NODE)
continue;
1534 if (patch > 1)
gml_lwpgerror(
"invalid GML representation", 52);
1539 if (!patch)
gml_lwpgerror(
"invalid GML representation", 53);
1567 *root_srid = srs.
srid;
1571 if (xnode->children == NULL)
1575 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1577 if (xa->type != XML_ELEMENT_NODE)
continue;
1586 if (!found)
return geom;
1589 for (xa = xa->children ; xa != NULL ; xa = xa->next)
1591 if (xa->type != XML_ELEMENT_NODE)
continue;
1595 if (xa->children != NULL)
1619 *root_srid = srs.
srid;
1623 if (xnode->children == NULL)
1626 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1629 if (xa->type != XML_ELEMENT_NODE)
continue;
1633 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1642 if (xa->children != NULL)
1667 *root_srid = srs.
srid;
1671 if (xnode->children == NULL)
1674 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1677 if (xa->type != XML_ELEMENT_NODE)
continue;
1680 if (xa->children != NULL)
1704 *root_srid = srs.
srid;
1708 if (xnode->children == NULL)
1711 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1715 if (xa->type != XML_ELEMENT_NODE)
continue;
1719 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1728 if (xa->children != NULL)
1753 *root_srid = srs.
srid;
1757 if (xnode->children == NULL)
1760 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1763 if (xa->type != XML_ELEMENT_NODE)
continue;
1766 if (xa->children != NULL)
1790 *root_srid = srs.
srid;
1794 if (xnode->children == NULL)
1797 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1800 if (xa->type != XML_ELEMENT_NODE)
continue;
1804 for (xb = xa->children ; xb != NULL ; xb = xb->next)
1813 if (xa->children != NULL)
1840 *root_srid = srs.
srid;
1844 if (xnode->children == NULL)
1848 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1850 if (xa->type != XML_ELEMENT_NODE)
continue;
1858 if (!found)
return geom;
1860 for (xa = xa->children ; xa != NULL ; xa = xa->next)
1863 if (xa->type != XML_ELEMENT_NODE)
continue;
1890 *root_srid = srs.
srid;
1894 if (xnode->children == NULL)
1897 for (xa = xnode->children ; xa != NULL ; xa = xa->next)
1899 if (xa->type != XML_ELEMENT_NODE)
continue;
1912 if (xa->children == NULL)
break;
1914 parse_gml(xa->children, hasz, root_srid));
1928 xmlNodePtr xmlroot=NULL;
1936 xmldoc = xmlReadMemory(xml, xml_size, NULL, NULL, 0);
1944 xmlroot = xmlDocGetRootElement(xmldoc);
1953 lwgeom =
parse_gml(xmlroot, &hasz, &root_srid);
1960 lwgeom->
srid = root_srid;
1985 xmlNodePtr xa = xnode;
1989 while (xa != NULL &&
1995 if (xa == NULL)
gml_lwpgerror(
"invalid GML representation", 55);
2000 *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)
LWPROJ * lwproj_from_str(const char *str_in, const char *str_out)
Allocate a new LWPROJ containing the reference to the PROJ's PJ If extra_geography_data is true,...
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
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 int gml_is_srs_axis_order_gis_friendly(int32_t srid)
Return 1 if the SRS definition from the authority has a GIS friendly order, that is easting,...
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 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)