From: Olivier Courtin Date: Fri, 6 Nov 2009 22:49:09 +0000 (+0000) Subject: finalize Xlink support (GML SF-2 fully compliant). Fix typo on PointProperty/Point... X-Git-Tag: 1.5.0b1~280 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fa590aee0a4308606e0ee33b5d21b08dc70bb537;p=postgis finalize Xlink support (GML SF-2 fully compliant). Fix typo on PointProperty/Point. Few comments and style corrections. Update unit tests. git-svn-id: http://svn.osgeo.org/postgis/trunk@4759 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_in_gml.c b/postgis/lwgeom_in_gml.c index 1608ed6bf..472832f22 100644 --- a/postgis/lwgeom_in_gml.c +++ b/postgis/lwgeom_in_gml.c @@ -20,7 +20,7 @@ * * GML versions supported: * - GML 3.2.1 Namespace -* - GML 3.1.1 Simple Features profile +* - GML 3.1.1 Simple Features profile SF-2 * - GML 3.1.0 and 3.0.0 SF elements and attributes * - GML 2.1.2 * Cf: @@ -113,10 +113,10 @@ Datum geom_from_gml(PG_FUNCTION_ARGS) xmlFreeDoc(xmldoc); xmlCleanupParser(); - /* GML geometry could be either 2 or 3D and can be nested mixed. + /* GML geometries could be either 2 or 3D and can be nested mixed. * Missing Z dimension is even tolerated inside some GML coords * - * So we deal with 3D in all structure allocation, and flag hasz + * So we deal with 3D in all structures allocation, and flag hasz * to false if we met once a missing Z dimension * In this case, we force recursive 2D. */ @@ -134,7 +134,71 @@ Datum geom_from_gml(PG_FUNCTION_ARGS) /** - * Return true if current node contains a simple xlink + * Return false if current element namespace is not a GML one + * Return true otherwise. + */ +static bool is_gml_namespace(xmlNodePtr xnode, bool is_strict) +{ + xmlNsPtr *ns, *p; + + ns = xmlGetNsList(xnode->doc, xnode); + /* + * If no namespace is available we could return true anyway + * (because we work only on GML fragment, we don't want to + * 'oblige' to add namespace on the geometry root node) + */ + if (ns == NULL) return !is_strict; + + /* + * Handle namespaces: + * - http://www.opengis.net/gml (GML 3.1.1 and priors) + * - http://www.opengis.net/gml/3.2 (GML 3.2.1) + */ + for (p=ns ; *p ; p++) { + if ((*p)->href == NULL) continue; + if (!strcmp((char *) (*p)->href, GML_NS) || + !strcmp((char *) (*p)->href, GML32_NS)) { + if ( (*p)->prefix == NULL || + !xmlStrcmp(xnode->ns->prefix, (*p)->prefix)) { + + xmlFree(ns); + return true; + } + } + } + + xmlFree(ns); + return false; +} + + +/** + * Retrieve a GML propertie from a node or NULL otherwise + * Respect namespaces if presents in the node element + */ +static xmlChar *gmlGetProp(xmlNodePtr xnode, xmlChar *prop) +{ + xmlChar *value; + + if (!is_gml_namespace(xnode, true)) + return xmlGetProp(xnode, prop); + /* + * Handle namespaces: + * - http://www.opengis.net/gml (GML 3.1.1 and priors) + * - http://www.opengis.net/gml/3.2 (GML 3.2.1) + */ + value = xmlGetNsProp(xnode, prop, (xmlChar *) GML_NS); + if (value == NULL) value = xmlGetNsProp(xnode, prop, (xmlChar *) GML32_NS); + + /* In last case try without explicit namespace */ + if (value == NULL) value = xmlGetNoNsProp(xnode, prop); + + return value; +} + + +/** + * Return true if current node contains a simple XLink * Return false otherwise. */ static bool is_xlink(xmlNodePtr node) @@ -161,16 +225,16 @@ static bool is_xlink(xmlNodePtr node) /** - * Return a xmlNodePtr on a node referenced by a xlink or NULL otherwise + * Return a xmlNodePtr on a node referenced by a XLink or NULL otherwise */ static xmlNodePtr get_xlink_node(xmlNodePtr xnode) { char *id; - xmlNodePtr node; xmlNsPtr *ns, *n; - xmlChar *href, *p; xmlXPathContext *ctx; xmlXPathObject *xpath; + xmlNodePtr node, ret_node; + xmlChar *href, *p, *node_id; href = xmlGetNsProp(xnode, (xmlChar *)"href", (xmlChar *) XLINK_NS); id = lwalloc((xmlStrlen(xnode->ns->prefix) * 2 + xmlStrlen(xnode->name) @@ -178,15 +242,15 @@ static xmlNodePtr get_xlink_node(xmlNodePtr xnode) p = href; p++; /* ignore '#' first char */ - /* Xpath pattern look like: //gml:point[@gml:id='p1'] */ + /* XPath pattern look like: //gml:point[@gml:id='p1'] */ sprintf(id, "//%s:%s[@%s:id='%s']", (char *) xnode->ns->prefix, (char *) xnode->name, (char *) xnode->ns->prefix, (char *) p); - xmlFree(href); ctx = xmlXPathNewContext(xnode->doc); if (ctx == NULL) { + xmlFree(href); lwfree(id); return NULL; } @@ -196,83 +260,32 @@ static xmlNodePtr get_xlink_node(xmlNodePtr xnode) for (n=ns ; *n; n++) xmlXPathRegisterNs(ctx, (*n)->prefix, (*n)->href); xmlFree(ns); - /* Execute Xpath expression */ + /* Execute XPath expression */ xpath = xmlXPathEvalExpression((xmlChar *) id, ctx); lwfree(id); if (xpath == NULL || xpath->nodesetval == NULL || xpath->nodesetval->nodeNr != 1) { + xmlFree(href); xmlXPathFreeObject(xpath); xmlXPathFreeContext(ctx); return NULL; } - node = xpath->nodesetval->nodeTab[0]; + ret_node = xpath->nodesetval->nodeTab[0]; xmlXPathFreeObject(xpath); xmlXPathFreeContext(ctx); - return node; -} - - -/** - * Return false if current element namespace is not a GML one - * Return true otherwise. - */ -static bool is_gml_namespace(xmlNodePtr xnode, bool is_strict) -{ - xmlNsPtr *ns, *p; - - ns = xmlGetNsList(xnode->doc, xnode); - /* - * If no namespace is available we could return true anyway - * (because we work only on GML fragment, we don't want to - * 'oblige' to add namespace on the geometry root node) - */ - if (ns == NULL) return !is_strict; - - /* - * Handle namespaces: - * - http://www.opengis.net/gml (GML 3.1.1 and priors) - * - http://www.opengis.net/gml/3.2 (GML 3.2.1) - */ - for (p=ns ; *p ; p++) { - if ((*p)->href == NULL) continue; - if (!strcmp((char *) (*p)->href, GML_NS) || - !strcmp((char *) (*p)->href, GML32_NS)) { - if ( (*p)->prefix == NULL || - !xmlStrcmp(xnode->ns->prefix, (*p)->prefix)) { - - xmlFree(ns); - return true; - } + /* Protection against circular calls */ + for (node = xnode ; node != NULL ; node = node->parent) { + if (node->type != XML_ELEMENT_NODE) continue; + node_id = gmlGetProp(node, (xmlChar *) "id"); + if (node_id != NULL) { + if (!xmlStrcmp(node_id, p)) + lwerror("invalid GML representation"); + xmlFree(node_id); } } - xmlFree(ns); - return false; -} - - -/** - * Retrieve a GML propertie from a node - * Respect namespaces if presents in the node element - */ -static xmlChar *gmlGetProp(xmlNodePtr xnode, xmlChar *prop) -{ - xmlChar *value; - - if (!is_gml_namespace(xnode, true)) - return xmlGetProp(xnode, prop); - /* - * Handle namespaces: - * - http://www.opengis.net/gml (GML 3.1.1 and priors) - * - http://www.opengis.net/gml/3.2 (GML 3.2.1) - */ - value = xmlGetNsProp(xnode, prop, (xmlChar *) GML_NS); - if (value == NULL) value = xmlGetNsProp(xnode, prop, (xmlChar *) GML32_NS); - - /* In last case try without explicit namespace */ - if (value == NULL) value = xmlGetNoNsProp(xnode, prop); - - return value; + xmlFree(href); + return ret_node; } @@ -343,14 +356,14 @@ static int gml_is_srid_planar(int srid) int is_planar, err; if (SPI_OK_CONNECT != SPI_connect ()) - lwerror("gml_is_srid_lat_lon: could not connect to SPI manager"); + lwerror("gml_is_srid_planar: could not connect to SPI manager"); /* A way to find if this projection is planar or geocentric */ sprintf(query, "SELECT position('+units=m ' in proj4text) \ FROM spatial_ref_sys WHERE srid='%d'", srid); err = SPI_exec(query, 1); - if (err < 0) lwerror("gml_is_srid_lat_lon: error executing query %d", err); + if (err < 0) lwerror("gml_is_srid_planar: error executing query %d", err); /* No entry in spatial_ref_sys */ if (SPI_processed <= 0) { @@ -464,7 +477,7 @@ static double parse_gml_double(char *d, bool space_before, bool space_after) /* * Double pattern * [-|\+]?[0-9]+(\.)?([0-9]+)?([Ee](\+|-)?[0-9]+)? - * We could also meet spaces before or after + * We could also meet spaces before and/or after * this pattern upon parameters */ @@ -690,7 +703,7 @@ static POINTARRAY* parse_gml_pos(xmlNodePtr xnode, bool *hasz) for (posnode = xnode ; posnode != NULL ; posnode = posnode->next) { - /* We only care about pos element */ + /* We only care about gml:pos element */ if (posnode->type != XML_ELEMENT_NODE) continue; if (strcmp((char *) posnode->name, "pos")) continue; @@ -871,20 +884,21 @@ static POINTARRAY* parse_gml_data(xmlNodePtr xnode, bool *hasz, int *root_srid) for (xb = xa->children ; xb != NULL ; xb = xb->next) { if (xb->type != XML_ELEMENT_NODE) continue; if (!is_gml_namespace(xb, false)) continue; - if (!strcmp((char *) xb->name, "point")) { + if (!strcmp((char *) xb->name, "Point")) { found = true; break; } } - - if (!found || xb == NULL) lwerror("invalid GML representation"); + if (!found || xb == NULL) + lwerror("invalid GML representation"); if (is_xlink(xb)) xb = get_xlink_node(xb); if (xb == NULL || xb->children == NULL) lwerror("invalid GML representation"); tmp_pa = parse_gml_data(xb->children, hasz, root_srid); - if (tmp_pa->npoints != 1) lwerror("invalid GML representation"); + if (tmp_pa->npoints != 1) + lwerror("invalid GML representation"); srs = parse_gml_srs(xb); if (srs->reverse_axis) tmp_pa = gml_reverse_axis_pa(tmp_pa); @@ -914,6 +928,8 @@ static LWGEOM* parse_gml_point(xmlNodePtr xnode, bool *hasz, int *root_srid) LWGEOM *geom; POINTARRAY *pa; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + if (xnode->children == NULL) lwerror("invalid GML representation"); pa = parse_gml_data(xnode->children, hasz, root_srid); if (pa->npoints != 1) lwerror("invalid GML representation"); @@ -943,6 +959,8 @@ static LWGEOM* parse_gml_line(xmlNodePtr xnode, bool *hasz, int *root_srid) LWGEOM *geom; POINTARRAY *pa; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + if (xnode->children == NULL) lwerror("invalid GML representation"); pa = parse_gml_data(xnode->children, hasz, root_srid); if (pa->npoints < 2) lwerror("invalid GML representation"); @@ -968,15 +986,17 @@ static LWGEOM* parse_gml_line(xmlNodePtr xnode, bool *hasz, int *root_srid) */ static LWGEOM* parse_gml_curve(xmlNodePtr xnode, bool *hasz, int *root_srid) { - xmlChar *interpolation = 0; - int lss, last, i; - POINTARRAY **ppa = 0; - POINTARRAY *pa = 0; xmlNodePtr xa; - LWGEOM *geom = 0; - gmlSrs *srs = 0; + int lss, last, i; bool found=false; + gmlSrs *srs=NULL; + LWGEOM *geom=NULL; + POINTARRAY *pa=NULL; + POINTARRAY **ppa=NULL; unsigned int npoints=0; + xmlChar *interpolation=NULL; + + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); /* Looking for gml:segments */ for (xa = xnode->children ; xa != NULL ; xa = xa->next) { @@ -1079,6 +1099,8 @@ static LWGEOM* parse_gml_polygon(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa, xb; POINTARRAY **ppa = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); for (xa = xnode->children ; xa != NULL ; xa = xa->next) { @@ -1160,14 +1182,16 @@ static LWGEOM* parse_gml_polygon(xmlNodePtr xnode, bool *hasz, int *root_srid) */ static LWGEOM* parse_gml_surface(xmlNodePtr xnode, bool *hasz, int *root_srid) { - xmlChar *interpolation = 0; xmlNodePtr xa, xb, xc; - int i, patch, ring = 1; - POINTARRAY **ppa = 0; - LWGEOM *geom = 0; - gmlSrs *srs = 0; + xmlChar *interpolation=NULL; + POINTARRAY **ppa=NULL; + int i, patch, ring=0; + LWGEOM *geom=NULL; + gmlSrs *srs=NULL; bool found=false; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); /* Looking for gml:patches */ for (xa = xnode->children ; xa != NULL ; xa = xa->next) { @@ -1245,7 +1269,9 @@ static LWGEOM* parse_gml_surface(xmlNodePtr xnode, bool *hasz, int *root_srid) || ( *hasz && !ptarray_isclosed3d(ppa[ring]))) lwerror("invalid GML representation"); - if (srs->reverse_axis) ppa[ring] = gml_reverse_axis_pa(ppa[ring]); + if (srs->reverse_axis) + ppa[ring] = gml_reverse_axis_pa(ppa[ring]); + ring++; } } @@ -1279,6 +1305,8 @@ static LWGEOM* parse_gml_mpoint(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa; LWGEOM *geom = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); if (!*root_srid) { *root_srid = srs->srid; @@ -1314,6 +1342,8 @@ static LWGEOM* parse_gml_mline(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa; LWGEOM *geom = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); if (!*root_srid) { *root_srid = srs->srid; @@ -1349,6 +1379,8 @@ static LWGEOM* parse_gml_mcurve(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa; LWGEOM *geom = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); if (!*root_srid) { *root_srid = srs->srid; @@ -1384,6 +1416,8 @@ static LWGEOM* parse_gml_mpoly(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa; LWGEOM *geom = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); if (!*root_srid) { *root_srid = srs->srid; @@ -1419,6 +1453,8 @@ static LWGEOM* parse_gml_msurface(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa; LWGEOM *geom = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); if (!*root_srid) { *root_srid = srs->srid; @@ -1454,6 +1490,8 @@ static LWGEOM* parse_gml_coll(xmlNodePtr xnode, bool *hasz, int *root_srid) xmlNodePtr xa; LWGEOM *geom = NULL; + if (is_xlink(xnode)) xnode = get_xlink_node(xnode); + srs = parse_gml_srs(xnode); if (!*root_srid) { *root_srid = srs->srid; diff --git a/regress/in_gml.sql b/regress/in_gml.sql index 58dde924b..45a5c2760 100644 --- a/regress/in_gml.sql +++ b/regress/in_gml.sql @@ -727,40 +727,239 @@ SELECT 'poslist_18', ST_AsEWKT(ST_GeomFromGML('!@#$ SELECT 'data_1', ST_AsEWKT(ST_GeomFromGML('1 23 4 5 67,8 9,101112')); -- Mixed pos, posList, pointProperty, pointRep -SELECT 'data_2', ST_AsEWKT(ST_GeomFromGML('1 23 4 5 67 89,10')); +SELECT 'data_2', ST_AsEWKT(ST_GeomFromGML('1 23 4 5 67 89,10')); + -- --- Xlink +-- XLink -- --- Xlink on a point -SELECT 'xlink_1', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +-- xlink with pointProperty +SELECT 'xlink_1', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: xlink:href destination is not defined -SELECT 'xlink_2', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_2', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: no href -SELECT 'xlink_3', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_3', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: empty href -SELECT 'xlink_4', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_4', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: no sharp char in href -SELECT 'xlink_5', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_5', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: no xlink namespace -SELECT 'xlink_6', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_6', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: wrong xlink namespace -SELECT 'xlink_7', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_7', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: no xlink:type -SELECT 'xlink_8', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_8', ST_AsEWKT(ST_GeomFromGML('1 23 4')); -- ERROR: xlink:type not simple -SELECT 'xlink_9', ST_AsEWKT(ST_GeomFromGML('1 23 4')); +SELECT 'xlink_9', ST_AsEWKT(ST_GeomFromGML('1 23 4')); + +-- ERROR: more than one destination is defined +SELECT 'xlink_10', ST_AsEWKT(ST_GeomFromGML('1 23 4')); + +-- xlink with pointRep +SELECT 'xlink_11', ST_AsEWKT(ST_GeomFromGML('1 23 4')); + +-- xlink on a point +SELECT 'xlink_12', ST_AsEWKT(ST_GeomFromGML('1 2')); + +-- xlink on a linestring +SELECT 'xlink_13', ST_AsEWKT(ST_GeomFromGML('1 2 3 4')); + +-- xlink on a curve +SELECT 'xlink_14', ST_AsEWKT(ST_GeomFromGML('1 2 3 4')); + +-- xlink on a polygon +SELECT 'xlink_15', ST_AsEWKT(ST_GeomFromGML('1 2 3 4 5 6 1 2')); + +-- xlink on a surface +SELECT 'xlink_16', ST_AsEWKT(ST_GeomFromGML('1 2 3 4 5 6 1 2')); + +-- xlink on a multipoint +SELECT 'xlink_17', ST_AsEWKT(ST_GeomFromGML('1 2')); + +-- xlink on a multiline +SELECT 'xlink_18', ST_AsEWKT(ST_GeomFromGML('1 2 3 4')); + +-- xlink on a multicurve +SELECT 'xlink_19', ST_AsEWKT(ST_GeomFromGML('1 2 3 4')); + +-- xlink on a multipolygon +SELECT 'xlink_20', ST_AsEWKT(ST_GeomFromGML('1 2 3 4 5 6 1 2')); + +-- xlink on a multisurface +SELECT 'xlink_21', ST_AsEWKT(ST_GeomFromGML('1 2 3 4 5 6 1 2')); + +-- xlink on a multigeometry +SELECT 'xlink_22', ST_AsEWKT(ST_GeomFromGML('1 2')); + +-- ERROR circular ref +SELECT 'xlink_23', ST_AsEWKT(ST_GeomFromGML('1 2')); + + + +-- +-- Bijective PostGIS GML test +-- + +-- Point GML 2 +SELECT 'gml_1', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('POINT(1 2)')))); + +-- Point GML 2 - 3D +SELECT 'gml_2', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('POINT(1 2 3)')))); + +-- Point GML 2 & SRID planar +SELECT 'gml_3', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;POINT(1 2)')))); + +-- Point GML 3 +SELECT 'gml_4', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('POINT(1 2)')))); + +-- Point GML 3 & SRID lat/lon +SELECT 'gml_5', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;POINT(1 2)'), 16))); + +-- Point GML 3 - 3D +SELECT 'gml_6', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('POINT(1 2 3)')))); + +-- Point GML 3 - 3D & SRID lat/lon +SELECT 'gml_7', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;POINT(1 2 3)'), 16))); + +-- Linestring GML 2 +SELECT 'gml_8', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('LINESTRING(1 2,3 4)')))); + +-- Linestring GML 2 - 3D +SELECT 'gml_9', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('LINESTRING(1 2 3,4 5 6)')))); + +-- Linestring GML 2 & SRID planar +SELECT 'gml_10', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;LINESTRING(1 2,3 4)')))); + +-- Linestring GML 3 +SELECT 'gml_11', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('LINESTRING(1 2,3 4)')))); + +-- Linestring GML 3 & SRID lat/lon +SELECT 'gml_12', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;LINESTRING(1 2,3 4)'), 16))); + +-- Linestring GML 3 - 3D +SELECT 'gml_13', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('LINESTRING(1 2 3,4 5 6)')))); + +-- Linestring GML 3 - 3D & SRID lat/lon +SELECT 'gml_14', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;LINESTRING(1 2 3,4 5 6)'), 16))); + +-- Polygon GML 2 +SELECT 'gml_15', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('POLYGON((1 2,3 4,5 6,1 2))')))); + +-- Polygon GML 2 - 3D +SELECT 'gml_16', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('POLYGON((1 2 3,4 5 6,7 8 9,1 2 3))')))); + +-- Polygon GML 2 & SRID planar +SELECT 'gml_17', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;POLYGON((1 2,3 4,5 6,1 2))')))); + +-- Polygon GML 3 +SELECT 'gml_18', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('POLYGON((1 2,3 4,5 6,1 2))')))); + +-- Polygon GML 3 & SRID lat/lon +SELECT 'gml_19', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;POLYGON((1 2,3 4,5 6,1 2))')))); + +-- Polygon GML 3 - 3D +SELECT 'gml_20', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('POLYGON((1 2 3,4 5 6,7 8 9,1 2 3))')))); + +-- Polygon GML 3 - 3D & SRID lat/lon +SELECT 'gml_21', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;POLYGON((1 2 3,4 5 6,7 8 9,1 2 3))')))); + +-- Multipoint GML 2 +SELECT 'gml_22', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('MULTIPOINT(1 2)')))); + +-- Multipoint GML 2 - 3D +SELECT 'gml_23', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('MULTIPOINT(1 2 3)')))); + +-- Multipoint GML 2 & SRID planar +SELECT 'gml_24', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;MULTIPOINT(1 2)')))); + +-- Multipoint GML 3 +SELECT 'gml_25', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('MULTIPOINT(1 2)')))); + +-- Multipoint GML 3 & SRID lat/lon +SELECT 'gml_26', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;MULTIPOINT(1 2)'), 16))); + +-- Multipoint GML 3 - 3D +SELECT 'gml_27', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('MULTIPOINT(1 2 3)')))); + +-- Multipoint GML 3 - 3D & SRID lat/lon +SELECT 'gml_28', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;MULTIPOINT(1 2 3)'), 16))); + +-- Multilinestring GML 2 +SELECT 'gml_29', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('MULTILINESTRING((1 2,3 4))')))); + +-- Multilinestring GML 2 - 3D +SELECT 'gml_30', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('MULTILINESTRING((1 2 3,4 5 6))')))); + +-- Multilinestring GML 2 & SRID planar +SELECT 'gml_31', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;MULTILINESTRING((1 2,3 4))')))); + +-- Multilinestring GML 3 +SELECT 'gml_32', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('MULTILINESTRING((1 2,3 4))')))); + +-- Multilinestring GML 3 & SRID lat/lon +SELECT 'gml_33', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;MULTILINESTRING((1 2,3 4))'), 16))); + +-- Multilinestring GML 3 - 3D +SELECT 'gml_34', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('MULTILINESTRING((1 2 3,4 5 6))')))); + +-- Multilinestring GML 3 - 3D & SRID lat/lon +SELECT 'gml_35', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;MULTILINESTRING((1 2 3,4 5 6))'), 16))); + +-- Multipolygon GML 2 +SELECT 'gml_36', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('MULTIPOLYGON(((1 2,3 4,5 6,1 2)))')))); + +-- Multipolygon GML 2 - 3D +SELECT 'gml_37', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3)))')))); + +-- Multipolygon GML 2 & SRID planar +SELECT 'gml_38', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;MULTIPOLYGON(((1 2,3 4,5 6,1 2)))')))); + +-- Multipolygon GML 3 +SELECT 'gml_39', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('MULTIPOLYGON(((1 2,3 4,5 6,1 2)))')))); + +-- Multipolygon GML 3 & SRID lat/lon +SELECT 'gml_40', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;MULTIPOLYGON(((1 2,3 4,5 6,1 2)))')))); + +-- Multipolygon GML 3 - 3D +SELECT 'gml_41', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3)))')))); + +-- Multipolygon GML 3 - 3D & SRID lat/lon +SELECT 'gml_42', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3)))')))); + +-- Collection GML 2 +SELECT 'gml_43', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('GEOMETRYCOLLECTION(POINT(1 2))')))); + +-- Collection GML 2 - 3D +SELECT 'gml_44', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('GEOMETRYCOLLECTION(POINT(1 2 3))')))); + +-- Collection GML 2 & SRID planar +SELECT 'gml_45', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(ST_AsEWKT('SRID=27582;GEOMETRYCOLLECTION(POINT(1 2))')))); + +-- Collection GML 3 +SELECT 'gml_46', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('GEOMETRYCOLLECTION(POINT(1 2))')))); + +-- Collection GML 3 & SRID lat/lon +SELECT 'gml_47', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;GEOMETRYCOLLECTION(POINT(1 2))'), 16))); + +-- Collection GML 3 - 3D +SELECT 'gml_48', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('GEOMETRYCOLLECTION(POINT(1 2 3))')))); + +-- Collection GML 3 - 3D & SRID lat/lon +SELECT 'gml_49', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;GEOMETRYCOLLECTION(POINT(1 2 3))'), 16))); + + + diff --git a/regress/in_gml_expected b/regress/in_gml_expected index 4bad3fd87..264efe670 100644 --- a/regress/in_gml_expected +++ b/regress/in_gml_expected @@ -235,6 +235,69 @@ ERROR: invalid GML representation ERROR: invalid GML representation ERROR: invalid GML representation ERROR: invalid GML representation +ERROR: invalid GML representation +xlink_11|LINESTRING(1 2,1 2,3 4) +xlink_12|GEOMETRYCOLLECTION(POINT(1 2),POINT(1 2)) +xlink_13|GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),LINESTRING(1 2,3 4)) +xlink_14|GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),LINESTRING(1 2,3 4)) +xlink_15|GEOMETRYCOLLECTION(POLYGON((1 2,3 4,5 6,1 2)),POLYGON((1 2,3 4,5 6,1 2))) +xlink_16|GEOMETRYCOLLECTION(POLYGON((1 2,3 4,5 6,1 2)),POLYGON((1 2,3 4,5 6,1 2))) +xlink_17|GEOMETRYCOLLECTION(MULTIPOINT(1 2),MULTIPOINT(1 2)) +xlink_18|GEOMETRYCOLLECTION(MULTILINESTRING((1 2,3 4)),MULTILINESTRING((1 2,3 4))) +xlink_19|GEOMETRYCOLLECTION(MULTILINESTRING((1 2,3 4)),MULTILINESTRING((1 2,3 4))) +xlink_20|GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2,3 4,5 6,1 2))),MULTIPOLYGON(((1 2,3 4,5 6,1 2)))) +xlink_21|GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2,3 4,5 6,1 2))),MULTIPOLYGON(((1 2,3 4,5 6,1 2)))) +xlink_22|GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 2)),GEOMETRYCOLLECTION(POINT(1 2))) +ERROR: invalid GML representation +gml_1|POINT(1 2) +gml_2|POINT(1 2 3) +gml_3|SRID=27582;POINT(1 2) +gml_4|POINT(1 2) +gml_5|SRID=4326;POINT(1 2) +gml_6|POINT(1 2 3) +gml_7|SRID=4326;POINT(1 2 3) +gml_8|LINESTRING(1 2,3 4) +gml_9|LINESTRING(1 2 3,4 5 6) +gml_10|SRID=27582;LINESTRING(1 2,3 4) +gml_11|LINESTRING(1 2,3 4) +gml_12|SRID=4326;LINESTRING(1 2,3 4) +gml_13|LINESTRING(1 2 3,4 5 6) +gml_14|SRID=4326;LINESTRING(1 2 3,4 5 6) +gml_15|POLYGON((1 2,3 4,5 6,1 2)) +gml_16|POLYGON((1 2 3,4 5 6,7 8 9,1 2 3)) +gml_17|SRID=27582;POLYGON((1 2,3 4,5 6,1 2)) +gml_18|POLYGON((1 2,3 4,5 6,1 2)) +gml_19|SRID=4326;POLYGON((1 2,3 4,5 6,1 2)) +gml_20|POLYGON((1 2 3,4 5 6,7 8 9,1 2 3)) +gml_21|SRID=4326;POLYGON((1 2 3,4 5 6,7 8 9,1 2 3)) +gml_22|MULTIPOINT(1 2) +gml_23|MULTIPOINT(1 2 3) +gml_24|SRID=27582;MULTIPOINT(1 2) +gml_25|MULTIPOINT(1 2) +gml_26|SRID=4326;MULTIPOINT(1 2) +gml_27|MULTIPOINT(1 2 3) +gml_28|SRID=4326;MULTIPOINT(1 2 3) +gml_29|MULTILINESTRING((1 2,3 4)) +gml_30|MULTILINESTRING((1 2 3,4 5 6)) +gml_31|SRID=27582;MULTILINESTRING((1 2,3 4)) +gml_32|MULTILINESTRING((1 2,3 4)) +gml_33|SRID=4326;MULTILINESTRING((1 2,3 4)) +gml_34|MULTILINESTRING((1 2 3,4 5 6)) +gml_35|SRID=4326;MULTILINESTRING((1 2 3,4 5 6)) +gml_36|MULTIPOLYGON(((1 2,3 4,5 6,1 2))) +gml_37|MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3))) +gml_38|SRID=27582;MULTIPOLYGON(((1 2,3 4,5 6,1 2))) +gml_39|MULTIPOLYGON(((1 2,3 4,5 6,1 2))) +gml_40|SRID=4326;MULTIPOLYGON(((1 2,3 4,5 6,1 2))) +gml_41|MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3))) +gml_42|SRID=4326;MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3))) +gml_43|GEOMETRYCOLLECTION(POINT(1 2)) +gml_44|GEOMETRYCOLLECTION(POINT(1 2 3)) +gml_45|SRID=27582;GEOMETRYCOLLECTION(POINT(1 2)) +gml_46|GEOMETRYCOLLECTION(POINT(1 2)) +gml_47|SRID=4326;GEOMETRYCOLLECTION(POINT(1 2)) +gml_48|GEOMETRYCOLLECTION(POINT(1 2 3)) +gml_49|SRID=4326;GEOMETRYCOLLECTION(POINT(1 2 3)) coord_1|POINT(1 2) coord_2|POINT(1 2 3) ERROR: invalid GML representation