UNPKG

kepler.gl

Version:

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

503 lines (497 loc) 67.9 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.tripVisConfigs = exports.featureResolver = exports.featureAccessor = exports.defaultThickness = exports.defaultLineWidth = exports["default"] = exports.COLUMN_MODE_TABLE = exports.COLUMN_MODE_GEOJSON = void 0; var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray")); var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get")); var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _lodash = _interopRequireDefault(require("lodash.memoize")); var _lodash2 = _interopRequireDefault(require("lodash.uniq")); var _baseLayer = _interopRequireWildcard(require("../base-layer")); var _geoLayers = require("@deck.gl/geo-layers"); var _constants = require("@kepler.gl/constants"); var _tripLayerIcon = _interopRequireDefault(require("./trip-layer-icon")); var _geojsonUtils = require("../geojson-layer/geojson-utils"); var _tripUtils = require("./trip-utils"); var _tripInfoModal = _interopRequireDefault(require("./trip-info-modal")); var _d3Array = require("d3-array"); 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; } 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; } function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _superPropGet(t, e, r, o) { var p = (0, _get2["default"])((0, _getPrototypeOf2["default"])(1 & o ? t.prototype : t), e, r); return 2 & o ? function (t) { return p.apply(r, t); } : p; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project var zoomFactorValue = 8; var defaultThickness = exports.defaultThickness = 0.5; var defaultLineWidth = exports.defaultLineWidth = 1; var tripVisConfigs = exports.tripVisConfigs = { opacity: 'opacity', thickness: { type: 'number', defaultValue: defaultThickness, label: 'Stroke Width', isRanged: false, range: [0, 100], step: 0.1, group: 'stroke', property: 'thickness' }, colorRange: 'colorRange', trailLength: 'trailLength', fadeTrail: 'fadeTrail', billboard: 'billboard', sizeRange: 'strokeWidthRange' }; var featureAccessor = exports.featureAccessor = function featureAccessor(_ref) { var geojson = _ref.geojson; return function (dc) { return function (d) { return dc.valueAt(d.index, geojson.fieldIdx); }; }; }; var featureResolver = exports.featureResolver = function featureResolver(_ref2) { var geojson = _ref2.geojson; return geojson.fieldIdx; }; var getTableModeValueAccessor = function getTableModeValueAccessor(f) { // Called from gpu-filter-utils.getFilterValueAccessor() return function (field) { return f.properties.values.map(function (v) { return field.valueAccessor(v); }); }; }; var getTableModeFieldValue = function getTableModeFieldValue(field, data) { var rv; if (typeof data === 'function') { rv = data(field); } else { rv = (0, _baseLayer.defaultGetFieldValue)(field, data); } return rv; }; var COLUMN_MODE_GEOJSON = exports.COLUMN_MODE_GEOJSON = 'geojson'; var COLUMN_MODE_TABLE = exports.COLUMN_MODE_TABLE = 'table'; var SUPPORTED_COLUMN_MODES = [{ key: COLUMN_MODE_GEOJSON, label: 'GeoJSON', requiredColumns: ['geojson'] }, { key: COLUMN_MODE_TABLE, label: 'Table columns', requiredColumns: ['id', 'lat', 'lng', 'timestamp'], optionalColumns: ['altitude'] }]; var DEFAULT_COLUMN_MODE = COLUMN_MODE_GEOJSON; var TripLayer = exports["default"] = /*#__PURE__*/function (_Layer) { function TripLayer(props) { var _this; (0, _classCallCheck2["default"])(this, TripLayer); _this = _callSuper(this, TripLayer, [props]); (0, _defineProperty2["default"])(_this, "dataToFeature", void 0); (0, _defineProperty2["default"])(_this, "dataToTimeStamp", void 0); (0, _defineProperty2["default"])(_this, "getFeature", void 0); (0, _defineProperty2["default"])(_this, "_layerInfoModal", void 0); _this.dataToFeature = []; _this.dataToTimeStamp = []; _this.dataContainer = null; _this.registerVisConfig(tripVisConfigs); _this.getFeature = (0, _lodash["default"])(featureAccessor, featureResolver); _this._layerInfoModal = (0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, COLUMN_MODE_TABLE, (0, _tripInfoModal["default"])(COLUMN_MODE_TABLE)), COLUMN_MODE_GEOJSON, (0, _tripInfoModal["default"])(COLUMN_MODE_GEOJSON)); return _this; } (0, _inherits2["default"])(TripLayer, _Layer); return (0, _createClass2["default"])(TripLayer, [{ key: "supportedColumnModes", get: function get() { return SUPPORTED_COLUMN_MODES; } }, { key: "type", get: function get() { return TripLayer.type; } }, { key: "name", get: function get() { return 'Trip'; } }, { key: "layerIcon", get: function get() { return _tripLayerIcon["default"]; } }, { key: "columnPairs", get: function get() { return this.defaultPointColumnPairs; } }, { key: "accessVSFieldValue", value: function accessVSFieldValue() { if (this.config.columnMode === COLUMN_MODE_GEOJSON) { return _baseLayer.defaultGetFieldValue; } return getTableModeFieldValue; } }, { key: "visualChannels", get: function get() { var visualChannels = _superPropGet(TripLayer, "visualChannels", this, 1); return _objectSpread(_objectSpread({}, visualChannels), {}, { color: _objectSpread(_objectSpread({}, visualChannels.color), {}, { accessor: 'getColor', nullValue: visualChannels.color.nullValue, getAttributeValue: function getAttributeValue(config) { return function (d) { return d.properties.lineColor || config.color; }; }, // used this to get updateTriggers defaultValue: function defaultValue(config) { return config.color; } }), size: _objectSpread(_objectSpread({}, visualChannels.size), {}, { property: 'stroke', accessor: 'getWidth', condition: function condition(config) { return config.visConfig.stroked; }, nullValue: 0, getAttributeValue: function getAttributeValue() { return function (d) { return d.properties.lineWidth || defaultLineWidth; }; } }) }); } }, { key: "animationDomain", get: function get() { return this.config.animation.domain; } }, { key: "layerInfoModal", get: function get() { return (0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, COLUMN_MODE_GEOJSON, { id: 'iconInfo', template: this._layerInfoModal[COLUMN_MODE_GEOJSON], modalProps: { title: 'modal.tripInfo.title' } }), COLUMN_MODE_TABLE, { id: 'iconInfo', template: this._layerInfoModal[COLUMN_MODE_TABLE], modalProps: { title: 'modal.tripInfo.titleTable' } }); } }, { key: "getPositionAccessor", value: function getPositionAccessor(dataContainer) { if (this.config.columnMode === COLUMN_MODE_GEOJSON) { return this.getFeature(this.config.columns)(dataContainer); } return null; } }, { key: "getDefaultLayerConfig", value: function getDefaultLayerConfig(props) { var _props$columnMode; return _objectSpread(_objectSpread({}, _superPropGet(TripLayer, "getDefaultLayerConfig", this, 3)([props])), {}, { columnMode: (_props$columnMode = props === null || props === void 0 ? void 0 : props.columnMode) !== null && _props$columnMode !== void 0 ? _props$columnMode : DEFAULT_COLUMN_MODE, animation: { enabled: true, domain: null } }); } }, { key: "getHoverData", value: function getHoverData(object, dataContainer, fields, animationConfig) { var _this$_findColumnMode; if (this.config.columnMode === COLUMN_MODE_GEOJSON) { // index for dataContainer is saved to feature.properties return dataContainer.row(object.properties.index); } return (_this$_findColumnMode = this._findColumnModeDatumForFeature(object.properties.index, animationConfig.currentTime)) === null || _this$_findColumnMode === void 0 ? void 0 : _this$_findColumnMode.datum; } }, { key: "calculateDataAttribute", value: function calculateDataAttribute(dataset) { var _this2 = this; switch (this.config.columnMode) { case COLUMN_MODE_GEOJSON: { return dataset.filteredIndex.map(function (i) { return _this2.dataToFeature[i]; }) // TODO d can be BinaryFeatureCollection, fix logic .filter(function (d) { var _geometry; return d && ((_geometry = d.geometry) === null || _geometry === void 0 ? void 0 : _geometry.type) === 'LineString'; }); } case COLUMN_MODE_TABLE: return (0, _geojsonUtils.applyFiltersToTableColumns)(dataset, this.dataToFeature); default: return []; } } }, { key: "formatLayerData", value: function formatLayerData(datasets, oldLayerData) { var _this3 = this; if (this.config.dataId === null) { return {}; } // to-do: parse segment from dataContainer var _datasets$this$config = datasets[this.config.dataId], dataContainer = _datasets$this$config.dataContainer, gpuFilter = _datasets$this$config.gpuFilter; var _this$updateData = this.updateData(datasets, oldLayerData), data = _this$updateData.data; var valueAccessor; if (this.config.columnMode === COLUMN_MODE_GEOJSON) { valueAccessor = function valueAccessor(dc, f, fieldIndex) { return dc.valueAt(f.properties.index, fieldIndex); }; } else { valueAccessor = getTableModeValueAccessor; } var indexAccessor = function indexAccessor(f) { return f.properties.index; }; var dataAccessor = function dataAccessor() { return function (d) { return { index: d.properties.index }; }; }; var accessors = this.getAttributeAccessors({ dataAccessor: dataAccessor, dataContainer: dataContainer }); var getFilterValue = gpuFilter.filterValueAccessor(dataContainer)(indexAccessor, valueAccessor); return _objectSpread({ data: data, getFilterValue: getFilterValue, getPath: function getPath(d) { return d.geometry.coordinates; }, getTimestamps: function getTimestamps(d) { return _this3.dataToTimeStamp[d.properties.index]; } }, accessors); } }, { key: "updateAnimationDomain", value: function updateAnimationDomain(domain) { this.updateLayerConfig({ animation: _objectSpread(_objectSpread({}, this.config.animation), {}, { domain: domain }) }); } }, { key: "updateLayerMeta", value: function updateLayerMeta(dataset) { var dataContainer = dataset.dataContainer; var getFeature; if (this.config.columnMode === COLUMN_MODE_GEOJSON) { getFeature = this.getPositionAccessor(dataContainer); if (getFeature === this.meta.getFeature) { // TODO: revisit this after gpu filtering return; } this.dataToFeature = (0, _geojsonUtils.getGeojsonDataMaps)(dataContainer, getFeature); } else { this.dataContainer = dataContainer; this.dataToFeature = (0, _geojsonUtils.groupColumnsAsGeoJson)(dataContainer, this.config.columns, 'timestamp'); } var _parseTripGeoJsonTime = (0, _tripUtils.parseTripGeoJsonTimestamp)(this.dataToFeature), dataToTimeStamp = _parseTripGeoJsonTime.dataToTimeStamp, animationDomain = _parseTripGeoJsonTime.animationDomain; this.dataToTimeStamp = dataToTimeStamp; this.updateAnimationDomain(animationDomain); // get bounds from features var bounds = (0, _geojsonUtils.getGeojsonBounds)(this.dataToFeature); // keep a record of what type of geometry the collection has var featureTypes = (0, _geojsonUtils.getGeojsonFeatureTypes)(this.dataToFeature); this.updateMeta({ bounds: bounds, featureTypes: featureTypes, getFeature: getFeature }); } }, { key: "setInitialLayerConfig", value: function setInitialLayerConfig(dataset) { var dataContainer = dataset.dataContainer; if (!dataContainer.numRows()) { return this; } // defefaultLayerProps will automatically find geojson column // if not found, we try to set it to id / lat /lng /ts if (!this.config.columns.geojson.value) { // find columns from lat, lng, id, and ts var columnConfig = (0, _geojsonUtils.detectTableColumns)(dataset, this.config.columns); if (columnConfig) { this.updateLayerConfig(_objectSpread(_objectSpread({}, columnConfig), {}, { columnMode: COLUMN_MODE_TABLE })); } else { return this; } } this.updateLayerMeta(dataset); return this; } }, { key: "renderLayer", value: function renderLayer(opts) { var _animationConfig$doma, _mapState$globe; var data = opts.data, gpuFilter = opts.gpuFilter, mapState = opts.mapState, animationConfig = opts.animationConfig; var visConfig = this.config.visConfig; var zoomFactor = this.getZoomFactor(mapState); var isValidTime = animationConfig && Array.isArray(animationConfig.domain) && animationConfig.domain.every(Number.isFinite) && Number.isFinite(animationConfig.currentTime); if (!isValidTime) { return []; } var domain0 = (_animationConfig$doma = animationConfig.domain) === null || _animationConfig$doma === void 0 ? void 0 : _animationConfig$doma[0]; var gpuFilterUpdateTriggers = { getFilterValue: gpuFilter.filterValueUpdateTriggers }; var updateTriggers = _objectSpread(_objectSpread({}, this.getVisualChannelUpdateTriggers()), {}, { getTimestamps: { columns: this.config.columns, domain0: domain0 } }, gpuFilterUpdateTriggers); var defaultLayerProps = this.getDefaultDeckLayerProps(opts); var billboardWidthFactor = visConfig.billboard ? _constants.PROJECTED_PIXEL_SIZE_MULTIPLIER : 1; var layerProps = _objectSpread(_objectSpread(_objectSpread({}, defaultLayerProps), data), {}, { getTimestamps: function getTimestamps(d) { return (data.getTimestamps(d) || []).map(function (ts) { return ts - domain0; }); }, widthScale: visConfig.thickness * zoomFactor * zoomFactorValue * billboardWidthFactor, capRounded: true, jointRounded: true, wrapLongitude: false, parameters: { depthTest: mapState.dragRotate, depthMask: false }, trailLength: visConfig.trailLength * 1000, fadeTrail: visConfig.fadeTrail, billboard: visConfig.billboard, // TODO: giuseppe this values becomes negative currentTime: animationConfig.currentTime - domain0, updateTriggers: updateTriggers, id: "".concat(defaultLayerProps.id).concat((_mapState$globe = mapState.globe) !== null && _mapState$globe !== void 0 && _mapState$globe.enabled ? '-globe' : '') }); return [new _geoLayers.TripsLayer(layerProps)]; } /** * Finds coordinates and datum at the current animation time by the specified feature index. * @param featureIndex * @param time * @returns {{datum: (null|string|*), idx: *, coords}|{datum: null, idx: number, coords: null}} */ }, { key: "_findColumnModeDatumForFeature", value: function _findColumnModeDatumForFeature(featureIndex, time) { if (this.config.columnMode === COLUMN_MODE_TABLE) { var object = this.dataToFeature[featureIndex]; var idx = (0, _d3Array.bisectRight)(this.dataToTimeStamp[featureIndex], time); // @ts-expect-error type geometry? var _ref4 = (object === null || object === void 0 ? void 0 : object.geometry) || { coordinates: [] }, coordinates = _ref4.coordinates; if (idx >= 0 && idx < coordinates.length) { var coords = coordinates[idx]; return { idx: idx, coords: coords, datum: coords === null || coords === void 0 ? void 0 : coords.datum }; } } return { idx: -1, coords: null, datum: null }; } }], [{ key: "type", get: function get() { return 'trip'; } }, { key: "findDefaultLayerProps", value: function findDefaultLayerProps(_ref5, foundLayers) { var _this4 = this; var label = _ref5.label, _ref5$fields = _ref5.fields, fields = _ref5$fields === void 0 ? [] : _ref5$fields, dataContainer = _ref5.dataContainer, id = _ref5.id; var geojsonColumns = fields.filter(function (f) { return f.type === 'geojson'; }).map(function (f) { return f.name; }); var defaultColumns = { geojson: (0, _lodash2["default"])([].concat((0, _toConsumableArray2["default"])(_constants.GEOJSON_FIELDS.geojson), (0, _toConsumableArray2["default"])(geojsonColumns))) }; var geoJsonColumns = this.findDefaultColumnField(defaultColumns, fields); var tripGeojsonColumns = (geoJsonColumns || []).filter(function (col) { return (0, _tripUtils.isTripGeoJsonField)(dataContainer, fields[col.geojson.fieldIdx]); }); if (tripGeojsonColumns.length) { return { props: tripGeojsonColumns.map(function (columns) { return { label: typeof label === 'string' && label.replace(/\.[^/.]+$/, '') || _this4.type, columns: columns, isVisible: true, columnMode: COLUMN_MODE_GEOJSON }; }), // if a geojson layer is created from this column, delete it foundLayers: foundLayers === null || foundLayers === void 0 ? void 0 : foundLayers.filter(function (prop) { return prop.type !== 'geojson' || prop.dataId !== id || !tripGeojsonColumns.find(function (c) { return prop.columns.geojson.name === c.geojson.name; }); }) }; } return { props: [] }; } }]); }(_baseLayer["default"]); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfbG9kYXNoIiwiX2ludGVyb3BSZXF1aXJlRGVmYXVsdCIsInJlcXVpcmUiLCJfbG9kYXNoMiIsIl9iYXNlTGF5ZXIiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsIl9nZW9MYXllcnMiLCJfY29uc3RhbnRzIiwiX3RyaXBMYXllckljb24iLCJfZ2VvanNvblV0aWxzIiwiX3RyaXBVdGlscyIsIl90cmlwSW5mb01vZGFsIiwiX2QzQXJyYXkiLCJfZ2V0UmVxdWlyZVdpbGRjYXJkQ2FjaGUiLCJlIiwiV2Vha01hcCIsInIiLCJ0IiwiX19lc01vZHVsZSIsIl90eXBlb2YiLCJoYXMiLCJnZXQiLCJuIiwiX19wcm90b19fIiwiYSIsIk9iamVjdCIsImRlZmluZVByb3BlcnR5IiwiZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9yIiwidSIsImhhc093blByb3BlcnR5IiwiY2FsbCIsImkiLCJzZXQiLCJvd25LZXlzIiwia2V5cyIsImdldE93blByb3BlcnR5U3ltYm9scyIsIm8iLCJmaWx0ZXIiLCJlbnVtZXJhYmxlIiwicHVzaCIsImFwcGx5IiwiX29iamVjdFNwcmVhZCIsImFyZ3VtZW50cyIsImxlbmd0aCIsImZvckVhY2giLCJfZGVmaW5lUHJvcGVydHkyIiwiZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyIsImRlZmluZVByb3BlcnRpZXMiLCJfY2FsbFN1cGVyIiwiX2dldFByb3RvdHlwZU9mMiIsIl9wb3NzaWJsZUNvbnN0cnVjdG9yUmV0dXJuMiIsIl9pc05hdGl2ZVJlZmxlY3RDb25zdHJ1Y3QiLCJSZWZsZWN0IiwiY29uc3RydWN0IiwiY29uc3RydWN0b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