kepler.gl.geoiq
Version:
kepler.gl is a webgl based application to visualize large scale location data in the browser
425 lines (384 loc) • 9.48 kB
JavaScript
// Copyright (c) 2019 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// vis-state-reducer
import ActionTypes from 'constants/action-types';
export function layerConfigChange(oldLayer, newConfig) {
// console.log(
// 'layerConfigChange',
// 'oldLayer',
// oldLayer,
// 'newConfig',
// newConfig
// );
return {
type: ActionTypes.LAYER_CONFIG_CHANGE,
oldLayer,
newConfig
};
}
export function updateLayerData(layer, collected) {
return {
type: ActionTypes.UPDATE_STATE_LAYER_DATA,
layer,
collected
};
}
export function axiosAPICAll(layer) {
return {
type: ActionTypes.ASYNC_API_CALL,
layer
};
}
export function layerTypeChange(oldLayer, newType) {
// console.log('layerTypeChange', 'oldLayer', oldLayer, 'newType', newType);
return {
type: ActionTypes.LAYER_TYPE_CHANGE,
oldLayer,
newType
};
}
export function layerVisualChannelConfigChange(oldLayer, newConfig, channel) {
// console.log(
// 'layerVisualChannelConfigChange',
// 'oldLayer',
// oldLayer,
// 'newConfig',
// newConfig,
// channel
// );
return {
type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE,
oldLayer,
newConfig,
channel
};
}
export function layerVisConfigChange(oldLayer, newVisConfig) {
// console.log(
// 'layerVisConfigChange',
// 'oldLayer',
// oldLayer,
// 'newVisConfig',
// newVisConfig
// );
return {
type: ActionTypes.LAYER_VIS_CONFIG_CHANGE,
oldLayer,
newVisConfig
};
}
export function widgetConfigChange(oldWidget, newConfig) {
return {
type: ActionTypes.WIDGET_CONFIG_CHANGE,
oldWidget,
newConfig
};
}
export function widgetTypeChange(oldWidget, newType) {
// console.log('widgetTypeChange', 'oldWidget', oldWidget, 'newType', newType);
return {
type: ActionTypes.WIDGET_TYPE_CHANGE,
oldWidget,
newType
};
}
export function widgetVisualChannelConfigChange(oldWidget, newConfig, channel) {
// console.log(
// 'widgetVisualChannelConfigChange',
// 'oldWidget',
// oldWidget,
// 'newConfig',
// newConfig,
// 'channel',
// channel
// );
return {
type: ActionTypes.WIDGET_VISUAL_CHANNEL_CHANGE,
oldWidget,
newConfig,
channel
};
}
export function widgetVisConfigChange(oldWidget, newVisConfig) {
// console.log(
// 'widgetVisConfigChange',
// 'oldWidget',
// oldWidget,
// 'newVisConfig',
// newVisConfig
// );
return {
type: ActionTypes.WIDGET_VIS_CONFIG_CHANGE,
oldWidget,
newVisConfig
};
}
export function updateLayerBlending(mode) {
// console.log('updateLayerBlending', 'mode', mode);
return {
type: ActionTypes.UPDATE_LAYER_BLENDING,
mode
};
}
export function interactionConfigChange(config) {
// console.log('interactionConfigChange', 'config', config);
return {
type: ActionTypes.INTERACTION_CONFIG_CHANGE,
config
};
}
export function setFilter(idx, prop, value) {
// console.log('setFilter', 'idx', idx, 'prop', prop, 'value', value);
return {
type: ActionTypes.SET_FILTER,
idx,
prop,
value
};
}
export function addFilter(dataId) {
// console.log('addFilter', 'dataID', dataId);
return {
type: ActionTypes.ADD_FILTER,
dataId
};
}
export function addLayer(props) {
// console.log('addLayer', 'props', props);
return {
type: ActionTypes.ADD_LAYER,
props
};
}
export function addWidget(props) {
// console.log('addWidget', 'props', props);
return {
type: ActionTypes.ADD_WIDGET,
props
};
}
export function reorderWidget(order) {
// console.log('reorderWidget', 'order', order);
return {
type: ActionTypes.REORDER_WIDGET,
order
};
}
export function reorderLayer(order) {
// console.log('reorderLayer', 'order', order);
return {
type: ActionTypes.REORDER_LAYER,
order
};
}
export function removeFilter(idx) {
// console.log('removeFilter', 'idx', idx);
return {
type: ActionTypes.REMOVE_FILTER,
idx
};
}
export function removeLayer(idx) {
// console.log('removeLayer', 'idx', idx);
return {
type: ActionTypes.REMOVE_LAYER,
idx
};
}
export function removeWidget(idx) {
// console.log('removeWidget', 'idx', idx);
return {
type: ActionTypes.REMOVE_WIDGET,
idx
};
}
export function removeDataset(key) {
// console.log('removeDataset', 'key', key);
return {
type: ActionTypes.REMOVE_DATASET,
key
};
}
export function showDatasetTable(dataId) {
// console.log('showDatasetTable', 'dataId', dataId);
return {
type: ActionTypes.SHOW_DATASET_TABLE,
dataId
};
}
/**
*
* @param datasets - Array of datasets :
* {info: {id: '', color: hex, label: '']}, data: {fields: [], rows: []}}
* @param options {centerMap, readOnly}
* @param config {visState, mapState, mapStyle}
* @returns {{type: null, datasets: *, options: *}}
*/
export function updateVisData(datasets, options, config) {
// console.log(
// 'updateVisData',
// 'datasets',
// datasets,
// 'options',
// options,
// 'config',
// config
// );
return {
type: ActionTypes.UPDATE_VIS_DATA,
datasets,
options,
config
};
}
export function toggleAnimation(idx) {
// console.log('toggleAnimation', 'idx', idx);
return {
type: ActionTypes.TOGGLE_FILTER_ANIMATION,
idx
};
}
export function updateAnimationSpeed(idx, speed) {
// console.log('updateAnimation', 'idx', idx, 'speed', speed);
return {
type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED,
idx,
speed
};
}
export function enlargeFilter(idx) {
// console.log('enlargeFilter', 'idx', idx);
return {
type: ActionTypes.ENLARGE_FILTER,
idx
};
}
export function onLayerHover(info) {
// console.log('onLayerHover', info);
return {
type: ActionTypes.LAYER_HOVER,
info
};
}
export function onLayerClick(info) {
// console.log('onLayerClick', info);
return {
type: ActionTypes.LAYER_CLICK,
info
};
}
export function onWidgetHover(info) {
// console.log('onWidgetHover', info);
return {
type: ActionTypes.WIDGET_HOVER,
info
};
}
export function onWidgetClick(info) {
// console.log('onWidgetClick', info);
return {
type: ActionTypes.WIDGET_CLICK,
info
};
}
export function onMapClick() {
// console.log('onMapClick');
return {
type: ActionTypes.MAP_CLICK
};
}
/**
* Toggle a single layer for a give map
* @param mapIndex
* @param layerId
* @returns {{type: *, mapIndex: *, layerId: *}}
*/
export function toggleLayerForMap(mapIndex, layerId) {
// console.log('toggleLAyerForMap', 'mapIndex', mapIndex, 'layerId', layerId);
return {
type: ActionTypes.TOGGLE_LAYER_FOR_MAP,
mapIndex,
layerId
};
}
/**
* Toggle a single widget for a give map
* @param mapIndex
* @param widgetId
* @returns {{type: *, mapIndex: *, widgetId: *}}
*/
export function toggleWidgetForMap(mapIndex, widgetId) {
// console.log('toggleWidgetForMap', mapIndex, widgetId);
return {
type: ActionTypes.TOGGLE_WIDGET_FOR_MAP,
mapIndex,
widgetId
};
}
/**
* Toggle layer visibility on split views
* @param layerIndex the layer we want to toggle visibility on
* @param mapIndex the map index
* @returns {{type: null, layerIndex: *, mapIndex: *}}
*/
export function setVisibleLayersForMap(mapIndex, layerIds) {
// console.log('setVisibleLayersForMap', mapIndex, layerIds);
return {
type: ActionTypes.SET_VISIBLE_LAYERS_FOR_MAP,
mapIndex,
layerIds
};
}
/**
* Toggle widget visibility on split views
* @param widgetIndex the widget we want to toggle visibility on
* @param mapIndex the map index
* @returns {{type: null, widgetIndex: *, mapIndex: *}}
*/
export function setVisibleWidgetsForMap(mapIndex, widgetIds) {
// console.log('setVisibleWidgetsForMap', mapIndex, widgetIds);
return {
type: ActionTypes.SET_VISIBLE_WIDGETS_FOR_MAP,
mapIndex,
widgetIds
};
}
export function setFilterPlot(idx, newProp) {
// console.log('setFilterPlot', idx, newProp);
return {
type: ActionTypes.SET_FILTER_PLOT,
idx,
newProp
};
}
export function loadFiles(files) {
// console.log('loadFiles', files);
return {
type: ActionTypes.LOAD_FILES,
files
};
}
export function loadFilesErr(error) {
// console.log('loadFilesErr', error);
return {
type: ActionTypes.LOAD_FILES_ERR,
error
};
}