UNPKG

kepler.gl

Version:

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

180 lines (175 loc) 24.1 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.generateMapboxLayers = generateMapboxLayers; exports.geoJsonFromData = geoJsonFromData; exports.gpuFilterToMapboxFilter = gpuFilterToMapboxFilter; exports.prefixGpuField = void 0; exports.updateMapboxLayers = updateMapboxLayers; var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _baseLayer = require("./base-layer"); var _utils = require("@kepler.gl/utils"); 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 /** * This function will convert layers to mapbox layers * @param layers the layers to be converted * @param layerData extra layer information * @param layerOrder the order by which we should convert layers * @param layersToRender {[id]: true | false} object whether each layer should be rendered * @returns */ function generateMapboxLayers() { var layers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var layerData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; var layerOrder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; var layersToRender = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; if (layerData.length > 0) { return layerOrder.slice().reverse().filter(function (layerId) { var layer = (0, _utils.findById)(layerId)(layers); return (layer === null || layer === void 0 ? void 0 : layer.overlayType) === _baseLayer.OVERLAY_TYPE_CONST.mapboxgl && layersToRender[layerId]; }).reduce(function (acc, layerId) { var layerIndex = layers.findIndex(function (l) { return l.id === layerId; }); if (layerIndex === -1) { return acc; } var layer = layers[layerIndex]; if (!(layer.overlayType === _baseLayer.OVERLAY_TYPE_CONST.mapboxgl && layersToRender[layerId])) { return acc; } return _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2["default"])({}, layer.id, { id: layer.id, data: layerData[layerIndex].data, isVisible: layer.config.isVisible, config: layerData[layerIndex].config, hidden: layer.config.hidden, sourceId: layerData[layerIndex].config.source })); }, {}); } return {}; } /** * Update mapbox layers on the given map * @param map * @param newLayers Map of new mapbox layers to be displayed * @param oldLayers Map of the old layers to be compare with the current ones to detect deleted layers * {layerId: sourceId} */ function updateMapboxLayers(map) { var newLayers = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var oldLayers = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; // delete no longer existed old layers if (oldLayers) { checkAndRemoveOldLayers(map, oldLayers, newLayers); } // insert or update new layer Object.values(newLayers).forEach(function (overlay) { var layerId = overlay.id, config = overlay.config, data = overlay.data, sourceId = overlay.sourceId, isVisible = overlay.isVisible; if (!data && !config) { return; } var _ref = oldLayers && oldLayers[layerId] || {}, oldData = _ref.data, oldConfig = _ref.config; if (data && data !== oldData) { updateSourceData(map, sourceId, data); } // compare with previous configs if (oldConfig !== config) { updateLayerConfig(map, layerId, config, isVisible); } }); } function checkAndRemoveOldLayers(map, oldLayers, newLayers) { Object.keys(oldLayers).forEach(function (layerId) { if (!newLayers[layerId]) { map.removeLayer(layerId); } }); } function updateLayerConfig(map, layerId, config, isVisible) { var mapboxLayer = map.getLayer(layerId); if (mapboxLayer) { // check if layer already is set // remove it if exists map.removeLayer(layerId); } map.addLayer(config); map.setLayoutProperty(layerId, 'visibility', isVisible ? 'visible' : 'none'); } function updateSourceData(map, sourceId, data) { var source = map.getSource(sourceId); if (!source) { map.addSource(sourceId, { type: 'geojson', data: data }); } else { source.setData(data); } } /** * * @param filteredIndex * @param getGeometry {({index: number}) => any} * @param getProperties {({index: number}) => any} * @returns FeatureCollection */ function geoJsonFromData() { var filteredIndex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; var getGeometry = arguments.length > 1 ? arguments[1] : undefined; var getProperties = arguments.length > 2 ? arguments[2] : undefined; var geojson = { type: 'FeatureCollection', features: [] }; for (var i = 0; i < filteredIndex.length; i++) { var index = filteredIndex[i]; var rowIndex = { index: index }; var geometry = getGeometry(rowIndex); if (geometry) { geojson.features.push({ type: 'Feature', properties: _objectSpread({ index: index }, getProperties(rowIndex)), geometry: geometry }); } } return geojson; } var prefixGpuField = exports.prefixGpuField = function prefixGpuField(name) { return "gpu:".concat(name); }; function gpuFilterToMapboxFilter(gpuFilter) { var filterRange = gpuFilter.filterRange, filterValueUpdateTriggers = gpuFilter.filterValueUpdateTriggers; var hasFilter = Object.values(filterValueUpdateTriggers).filter(function (d) { return d; }); if (!hasFilter.length) { return null; } var condition = ['all']; // [">=", key, value] // ["<=", key, value] var expressions = Object.values(filterValueUpdateTriggers).reduce(function (accu, gpu, i) { return gpu !== null && gpu !== void 0 && gpu.name ? [].concat((0, _toConsumableArray2["default"])(accu), [['>=', prefixGpuField(gpu.name), filterRange[i][0]], ['<=', prefixGpuField(gpu.name), filterRange[i][1]]]) : accu; }, condition); return expressions; } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfYmFzZUxheWVyIiwicmVxdWlyZSIsIl91dGlscyIsIm93bktleXMiLCJlIiwiciIsInQiLCJPYmplY3QiLCJrZXlzIiwiZ2V0T3duUHJvcGVydHlTeW1ib2xzIiwibyIsImZpbHRlciIsImdldE93blByb3BlcnR5RGVzY3JpcHRvciIsImVudW1lcmFibGUiLCJwdXNoIiwi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