@haniffalab/cherita-react 1.3.0-dev.2025-06-04.0123fe8a → 1.3.0-dev.2025-06-04.6573608f
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.
|
@@ -44,7 +44,7 @@ const INITIAL_VIEW_STATE = {
|
|
|
44
44
|
function Scatterplot(_ref) {
|
|
45
45
|
var _settings$selectedObs3, _features$features2, _obsmData$serverError, _xData$serverError, _obsData$serverError, _labelObsData$serverE, _settings$selectedVar, _settings$selectedObs4, _obsmData$data;
|
|
46
46
|
let {
|
|
47
|
-
radius =
|
|
47
|
+
radius = null,
|
|
48
48
|
setShowObs,
|
|
49
49
|
setShowVars,
|
|
50
50
|
isFullscreen = false
|
|
@@ -69,6 +69,7 @@ function Scatterplot(_ref) {
|
|
|
69
69
|
values: [],
|
|
70
70
|
sliceValues: []
|
|
71
71
|
});
|
|
72
|
+
const [radiusScale, setRadiusScale] = (0, _react.useState)(radius || 1);
|
|
72
73
|
|
|
73
74
|
// EditableGeoJsonLayer
|
|
74
75
|
const [mode, setMode] = (0, _react.useState)(() => _editModes.ViewMode);
|
|
@@ -85,6 +86,15 @@ function Scatterplot(_ref) {
|
|
|
85
86
|
const labelObsData = (0, _zarrData.useLabelObsData)();
|
|
86
87
|
// @TODO: assert length of obsmData, xData, obsData is equal
|
|
87
88
|
|
|
89
|
+
const getRadiusScale = (0, _react.useCallback)(bounds => {
|
|
90
|
+
if (!!radius) return radius;
|
|
91
|
+
// From 28 degrees ~= 30km -> 30m radius
|
|
92
|
+
const lonDim = bounds[1][0] - bounds[0][0];
|
|
93
|
+
const latDim = bounds[1][1] - bounds[0][1];
|
|
94
|
+
const minDim = Math.min(lonDim, latDim);
|
|
95
|
+
const rs = 0.01 / minDim * 111111;
|
|
96
|
+
return rs;
|
|
97
|
+
}, [radius]);
|
|
88
98
|
(0, _react.useEffect)(() => {
|
|
89
99
|
if (!obsmData.isPending && !obsmData.serverError) {
|
|
90
100
|
var _deckRef$current, _deckRef$current2;
|
|
@@ -98,11 +108,13 @@ function Scatterplot(_ref) {
|
|
|
98
108
|
const {
|
|
99
109
|
latitude,
|
|
100
110
|
longitude,
|
|
101
|
-
zoom
|
|
111
|
+
zoom,
|
|
112
|
+
bounds
|
|
102
113
|
} = mapHelper.fitBounds(obsmData.data, {
|
|
103
114
|
width: deckRef === null || deckRef === void 0 || (_deckRef$current = deckRef.current) === null || _deckRef$current === void 0 || (_deckRef$current = _deckRef$current.deck) === null || _deckRef$current === void 0 ? void 0 : _deckRef$current.width,
|
|
104
115
|
height: deckRef === null || deckRef === void 0 || (_deckRef$current2 = deckRef.current) === null || _deckRef$current2 === void 0 || (_deckRef$current2 = _deckRef$current2.deck) === null || _deckRef$current2 === void 0 ? void 0 : _deckRef$current2.height
|
|
105
116
|
});
|
|
117
|
+
setRadiusScale(getRadiusScale(bounds));
|
|
106
118
|
setViewState(v => {
|
|
107
119
|
return _objectSpread(_objectSpread({}, v), {}, {
|
|
108
120
|
longitude: longitude,
|
|
@@ -118,7 +130,7 @@ function Scatterplot(_ref) {
|
|
|
118
130
|
});
|
|
119
131
|
});
|
|
120
132
|
}
|
|
121
|
-
}, [settings.selectedObsm, obsmData.data, obsmData.isPending, obsmData.serverError]);
|
|
133
|
+
}, [settings.selectedObsm, getRadiusScale, obsmData.data, obsmData.isPending, obsmData.serverError]);
|
|
122
134
|
const getBounds = (0, _react.useCallback)(() => {
|
|
123
135
|
var _deckRef$current3, _deckRef$current4;
|
|
124
136
|
const {
|
|
@@ -232,7 +244,7 @@ function Scatterplot(_ref) {
|
|
|
232
244
|
id: "cherita-layer-scatterplot",
|
|
233
245
|
pickable: true,
|
|
234
246
|
data: data.positions,
|
|
235
|
-
radiusScale:
|
|
247
|
+
radiusScale: radiusScale,
|
|
236
248
|
radiusMinPixels: 1,
|
|
237
249
|
getPosition: d => d,
|
|
238
250
|
getFillColor: getFillColor,
|
|
@@ -275,7 +287,7 @@ function Scatterplot(_ref) {
|
|
|
275
287
|
}
|
|
276
288
|
}
|
|
277
289
|
})];
|
|
278
|
-
}, [data.positions, features, getFillColor, getRadius, mode,
|
|
290
|
+
}, [data.positions, features, getFillColor, getRadius, mode, radiusScale, selectedFeatureIndexes]);
|
|
279
291
|
const layers = (0, _react.useDeferredValue)(mode === _editModes.ViewMode ? memoizedLayers.reverse() : memoizedLayers); // draw scatterplot on top of polygons when in ViewMode
|
|
280
292
|
|
|
281
293
|
(0, _react.useEffect)(() => {
|
|
@@ -36,7 +36,7 @@ const INITIAL_VIEW_STATE = {
|
|
|
36
36
|
export function Scatterplot(_ref) {
|
|
37
37
|
var _settings$selectedObs3, _features$features2, _obsmData$serverError, _xData$serverError, _obsData$serverError, _labelObsData$serverE, _settings$selectedVar, _settings$selectedObs4, _obsmData$data;
|
|
38
38
|
let {
|
|
39
|
-
radius =
|
|
39
|
+
radius = null,
|
|
40
40
|
setShowObs,
|
|
41
41
|
setShowVars,
|
|
42
42
|
isFullscreen = false
|
|
@@ -61,6 +61,7 @@ export function Scatterplot(_ref) {
|
|
|
61
61
|
values: [],
|
|
62
62
|
sliceValues: []
|
|
63
63
|
});
|
|
64
|
+
const [radiusScale, setRadiusScale] = useState(radius || 1);
|
|
64
65
|
|
|
65
66
|
// EditableGeoJsonLayer
|
|
66
67
|
const [mode, setMode] = useState(() => ViewMode);
|
|
@@ -77,6 +78,15 @@ export function Scatterplot(_ref) {
|
|
|
77
78
|
const labelObsData = useLabelObsData();
|
|
78
79
|
// @TODO: assert length of obsmData, xData, obsData is equal
|
|
79
80
|
|
|
81
|
+
const getRadiusScale = useCallback(bounds => {
|
|
82
|
+
if (!!radius) return radius;
|
|
83
|
+
// From 28 degrees ~= 30km -> 30m radius
|
|
84
|
+
const lonDim = bounds[1][0] - bounds[0][0];
|
|
85
|
+
const latDim = bounds[1][1] - bounds[0][1];
|
|
86
|
+
const minDim = Math.min(lonDim, latDim);
|
|
87
|
+
const rs = 0.01 / minDim * 111111;
|
|
88
|
+
return rs;
|
|
89
|
+
}, [radius]);
|
|
80
90
|
useEffect(() => {
|
|
81
91
|
if (!obsmData.isPending && !obsmData.serverError) {
|
|
82
92
|
var _deckRef$current, _deckRef$current2;
|
|
@@ -90,11 +100,13 @@ export function Scatterplot(_ref) {
|
|
|
90
100
|
const {
|
|
91
101
|
latitude,
|
|
92
102
|
longitude,
|
|
93
|
-
zoom
|
|
103
|
+
zoom,
|
|
104
|
+
bounds
|
|
94
105
|
} = mapHelper.fitBounds(obsmData.data, {
|
|
95
106
|
width: deckRef === null || deckRef === void 0 || (_deckRef$current = deckRef.current) === null || _deckRef$current === void 0 || (_deckRef$current = _deckRef$current.deck) === null || _deckRef$current === void 0 ? void 0 : _deckRef$current.width,
|
|
96
107
|
height: deckRef === null || deckRef === void 0 || (_deckRef$current2 = deckRef.current) === null || _deckRef$current2 === void 0 || (_deckRef$current2 = _deckRef$current2.deck) === null || _deckRef$current2 === void 0 ? void 0 : _deckRef$current2.height
|
|
97
108
|
});
|
|
109
|
+
setRadiusScale(getRadiusScale(bounds));
|
|
98
110
|
setViewState(v => {
|
|
99
111
|
return _objectSpread(_objectSpread({}, v), {}, {
|
|
100
112
|
longitude: longitude,
|
|
@@ -110,7 +122,7 @@ export function Scatterplot(_ref) {
|
|
|
110
122
|
});
|
|
111
123
|
});
|
|
112
124
|
}
|
|
113
|
-
}, [settings.selectedObsm, obsmData.data, obsmData.isPending, obsmData.serverError]);
|
|
125
|
+
}, [settings.selectedObsm, getRadiusScale, obsmData.data, obsmData.isPending, obsmData.serverError]);
|
|
114
126
|
const getBounds = useCallback(() => {
|
|
115
127
|
var _deckRef$current3, _deckRef$current4;
|
|
116
128
|
const {
|
|
@@ -224,7 +236,7 @@ export function Scatterplot(_ref) {
|
|
|
224
236
|
id: "cherita-layer-scatterplot",
|
|
225
237
|
pickable: true,
|
|
226
238
|
data: data.positions,
|
|
227
|
-
radiusScale:
|
|
239
|
+
radiusScale: radiusScale,
|
|
228
240
|
radiusMinPixels: 1,
|
|
229
241
|
getPosition: d => d,
|
|
230
242
|
getFillColor: getFillColor,
|
|
@@ -267,7 +279,7 @@ export function Scatterplot(_ref) {
|
|
|
267
279
|
}
|
|
268
280
|
}
|
|
269
281
|
})];
|
|
270
|
-
}, [data.positions, features, getFillColor, getRadius, mode,
|
|
282
|
+
}, [data.positions, features, getFillColor, getRadius, mode, radiusScale, selectedFeatureIndexes]);
|
|
271
283
|
const layers = useDeferredValue(mode === ViewMode ? memoizedLayers.reverse() : memoizedLayers); // draw scatterplot on top of polygons when in ViewMode
|
|
272
284
|
|
|
273
285
|
useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haniffalab/cherita-react",
|
|
3
|
-
"version": "1.3.0-dev.2025-06-04.
|
|
3
|
+
"version": "1.3.0-dev.2025-06-04.6573608f",
|
|
4
4
|
"author": "Haniffa Lab",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"url": "https://github.com/haniffalab/cherita-react/issues"
|
|
127
127
|
},
|
|
128
128
|
"homepage": "https://github.com/haniffalab/cherita-react#readme",
|
|
129
|
-
"prereleaseSha": "
|
|
129
|
+
"prereleaseSha": "6573608f6ab26442b5badaea1be8d5dff17b1344"
|
|
130
130
|
}
|