diff --git a/test/spec/ol/format/topojson.test.js b/test/spec/ol/format/topojson.test.js index e53775df0d..5f1753103e 100644 --- a/test/spec/ol/format/topojson.test.js +++ b/test/spec/ol/format/topojson.test.js @@ -64,6 +64,31 @@ describe('ol.format.TopoJSON', function() { describe('#readFeatures()', function() { + it('parses simple.json', function(done) { + afterLoadText('spec/ol/format/topojson/simple.json', function(text) { + var features = format.readFeatures(text); + expect(features.length).to.be(3); + + var point = features[0].getGeometry(); + expect(point.getType()).to.be('Point'); + expect(point.getFlatCoordinates()).to.eql([102, 0.5]); + + var line = features[1].getGeometry(); + expect(line.getType()).to.be('LineString'); + expect(line.getFlatCoordinates()).to.eql([ + 102, 0, 103, 1, 104, 0, 105, 1 + ]); + + var polygon = features[2].getGeometry(); + expect(polygon.getType()).to.be('Polygon'); + expect(polygon.getFlatCoordinates()).to.eql([ + 100, 0, 100, 1, 101, 1, 101, 0, 100, 0 + ]); + + done(); + }); + }); + it('parses world-110m.json', function(done) { afterLoadText('spec/ol/format/topojson/world-110m.json', function(text) { diff --git a/test/spec/ol/format/topojson/simple.json b/test/spec/ol/format/topojson/simple.json new file mode 100644 index 0000000000..70a9f1455a --- /dev/null +++ b/test/spec/ol/format/topojson/simple.json @@ -0,0 +1,39 @@ +{ + "type": "Topology", + "objects": { + "example": { + "type": "GeometryCollection", + "geometries": [ + { + "type": "Point", + "properties": { + "prop0": "value0" + }, + "coordinates": [102, 0.5] + }, + { + "type": "LineString", + "properties": { + "prop0": "value0", + "prop1": 0 + }, + "arcs": [0] + }, + { + "type": "Polygon", + "properties": { + "prop0": "value0", + "prop1": { + "this": "that" + } + }, + "arcs": [[-2]] + } + ] + } + }, + "arcs": [ + [[102, 0], [103, 1], [104, 0], [105, 1]], + [[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]] + ] +} \ No newline at end of file