UNPKG

kepler.gl

Version:

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

149 lines (143 loc) 23.4 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.getArrowTextVector = exports.formatTextLabelData = exports.defaultPadding = void 0; exports.getTextOffsetByRadius = getTextOffsetByRadius; exports.textLabelAccessor = void 0; var arrow = _interopRequireWildcard(require("apache-arrow")); var _viewportMercatorProject = require("viewport-mercator-project"); var _utils = require("@kepler.gl/utils"); var _commonUtils = require("@kepler.gl/common-utils"); var _lodash = _interopRequireDefault(require("lodash.uniq")); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project var defaultPadding = exports.defaultPadding = 20; function getTextOffsetByRadius(radiusScale, getRadius, mapState) { return function (textLabel) { var distanceScale = (0, _viewportMercatorProject.getDistanceScales)(mapState); var xMult = textLabel.anchor === 'middle' ? 0 : textLabel.anchor === 'start' ? 1 : -1; var yMult = textLabel.alignment === 'center' ? 0 : textLabel.alignment === 'bottom' ? 1 : -1; var sizeOffset = textLabel.alignment === 'center' ? 0 : textLabel.alignment === 'bottom' ? textLabel.size : textLabel.size; var pixelRadius = radiusScale * distanceScale.pixelsPerMeter[0]; var padding = defaultPadding; return typeof getRadius === 'function' ? function (d) { return [xMult * (getRadius(d) * pixelRadius + padding), yMult * (getRadius(d) * pixelRadius + padding + sizeOffset)]; } : [xMult * (getRadius * pixelRadius + padding), yMult * (getRadius * pixelRadius + padding + sizeOffset)]; }; } // eslint-disable-next-line @typescript-eslint/no-unused-vars var textLabelAccessor = exports.textLabelAccessor = function textLabelAccessor(textLabel) { return function (dc) { return function (d) { var val = textLabel.field.valueAccessor(d); return (0, _commonUtils.notNullorUndefined)(val) ? String(val) : ''; }; }; }; var formatTextLabelData = exports.formatTextLabelData = function formatTextLabelData(_ref) { var textLabel = _ref.textLabel, triggerChanged = _ref.triggerChanged, oldLayerData = _ref.oldLayerData, data = _ref.data, dataContainer = _ref.dataContainer, filteredIndex = _ref.filteredIndex; return textLabel.map(function (tl, i) { if (!tl.field) { // if no field selected, return { getText: null, characterSet: [] }; } var getTextAccessor = textLabelAccessor(tl)(dataContainer); var characterSet; var getText = getTextAccessor; var rebuildArrowTextVector = true; if (!(triggerChanged !== null && triggerChanged !== void 0 && triggerChanged["getLabelCharacterSet-".concat(i)]) && oldLayerData && oldLayerData.textLabels && oldLayerData.textLabels[i]) { characterSet = oldLayerData.textLabels[i].characterSet; getText = oldLayerData.textLabels[i].getText; rebuildArrowTextVector = false; } else { if (data instanceof arrow.Table) { // we don't filter out arrow tables, // so we use filteredIndex array instead var allLabels = []; if (tl.field) { if (filteredIndex) { filteredIndex.forEach(function (value, index) { if (value > 0) allLabels.push(getTextAccessor({ index: index })); }); } else { for (var index = 0; index < dataContainer.numRows(); ++index) { allLabels.push(getTextAccessor({ index: index })); } } } characterSet = (0, _lodash["default"])(allLabels.join('')); } else { var _allLabels = tl.field ? data.map(getTextAccessor) : []; characterSet = (0, _lodash["default"])(_allLabels.join('')); } } // For Arrow Layers getText has to be an arrow vector. // For now check here for ArrowTable, not ArrowDataContainer. if (rebuildArrowTextVector && data instanceof arrow.Table && dataContainer instanceof _utils.ArrowDataContainer) { getText = dataContainer.getColumn(tl.field.fieldIdx); try { getText = getArrowTextVector(getText, getTextAccessor); } catch (error) { // empty text labels getText = getArrowTextVector(getText, function () { return ' '; }); } } return { characterSet: characterSet, getText: getText }; }); }; /** * Get an arrow vector suitable to render text labels with arrow layers. * @param getText A candidate arrow vector to use for text labels. * @param getTextAccessor Text label accessor. */ var getArrowTextVector = exports.getArrowTextVector = function getArrowTextVector(candidateTextVector, getTextAccessor) { // if the passed vector is suitable for text labels if (arrow.DataType.isUtf8(candidateTextVector === null || candidateTextVector === void 0 ? void 0 : candidateTextVector.type)) { return candidateTextVector; } // create utf8 vector from source vector with the same number of batches. // @ts-expect-error var offsets = candidateTextVector._offsets; var numOffsets = offsets.length; var batchVectors = []; var datum = { index: 0 }; for (var batchIndex = 0; batchIndex < numOffsets - 1; batchIndex++) { var batchStart = offsets[batchIndex]; var batchEnd = offsets[batchIndex + 1]; var batchLabels = []; for (var rowIndex = batchStart; rowIndex < batchEnd; ++rowIndex) { datum.index = rowIndex; batchLabels.push(getTextAccessor(datum)); } batchVectors.push(arrow.vectorFromArray(batchLabels, new arrow.Utf8())); } var input = batchVectors.flatMap(function (x) { return x.data; }).flat(Number.POSITIVE_INFINITY); return new arrow.Vector(input); }; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJhcnJvdyIsIl9pbnRlcm9wUmVxdWlyZVdpbGRjYXJkIiwicmVxdWlyZSIsIl92aWV3cG9ydE1lcmNhdG9yUHJvamVjdCIsIl91dGlscyIsIl9jb21tb25VdGlscyIsIl9sb2Rhc2giLCJfaW50ZXJvcFJlcXVpcmVEZWZhdWx0IiwiX2dldFJlcXVpcmVXaWxkY2FyZENhY2hlIiwiZSIsIldlYWtNYXAiLCJyIiwidCIsIl9fZXNNb2R1bGUiLCJfdHlwZW9mIiwiaGFzIiwiZ2V0IiwibiIsIl9fcHJvdG9fXyIsImEiLCJPYmplY3QiLCJkZWZpbmVQcm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