@carto/kepler.gl 0.0.48-alpha.custom-markers.3 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/common/field-selector.js +3 -7
- package/dist/components/common/item-selector/item-selector.js +1 -6
- package/dist/components/common/styled-components.js +2 -2
- package/dist/components/index.js +1 -10
- package/dist/components/kepler-gl.js +1 -2
- package/dist/components/side-panel/layer-panel/layer-configurator.js +8 -16
- package/dist/components/side-panel/layer-panel/vis-config-by-field-selector.js +3 -19
- package/dist/constants/default-settings.js +5 -6
- package/dist/layers/base-layer.js +5 -111
- package/dist/layers/geojson-layer/geojson-layer.js +2 -2
- package/dist/layers/layer-factory.js +1 -23
- package/dist/layers/point-layer/point-layer.js +22 -123
- package/dist/localization/en.js +3 -9
- package/dist/processors/data-processor.js +2 -4
- package/dist/utils/layer-utils.js +3 -5
- package/dist/utils/table-utils/kepler-table.js +3 -2
- package/package.json +4 -7
- package/src/components/common/field-selector.js +6 -12
- package/src/components/common/item-selector/item-selector.js +0 -4
- package/src/components/common/styled-components.js +1 -1
- package/src/components/index.js +0 -1
- package/src/components/kepler-gl.js +0 -1
- package/src/components/side-panel/layer-panel/layer-configurator.js +10 -27
- package/src/components/side-panel/layer-panel/vis-config-by-field-selector.js +1 -11
- package/src/constants/default-settings.js +3 -7
- package/src/layers/base-layer.js +2 -80
- package/src/layers/geojson-layer/geojson-layer.js +1 -2
- package/src/layers/layer-factory.js +0 -22
- package/src/layers/point-layer/point-layer.js +27 -132
- package/src/localization/en.js +2 -8
- package/src/processors/data-processor.js +0 -3
- package/src/utils/layer-utils.js +2 -4
- package/src/utils/table-utils/kepler-table.js +1 -1
- package/CHANGELOG.md +0 -711
- package/dist/components/side-panel/layer-panel/custom-markers-config-group.js +0 -40
- package/src/components/side-panel/layer-panel/custom-markers-config-group.js +0 -30
|
@@ -113,9 +113,7 @@ function FieldSelectorFactory(FieldListItemFactory) {
|
|
|
113
113
|
closeOnSelect: PropTypes.bool,
|
|
114
114
|
showToken: PropTypes.bool,
|
|
115
115
|
suggested: PropTypes.arrayOf(PropTypes.any),
|
|
116
|
-
CustomChickletComponent: PropTypes.func
|
|
117
|
-
onBlur: PropTypes.func,
|
|
118
|
-
onFocus: PropTypes.func
|
|
116
|
+
CustomChickletComponent: PropTypes.func
|
|
119
117
|
};
|
|
120
118
|
|
|
121
119
|
static defaultProps = {
|
|
@@ -135,17 +133,15 @@ function FieldSelectorFactory(FieldListItemFactory) {
|
|
|
135
133
|
|
|
136
134
|
fieldsSelector = props => props.fields;
|
|
137
135
|
filteredFieldsSelector = props =>
|
|
138
|
-
props.withAggregator
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
!toArray(props.value).find(d => (d.name ? d.name === field.name : d === field.name))
|
|
143
|
-
);
|
|
136
|
+
props.withAggregator ? props.fields : props.fields.filter(
|
|
137
|
+
field =>
|
|
138
|
+
!toArray(props.value).find(d => (d.name ? d.name === field.name : d === field.name))
|
|
139
|
+
);
|
|
144
140
|
valueSelector = props => props.value;
|
|
145
141
|
aggregatorSelector = props => props.aggregator;
|
|
146
142
|
filterFieldTypesSelector = props => props.filterFieldTypes;
|
|
147
143
|
showTokenSelector = props => props.showToken;
|
|
148
|
-
withAggregatorSelector = props => props.withAggregator
|
|
144
|
+
withAggregatorSelector = props => props.withAggregator
|
|
149
145
|
|
|
150
146
|
selectedItemsSelector = createSelector(
|
|
151
147
|
this.fieldsSelector,
|
|
@@ -219,8 +215,6 @@ function FieldSelectorFactory(FieldListItemFactory) {
|
|
|
219
215
|
DropdownHeaderComponent={this.props.suggested ? SuggestedFieldHeader : null}
|
|
220
216
|
CustomChickletComponent={this.props.CustomChickletComponent}
|
|
221
217
|
withSubOptions={this.props.withAggregator}
|
|
222
|
-
onBlur={this.props.onBlur}
|
|
223
|
-
onFocus={this.props.onFocus}
|
|
224
218
|
/>
|
|
225
219
|
</div>
|
|
226
220
|
);
|
|
@@ -135,7 +135,6 @@ class ItemSelector extends Component {
|
|
|
135
135
|
multiSelect: PropTypes.bool,
|
|
136
136
|
inputTheme: PropTypes.string,
|
|
137
137
|
onBlur: PropTypes.func,
|
|
138
|
-
onFocus: PropTypes.func,
|
|
139
138
|
placeholder: PropTypes.string,
|
|
140
139
|
closeOnSelect: PropTypes.bool,
|
|
141
140
|
typeaheadPlaceholder: PropTypes.string,
|
|
@@ -243,9 +242,6 @@ class ItemSelector extends Component {
|
|
|
243
242
|
_showTypeahead = e => {
|
|
244
243
|
e.stopPropagation();
|
|
245
244
|
if (!this.props.disabled && !this.props.isLoading) {
|
|
246
|
-
if (!this.state.showTypeahead && this.props.onFocus) {
|
|
247
|
-
this.props.onFocus();
|
|
248
|
-
}
|
|
249
245
|
this.setState({
|
|
250
246
|
showTypeahead: true
|
|
251
247
|
});
|
|
@@ -85,7 +85,7 @@ export const SBFlexboxNoMargin = styled.div`
|
|
|
85
85
|
export const PanelLabel = styled.label.attrs({
|
|
86
86
|
className: 'side-panel-panel__label'
|
|
87
87
|
})`
|
|
88
|
-
color: ${props =>
|
|
88
|
+
color: ${props => props.theme.labelColor};
|
|
89
89
|
display: inline-block;
|
|
90
90
|
font-size: 11px;
|
|
91
91
|
font-weight: 400;
|
package/src/components/index.js
CHANGED
|
@@ -73,7 +73,6 @@ export {
|
|
|
73
73
|
export {default as LayerPanelFactory} from './side-panel/layer-panel/layer-panel';
|
|
74
74
|
export {default as LayerPanelHeaderFactory} from './side-panel/layer-panel/layer-panel-header';
|
|
75
75
|
export {default as LayerConfiguratorFactory} from './side-panel/layer-panel/layer-configurator';
|
|
76
|
-
export {default as CustomMarkersConfigGroupFactory} from './side-panel/layer-panel/custom-markers-config-group';
|
|
77
76
|
export {default as TextLabelPanelFactory} from './side-panel/layer-panel/text-label-panel';
|
|
78
77
|
export {LayerConfigGroupLabelFactory} from './side-panel/layer-panel/layer-config-group';
|
|
79
78
|
export {default as LayerVisibilityByZoomFactory} from './side-panel/layer-panel/layer-visibility-by-zoom';
|
|
@@ -130,7 +130,6 @@ export const mapFieldsSelector = props => ({
|
|
|
130
130
|
clicked: props.visState.clicked,
|
|
131
131
|
mousePos: props.visState.mousePos,
|
|
132
132
|
animationConfig: props.visState.animationConfig,
|
|
133
|
-
customMarkersStatus: props.visState.customMarkersStatus,
|
|
134
133
|
|
|
135
134
|
// uiState
|
|
136
135
|
activeSidePanel: props.uiState.activeSidePanel,
|
|
@@ -36,7 +36,6 @@ import SourceDataSelectorFactory from 'components/side-panel/common/source-data-
|
|
|
36
36
|
import VisConfigSwitchFactory from './vis-config-switch';
|
|
37
37
|
import VisConfigSliderFactory from './vis-config-slider';
|
|
38
38
|
import LayerConfigGroupFactory, {ConfigGroupCollapsibleContent} from './layer-config-group';
|
|
39
|
-
import CustomMarkersConfigGroupFactory from './custom-markers-config-group';
|
|
40
39
|
import TextLabelPanelFactory from './text-label-panel';
|
|
41
40
|
|
|
42
41
|
import {capitalizeFirstLetter} from 'utils/utils';
|
|
@@ -103,8 +102,7 @@ LayerConfiguratorFactory.deps = [
|
|
|
103
102
|
LayerVisibilityByZoomFactory,
|
|
104
103
|
LayerColorSelectorFactory,
|
|
105
104
|
LayerColorRangeSelectorFactory,
|
|
106
|
-
ArcLayerColorSelectorFactory
|
|
107
|
-
CustomMarkersConfigGroupFactory
|
|
105
|
+
ArcLayerColorSelectorFactory
|
|
108
106
|
];
|
|
109
107
|
|
|
110
108
|
export default function LayerConfiguratorFactory(
|
|
@@ -120,8 +118,7 @@ export default function LayerConfiguratorFactory(
|
|
|
120
118
|
LayerVisibilityByZoom,
|
|
121
119
|
LayerColorSelector,
|
|
122
120
|
LayerColorRangeSelector,
|
|
123
|
-
ArcLayerColorSelector
|
|
124
|
-
CustomMarkersConfigGroup
|
|
121
|
+
ArcLayerColorSelector
|
|
125
122
|
) {
|
|
126
123
|
class LayerConfigurator extends Component {
|
|
127
124
|
static propTypes = {
|
|
@@ -202,19 +199,8 @@ export default function LayerConfiguratorFactory(
|
|
|
202
199
|
</LayerConfigGroup>
|
|
203
200
|
) : null}
|
|
204
201
|
|
|
205
|
-
{layer.type === LAYER_TYPES.point ? (
|
|
206
|
-
<CustomMarkersConfigGroup
|
|
207
|
-
layer={layer}
|
|
208
|
-
visConfiguratorProps={visConfiguratorProps}
|
|
209
|
-
layerChannelConfigProps={layerChannelConfigProps}
|
|
210
|
-
/>
|
|
211
|
-
) : null}
|
|
212
|
-
|
|
213
202
|
{/* Radius */}
|
|
214
|
-
<LayerConfigGroup
|
|
215
|
-
label={layer.config.visConfig.customMarkers ? 'layer.size' : 'layer.radius'}
|
|
216
|
-
collapsible
|
|
217
|
-
>
|
|
203
|
+
<LayerConfigGroup label={'layer.radius'} collapsible>
|
|
218
204
|
{!layer.config.sizeField ? (
|
|
219
205
|
<VisConfigSlider
|
|
220
206
|
{...layer.visConfigSettings.radius}
|
|
@@ -239,7 +225,6 @@ export default function LayerConfiguratorFactory(
|
|
|
239
225
|
<VisConfigSwitch
|
|
240
226
|
{...layer.visConfigSettings.fixedRadius}
|
|
241
227
|
{...visConfiguratorProps}
|
|
242
|
-
disabled={layer.config.visConfig.customMarkers}
|
|
243
228
|
/>
|
|
244
229
|
) : null}
|
|
245
230
|
</ConfigGroupCollapsibleContent>
|
|
@@ -1046,6 +1031,7 @@ export function LayerColorSelectorFactory(ColorSelector) {
|
|
|
1046
1031
|
class LayerColorSelector extends Component {
|
|
1047
1032
|
render() {
|
|
1048
1033
|
const {layer, onChange, selectedColor, property = 'color', setColorUI} = this.props;
|
|
1034
|
+
|
|
1049
1035
|
return (
|
|
1050
1036
|
<SidePanelSection>
|
|
1051
1037
|
<PanelLabel>
|
|
@@ -1074,6 +1060,7 @@ export function ArcLayerColorSelectorFactory(ColorSelector) {
|
|
|
1074
1060
|
class ArcLayerColorSelector extends Component {
|
|
1075
1061
|
render() {
|
|
1076
1062
|
const {layer, onChangeConfig, onChangeVisConfig, property = 'color', setColorUI} = this.props;
|
|
1063
|
+
|
|
1077
1064
|
return (
|
|
1078
1065
|
<SidePanelSection>
|
|
1079
1066
|
<PanelLabel>
|
|
@@ -1166,17 +1153,14 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
|
|
|
1166
1153
|
const scaleOptions = layer.getScaleOptions(channel.key);
|
|
1167
1154
|
const showScaleCustomizable =
|
|
1168
1155
|
channelScaleType === CHANNEL_SCALES.color &&
|
|
1169
|
-
scale &&
|
|
1170
1156
|
layer.config[scale] &&
|
|
1171
1157
|
Boolean(layer.config[field]) &&
|
|
1172
|
-
scaleOptions
|
|
1173
|
-
const showScale =
|
|
1158
|
+
scaleOptions.length > 0;
|
|
1159
|
+
const showScale =
|
|
1174
1160
|
!showScaleCustomizable &&
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
scaleOptions?.length > 1
|
|
1179
|
-
);
|
|
1161
|
+
!layer.isAggregated &&
|
|
1162
|
+
layer.config[scale] &&
|
|
1163
|
+
scaleOptions.length > 1;
|
|
1180
1164
|
const defaultDescription = 'layerConfiguration.defaultDescription';
|
|
1181
1165
|
const visRange = layer.config.visConfig[range];
|
|
1182
1166
|
const aggregator = layer.config.visConfig[aggregation];
|
|
@@ -1306,5 +1290,4 @@ export const AggregationTypeSelector = ({layer, channel, onChange}) => {
|
|
|
1306
1290
|
</SidePanelSection>
|
|
1307
1291
|
);
|
|
1308
1292
|
};
|
|
1309
|
-
|
|
1310
1293
|
/* eslint-enable max-params */
|
|
@@ -62,14 +62,6 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
|
|
|
62
62
|
this.props.updateField(val);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
_onFieldSelectorFocused = () => {
|
|
66
|
-
this.setState({fieldSelectorActive: true});
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
_onFieldSelectorBlur = () => {
|
|
70
|
-
this.setState({fieldSelectorActive: false});
|
|
71
|
-
};
|
|
72
|
-
|
|
73
65
|
render() {
|
|
74
66
|
const {
|
|
75
67
|
property,
|
|
@@ -88,7 +80,7 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
|
|
|
88
80
|
<SidePanelSection>
|
|
89
81
|
<SidePanelSection>
|
|
90
82
|
<PanelLabelWrapper>
|
|
91
|
-
<PanelLabel
|
|
83
|
+
<PanelLabel>
|
|
92
84
|
{(label && <FormattedMessage id={label} />) || (
|
|
93
85
|
<FormattedMessage
|
|
94
86
|
id="layer.propertyBasedOn"
|
|
@@ -118,8 +110,6 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
|
|
|
118
110
|
isLoading={this.props.isLoading}
|
|
119
111
|
withAggregator={this.props.fieldsAggregated}
|
|
120
112
|
aggregator={this.props.fieldsAggregated && this.props.aggregator}
|
|
121
|
-
onFocus={this._onFieldSelectorFocused}
|
|
122
|
-
onBlur={this._onFieldSelectorBlur}
|
|
123
113
|
/>
|
|
124
114
|
</SidePanelSection>
|
|
125
115
|
<div>
|
|
@@ -431,7 +431,6 @@ export const CHANNEL_SCALES = keyMirror({
|
|
|
431
431
|
color: null,
|
|
432
432
|
radius: null,
|
|
433
433
|
size: null,
|
|
434
|
-
customMarker: null,
|
|
435
434
|
colorAggr: null,
|
|
436
435
|
sizeAggr: null
|
|
437
436
|
});
|
|
@@ -506,8 +505,7 @@ export const FIELD_AGGREGATORS = [
|
|
|
506
505
|
export const linearFieldScaleFunctions = {
|
|
507
506
|
[CHANNEL_SCALES.color]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile, SCALE_TYPES.custom],
|
|
508
507
|
[CHANNEL_SCALES.radius]: [SCALE_TYPES.sqrt],
|
|
509
|
-
[CHANNEL_SCALES.size]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
|
|
510
|
-
[CHANNEL_SCALES.customMarker]: [SCALE_TYPES.ordinal]
|
|
508
|
+
[CHANNEL_SCALES.size]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
|
|
511
509
|
};
|
|
512
510
|
|
|
513
511
|
export const linearFieldAggrScaleFunctions = {
|
|
@@ -535,8 +533,7 @@ export const linearFieldAggrScaleFunctions = {
|
|
|
535
533
|
export const ordinalFieldScaleFunctions = {
|
|
536
534
|
[CHANNEL_SCALES.color]: [SCALE_TYPES.ordinal],
|
|
537
535
|
[CHANNEL_SCALES.radius]: [SCALE_TYPES.point],
|
|
538
|
-
[CHANNEL_SCALES.size]: [SCALE_TYPES.point]
|
|
539
|
-
[CHANNEL_SCALES.customMarker]: [SCALE_TYPES.ordinal]
|
|
536
|
+
[CHANNEL_SCALES.size]: [SCALE_TYPES.point]
|
|
540
537
|
};
|
|
541
538
|
|
|
542
539
|
export const ordinalFieldAggrScaleFunctions = {
|
|
@@ -557,8 +554,7 @@ export const ordinalFieldAggrScaleFunctions = {
|
|
|
557
554
|
export const notSupportedScaleOpts = {
|
|
558
555
|
[CHANNEL_SCALES.color]: [],
|
|
559
556
|
[CHANNEL_SCALES.radius]: [],
|
|
560
|
-
[CHANNEL_SCALES.size]: []
|
|
561
|
-
[CHANNEL_SCALES.customMarker]: []
|
|
557
|
+
[CHANNEL_SCALES.size]: []
|
|
562
558
|
};
|
|
563
559
|
|
|
564
560
|
export const notSupportAggrOpts = {
|
package/src/layers/base-layer.js
CHANGED
|
@@ -56,7 +56,6 @@ import {getSampleData} from 'utils/table-utils/data-container-utils';
|
|
|
56
56
|
|
|
57
57
|
import {hexToRgb, getColorGroupByName, reverseColorRange} from 'utils/color-utils';
|
|
58
58
|
import {getMaskExtensionProps} from 'utils/layer-utils';
|
|
59
|
-
import {scaleOrdinal} from 'd3-scale';
|
|
60
59
|
|
|
61
60
|
/** @typedef {import('./index').Layer} LayerClass} */
|
|
62
61
|
|
|
@@ -66,10 +65,6 @@ import {scaleOrdinal} from 'd3-scale';
|
|
|
66
65
|
*/
|
|
67
66
|
export const LAYER_ID_LENGTH = 6;
|
|
68
67
|
|
|
69
|
-
// Note, this is is SVG of solid circle encoded as data-uri
|
|
70
|
-
const FALLBACK_ICON =
|
|
71
|
-
'data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==';
|
|
72
|
-
|
|
73
68
|
const MAX_SAMPLE_SIZE = 5000;
|
|
74
69
|
const defaultDomain = [0, 1];
|
|
75
70
|
const dataFilterExtension = new DataFilterExtension({filterSize: MAX_GPU_FILTERS});
|
|
@@ -813,39 +808,6 @@ class Layer {
|
|
|
813
808
|
return this.getVisChannelScale(colorScale, colorDomain, colorRange.colors.map(hexToRgb));
|
|
814
809
|
}
|
|
815
810
|
|
|
816
|
-
getCustomMarkersScale(range) {
|
|
817
|
-
let unknownValue = FALLBACK_ICON;
|
|
818
|
-
if (!range) {
|
|
819
|
-
return () => unknownValue;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
const mapping = new Map();
|
|
823
|
-
|
|
824
|
-
if (Array.isArray(range)) {
|
|
825
|
-
for (const {value, markerUrl} of range) {
|
|
826
|
-
if (value === null) {
|
|
827
|
-
unknownValue = markerUrl;
|
|
828
|
-
} else if (markerUrl) {
|
|
829
|
-
mapping.set(value, markerUrl);
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
} else {
|
|
833
|
-
unknownValue = range.othersMarker;
|
|
834
|
-
for (const {value, markerUrl} of range.markerMap) {
|
|
835
|
-
if (markerUrl) {
|
|
836
|
-
mapping.set(value, markerUrl);
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
// @ts-ignore d3 scale
|
|
842
|
-
const scale = scaleOrdinal()
|
|
843
|
-
.domain(Array.from(mapping.keys()))
|
|
844
|
-
.range(Array.from(mapping.values()))
|
|
845
|
-
.unknown(unknownValue);
|
|
846
|
-
return scale;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
811
|
/**
|
|
850
812
|
* Mapping from visual channels to deck.gl accesors
|
|
851
813
|
* @param {Object} param Parameters
|
|
@@ -856,7 +818,6 @@ class Layer {
|
|
|
856
818
|
getAttributeAccessors({dataAccessor = defaultDataAccessor, dataContainer}) {
|
|
857
819
|
const attributeAccessors = {};
|
|
858
820
|
|
|
859
|
-
// eslint-disable-next-line complexity
|
|
860
821
|
Object.keys(this.visualChannels).forEach(channel => {
|
|
861
822
|
const {
|
|
862
823
|
field,
|
|
@@ -872,13 +833,8 @@ class Layer {
|
|
|
872
833
|
aggregation
|
|
873
834
|
} = this.visualChannels[channel];
|
|
874
835
|
|
|
875
|
-
const shouldGetScale =
|
|
876
|
-
(scale || channelScaleType === 'identity') && this.config[field]
|
|
877
|
-
);
|
|
836
|
+
const shouldGetScale = this.config[field];
|
|
878
837
|
|
|
879
|
-
if (field === 'rotationField') {
|
|
880
|
-
console.log('recreating rotationField accessor', this.config[field]);
|
|
881
|
-
}
|
|
882
838
|
if (shouldGetScale) {
|
|
883
839
|
const args = [this.config[scale], this.config[domain], this.config.visConfig[range]];
|
|
884
840
|
const isFixed = fixed && this.config.visConfig[fixed];
|
|
@@ -888,12 +844,8 @@ class Layer {
|
|
|
888
844
|
const aggregationValue = this.config.visConfig[aggregation];
|
|
889
845
|
|
|
890
846
|
const scaleFunction =
|
|
891
|
-
channelScaleType ===
|
|
892
|
-
? v => v
|
|
893
|
-
: channelScaleType === CHANNEL_SCALES.color
|
|
847
|
+
channelScaleType === CHANNEL_SCALES.color
|
|
894
848
|
? this.getColorScale(...args)
|
|
895
|
-
: channelScaleType === CHANNEL_SCALES.customMarker
|
|
896
|
-
? this.getCustomMarkersScale(this.config.visConfig[range])
|
|
897
849
|
: this.getVisChannelScale(...args, isFixed);
|
|
898
850
|
|
|
899
851
|
attributeAccessors[accessor] = d =>
|
|
@@ -1239,12 +1191,6 @@ class Layer {
|
|
|
1239
1191
|
return fixed ? 1 : (this.config[field] ? 1 : radius);
|
|
1240
1192
|
}
|
|
1241
1193
|
|
|
1242
|
-
getMaxMarkerSize() {
|
|
1243
|
-
const {sizeField, visConfig} = this.config;
|
|
1244
|
-
const {radiusRange, radius} = visConfig;
|
|
1245
|
-
return Math.ceil((sizeField ? radiusRange[1] : radius));
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
1194
|
getRadiusUnit(fixedRadius) {
|
|
1249
1195
|
const radiusChannel = Object.values(this.visualChannels).find(vc => vc.property === 'radius');
|
|
1250
1196
|
|
|
@@ -1354,30 +1300,6 @@ class Layer {
|
|
|
1354
1300
|
}, []);
|
|
1355
1301
|
}
|
|
1356
1302
|
|
|
1357
|
-
/**
|
|
1358
|
-
* Create deck.gl `IconLayer` "autoPack" mode accessor for custom markers.
|
|
1359
|
-
*
|
|
1360
|
-
* @param {*} customMarkersStatus Record<url, UrlStatus> provided by builder, UrlStatus `ok` means URL is ok and ready to render
|
|
1361
|
-
* @param {*} iconUrlAccessor deck.gl accessor (or value) that resolves to URL of icon for given row
|
|
1362
|
-
* @returns deck.gl accessor that returns UnpackedIcon ready to consume by IconLayer
|
|
1363
|
-
*/
|
|
1364
|
-
getCustomMarkerIconAccessor(customMarkersStatus, iconUrlAccessor) {
|
|
1365
|
-
const maxIconSize = this.getMaxMarkerSize();
|
|
1366
|
-
|
|
1367
|
-
return d => {
|
|
1368
|
-
const wantedUrl =
|
|
1369
|
-
(typeof iconUrlAccessor === 'function') ? iconUrlAccessor(d) : iconUrlAccessor;
|
|
1370
|
-
const url = customMarkersStatus?.[wantedUrl] === 'ok' ? wantedUrl : FALLBACK_ICON;
|
|
1371
|
-
return {
|
|
1372
|
-
id: `${url}@@${maxIconSize}`,
|
|
1373
|
-
url,
|
|
1374
|
-
width: maxIconSize,
|
|
1375
|
-
height: maxIconSize,
|
|
1376
|
-
mask: true
|
|
1377
|
-
};
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
1303
|
calculateDataAttribute(keplerTable, getPosition) {
|
|
1382
1304
|
// implemented in subclasses
|
|
1383
1305
|
return [];
|
|
@@ -30,8 +30,7 @@ import {LAYER_VIS_CONFIGS} from 'layers/layer-factory';
|
|
|
30
30
|
|
|
31
31
|
const SUPPORTED_ANALYZER_TYPES = {
|
|
32
32
|
[DATA_TYPES.GEOMETRY]: true,
|
|
33
|
-
[DATA_TYPES.GEOMETRY_FROM_STRING]: true
|
|
34
|
-
[DATA_TYPES.PAIR_GEOMETRY_FROM_STRING]: true
|
|
33
|
+
[DATA_TYPES.GEOMETRY_FROM_STRING]: true
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
export const geojsonVisConfigs = {
|
|
@@ -26,7 +26,6 @@ import {DEFAULT_COLOR_RANGE} from 'constants/color-ranges';
|
|
|
26
26
|
export const PROPERTY_GROUPS = keyMirror({
|
|
27
27
|
color: null,
|
|
28
28
|
stroke: null,
|
|
29
|
-
customMarkers: null,
|
|
30
29
|
radius: null,
|
|
31
30
|
height: null,
|
|
32
31
|
angle: null,
|
|
@@ -430,27 +429,6 @@ export const LAYER_VIS_CONFIGS = {
|
|
|
430
429
|
step: 0.1,
|
|
431
430
|
group: PROPERTY_GROUPS.cell,
|
|
432
431
|
property: 'radius'
|
|
433
|
-
},
|
|
434
|
-
customMarkers: {
|
|
435
|
-
type: 'boolean',
|
|
436
|
-
defaultValue: false,
|
|
437
|
-
label: 'layerVisConfigs.customMarkers',
|
|
438
|
-
group: PROPERTY_GROUPS.customMarkers,
|
|
439
|
-
property: 'customMarkers'
|
|
440
|
-
},
|
|
441
|
-
customMarkersUrl: {
|
|
442
|
-
type: 'text',
|
|
443
|
-
defaultValue: '',
|
|
444
|
-
label: 'layerVisConfigs.addUrl',
|
|
445
|
-
group: PROPERTY_GROUPS.customMarkers,
|
|
446
|
-
property: 'customMarkersUrl'
|
|
447
|
-
},
|
|
448
|
-
customMarkersRange: {
|
|
449
|
-
type: 'markers-range-select',
|
|
450
|
-
defaultValue: undefined,
|
|
451
|
-
label: 'layerVisConfigs.colorRange',
|
|
452
|
-
group: PROPERTY_GROUPS.customMarkers,
|
|
453
|
-
property: 'customMarkersRange'
|
|
454
432
|
}
|
|
455
433
|
};
|
|
456
434
|
|
|
@@ -20,13 +20,12 @@
|
|
|
20
20
|
|
|
21
21
|
import {BrushingExtension} from '@deck.gl/extensions';
|
|
22
22
|
import {ScatterplotLayer} from '@deck.gl/layers';
|
|
23
|
-
import {IconLayer} from '@deck.gl/layers';
|
|
24
23
|
|
|
25
24
|
import Layer from '../base-layer';
|
|
26
25
|
import {hexToRgb} from 'utils/color-utils';
|
|
27
26
|
import {findDefaultColorField} from 'utils/dataset-utils';
|
|
28
27
|
import PointLayerIcon from './point-layer-icon';
|
|
29
|
-
import {DEFAULT_LAYER_COLOR, CHANNEL_SCALES
|
|
28
|
+
import {DEFAULT_LAYER_COLOR, CHANNEL_SCALES} from 'constants/default-settings';
|
|
30
29
|
|
|
31
30
|
import {getTextOffsetByRadius, formatTextLabelData} from '../layer-text-label';
|
|
32
31
|
|
|
@@ -44,9 +43,6 @@ const brushingExtension = new BrushingExtension();
|
|
|
44
43
|
export const pointVisConfigs = {
|
|
45
44
|
radius: 'radius',
|
|
46
45
|
fixedRadius: 'fixedRadius',
|
|
47
|
-
customMarkers: 'customMarkers',
|
|
48
|
-
customMarkersUrl: 'customMarkersUrl',
|
|
49
|
-
customMarkersRange: 'customMarkersRange',
|
|
50
46
|
opacity: 'opacity',
|
|
51
47
|
outline: 'outline',
|
|
52
48
|
thickness: 'thickness',
|
|
@@ -126,31 +122,6 @@ export default class PointLayer extends Layer {
|
|
|
126
122
|
channelScaleType: 'radius',
|
|
127
123
|
accessor: 'getRadius',
|
|
128
124
|
defaultValue: 1
|
|
129
|
-
},
|
|
130
|
-
customMarkers: {
|
|
131
|
-
property: 'customMarkers',
|
|
132
|
-
key: 'customMarkers',
|
|
133
|
-
field: 'customMarkersField',
|
|
134
|
-
scale: 'customMarkersScale',
|
|
135
|
-
domain: 'customMarkersDomain',
|
|
136
|
-
range: 'customMarkersRange',
|
|
137
|
-
fixed: 'customMarkersUrl',
|
|
138
|
-
channelScaleType: CHANNEL_SCALES.customMarker,
|
|
139
|
-
accessor: 'getIconUrl',
|
|
140
|
-
supportedFieldTypes: ['string'],
|
|
141
|
-
defaultValue: config => config.visConfig.customMarkersUrl,
|
|
142
|
-
condition: config => config.visConfig.customMarkers
|
|
143
|
-
},
|
|
144
|
-
rotation: {
|
|
145
|
-
property: 'rotation',
|
|
146
|
-
key: 'rotation',
|
|
147
|
-
field: 'rotationField',
|
|
148
|
-
channelScaleType: 'identity',
|
|
149
|
-
accessor: 'getAngle',
|
|
150
|
-
supportedFieldTypes: ['float', 'integer', 'real', 'number'],
|
|
151
|
-
defaultValue: () => 0,
|
|
152
|
-
nullValue: 0,
|
|
153
|
-
condition: config => config.rotationField
|
|
154
125
|
}
|
|
155
126
|
};
|
|
156
127
|
}
|
|
@@ -210,10 +181,7 @@ export default class PointLayer extends Layer {
|
|
|
210
181
|
// add stroke color visual channel
|
|
211
182
|
strokeColorField: null,
|
|
212
183
|
strokeColorDomain: [0, 1],
|
|
213
|
-
strokeColorScale: 'quantile'
|
|
214
|
-
|
|
215
|
-
customMarkersField: null,
|
|
216
|
-
customMarkersScale: 'ordinal'
|
|
184
|
+
strokeColorScale: 'quantile'
|
|
217
185
|
};
|
|
218
186
|
}
|
|
219
187
|
|
|
@@ -269,22 +237,22 @@ export default class PointLayer extends Layer {
|
|
|
269
237
|
this.updateMeta({bounds});
|
|
270
238
|
}
|
|
271
239
|
|
|
272
|
-
isLayerHovered(objectInfo) {
|
|
273
|
-
return (
|
|
274
|
-
(objectInfo?.picked && objectInfo?.layer?.props?.id === this.id) ||
|
|
275
|
-
objectInfo?.layer?.props?.id === `${this.id}-icon`
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// eslint-disable-next-line complexity
|
|
280
240
|
renderLayer(opts) {
|
|
281
|
-
const {data, gpuFilter, objectHovered, mapState, interactionConfig
|
|
241
|
+
const {data, gpuFilter, objectHovered, mapState, interactionConfig} = opts;
|
|
282
242
|
|
|
283
243
|
// if no field size is defined we need to pass fixed radius = false
|
|
284
244
|
const fixedRadius = this.config.visConfig.fixedRadius && Boolean(this.config.sizeField);
|
|
285
245
|
const radiusScale = this.getRadiusScale(fixedRadius);
|
|
286
246
|
const radiusUnits = this.getRadiusUnit(fixedRadius);
|
|
287
247
|
|
|
248
|
+
const layerProps = {
|
|
249
|
+
stroked: this.config.visConfig.outline,
|
|
250
|
+
filled: this.config.visConfig.filled,
|
|
251
|
+
lineWidthScale: this.config.visConfig.thickness,
|
|
252
|
+
radiusScale,
|
|
253
|
+
...(this.config.visConfig.fixedRadius ? {} : {radiusMaxPixels: 500})
|
|
254
|
+
};
|
|
255
|
+
|
|
288
256
|
const updateTriggers = {
|
|
289
257
|
getPosition: this.config.columns,
|
|
290
258
|
getFilterValue: gpuFilter.filterValueUpdateTriggers,
|
|
@@ -310,97 +278,16 @@ export default class PointLayer extends Layer {
|
|
|
310
278
|
};
|
|
311
279
|
const hoveredObject = this.hasHoveredObject(objectHovered);
|
|
312
280
|
|
|
313
|
-
const textLabelLayer = this.renderTextLabelLayer(
|
|
314
|
-
{
|
|
315
|
-
getPosition: data.getPosition,
|
|
316
|
-
sharedProps,
|
|
317
|
-
getPixelOffset,
|
|
318
|
-
updateTriggers
|
|
319
|
-
},
|
|
320
|
-
opts
|
|
321
|
-
);
|
|
322
|
-
const commonLayerProps = {
|
|
323
|
-
...defaultLayerProps,
|
|
324
|
-
parameters: {
|
|
325
|
-
// circles will be flat on the map when the altitude column is not used
|
|
326
|
-
depthTest: this.config.columns.altitude?.fieldIdx > -1
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
const customMarkersField = this.config.customMarkersField;
|
|
331
|
-
const {customMarkers, customMarkersUrl, customMarkersRange} = this.config.visConfig;
|
|
332
|
-
const customMarkersConfigured =
|
|
333
|
-
customMarkers && Boolean(customMarkersUrl || (customMarkersField && customMarkersRange));
|
|
334
|
-
const customMarkersMisConfigured = customMarkers && !customMarkersConfigured;
|
|
335
|
-
|
|
336
|
-
if (customMarkersConfigured) {
|
|
337
|
-
const maxIconSize = this.getMaxMarkerSize();
|
|
338
|
-
const getIcon = this.getCustomMarkerIconAccessor(customMarkersStatus, data.getIconUrl);
|
|
339
|
-
const iconLayerProps = {
|
|
340
|
-
getIcon,
|
|
341
|
-
getPosition: data.getPosition,
|
|
342
|
-
getSize: data.getRadius,
|
|
343
|
-
getAngle: data.getAngle,
|
|
344
|
-
sizeScale: radiusScale,
|
|
345
|
-
sizeUnits: 'pixels',
|
|
346
|
-
loadOptions: {
|
|
347
|
-
image: {
|
|
348
|
-
type: 'imagebitmap'
|
|
349
|
-
},
|
|
350
|
-
imagebitmap: {
|
|
351
|
-
resizeWidth: maxIconSize,
|
|
352
|
-
resizeHeight: maxIconSize,
|
|
353
|
-
resizeQuality: 'high'
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
};
|
|
357
|
-
|
|
358
|
-
return [
|
|
359
|
-
new IconLayer({
|
|
360
|
-
...commonLayerProps,
|
|
361
|
-
...iconLayerProps,
|
|
362
|
-
id: `${defaultLayerProps.id}-icon`,
|
|
363
|
-
data: data.data,
|
|
364
|
-
getColor: this.config.visConfig.filled ? data.getFillColor : UNKNOWN_COLOR,
|
|
365
|
-
getFilterValue: data.getFilterValue,
|
|
366
|
-
updateTriggers: {
|
|
367
|
-
getFilterValue: updateTriggers.getFilterValue,
|
|
368
|
-
getColor: [updateTriggers.getFillColor, this.config.visConfig.filled],
|
|
369
|
-
getIcon: [updateTriggers.getIconUrl, maxIconSize, customMarkersStatus],
|
|
370
|
-
getSize: updateTriggers.getRadius,
|
|
371
|
-
getAngle: updateTriggers.getAngle
|
|
372
|
-
}
|
|
373
|
-
}),
|
|
374
|
-
...(hoveredObject
|
|
375
|
-
? [
|
|
376
|
-
new IconLayer({
|
|
377
|
-
...iconLayerProps,
|
|
378
|
-
...this.getDefaultHoverLayerProps(),
|
|
379
|
-
id: `${defaultLayerProps.id}-icon-hovered`,
|
|
380
|
-
data: [hoveredObject],
|
|
381
|
-
getColor: this.config.highlightColor
|
|
382
|
-
})
|
|
383
|
-
]
|
|
384
|
-
: []),
|
|
385
|
-
...textLabelLayer
|
|
386
|
-
];
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const scatterPlotLayerProps = {
|
|
390
|
-
stroked: this.config.visConfig.outline,
|
|
391
|
-
filled: this.config.visConfig.filled,
|
|
392
|
-
lineWidthScale: this.config.visConfig.thickness,
|
|
393
|
-
// TODO: invent better way to render something when customMarkers are not yet configured
|
|
394
|
-
radiusScale: customMarkersMisConfigured ? radiusScale / 2 : radiusScale,
|
|
395
|
-
...(this.config.visConfig.fixedRadius ? {} : {radiusMaxPixels: 500})
|
|
396
|
-
};
|
|
397
|
-
|
|
398
281
|
return [
|
|
399
282
|
new ScatterplotLayer({
|
|
283
|
+
...defaultLayerProps,
|
|
400
284
|
...brushingProps,
|
|
285
|
+
...layerProps,
|
|
401
286
|
...data,
|
|
402
|
-
|
|
403
|
-
|
|
287
|
+
parameters: {
|
|
288
|
+
// circles will be flat on the map when the altitude column is not used
|
|
289
|
+
depthTest: this.config.columns.altitude?.fieldIdx > -1
|
|
290
|
+
},
|
|
404
291
|
radiusUnits,
|
|
405
292
|
lineWidthUnits: 'pixels',
|
|
406
293
|
updateTriggers,
|
|
@@ -411,7 +298,7 @@ export default class PointLayer extends Layer {
|
|
|
411
298
|
? [
|
|
412
299
|
new ScatterplotLayer({
|
|
413
300
|
...this.getDefaultHoverLayerProps(),
|
|
414
|
-
...
|
|
301
|
+
...layerProps,
|
|
415
302
|
data: [hoveredObject],
|
|
416
303
|
getLineColor: this.config.highlightColor,
|
|
417
304
|
getFillColor: this.config.highlightColor,
|
|
@@ -421,7 +308,15 @@ export default class PointLayer extends Layer {
|
|
|
421
308
|
]
|
|
422
309
|
: []),
|
|
423
310
|
// text label layer
|
|
424
|
-
...
|
|
311
|
+
...this.renderTextLabelLayer(
|
|
312
|
+
{
|
|
313
|
+
getPosition: data.getPosition,
|
|
314
|
+
sharedProps,
|
|
315
|
+
getPixelOffset,
|
|
316
|
+
updateTriggers
|
|
317
|
+
},
|
|
318
|
+
opts
|
|
319
|
+
)
|
|
425
320
|
];
|
|
426
321
|
}
|
|
427
322
|
}
|