From 82f267f0c5852dce0e76daab3bf809979401eb28 Mon Sep 17 00:00:00 2001 From: Florent gravin Date: Tue, 23 Sep 2014 14:51:45 +0200 Subject: [PATCH] Add test to parse WFS with GML 2.1.2 --- test/spec/ol/format/wfs/polygonv2.xml | 89 +++++++++++++++++++++++++++ test/spec/ol/format/wfsformat.test.js | 39 ++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 test/spec/ol/format/wfs/polygonv2.xml diff --git a/test/spec/ol/format/wfs/polygonv2.xml b/test/spec/ol/format/wfs/polygonv2.xml new file mode 100644 index 0000000000..a8140cdf36 --- /dev/null +++ b/test/spec/ol/format/wfs/polygonv2.xml @@ -0,0 +1,89 @@ + + + + + -0.768746,47.003018 3.002191,47.925567 + + + + + + + -0.768746,47.003018 0.532597,47.925567 + + + + + + + + + -0.318987,47.003018 -0.768746,47.358268 -0.574463,47.684285 -0.347374,47.854602 -0.006740,47.925567 0.135191,47.726864 0.149384,47.599127 0.419052,47.670092 0.532597,47.428810 0.305508,47.443003 0.475824,47.144948 0.064225,47.201721 -0.318987,47.003018 + + + + + -0.035126,47.485582 -0.035126,47.485582 -0.049319,47.641706 -0.233829,47.655899 -0.375760,47.457196 -0.276408,47.286879 -0.035126,47.485582 + + + + + + + 1 + My Polygon with hole + 0 + + + + + + + 1.511919,47.088176 3.002191,47.882988 + + + + + + + 1.625463,47.357844 1.511919,47.741057 1.880938,47.882988 2.420275,47.797830 2.789295,47.485582 3.002191,47.457196 2.874453,47.088176 2.178993,47.343651 1.625463,47.357844 + + + + + 2 + My simple Polygon + 0 + + + + + + + 0.000000,45.000000 2.000000,47.000000 + + + + + + + + + 0.000000,45.000000 2.000000,45.000000 2.000000,47.000000 0.000000,47.000000 0.000000,45.000000 + + + + + 0.500000,45.500000 1.500000,45.500000 1.500000,46.500000 0.500000,46.500000 0.500000,45.500000 + + + + + + + 3 + my polygon with hole + 3 + + + \ No newline at end of file diff --git a/test/spec/ol/format/wfsformat.test.js b/test/spec/ol/format/wfsformat.test.js index a68e3b1e55..6beb04c78a 100644 --- a/test/spec/ol/format/wfsformat.test.js +++ b/test/spec/ol/format/wfsformat.test.js @@ -50,6 +50,43 @@ describe('ol.format.WFS', function() { }); + describe('when parsing mapserver GML2 polygon', function() { + + var features, feature, xml; + var config = { + 'featureNS': 'http://mapserver.gis.umn.edu/mapserver', + 'featureType': 'polygon', + 'gmlFormat': new ol.format.GML.v2() + }; + + before(function(done) { + proj4.defs('urn:x-ogc:def:crs:EPSG:4326', proj4.defs('EPSG:4326')); + afterLoadText('spec/ol/format/wfs/polygonv2.xml', function(data) { + try { + xml = data; + features = new ol.format.WFS(config).readFeatures(xml); + } catch (e) { + done(e); + } + done(); + }); + }); + + it('creates 3 features', function() { + expect(features).to.have.length(3); + }); + + it('creates a polygon for My Polygon with hole', function() { + feature = features[0]; + expect(feature.getId()).to.equal('1'); + expect(feature.get('name')).to.equal('My Polygon with hole'); + expect(feature.getGeometry()).to.be.an(ol.geom.MultiPolygon); + expect(feature.getGeometry().getFlatCoordinates()). + to.have.length(60); + }); + + }); + describe('when parsing FeatureCollection', function() { var response; before(function(done) { @@ -403,5 +440,7 @@ goog.require('ol.geom.MultiLineString'); goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.geom.Polygon'); +goog.require('ol.format.GML'); +goog.require('ol.format.GML.v2'); goog.require('ol.format.WFS'); goog.require('ol.proj');