diff --git a/src/ol/parser/topojson.js b/src/ol/parser/topojson.js index baedc9cdfe..a6221782ca 100644 --- a/src/ol/parser/topojson.js +++ b/src/ol/parser/topojson.js @@ -74,7 +74,7 @@ ol.parser.TopoJSON.prototype.concatenateArcs_ = function(indices, arcs) { */ ol.parser.TopoJSON.prototype.read = function(str) { var topology = /** @type {TopoJSONTopology} */ (JSON.parse(str)); - return this.readFeaturesFromObject(topology); + return this.readFeaturesFromObject(topology).features; }; @@ -83,7 +83,7 @@ ol.parser.TopoJSON.prototype.read = function(str) { * * @param {string} str TopoJSON topology string. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ ol.parser.TopoJSON.prototype.readFeaturesFromString = function(str, opt_options) { @@ -91,7 +91,8 @@ ol.parser.TopoJSON.prototype.readFeaturesFromString = if (topology.type !== 'Topology') { throw new Error('Not a "Topology" type object'); } - return this.readFeaturesFromTopology_(topology, opt_options); + return {features: this.readFeaturesFromTopology_(topology, opt_options), + metadata: {projection: 'EPSG:4326'}}; }; @@ -100,14 +101,15 @@ ol.parser.TopoJSON.prototype.readFeaturesFromString = * * @param {TopoJSONTopology} topology TopoJSON topology object. * @param {ol.parser.ReadFeaturesOptions=} opt_options Reader options. - * @return {Array.} Array of features. + * @return {ol.parser.ReadFeaturesResult} Features and metadata. */ ol.parser.TopoJSON.prototype.readFeaturesFromObject = function(topology, opt_options) { if (topology.type !== 'Topology') { throw new Error('Not a "Topology" type object'); } - return this.readFeaturesFromTopology_(topology, opt_options); + return {features: this.readFeaturesFromTopology_(topology, opt_options), + metadata: {projection: 'EPSG:4326'}}; }; diff --git a/test/spec/ol/parser/topojson.test.js b/test/spec/ol/parser/topojson.test.js index b02a112a0b..aa80cf2d28 100644 --- a/test/spec/ol/parser/topojson.test.js +++ b/test/spec/ol/parser/topojson.test.js @@ -79,13 +79,13 @@ describe('ol.parser.TopoJSON', function() { }; var result = parser.readFeaturesFromString(text, {callback: callback}); - expect(result.length).to.be(178); + expect(result.features.length).to.be(178); expect(pointVertices.coordinates.length).to.be(0); expect(lineVertices.coordinates.length).to.be(0); expect(polygonVertices.coordinates.length).to.be(31400); - var first = result[0]; + var first = result.features[0]; expect(first).to.be.a(ol.Feature); var firstGeom = first.getGeometry(); expect(firstGeom).to.be.a(ol.geom.MultiPolygon); @@ -93,7 +93,7 @@ describe('ol.parser.TopoJSON', function() { -180, 180, -85.60903777459777, 83.64513000000002 ]); - var last = result[177]; + var last = result.features[177]; expect(last).to.be.a(ol.Feature); var lastGeom = last.getGeometry(); expect(lastGeom).to.be.a(ol.geom.Polygon);