From 39ead1bb49ec833dd03a4475e799063b92796a4b Mon Sep 17 00:00:00 2001 From: Nicholas L Date: Sat, 16 Jan 2016 22:29:08 +1300 Subject: [PATCH] Remove use of goog.array.flatten --- src/ol/array.js | 15 +++++++++++++++ src/ol/format/esrijsonformat.js | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ol/array.js b/src/ol/array.js index 9bd4df5a7a..10b2bb4bc2 100644 --- a/src/ol/array.js +++ b/src/ol/array.js @@ -127,3 +127,18 @@ ol.array.reverseSubArray = function(arr, begin, end) { --end; } }; + +/** + * @param {Array.<*>} arr Array. + * @return {!Array} Flattened Array. + */ +ol.array.flatten = function(arr) { + var data = arr.reduce(function(flattened, value) { + if (goog.isArray(value)) { + return flattened.concat(ol.array.flatten(value)); + } else { + return flattened.concat(value); + } + }, []); + return data; +}; diff --git a/src/ol/format/esrijsonformat.js b/src/ol/format/esrijsonformat.js index 5831756aa5..7d62c8d00d 100644 --- a/src/ol/format/esrijsonformat.js +++ b/src/ol/format/esrijsonformat.js @@ -1,8 +1,8 @@ goog.provide('ol.format.EsriJSON'); -goog.require('goog.array'); goog.require('goog.asserts'); goog.require('goog.object'); +goog.require('ol.array'); goog.require('ol.Feature'); goog.require('ol.extent'); goog.require('ol.format.Feature'); @@ -104,7 +104,7 @@ ol.format.EsriJSON.convertRings_ = function(rings, layout) { var holes = []; var i, ii; for (i = 0, ii = rings.length; i < ii; ++i) { - var flatRing = goog.array.flatten(rings[i]); + var flatRing = ol.array.flatten(rings[i]); // is this ring an outer ring? is it clockwise? var clockwise = ol.geom.flat.orient.linearRingIsClockwise(flatRing, 0, flatRing.length, layout.length);