UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

73 lines (72 loc) 7.17 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.getMVTMetadata = getMVTMetadata; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); var _mvt = require("@loaders.gl/mvt"); // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project /** * MVTSource in current loaders ignores attribution * TODO: remove once MVTSource is ready */ function getMVTMetadata(_x) { return _getMVTMetadata.apply(this, arguments); } function _getMVTMetadata() { _getMVTMetadata = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(metadataURL) { var _TileJSONLoader$parse; var response, tileJSON, metadata, rawMetadata; return _regenerator["default"].wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: if (metadataURL) { _context.next = 2; break; } return _context.abrupt("return", null); case 2: _context.prev = 2; _context.next = 5; return fetch(metadataURL); case 5: response = _context.sent; _context.next = 12; break; case 8: _context.prev = 8; _context.t0 = _context["catch"](2); // eslint-disable-next-line no-console console.error(_context.t0.message); return _context.abrupt("return", null); case 12: if (response.ok) { _context.next = 15; break; } // eslint-disable-next-line no-console console.error(response.statusText); return _context.abrupt("return", null); case 15: _context.next = 17; return response.text(); case 17: tileJSON = _context.sent; metadata = ((_TileJSONLoader$parse = _mvt.TileJSONLoader.parseTextSync) === null || _TileJSONLoader$parse === void 0 ? void 0 : _TileJSONLoader$parse.call(_mvt.TileJSONLoader, tileJSON)) || null; rawMetadata = JSON.parse(tileJSON); if (rawMetadata !== null && rawMetadata !== void 0 && rawMetadata.attribution) { metadata.attributions = [rawMetadata.attribution]; } return _context.abrupt("return", metadata); case 22: case "end": return _context.stop(); } }, _callee, null, [[2, 8]]); })); return _getMVTMetadata.apply(this, arguments); } //# sourceMappingUR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