kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
100 lines (97 loc) • 10.2 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _readOnlyError2 = _interopRequireDefault(require("@babel/runtime/helpers/readOnlyError"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
/**
* Custom iterator for data in a set of tiles
*/
var TileSetIterator = /*#__PURE__*/function () {
function TileSetIterator(tiles) {
(0, _classCallCheck2["default"])(this, TileSetIterator);
(0, _defineProperty2["default"])(this, "tileIterator", null);
(0, _defineProperty2["default"])(this, "tileIndex", -1);
this.tiles = tiles;
}
return (0, _createClass2["default"])(TileSetIterator, [{
key: "nextTile",
value: function nextTile() {
if (this.tileIndex < this.tiles.length - 1) {
this.tileIndex++;
this.tileIterator = this.tiles[this.tileIndex][Symbol.iterator]();
} else {
this.tileIterator = null;
}
}
}, {
key: "next",
value: function next() {
// Startup: Get the iterator for the next tile
if (this.tileIterator === null) this.nextTile();
// Finish: We have no more tiles, we're done
if (this.tileIterator === null) return {
done: true,
value: null
};
var next = this.tileIterator.next();
// If we have a value for the current tile, return it
if (!next.done) {
return next;
}
// Otherwise, go on to the next tile
this.tileIterator = null;
return this.next();
}
}, {
key: Symbol.iterator,
value: function value() {
return this;
}
}]);
}();
/**
* An iterable object that can iterate over all rows
* in a set of tiles, treat the set as a single iterable
*/
var IterableTileSet = exports["default"] = /*#__PURE__*/function () {
function IterableTileSet(tiles, getRowCount) {
(0, _classCallCheck2["default"])(this, IterableTileSet);
(0, _defineProperty2["default"])(this, "rowCount", 0);
(0, _defineProperty2["default"])(this, "rowCounts", []);
this.tiles = tiles;
var _iterator = _createForOfIteratorHelper(tiles),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _tile = _step.value;
var count = getRowCount(_tile);
this.rowCount += count;
this.rowCounts.push(count);
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
/**
* Iterate over all values in the set
*/
return (0, _createClass2["default"])(IterableTileSet, [{
key: Symbol.iterator,
value: function value() {
return new TileSetIterator(this.tiles);
}
}]);
}();
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJUaWxlU2V0SXRlcmF0b3IiLCJ0aWxlcyIsIl9jbGFzc0NhbGxDaGVjazIiLCJfZGVmaW5lUHJvcGVydHkyIiwiX2NyZ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