@jupytergis/base 0.1.6 → 0.1.7
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/lib/classificationModes.d.ts +13 -0
- package/lib/classificationModes.js +326 -0
- package/lib/commands.js +1 -1
- package/lib/dialogs/symbology/classificationModes.d.ts +13 -0
- package/lib/dialogs/symbology/classificationModes.js +326 -0
- package/lib/dialogs/symbology/components/color_ramp/CanvasSelectComponent.d.ts +11 -0
- package/lib/dialogs/symbology/components/color_ramp/CanvasSelectComponent.js +119 -0
- package/lib/dialogs/symbology/components/color_ramp/ColorRamp.d.ts +15 -0
- package/lib/dialogs/symbology/components/color_ramp/ColorRamp.js +33 -0
- package/lib/dialogs/symbology/components/color_ramp/ColorRampEntry.d.ts +9 -0
- package/lib/dialogs/symbology/components/color_ramp/ColorRampEntry.js +24 -0
- package/lib/dialogs/symbology/components/color_ramp/ModeSelectRow.d.ts +10 -0
- package/lib/dialogs/symbology/components/color_ramp/ModeSelectRow.js +11 -0
- package/lib/dialogs/symbology/components/color_stops/StopContainer.d.ts +9 -0
- package/lib/dialogs/symbology/components/color_stops/StopContainer.js +28 -0
- package/lib/dialogs/{components/symbology → symbology/components/color_stops}/StopRow.js +9 -2
- package/lib/dialogs/symbology/hooks/useGetProperties.d.ts +12 -0
- package/lib/dialogs/symbology/hooks/useGetProperties.js +47 -0
- package/lib/dialogs/{symbologyDialog.js → symbology/symbologyDialog.js} +3 -3
- package/lib/dialogs/symbology/symbologyUtils.d.ts +9 -0
- package/lib/dialogs/symbology/symbologyUtils.js +94 -0
- package/lib/dialogs/symbology/tiff_layer/TiffRendering.d.ts +4 -0
- package/lib/dialogs/{components/symbology/BandRendering.js → symbology/tiff_layer/TiffRendering.js} +3 -3
- package/lib/dialogs/{components/symbology → symbology/tiff_layer/components}/BandRow.d.ts +1 -1
- package/lib/dialogs/{components/symbology → symbology/tiff_layer/types}/SingleBandPseudoColor.d.ts +9 -1
- package/lib/dialogs/{components/symbology → symbology/tiff_layer/types}/SingleBandPseudoColor.js +113 -57
- package/lib/dialogs/{components/symbology → symbology/vector_layer}/VectorRendering.d.ts +1 -1
- package/lib/dialogs/{components/symbology → symbology/vector_layer}/VectorRendering.js +10 -13
- package/lib/dialogs/symbology/vector_layer/components/ValueSelect.d.ts +8 -0
- package/lib/dialogs/symbology/vector_layer/components/ValueSelect.js +7 -0
- package/lib/dialogs/symbology/vector_layer/types/Categorized.d.ts +4 -0
- package/lib/dialogs/symbology/vector_layer/types/Categorized.js +94 -0
- package/lib/dialogs/symbology/vector_layer/types/Graduated.js +169 -0
- package/lib/dialogs/{components/symbology → symbology/vector_layer/types}/SimpleSymbol.js +8 -13
- package/lib/formbuilder/objectform/vectorlayerform.js +1 -0
- package/lib/formbuilder/objectform/webGlLayerForm.js +1 -0
- package/lib/index.d.ts +6 -4
- package/lib/index.js +6 -4
- package/lib/mainview/mainView.d.ts +3 -1
- package/lib/mainview/mainView.js +66 -18
- package/lib/store.d.ts +9 -0
- package/lib/store.js +25 -0
- package/lib/toolbar/widget.js +1 -1
- package/lib/types.d.ts +14 -0
- package/package.json +16 -17
- package/style/symbologyDialog.css +104 -3
- package/lib/dialogs/components/symbology/BandRendering.d.ts +0 -4
- package/lib/dialogs/components/symbology/Graduated.js +0 -188
- /package/lib/dialogs/{components/symbology → symbology/components/color_stops}/StopRow.d.ts +0 -0
- /package/lib/dialogs/{symbologyDialog.d.ts → symbology/symbologyDialog.d.ts} +0 -0
- /package/lib/dialogs/{components/symbology → symbology/tiff_layer/components}/BandRow.js +0 -0
- /package/lib/dialogs/{components/symbology → symbology/vector_layer/types}/Graduated.d.ts +0 -0
- /package/lib/dialogs/{components/symbology → symbology/vector_layer/types}/SimpleSymbol.d.ts +0 -0
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { Button } from '@jupyterlab/ui-components';
|
|
2
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
-
import StopRow from './StopRow';
|
|
4
|
-
const Graduated = ({ context, state, okSignalPromise, cancel, layerId }) => {
|
|
5
|
-
const selectedValueRef = useRef();
|
|
6
|
-
const selectedMethodRef = useRef();
|
|
7
|
-
const stopRowsRef = useRef();
|
|
8
|
-
const layerStateRef = useRef();
|
|
9
|
-
const [selectedValue, setSelectedValue] = useState('');
|
|
10
|
-
const [featureProperties, setFeatureProperties] = useState({});
|
|
11
|
-
const [selectedMethod, setSelectedMethod] = useState('color');
|
|
12
|
-
const [stopRows, setStopRows] = useState([]);
|
|
13
|
-
const [methodOptions, setMethodOptions] = useState(['color']);
|
|
14
|
-
const [layerState, setLayerState] = useState();
|
|
15
|
-
if (!layerId) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const layer = context.model.getLayer(layerId);
|
|
19
|
-
if (!(layer === null || layer === void 0 ? void 0 : layer.parameters)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
const getProperties = async () => {
|
|
24
|
-
var _a, _b;
|
|
25
|
-
if (!layerId) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const model = context.model;
|
|
29
|
-
const layer = model.getLayer(layerId);
|
|
30
|
-
const source = model.getSource((_a = layer === null || layer === void 0 ? void 0 : layer.parameters) === null || _a === void 0 ? void 0 : _a.source);
|
|
31
|
-
if (!source) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const data = await model.readGeoJSON((_b = source.parameters) === null || _b === void 0 ? void 0 : _b.path);
|
|
35
|
-
const featureProps = {};
|
|
36
|
-
data === null || data === void 0 ? void 0 : data.features.forEach((feature) => {
|
|
37
|
-
feature.properties &&
|
|
38
|
-
Object.entries(feature.properties).forEach(([key, value]) => {
|
|
39
|
-
if (!(key in featureProps)) {
|
|
40
|
-
featureProps[key] = new Set();
|
|
41
|
-
}
|
|
42
|
-
featureProps[key].add(value);
|
|
43
|
-
});
|
|
44
|
-
setFeatureProperties(featureProps);
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
getProperties();
|
|
48
|
-
buildColorInfo();
|
|
49
|
-
okSignalPromise.promise.then(okSignal => {
|
|
50
|
-
okSignal.connect(handleOk, this);
|
|
51
|
-
});
|
|
52
|
-
return () => {
|
|
53
|
-
okSignalPromise.promise.then(okSignal => {
|
|
54
|
-
okSignal.disconnect(handleOk, this);
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
selectedValueRef.current = selectedValue;
|
|
60
|
-
selectedMethodRef.current = selectedMethod;
|
|
61
|
-
stopRowsRef.current = stopRows;
|
|
62
|
-
layerStateRef.current = layerState;
|
|
63
|
-
}, [selectedValue, selectedMethod, stopRows, layerState]);
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
populateOptions();
|
|
66
|
-
}, [featureProperties]);
|
|
67
|
-
const buildColorInfo = () => {
|
|
68
|
-
var _a;
|
|
69
|
-
// This it to parse a color object on the layer
|
|
70
|
-
if (!((_a = layer.parameters) === null || _a === void 0 ? void 0 : _a.color)) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const color = layer.parameters.color;
|
|
74
|
-
// If color is a string we don't need to parse
|
|
75
|
-
if (typeof color === 'string') {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const prefix = layer.parameters.type === 'circle' ? 'circle-' : '';
|
|
79
|
-
if (!color[`${prefix}fill-color`]) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const valueColorPairs = [];
|
|
83
|
-
// So if it's not a string then it's an array and we parse
|
|
84
|
-
// Color[0] is the operator used for the color expression
|
|
85
|
-
switch (color[`${prefix}fill-color`][0]) {
|
|
86
|
-
case 'interpolate': {
|
|
87
|
-
// First element is interpolate for linear selection
|
|
88
|
-
// Second element is type of interpolation (ie linear)
|
|
89
|
-
// Third is input value that stop values are compared with
|
|
90
|
-
// Fourth and on is value:color pairs
|
|
91
|
-
for (let i = 3; i < color[`${prefix}fill-color`].length; i += 2) {
|
|
92
|
-
const obj = {
|
|
93
|
-
stop: color[`${prefix}fill-color`][i],
|
|
94
|
-
output: color[`${prefix}fill-color`][i + 1]
|
|
95
|
-
};
|
|
96
|
-
valueColorPairs.push(obj);
|
|
97
|
-
}
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
setStopRows(valueColorPairs);
|
|
102
|
-
};
|
|
103
|
-
const populateOptions = async () => {
|
|
104
|
-
var _a;
|
|
105
|
-
// Set up method options
|
|
106
|
-
if (((_a = layer === null || layer === void 0 ? void 0 : layer.parameters) === null || _a === void 0 ? void 0 : _a.type) === 'circle') {
|
|
107
|
-
const options = ['color', 'radius'];
|
|
108
|
-
setMethodOptions(options);
|
|
109
|
-
}
|
|
110
|
-
const layerState = await state.fetch(`jupytergis:${layerId}`);
|
|
111
|
-
let value, method;
|
|
112
|
-
if (layerState) {
|
|
113
|
-
value = layerState
|
|
114
|
-
.graduatedValue;
|
|
115
|
-
method = layerState
|
|
116
|
-
.graduatedMethod;
|
|
117
|
-
}
|
|
118
|
-
setLayerState(layerState);
|
|
119
|
-
setSelectedValue(value ? value : Object.keys(featureProperties)[0]);
|
|
120
|
-
setSelectedMethod(method ? method : 'color');
|
|
121
|
-
};
|
|
122
|
-
const handleOk = () => {
|
|
123
|
-
var _a;
|
|
124
|
-
if (!layer.parameters) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
state.save(`jupytergis:${layerId}`, Object.assign(Object.assign({}, layerStateRef.current), { renderType: 'Graduated', graduatedValue: selectedValueRef.current, graduatedMethod: selectedMethodRef.current }));
|
|
128
|
-
const colorExpr = [];
|
|
129
|
-
colorExpr.push('interpolate');
|
|
130
|
-
colorExpr.push(['linear']);
|
|
131
|
-
colorExpr.push(['get', selectedValueRef.current]);
|
|
132
|
-
(_a = stopRowsRef.current) === null || _a === void 0 ? void 0 : _a.map(stop => {
|
|
133
|
-
colorExpr.push(stop.stop);
|
|
134
|
-
colorExpr.push(stop.output);
|
|
135
|
-
});
|
|
136
|
-
const newStyle = Object.assign({}, layer.parameters.color);
|
|
137
|
-
if (selectedMethodRef.current === 'color') {
|
|
138
|
-
if (layer.parameters.type === 'fill') {
|
|
139
|
-
newStyle['fill-color'] = colorExpr;
|
|
140
|
-
}
|
|
141
|
-
if (layer.parameters.type === 'line') {
|
|
142
|
-
newStyle['stroke-color'] = colorExpr;
|
|
143
|
-
}
|
|
144
|
-
if (layer.parameters.type === 'circle') {
|
|
145
|
-
newStyle['circle-fill-color'] = colorExpr;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
if (selectedMethodRef.current === 'radius') {
|
|
149
|
-
if (layer.parameters.type === 'circle') {
|
|
150
|
-
newStyle['circle-radius'] = colorExpr;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
layer.parameters.color = newStyle;
|
|
154
|
-
context.model.sharedModel.updateLayer(layerId, layer);
|
|
155
|
-
cancel();
|
|
156
|
-
};
|
|
157
|
-
const addStopRow = () => {
|
|
158
|
-
setStopRows([
|
|
159
|
-
{
|
|
160
|
-
stop: 0,
|
|
161
|
-
output: [0, 0, 0, 1]
|
|
162
|
-
},
|
|
163
|
-
...stopRows
|
|
164
|
-
]);
|
|
165
|
-
};
|
|
166
|
-
const deleteStopRow = (index) => {
|
|
167
|
-
const newFilters = [...stopRows];
|
|
168
|
-
newFilters.splice(index, 1);
|
|
169
|
-
setStopRows(newFilters);
|
|
170
|
-
};
|
|
171
|
-
return (React.createElement("div", { className: "jp-gis-layer-symbology-container" },
|
|
172
|
-
React.createElement("div", { className: "jp-gis-symbology-row" },
|
|
173
|
-
React.createElement("label", { htmlFor: 'vector-value-select' }, "Value:"),
|
|
174
|
-
React.createElement("div", { className: "jp-select-wrapper" },
|
|
175
|
-
React.createElement("select", { name: 'vector-value-select', onChange: event => setSelectedValue(event.target.value), className: "jp-mod-styled" }, Object.keys(featureProperties).map((feature, index) => (React.createElement("option", { key: index, value: feature, selected: feature === selectedValue, className: "jp-mod-styled" }, feature)))))),
|
|
176
|
-
React.createElement("div", { className: "jp-gis-symbology-row" },
|
|
177
|
-
React.createElement("label", { htmlFor: 'vector-method-select' }, "Method:"),
|
|
178
|
-
React.createElement("div", { className: "jp-select-wrapper" },
|
|
179
|
-
React.createElement("select", { name: 'vector-method-select', onChange: event => setSelectedMethod(event.target.value), className: "jp-mod-styled" }, methodOptions.map((method, index) => (React.createElement("option", { key: index, value: method, selected: method === selectedMethod, className: "jp-mod-styled" }, method)))))),
|
|
180
|
-
React.createElement("div", { className: "jp-gis-stop-container" },
|
|
181
|
-
React.createElement("div", { className: "jp-gis-stop-labels", style: { display: 'flex', gap: 6 } },
|
|
182
|
-
React.createElement("span", { style: { flex: '0 0 18%' } }, "Value"),
|
|
183
|
-
React.createElement("span", null, "Output Value")),
|
|
184
|
-
stopRows.map((stop, index) => (React.createElement(StopRow, { key: `${index}-${stop.output}`, index: index, value: stop.stop, outputValue: stop.output, stopRows: stopRows, setStopRows: setStopRows, deleteRow: () => deleteStopRow(index), useNumber: selectedMethod === 'radius' ? true : false })))),
|
|
185
|
-
React.createElement("div", { className: "jp-gis-symbology-button-container" },
|
|
186
|
-
React.createElement(Button, { className: "jp-Dialog-button jp-mod-accept jp-mod-styled", onClick: addStopRow }, "Add Stop"))));
|
|
187
|
-
};
|
|
188
|
-
export default Graduated;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/dialogs/{components/symbology → symbology/vector_layer/types}/SimpleSymbol.d.ts
RENAMED
|
File without changes
|