static LWGEOM* parse_gml_mpoint(xmlNodePtr xnode, bool *hasz, int *root_srid)
{
gmlSrs srs;
- xmlNodePtr xa;
+ xmlNodePtr xa, xb;
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
/* MultiPoint/pointMember */
if (xa->type != XML_ELEMENT_NODE) continue;
if (!is_gml_namespace(xa, false)) continue;
- if (strcmp((char *) xa->name, "pointMember")) continue;
- if (xa->children != NULL)
- geom = (LWGEOM*)lwmpoint_add_lwpoint((LWMPOINT*)geom,
- (LWPOINT*)parse_gml(xa->children, hasz, root_srid));
+ if (!strcmp((char *) xa->name, "pointMembers"))
+ {
+ for (xb = xa->children ; xb != NULL ; xb = xb->next)
+ {
+ if (xb != NULL)
+ geom = (LWGEOM*)lwmpoint_add_lwpoint((LWMPOINT*)geom,
+ (LWPOINT*)parse_gml(xb, hasz, root_srid));
+ }
+ }
+ else if (!strcmp((char *) xa->name, "pointMember"))
+ {
+ if (xa->children != NULL)
+ geom = (LWGEOM*)lwmpoint_add_lwpoint((LWMPOINT*)geom,
+ (LWPOINT*)parse_gml(xa->children, hasz, root_srid));
+ }
}
return geom;
static LWGEOM* parse_gml_mcurve(xmlNodePtr xnode, bool *hasz, int *root_srid)
{
gmlSrs srs;
- xmlNodePtr xa;
+ xmlNodePtr xa, xb;
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
/* MultiCurve/curveMember */
if (xa->type != XML_ELEMENT_NODE) continue;
if (!is_gml_namespace(xa, false)) continue;
- if (strcmp((char *) xa->name, "curveMember")) continue;
- if (xa->children != NULL)
- geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
- (LWLINE*)parse_gml(xa->children, hasz, root_srid));
+ if (!strcmp((char *) xa->name, "curveMembers"))
+ {
+ for (xb = xa->children ; xb != NULL ; xb = xb->next)
+ {
+ if (xb != NULL)
+ geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
+ (LWLINE*)parse_gml(xb, hasz, root_srid));
+ }
+ }
+ else if (!strcmp((char *) xa->name, "curveMember"))
+ {
+ if (xa->children != NULL)
+ geom = (LWGEOM*)lwmline_add_lwline((LWMLINE*)geom,
+ (LWLINE*)parse_gml(xa->children, hasz, root_srid));
+ }
}
return geom;
static LWGEOM* parse_gml_msurface(xmlNodePtr xnode, bool *hasz, int *root_srid)
{
gmlSrs srs;
- xmlNodePtr xa;
+ xmlNodePtr xa, xb;
LWGEOM *geom = NULL;
if (is_xlink(xnode)) xnode = get_xlink_node(xnode);
/* MultiSurface/surfaceMember */
if (xa->type != XML_ELEMENT_NODE) continue;
if (!is_gml_namespace(xa, false)) continue;
- if (strcmp((char *) xa->name, "surfaceMember")) continue;
- if (xa->children != NULL)
- geom = (LWGEOM*)lwmpoly_add_lwpoly((LWMPOLY*)geom,
- (LWPOLY*)parse_gml(xa->children, hasz, root_srid));
+ if (!strcmp((char *) xa->name, "surfaceMembers"))
+ {
+ for (xb = xa->children ; xb != NULL ; xb = xb->next)
+ {
+ if (xb != NULL)
+ geom = (LWGEOM*)lwmpoly_add_lwpoly((LWMPOLY*)geom,
+ (LWPOLY*)parse_gml(xb, hasz, root_srid));
+ }
+ }
+ else if (!strcmp((char *) xa->name, "surfaceMember"))
+ {
+ if (xa->children != NULL)
+ geom = (LWGEOM*)lwmpoly_add_lwpoly((LWMPOLY*)geom,
+ (LWPOLY*)parse_gml(xa->children, hasz, root_srid));
+ }
}
return geom;
-- Mixed srsName
SELECT 'mpoint_7', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPoint srsName="EPSG:27582"><gml:pointMember><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point srsName="EPSG:27562"><gml:coordinates>400000,5000000</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>'));
+-- 1 point in pointMembers
+SELECT 'mpoint_8', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPoint><gml:pointMembers><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point></gml:pointMembers></gml:MultiPoint>'));
+-- 2 points in pointMembers
+SELECT 'mpoint_9', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPoint><gml:pointMembers><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point><gml:Point><gml:coordinates>3,4</gml:coordinates></gml:Point></gml:pointMembers></gml:MultiPoint>'));
+
+-- Empty pointMembers
+SELECT 'mpoint_10', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPoint><gml:pointMembers></gml:pointMembers></gml:MultiPoint>'));
--
SELECT 'mline_9', ST_AsEWKT(ST_GeomFromGML('<gml:MultiLineString srsName="EPSG:27582"><gml:lineStringMember><gml:LineString><gml:coordinates>1,2 3,4</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString srsName="EPSG:27562"><gml:coordinates>400000,5000000 400010,5000010</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>'));
-
-
--
-- MultiCurve
--
-- Mixed srsName
SELECT 'mcurve_9', ST_AsEWKT(ST_GeomFromGML('<gml:MultiCurve srsName="EPSG:27582"><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:coordinates>1,2 3,4</gml:coordinates></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember><gml:curveMember><gml:Curve srsName="EPSG:27562"><gml:segments><gml:LineStringSegment><gml:coordinates>400000,5000000 400010,5000010</gml:coordinates></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve>'));
+-- 1 curve in curveMembers
+SELECT 'mcurve_10', ST_AsEWKT(ST_GeomFromGML('<gml:MultiCurve><gml:curveMembers><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList>1 2 3 4</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMembers></gml:MultiCurve>'));
+
+-- 2 curves in curveMembers
+SELECT 'mcurve_11', ST_AsEWKT(ST_GeomFromGML('<gml:MultiCurve><gml:curveMembers><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList>1 2 3 4</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList>5 6 7 8</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMembers></gml:MultiCurve>'));
+
+SELECT 'mcurve_12', ST_AsEWKT(ST_GeomFromGML('<gml:MultiCurve><gml:curveMembers></gml:curveMembers></gml:MultiCurve>'));
--
-- Mixed srsName
SELECT 'msurface_9', ST_AsEWKT(ST_GeomFromGML('<gml:MultiSurface srsName="EPSG:27582"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:coordinates>1,2 3,4 5,6 1,2</gml:coordinates></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember><gml:surfaceMember><gml:Polygon srsName="EPSG:27562"><gml:exterior><gml:LinearRing><gml:coordinates>400000,5000000 400010,5000010 400020,5000020 400000,5000000</gml:coordinates></gml:LinearRing></gml:exterior><gml:interior><gml:LinearRing><gml:coordinates>400100,5000100 400110,5000110 400120,5000120 400100,5000100</gml:coordinates></gml:LinearRing></gml:interior></gml:Polygon></gml:surfaceMember></gml:MultiSurface>'));
+-- 1 surface in surfaceMembers
+SELECT 'msurface_10', ST_AsEWKT(ST_GeomFromGML('<gml:MultiSurface><gml:surfaceMembers><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>1 2 3 4 5 6 1 2</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMembers></gml:MultiSurface>'));
+
+-- 2 surfaces in surfaceMembers
+SELECT 'msurface_11', ST_AsEWKT(ST_GeomFromGML('<gml:MultiSurface><gml:surfaceMembers><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>1 2 3 4 5 6 1 2</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList>7 8 9 10 11 12 7 8</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMembers></gml:MultiSurface>'));
+
+-- Empty surfaceMembers
+SELECT 'msurface_12', ST_AsEWKT(ST_GeomFromGML('<gml:MultiSurface><gml:surfaceMembers></gml:surfaceMembers></gml:MultiSurface>'));
--
mpoint_5|MULTIPOINT EMPTY
mpoint_6|MULTIPOINT(1 2,3 4)
mpoint_7|SRID=27582;MULTIPOINT(1 2,400000 7000000)
+mpoint_8|MULTIPOINT(1 2)
+mpoint_9|MULTIPOINT(1 2,3 4)
+mpoint_10|MULTIPOINT EMPTY
mline_1|MULTILINESTRING((1 2,3 4))
mline_2|MULTILINESTRING((1 2,3 4),(5 6,7 8))
mline_3|SRID=4326;MULTILINESTRING((1 2,3 4))
mcurve_7|MULTILINESTRING((1 2,4 5),(7 8,9 10))
mcurve_8|MULTILINESTRING((1 2,3 4),(5 6,8 9))
mcurve_9|SRID=27582;MULTILINESTRING((1 2,3 4),(400000 7000000,400010 7000010))
+mcurve_10|MULTILINESTRING((1 2,3 4))
+mcurve_11|MULTILINESTRING((1 2,3 4),(5 6,7 8))
+mcurve_12|MULTILINESTRING EMPTY
mpoly_1|MULTIPOLYGON(((1 2,3 4,5 6,1 2)))
mpoly_2|MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))
mpoly_3|SRID=4326;MULTIPOLYGON(((1 2,3 4,5 6,1 2)))
msurface_7|MULTIPOLYGON(((1 2,4 5,7 8,1 2)),((10 11,12 13,14 15,10 11)))
msurface_8|MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,10 11,13 14,7 8)))
msurface_9|SRID=27582;MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((400000 7000000,400010 7000010,400020 7000020,400000 7000000),(400100 7000100,400110 7000110,400120 7000120,400100 7000100)))
+msurface_10|MULTIPOLYGON(((1 2,3 4,5 6,1 2)))
+msurface_11|MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))
+msurface_12|MULTIPOLYGON EMPTY
polyhedralsurface_1|POLYHEDRALSURFACE(((1 2 3,4 5 6,7 8 9,1 2 3)))
polyhedralsurface_2|SRID=4326;POLYHEDRALSURFACE(((1 2 3,4 5 6,7 8 9,1 2 3)))
ERROR: invalid GML representation