From 8f62eab52e8db6434d25d53b4dcead870bc41838 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 26 Apr 2007 13:31:46 +0000 Subject: [PATCH] Add GML format test, which for the time being only has a constructor and getFID tests, to test for broken fid parser, patch provided by Andreas Hocevar in #679 . git-svn-id: http://svn.openlayers.org/trunk/openlayers@3096 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Format/GML.js | 12 +++++--- tests/Format/test_GML.html | 57 ++++++++++++++++++++++++++++++++++++ tests/list-tests.html | 1 + 3 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 tests/Format/test_GML.html diff --git a/lib/OpenLayers/Format/GML.js b/lib/OpenLayers/Format/GML.js index 3695684ab2..873d970c11 100644 --- a/lib/OpenLayers/Format/GML.js +++ b/lib/OpenLayers/Format/GML.js @@ -84,13 +84,11 @@ OpenLayers.Format.GML.prototype = var feature = new OpenLayers.Feature.Vector(); - if (xmlNode.firstChild.attributes && xmlNode.firstChild.attributes['fid']) { - feature.fid = xmlNode.firstChild.attributes['fid'].nodeValue; - } - // match MultiPolygon if (OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon").length != 0) { var multipolygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPolygon")[0]; + feature.fid = multipolygon.parentNode.parentNode.getAttribute('fid'); + geom = new OpenLayers.Geometry.MultiPolygon(); var polygons = OpenLayers.Ajax.getElementsByTagNameNS(multipolygon, this.gmlns, "gml", "Polygon"); @@ -104,6 +102,7 @@ OpenLayers.Format.GML.prototype = this.gmlns, "gml", "MultiLineString").length != 0) { var multilinestring = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiLineString")[0]; + feature.fid = multilinestring.parentNode.parentNode.getAttribute('fid'); geom = new OpenLayers.Geometry.MultiLineString(); var lineStrings = OpenLayers.Ajax.getElementsByTagNameNS(multilinestring, this.gmlns, "gml", "LineString"); @@ -122,6 +121,7 @@ OpenLayers.Format.GML.prototype = this.gmlns, "gml", "MultiPoint").length != 0) { var multiPoint = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "MultiPoint")[0]; + feature.fid = multiPoint.parentNode.parentNode.getAttribute('fid'); geom = new OpenLayers.Geometry.MultiPoint(); @@ -138,6 +138,7 @@ OpenLayers.Format.GML.prototype = this.gmlns, "gml", "Polygon").length != 0) { var polygon = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "Polygon")[0]; + feature.fid = polygon.parentNode.parentNode.getAttribute('fid'); geom = this.parsePolygonNode(polygon); } @@ -146,6 +147,8 @@ OpenLayers.Format.GML.prototype = this.gmlns, "gml", "LineString").length != 0) { var lineString = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "LineString")[0]; + feature.fid = lineString.parentNode.parentNode.getAttribute('fid'); + p = this.parseCoords(lineString); if (p.points) { geom = new OpenLayers.Geometry.LineString(p.points); @@ -157,6 +160,7 @@ OpenLayers.Format.GML.prototype = this.gmlns, "gml", "Point").length != 0) { var point = OpenLayers.Ajax.getElementsByTagNameNS(xmlNode, this.gmlns, "gml", "Point")[0]; + feature.fid = point.parentNode.parentNode.getAttribute('fid'); p = this.parseCoords(point); if (p.points) { diff --git a/tests/Format/test_GML.html b/tests/Format/test_GML.html new file mode 100644 index 0000000000..2d08ee7cc2 --- /dev/null +++ b/tests/Format/test_GML.html @@ -0,0 +1,57 @@ + + + + + + + + diff --git a/tests/list-tests.html b/tests/list-tests.html index d8104a89e4..cd719c67aa 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -17,6 +17,7 @@
  • Geometry/test_Rectangle.html
  • Geometry/test_Surface.html
  • test_Format.html
  • +
  • Format/test_GML.html
  • Format/test_WKT.html
  • test_Icon.html
  • test_Marker.html