kepler.gl
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
54 lines (48 loc) • 6.87 kB
JavaScript
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.computeChunkOffsets = computeChunkOffsets;
exports.getPickingInfo = getPickingInfo;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
// SPDX-License-Identifier: MIT
// Copyright contributors to the kepler.gl project
// deck.gl-community
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
function getPickingInfo(_ref, table) {
var info = _ref.info,
sourceLayer = _ref.sourceLayer;
// Geometry index as rendered
var index = info.index;
// if a Multi- geometry dataset, map from the rendered index back to the
// feature index
if (sourceLayer.props.data.invertedGeomOffsets) {
index = sourceLayer.props.data.invertedGeomOffsets[index];
}
var recordBatchIdx = sourceLayer.props.recordBatchIdx;
var tableOffsets = sourceLayer.props.tableOffsets;
var batch = table.batches[recordBatchIdx];
var row = batch.get(index);
if (row === null) {
return info;
}
var currentBatchOffset = tableOffsets[recordBatchIdx];
// Update index to be _global_ index, not within the specific record batch
index += currentBatchOffset;
return _objectSpread(_objectSpread({}, info), {}, {
index: index,
object: row
});
}
// This is vendored from Arrow JS because it's a private API
function computeChunkOffsets(chunks) {
return chunks.reduce(function (offsets, chunk, index) {
offsets[index + 1] = offsets[index] + chunk.length;
return offsets;
}, new Uint32Array(chunks.length + 1));
}
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJnZXRQaWNraW5nSW5mbyIsIl9yZWYiLCJ0YWJsZSIsImluZm8iLCJzb3VyY2VMYXllciIsImluZGV4IiwicHJvcHMiLCJkYXRhIiwiaW52ZXJ0ZWRHZW9tT2Zmc2V0cyIsInJlY29yZEJhdGNoSWR4IiwidGFibGVPZmZzZXRzIiwiYmF0Y2giLCJiYXRjaGVzIiwicm93IiwiZ2V0IiwiY3VycmVudEJhdGNoT2Zmc2V0IiwiX29iamVjdFNwcmVhZCIsIm9iamVjdCIsImNvbXB1dGVDaHVua09mZnNldHMiLCJjaHVua3MiLCJyZWR1Y2UiLCJvZmZzZXRzIiwiY2h1bmsiLCJsZW5ndGgiLCJVaW50MzJBcnJheSJdLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy91dGlscy9waWNraW5nLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIFNQRFgtTGljZW5zZS1JZGVudGlmaWVyOiBNSVRcbi8vIENvcHlyaWdodCBjb250cmlidXRvcnMgdG8gdGhlIGtlcGxlci5nbCBwcm9qZWN0XG5cbi8vIGRlY2suZ2wtY29tbXVuaXR5XG4vLyBTUERYLUxpY2Vuc2UtSWRlbnRpZmllcjogTUlUXG4vLyBDb3B5cmlnaHQgKGMpIHZpcy5nbCBjb250cmlidXRvcnNcblxuaW1wb3J0ICogYXMgYXJyb3cgZnJvbSAnYXBhY2hlLWFycm93JztcbmltcG9ydCB7R2V0UGlja2luZ0luZm9QYXJhbXN9IGZyb20gJ0BkZWNrLmdsL2NvcmUvdHlwZWQnO1xuaW1wb3J0IHtHZW9BcnJvd1BpY2tpbmdJbmZvfSBmcm9tICcuLi90eXBlcyc7XG5cbmV4cG9ydCBpbnRlcmZhY2UgR2VvQXJyb3dFeHRyYVBpY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