From a2f99f8e3957d140b6310424432de820d7f0284c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 12 Jan 2017 10:26:06 +0100 Subject: [PATCH 1/3] Correct spelling --- src/ol/format/esrijson.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/format/esrijson.js b/src/ol/format/esrijson.js index 4d7e60a862..3223a098cf 100644 --- a/src/ol/format/esrijson.js +++ b/src/ol/format/esrijson.js @@ -96,7 +96,7 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { * @param {Array.>>} rings Rings. * @param {ol.geom.GeometryLayout} layout Geometry layout. * @private - * @return {Array.>>} Transoformed rings. + * @return {Array.>>} Transformed rings. */ ol.format.EsriJSON.convertRings_ = function(rings, layout) { var outerRings = []; From ed7904852847145d0da0e522ebcb817cd263ae7c Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 12 Jan 2017 10:34:17 +0100 Subject: [PATCH 2/3] Use ol.geom.flat.deflate.coordinates to flatten array --- src/ol/format/esrijson.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ol/format/esrijson.js b/src/ol/format/esrijson.js index 3223a098cf..a304cacec9 100644 --- a/src/ol/format/esrijson.js +++ b/src/ol/format/esrijson.js @@ -2,7 +2,6 @@ goog.provide('ol.format.EsriJSON'); goog.require('ol'); goog.require('ol.Feature'); -goog.require('ol.array'); goog.require('ol.asserts'); goog.require('ol.extent'); goog.require('ol.format.Feature'); @@ -16,6 +15,7 @@ goog.require('ol.geom.MultiPoint'); goog.require('ol.geom.MultiPolygon'); goog.require('ol.geom.Point'); goog.require('ol.geom.Polygon'); +goog.require('ol.geom.flat.deflate'); goog.require('ol.geom.flat.orient'); goog.require('ol.obj'); goog.require('ol.proj'); @@ -99,11 +99,13 @@ ol.format.EsriJSON.readGeometry_ = function(object, opt_options) { * @return {Array.>>} Transformed rings. */ ol.format.EsriJSON.convertRings_ = function(rings, layout) { + var flatRing = []; var outerRings = []; var holes = []; var i, ii; for (i = 0, ii = rings.length; i < ii; ++i) { - var flatRing = ol.array.flatten(rings[i]); + flatRing.length = 0; + ol.geom.flat.deflate.coordinates(flatRing, 0, rings[i], layout.length); // is this ring an outer ring? is it clockwise? var clockwise = ol.geom.flat.orient.linearRingIsClockwise(flatRing, 0, flatRing.length, layout.length); From d8c5e81675f5c0c65075b47c82205c4b176ae289 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Thu, 12 Jan 2017 10:35:09 +0100 Subject: [PATCH 3/3] Remove unused ol.array.flatten function --- src/ol/array.js | 16 ---------------- test/spec/ol/array.test.js | 10 ---------- 2 files changed, 26 deletions(-) diff --git a/src/ol/array.js b/src/ol/array.js index 33f8b56ba7..669d5e6f6f 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -124,22 +124,6 @@ ol.array.reverseSubArray = function(arr, begin, end) { }; -/** - * @param {Array.<*>} arr Array. - * @return {!Array.} Flattened Array. - */ -ol.array.flatten = function(arr) { - var data = arr.reduce(function(flattened, value) { - if (Array.isArray(value)) { - return flattened.concat(ol.array.flatten(value)); - } else { - return flattened.concat(value); - } - }, []); - return data; -}; - - /** * @param {Array.} arr The array to modify. * @param {Array.|VALUE} data The elements or arrays of elements diff --git a/test/spec/ol/array.test.js b/test/spec/ol/array.test.js index 694fe91be8..bf5290bebe 100644 --- a/test/spec/ol/array.test.js +++ b/test/spec/ol/array.test.js @@ -427,16 +427,6 @@ describe('ol.array', function() { }); }); - describe('flatten', function() { - it('flattens different kinds of nested arrays', function() { - expect(ol.array.flatten([1, 2])).to.eql([1, 2]); - expect(ol.array.flatten([1, [2, [3, [4, 5]]]])).to.eql([1, 2, 3, 4, 5]); - expect(ol.array.flatten([[[[1], 2], 3], 4])).to.eql([1, 2, 3, 4]); - expect(ol.array.flatten([[1]])).to.eql([1]); - expect(ol.array.flatten([])).to.eql([]); - }); - }); - describe('isSorted', function() { it('works with just an array as argument', function() { expect(ol.array.isSorted([1, 2, 3])).to.be(true);