Remove use of goog.array.flatten

This commit is contained in:
Nicholas L
2016-01-16 22:29:08 +13:00
parent 21b740ccf9
commit 39ead1bb49
2 changed files with 17 additions and 2 deletions

View File

@@ -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;
};

View File

@@ -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);