@tsingroc/tsingroc-components 5.0.0-alpha.11 → 5.0.0-alpha.13

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.
Files changed (150) hide show
  1. package/dist/components/Auth.d.ts +310 -0
  2. package/dist/components/Auth.js +267 -0
  3. package/dist/components/AutoResizedECharts.d.ts +21 -0
  4. package/dist/components/AutoResizedECharts.js +98 -0
  5. package/dist/components/Calendar.d.ts +50 -0
  6. package/dist/components/Calendar.js +130 -0
  7. package/dist/components/CircularProgress.d.ts +21 -0
  8. package/dist/components/CircularProgress.js +34 -0
  9. package/dist/components/ConnectedECharts.d.ts +31 -0
  10. package/dist/components/ConnectedECharts.js +100 -0
  11. package/dist/components/ECharts.d.ts +57 -0
  12. package/dist/components/ECharts.js +255 -0
  13. package/dist/components/Header.d.ts +67 -0
  14. package/dist/components/Header.js +171 -0
  15. package/dist/components/ImageBackground.d.ts +32 -0
  16. package/dist/components/ImageBackground.js +76 -0
  17. package/dist/components/IndicatorLight.d.ts +44 -0
  18. package/dist/components/IndicatorLight.js +124 -0
  19. package/dist/components/LeftAlignedECharts.d.ts +42 -0
  20. package/dist/components/LeftAlignedECharts.js +270 -0
  21. package/dist/components/LineChartEditor.d.ts +74 -0
  22. package/dist/components/LineChartEditor.js +458 -0
  23. package/dist/components/LineChartTable.d.ts +38 -0
  24. package/dist/components/LineChartTable.js +245 -0
  25. package/dist/components/LinkedLineChart.d.ts +45 -0
  26. package/dist/components/LinkedLineChart.js +159 -0
  27. package/dist/components/QuickDateRangePicker.d.ts +30 -0
  28. package/dist/components/QuickDateRangePicker.js +58 -0
  29. package/dist/components/SegmentedButtons.d.ts +22 -0
  30. package/dist/components/SegmentedButtons.js +86 -0
  31. package/dist/components/SelectableECharts.d.ts +22 -0
  32. package/dist/components/SelectableECharts.js +402 -0
  33. package/dist/components/Sidebar.d.ts +79 -0
  34. package/dist/components/Sidebar.js +178 -0
  35. package/dist/components/TsingrocDatePicker.d.ts +38 -0
  36. package/dist/components/TsingrocDatePicker.js +64 -0
  37. package/dist/components/TsingrocTheme.d.ts +15 -0
  38. package/dist/components/TsingrocTheme.js +72 -0
  39. package/dist/components/UserButton.d.ts +42 -0
  40. package/dist/components/UserButton.js +105 -0
  41. package/dist/components/VerticalColorLegend.d.ts +7 -0
  42. package/dist/components/VerticalColorLegend.js +208 -0
  43. package/dist/components/WeatherMap.d.ts +18 -0
  44. package/dist/components/WeatherMap.js +658 -0
  45. package/dist/deckgl/TiandituLayer.d.ts +13 -0
  46. package/dist/deckgl/TiandituLayer.js +44 -0
  47. package/dist/deckgl/WeatherData.d.ts +53 -0
  48. package/dist/deckgl/WeatherData.js +94 -0
  49. package/dist/deckgl/index.d.ts +1 -0
  50. package/dist/deckgl/index.js +1 -0
  51. package/dist/echarts/coordinateSystems/grid.d.ts +43 -0
  52. package/dist/echarts/coordinateSystems/grid.js +108 -0
  53. package/dist/echarts/coordinateSystems/index.js +2 -0
  54. package/dist/echarts/coordinateSystems/polar.d.ts +45 -0
  55. package/dist/echarts/coordinateSystems/polar.js +96 -0
  56. package/dist/echarts/gl-types.d.js +0 -0
  57. package/dist/echarts/gl.d.ts +115 -0
  58. package/dist/echarts/gl.js +47 -0
  59. package/dist/echarts/index.d.ts +46 -0
  60. package/dist/echarts/index.js +46 -0
  61. package/dist/echarts/legend.d.ts +17 -0
  62. package/dist/echarts/legend.js +15 -0
  63. package/dist/echarts/radar.d.ts +24 -0
  64. package/dist/echarts/radar.js +22 -0
  65. package/dist/echarts/series/barSeries.d.ts +23 -0
  66. package/dist/echarts/series/barSeries.js +18 -0
  67. package/dist/echarts/series/boxplotSeries.d.ts +21 -0
  68. package/dist/echarts/series/boxplotSeries.js +40 -0
  69. package/dist/echarts/series/index.js +7 -0
  70. package/dist/echarts/series/intervalSeries.d.ts +32 -0
  71. package/dist/echarts/series/intervalSeries.js +55 -0
  72. package/dist/echarts/series/lineSeries.d.ts +36 -0
  73. package/dist/echarts/series/lineSeries.js +45 -0
  74. package/dist/echarts/series/maxBarSeries.d.ts +18 -0
  75. package/dist/echarts/series/maxBarSeries.js +39 -0
  76. package/dist/echarts/series/pieSeries.d.ts +31 -0
  77. package/dist/echarts/series/pieSeries.js +47 -0
  78. package/dist/echarts/series/windLineSeries.d.ts +47 -0
  79. package/dist/echarts/series/windLineSeries.js +51 -0
  80. package/{src/echarts/tooltip.ts → dist/echarts/tooltip.d.ts} +1 -5
  81. package/dist/echarts/tooltip.js +22 -0
  82. package/dist/env.d.js +0 -0
  83. package/dist/index.d.ts +21 -0
  84. package/dist/index.js +21 -0
  85. package/dist/utils/debug.d.ts +1 -0
  86. package/dist/utils/debug.js +25 -0
  87. package/dist/utils/destructureLineDataItem.d.ts +6 -0
  88. package/dist/utils/destructureLineDataItem.js +17 -0
  89. package/dist/utils/filterMap.d.ts +1 -0
  90. package/dist/utils/filterMap.js +11 -0
  91. package/dist/utils/index.d.ts +8 -0
  92. package/dist/utils/index.js +8 -0
  93. package/dist/utils/math.d.ts +9 -0
  94. package/{src/utils/math.ts → dist/utils/math.js} +2 -2
  95. package/dist/utils/mock.d.ts +8 -0
  96. package/dist/utils/mock.js +40 -0
  97. package/dist/utils/normalizeIntoArray.d.ts +1 -0
  98. package/dist/utils/normalizeIntoArray.js +3 -0
  99. package/dist/utils/startOfQuarter.d.ts +2 -0
  100. package/dist/utils/startOfQuarter.js +4 -0
  101. package/dist/utils/timeAxisLabel.d.ts +5 -0
  102. package/dist/utils/timeAxisLabel.js +18 -0
  103. package/package.json +26 -14
  104. package/src/components/Auth.tsx +0 -623
  105. package/src/components/AutoResizedECharts.tsx +0 -70
  106. package/src/components/Calendar.tsx +0 -182
  107. package/src/components/CircularProgress.tsx +0 -38
  108. package/src/components/ConnectedECharts.tsx +0 -62
  109. package/src/components/ECharts.tsx +0 -206
  110. package/src/components/Header.tsx +0 -136
  111. package/src/components/ImageBackground.tsx +0 -58
  112. package/src/components/IndicatorLight.tsx +0 -106
  113. package/src/components/LeftAlignedECharts.tsx +0 -190
  114. package/src/components/LineChartEditor.tsx +0 -558
  115. package/src/components/LineChartTable.tsx +0 -286
  116. package/src/components/LinkedECharts.tsx +0 -51
  117. package/src/components/LinkedLineChart.tsx +0 -144
  118. package/src/components/QuickDateRangePicker.tsx +0 -84
  119. package/src/components/SegmentedButtons.tsx +0 -46
  120. package/src/components/Sidebar.tsx +0 -271
  121. package/src/components/StrictECharts.d.ts +0 -47
  122. package/src/components/StrictECharts.js +0 -1
  123. package/src/components/TsingrocDatePicker.tsx +0 -103
  124. package/src/components/TsingrocTheme.tsx +0 -48
  125. package/src/components/UserButton.tsx +0 -165
  126. package/src/components/VerticalColorLegend.tsx +0 -73
  127. package/src/components/WeatherMap.tsx +0 -522
  128. package/src/deckgl/TiandituLayer.ts +0 -56
  129. package/src/deckgl/WeatherData.ts +0 -157
  130. package/src/deckgl/index.ts +0 -4
  131. package/src/echarts/coordinateSystems/grid.ts +0 -143
  132. package/src/echarts/coordinateSystems/polar.ts +0 -148
  133. package/src/echarts/gl.ts +0 -159
  134. package/src/echarts/index.ts +0 -129
  135. package/src/echarts/legend.ts +0 -36
  136. package/src/echarts/radar.ts +0 -46
  137. package/src/echarts/series/barSeries.ts +0 -37
  138. package/src/echarts/series/boxplotSeries.ts +0 -62
  139. package/src/echarts/series/intervalSeries.ts +0 -70
  140. package/src/echarts/series/lineSeries.ts +0 -78
  141. package/src/echarts/series/maxBarSeries.ts +0 -55
  142. package/src/echarts/series/pieSeries.ts +0 -76
  143. package/src/echarts/series/windLineSeries.ts +0 -113
  144. package/src/index.ts +0 -120
  145. package/src/types.d.ts +0 -5
  146. package/src/utils/debug.ts +0 -39
  147. package/src/utils/mock.ts +0 -69
  148. package/src/utils/startOfQuarter.ts +0 -6
  149. /package/{src/echarts/coordinateSystems/index.ts → dist/echarts/coordinateSystems/index.d.ts} +0 -0
  150. /package/{src/echarts/series/index.ts → dist/echarts/series/index.d.ts} +0 -0
@@ -0,0 +1,658 @@
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { Button, Flex, Slider, Spin, theme } from "antd";
3
+ import { createStyles } from "antd-style";
4
+ import dayjs from "dayjs";
5
+ import DeckGL from "deck.gl";
6
+ import { useMemo, useState } from "react";
7
+ import { MdDewPoint, MdThermostat } from "react-icons/md";
8
+ import { WiBarometer, WiCloudy, WiHumidity, WiRain, WiStrongWind } from "react-icons/wi";
9
+ import * as wl from "weatherlayers-gl";
10
+ import { TiandituLayer } from "../deckgl";
11
+ import { extractMagnitudeData, extractScalarData, extractVectorData, getBounds } from "../deckgl/WeatherData";
12
+ import TsingrocTheme from "./TsingrocTheme";
13
+ import VerticalColorLegend from "./VerticalColorLegend";
14
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
+ /**
16
+ * 一张显示各类天气信息的地图。
17
+ *
18
+ * 多余的属性会被传递给组件最外层的 [`div` 元素][1]。
19
+ *
20
+ * [1]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div
21
+ */
22
+ function WeatherMap(props) {
23
+ const $ = _c(81);
24
+ let data;
25
+ let rest;
26
+ let tiandituTk;
27
+ if ($[0] !== props) {
28
+ ({
29
+ tiandituTk,
30
+ data,
31
+ ...rest
32
+ } = props);
33
+ $[0] = props;
34
+ $[1] = data;
35
+ $[2] = rest;
36
+ $[3] = tiandituTk;
37
+ } else {
38
+ data = $[1];
39
+ rest = $[2];
40
+ tiandituTk = $[3];
41
+ }
42
+ const {
43
+ token
44
+ } = theme.useToken();
45
+ const boundingBox = data ? getBounds(data) : undefined;
46
+ const [selectedScalar, setSelectedScalar] = useState(SCALAR_VARIABLES[0]);
47
+ const hasWind = !!(data && data.data_vars.wind_component_u_10m && data.data_vars.wind_component_v_10m);
48
+ let t0;
49
+ bb0: {
50
+ if (!data) {
51
+ t0 = undefined;
52
+ break bb0;
53
+ }
54
+ if (selectedScalar.key === "wind_speed_10m" && !data.data_vars.wind_speed_10m && hasWind) {
55
+ let t1;
56
+ if ($[4] !== data) {
57
+ t1 = extractMagnitudeData(data, "wind_component_u_10m", "wind_component_v_10m");
58
+ $[4] = data;
59
+ $[5] = t1;
60
+ } else {
61
+ t1 = $[5];
62
+ }
63
+ t0 = t1;
64
+ break bb0;
65
+ }
66
+ let t1;
67
+ if ($[6] !== data || $[7] !== selectedScalar.key) {
68
+ t1 = extractScalarData(data, selectedScalar.key);
69
+ $[6] = data;
70
+ $[7] = selectedScalar.key;
71
+ $[8] = t1;
72
+ } else {
73
+ t1 = $[8];
74
+ }
75
+ t0 = t1;
76
+ }
77
+ const scalarFrames = t0;
78
+ const [showWind, setShowWind] = useState(true);
79
+ let t1;
80
+ bb1: {
81
+ if (!(hasWind && showWind)) {
82
+ t1 = undefined;
83
+ break bb1;
84
+ }
85
+ let t2;
86
+ if ($[9] !== data) {
87
+ t2 = extractVectorData(data, "wind_component_u_10m", "wind_component_v_10m");
88
+ $[9] = data;
89
+ $[10] = t2;
90
+ } else {
91
+ t2 = $[10];
92
+ }
93
+ t1 = t2;
94
+ }
95
+ const windFrames = t1;
96
+ const [timeIdx, setTimeIdx] = useState(0);
97
+ const scalarFrame = scalarFrames?.[timeIdx];
98
+ const windFrame = windFrames?.[timeIdx];
99
+ let t2;
100
+ bb2: {
101
+ if (!scalarFrame) {
102
+ t2 = undefined;
103
+ break bb2;
104
+ }
105
+ let t3;
106
+ if ($[11] !== scalarFrame.max || $[12] !== scalarFrame.min || $[13] !== selectedScalar.adaptivePalette) {
107
+ t3 = adaptiveColorCoding(scalarFrame.min, scalarFrame.max, selectedScalar.adaptivePalette);
108
+ $[11] = scalarFrame.max;
109
+ $[12] = scalarFrame.min;
110
+ $[13] = selectedScalar.adaptivePalette;
111
+ $[14] = t3;
112
+ } else {
113
+ t3 = $[14];
114
+ }
115
+ t2 = t3;
116
+ }
117
+ const palette = t2;
118
+ const T0 = TsingrocTheme;
119
+ let t3;
120
+ if ($[15] !== rest.style) {
121
+ t3 = {
122
+ position: "relative",
123
+ ...rest.style
124
+ };
125
+ $[15] = rest.style;
126
+ $[16] = t3;
127
+ } else {
128
+ t3 = $[16];
129
+ }
130
+ const T1 = DeckGL;
131
+ let t4;
132
+ let t5;
133
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
134
+ t4 = {
135
+ longitude: 0,
136
+ latitude: 0,
137
+ zoom: 0,
138
+ maxPitch: 0
139
+ };
140
+ t5 = {
141
+ dragRotate: false
142
+ };
143
+ $[17] = t4;
144
+ $[18] = t5;
145
+ } else {
146
+ t4 = $[17];
147
+ t5 = $[18];
148
+ }
149
+ let t6;
150
+ if ($[19] !== tiandituTk) {
151
+ t6 = new TiandituLayer({
152
+ id: "base",
153
+ tiandituTk
154
+ });
155
+ $[19] = tiandituTk;
156
+ $[20] = t6;
157
+ } else {
158
+ t6 = $[20];
159
+ }
160
+ let t7;
161
+ if ($[21] !== tiandituTk) {
162
+ t7 = new TiandituLayer({
163
+ id: "ann",
164
+ tiandituTk,
165
+ layer: "annotation"
166
+ });
167
+ $[21] = tiandituTk;
168
+ $[22] = t7;
169
+ } else {
170
+ t7 = $[22];
171
+ }
172
+ const t8 = scalarFrame ? new wl.RasterLayer({
173
+ id: "scalar",
174
+ opacity: 0.5,
175
+ bounds: boundingBox,
176
+ image: scalarFrame.image,
177
+ palette
178
+ }) : null;
179
+ const t9 = windFrame ? new wl.ParticleLayer({
180
+ id: "wind",
181
+ opacity: 0.5,
182
+ bounds: boundingBox,
183
+ image: windFrame,
184
+ numParticles: 1000,
185
+ maxAge: 30,
186
+ speedFactor: 10,
187
+ width: window.devicePixelRatio
188
+ }) : null;
189
+ let t10;
190
+ if ($[23] !== t6 || $[24] !== t7 || $[25] !== t8 || $[26] !== t9) {
191
+ t10 = [t6, t7, t8, t9];
192
+ $[23] = t6;
193
+ $[24] = t7;
194
+ $[25] = t8;
195
+ $[26] = t9;
196
+ $[27] = t10;
197
+ } else {
198
+ t10 = $[27];
199
+ }
200
+ let t11;
201
+ if ($[28] !== T1 || $[29] !== t10 || $[30] !== t4 || $[31] !== t5) {
202
+ t11 = /*#__PURE__*/_jsx(T1, {
203
+ initialViewState: t4,
204
+ controller: t5,
205
+ layers: t10
206
+ });
207
+ $[28] = T1;
208
+ $[29] = t10;
209
+ $[30] = t4;
210
+ $[31] = t5;
211
+ $[32] = t11;
212
+ } else {
213
+ t11 = $[32];
214
+ }
215
+ let t12;
216
+ if ($[33] !== data || $[34] !== setTimeIdx || $[35] !== timeIdx) {
217
+ t12 = data && /*#__PURE__*/_jsx("div", {
218
+ style: {
219
+ position: "absolute",
220
+ inset: "auto 0 0 0",
221
+ padding: "4px 8px 0 8px",
222
+ background: "linear-gradient(to bottom, transparent, #0007)"
223
+ },
224
+ children: /*#__PURE__*/_jsx(Slider, {
225
+ value: timeIdx,
226
+ min: 0,
227
+ max: data.dims.time - 1,
228
+ step: 1,
229
+ onChange: setTimeIdx,
230
+ tooltip: {
231
+ formatter: value => dayjs.unix(data.coords.time[value]).format("YYYY-MM-DD HH:mm:ss")
232
+ }
233
+ })
234
+ });
235
+ $[33] = data;
236
+ $[34] = setTimeIdx;
237
+ $[35] = timeIdx;
238
+ $[36] = t12;
239
+ } else {
240
+ t12 = $[36];
241
+ }
242
+ let t13;
243
+ if ($[37] !== token.borderRadius || $[38] !== token.colorBgMask || $[39] !== token.paddingXXS) {
244
+ t13 = {
245
+ position: "absolute",
246
+ inset: "8px 8px auto auto",
247
+ borderRadius: token.borderRadius,
248
+ padding: token.paddingXXS,
249
+ background: token.colorBgMask
250
+ };
251
+ $[37] = token.borderRadius;
252
+ $[38] = token.colorBgMask;
253
+ $[39] = token.paddingXXS;
254
+ $[40] = t13;
255
+ } else {
256
+ t13 = $[40];
257
+ }
258
+ let t14;
259
+ if ($[41] !== data || $[42] !== hasWind || $[43] !== selectedScalar || $[44] !== setSelectedScalar) {
260
+ let t15;
261
+ if ($[46] !== data || $[47] !== hasWind) {
262
+ t15 = scalar => !data || scalar.key in data.data_vars || scalar.key === "wind_speed_10m" && hasWind;
263
+ $[46] = data;
264
+ $[47] = hasWind;
265
+ $[48] = t15;
266
+ } else {
267
+ t15 = $[48];
268
+ }
269
+ let t16;
270
+ if ($[49] !== selectedScalar || $[50] !== setSelectedScalar) {
271
+ t16 = scalar_0 => /*#__PURE__*/_jsx(ToolbarButton, {
272
+ icon: scalar_0.icon,
273
+ selected: selectedScalar.key === scalar_0.key,
274
+ onClick: () => setSelectedScalar(scalar_0),
275
+ children: scalar_0.name
276
+ }, scalar_0.key);
277
+ $[49] = selectedScalar;
278
+ $[50] = setSelectedScalar;
279
+ $[51] = t16;
280
+ } else {
281
+ t16 = $[51];
282
+ }
283
+ t14 = SCALAR_VARIABLES.filter(t15).map(t16);
284
+ $[41] = data;
285
+ $[42] = hasWind;
286
+ $[43] = selectedScalar;
287
+ $[44] = setSelectedScalar;
288
+ $[45] = t14;
289
+ } else {
290
+ t14 = $[45];
291
+ }
292
+ let t15;
293
+ if ($[52] !== token.marginXXS) {
294
+ t15 = /*#__PURE__*/_jsx("hr", {
295
+ style: {
296
+ margin: token.marginXXS
297
+ }
298
+ });
299
+ $[52] = token.marginXXS;
300
+ $[53] = t15;
301
+ } else {
302
+ t15 = $[53];
303
+ }
304
+ let t16;
305
+ if ($[54] !== data || $[55] !== hasWind || $[56] !== setShowWind || $[57] !== showWind) {
306
+ t16 = (!data || hasWind) && /*#__PURE__*/_jsx(ToolbarButton, {
307
+ icon: /*#__PURE__*/_jsx(WiStrongWind, {}),
308
+ selected: showWind,
309
+ onClick: () => setShowWind(_temp),
310
+ children: "\u98CE\u529B\u8F68\u8FF9"
311
+ });
312
+ $[54] = data;
313
+ $[55] = hasWind;
314
+ $[56] = setShowWind;
315
+ $[57] = showWind;
316
+ $[58] = t16;
317
+ } else {
318
+ t16 = $[58];
319
+ }
320
+ let t17;
321
+ if ($[59] !== t13 || $[60] !== t14 || $[61] !== t15 || $[62] !== t16) {
322
+ t17 = /*#__PURE__*/_jsxs(Flex, {
323
+ vertical: true,
324
+ style: t13,
325
+ children: [t14, t15, t16]
326
+ });
327
+ $[59] = t13;
328
+ $[60] = t14;
329
+ $[61] = t15;
330
+ $[62] = t16;
331
+ $[63] = t17;
332
+ } else {
333
+ t17 = $[63];
334
+ }
335
+ let t18;
336
+ if ($[64] !== palette || $[65] !== selectedScalar) {
337
+ t18 = palette && /*#__PURE__*/_jsx(VerticalColorLegend, {
338
+ title: selectedScalar.name + "\uFF08" + selectedScalar.unit + "\uFF09",
339
+ palette: palette,
340
+ style: {
341
+ position: "absolute",
342
+ inset: "auto auto 32px 13px",
343
+ height: 135,
344
+ pointerEvents: "none"
345
+ }
346
+ });
347
+ $[64] = palette;
348
+ $[65] = selectedScalar;
349
+ $[66] = t18;
350
+ } else {
351
+ t18 = $[66];
352
+ }
353
+ let t19;
354
+ if ($[67] !== data || $[68] !== token.colorFillSecondary) {
355
+ t19 = !data && /*#__PURE__*/_jsx(Spin, {
356
+ size: "large",
357
+ style: {
358
+ position: "absolute",
359
+ inset: 0,
360
+ background: token.colorFillSecondary,
361
+ display: "flex",
362
+ alignItems: "center",
363
+ justifyContent: "center"
364
+ }
365
+ });
366
+ $[67] = data;
367
+ $[68] = token.colorFillSecondary;
368
+ $[69] = t19;
369
+ } else {
370
+ t19 = $[69];
371
+ }
372
+ let t20;
373
+ if ($[70] !== rest || $[71] !== t11 || $[72] !== t12 || $[73] !== t17 || $[74] !== t18 || $[75] !== t19 || $[76] !== t3) {
374
+ t20 = /*#__PURE__*/_jsxs("div", {
375
+ ...rest,
376
+ style: t3,
377
+ children: [t11, t12, t17, t18, t19]
378
+ });
379
+ $[70] = rest;
380
+ $[71] = t11;
381
+ $[72] = t12;
382
+ $[73] = t17;
383
+ $[74] = t18;
384
+ $[75] = t19;
385
+ $[76] = t3;
386
+ $[77] = t20;
387
+ } else {
388
+ t20 = $[77];
389
+ }
390
+ let t21;
391
+ if ($[78] !== T0 || $[79] !== t20) {
392
+ t21 = /*#__PURE__*/_jsx(T0, {
393
+ children: t20
394
+ });
395
+ $[78] = T0;
396
+ $[79] = t20;
397
+ $[80] = t21;
398
+ } else {
399
+ t21 = $[80];
400
+ }
401
+ return t21;
402
+ }
403
+ function _temp(b) {
404
+ return !b;
405
+ }
406
+ export default WeatherMap;
407
+ function ToolbarButton(props) {
408
+ const $ = _c(18);
409
+ let children;
410
+ let className;
411
+ let rest;
412
+ let selected;
413
+ if ($[0] !== props) {
414
+ ({
415
+ selected,
416
+ className,
417
+ children,
418
+ ...rest
419
+ } = props);
420
+ $[0] = props;
421
+ $[1] = children;
422
+ $[2] = className;
423
+ $[3] = rest;
424
+ $[4] = selected;
425
+ } else {
426
+ children = $[1];
427
+ className = $[2];
428
+ rest = $[3];
429
+ selected = $[4];
430
+ }
431
+ const {
432
+ cx,
433
+ styles
434
+ } = useStyles();
435
+ let t0;
436
+ if ($[5] !== className || $[6] !== cx || $[7] !== selected || $[8] !== styles.toolbarButton || $[9] !== styles.toolbarButtonSelected) {
437
+ t0 = cx(styles.toolbarButton, {
438
+ [styles.toolbarButtonSelected]: selected
439
+ }, className);
440
+ $[5] = className;
441
+ $[6] = cx;
442
+ $[7] = selected;
443
+ $[8] = styles.toolbarButton;
444
+ $[9] = styles.toolbarButtonSelected;
445
+ $[10] = t0;
446
+ } else {
447
+ t0 = $[10];
448
+ }
449
+ let t1;
450
+ if ($[11] !== children || $[12] !== styles.toolbarButtonText) {
451
+ t1 = /*#__PURE__*/_jsx("span", {
452
+ className: styles.toolbarButtonText,
453
+ children: children
454
+ });
455
+ $[11] = children;
456
+ $[12] = styles.toolbarButtonText;
457
+ $[13] = t1;
458
+ } else {
459
+ t1 = $[13];
460
+ }
461
+ let t2;
462
+ if ($[14] !== rest || $[15] !== t0 || $[16] !== t1) {
463
+ t2 = /*#__PURE__*/_jsx(Button, {
464
+ color: "default",
465
+ variant: "text",
466
+ className: t0,
467
+ ...rest,
468
+ children: t1
469
+ });
470
+ $[14] = rest;
471
+ $[15] = t0;
472
+ $[16] = t1;
473
+ $[17] = t2;
474
+ } else {
475
+ t2 = $[17];
476
+ }
477
+ return t2;
478
+ }
479
+ const useStyles = createStyles(({
480
+ token,
481
+ css,
482
+ prefixCls
483
+ }) => {
484
+ return {
485
+ toolbarButton: css`
486
+ padding: 0 ${token.paddingXS}px;
487
+ background: transparent;
488
+
489
+ &:hover:hover:hover {
490
+ background: ${token.colorFillSecondary};
491
+ }
492
+
493
+ &:active:active:active {
494
+ background: ${token.colorFill};
495
+ }
496
+
497
+ &,
498
+ &:hover:hover:hover {
499
+ color: ${token.colorWhite};
500
+ }
501
+
502
+ > .${prefixCls}-btn-icon {
503
+ font-size: 18px;
504
+ }
505
+ `,
506
+ toolbarButtonSelected: css`
507
+ &,
508
+ &:hover:hover:hover {
509
+ background: ${token.colorBgContainer};
510
+ color: ${token.colorText};
511
+ }
512
+
513
+ &::before {
514
+ content: "";
515
+ position: absolute;
516
+ inset: -1px;
517
+ border: inherit;
518
+ border-radius: inherit;
519
+ transition: inherit;
520
+ }
521
+
522
+ &:hover:hover:hover::before {
523
+ background: ${token.colorFillSecondary};
524
+ }
525
+
526
+ &:active:active:active::before {
527
+ background: ${token.colorFill};
528
+ }
529
+ `,
530
+ toolbarButtonText: css`
531
+ flex-basis: 100%;
532
+ text-align: left;
533
+ `
534
+ };
535
+ });
536
+ const iconSizeFix = ratio => ({
537
+ fontSize: `${ratio}em`,
538
+ margin: `${-(1 - 1 / ratio) / 3}em ${-(1 - 1 / ratio) / 2}em`
539
+ });
540
+ const TEMPERATURE_ADAPTIVE_PALETTE = {
541
+ min: [128, 65, 157],
542
+ zero: [239, 255, 45],
543
+ max: [254, 19, 12]
544
+ };
545
+ const TEMPERATURE_FIXED_PALETTE = [[-18, [78, 138, 221]], [-17, [87, 144, 222]], [-16, [97, 150, 224]], [-15, [106, 156, 225]], [-14, [116, 163, 226]], [-13, [125, 169, 227]], [-12, [135, 175, 229]], [-11, [145, 181, 230]], [-10, [155, 188, 232]], [-9, [154, 192, 226]], [-8, [154, 196, 220]], [-7, [154, 200, 214]], [-6, [154, 205, 208]], [-5, [153, 209, 202]], [-4, [152, 214, 196]], [-3, [151, 223, 184]], [-2, [151, 232, 173]], [-1, [183, 227, 149]], [0, [215, 222, 125]], [1, [224, 220, 118]], [2, [234, 219, 112]], [3, [239, 218, 105]], [4, [244, 217, 99]], [5, [247, 210, 89]], [6, [250, 204, 79]], [7, [248, 192, 62]], [8, [247, 180, 45]], [9, [244, 167, 22]], [10, [242, 155, 0]], [11, [241, 151, 1]], [12, [241, 147, 3]], [13, [240, 140, 6]], [14, [240, 133, 10]], [15, [239, 125, 13]], [16, [239, 117, 17]], [17, [238, 109, 20]], [18, [238, 101, 24]], [19, [238, 94, 27]], [20, [238, 88, 31]], [21, [234, 81, 28]], [22, [231, 75, 26]], [23, [227, 69, 24]], [24, [224, 63, 22]], [25, [220, 57, 20]], [26, [217, 51, 18]], [27, [212, 43, 16]], [28, [208, 36, 14]], [29, [201, 18, 8]], [30, [194, 0, 3]], [31, [187, 0, 6]], [32, [181, 1, 9]], [33, [175, 1, 12]], [34, [169, 2, 16]], [35, [153, 3, 20]], [36, [138, 5, 25]], [37, [124, 2, 23]], [38, [111, 0, 21]], [39, [95, 0, 18]], [40, [80, 0, 15]], [41, [70, 0, 15]], [42, [60, 0, 15]], [43, [50, 0, 15]], [44, [40, 0, 15]], [45, [30, 0, 15]], [46, [20, 0, 15]]];
546
+ const SCALAR_VARIABLES = [{
547
+ key: "temperature_2m",
548
+ name: "温度",
549
+ unit: "℃",
550
+ icon: /*#__PURE__*/_jsx(MdThermostat, {}),
551
+ adaptivePalette: TEMPERATURE_ADAPTIVE_PALETTE,
552
+ fixedPalette: TEMPERATURE_FIXED_PALETTE
553
+ }, {
554
+ key: "surface_pressure",
555
+ name: "气压",
556
+ unit: "hPa",
557
+ icon: /*#__PURE__*/_jsx(WiBarometer, {
558
+ style: iconSizeFix(1.4)
559
+ }),
560
+ adaptivePalette: {
561
+ min: [80, 202, 75],
562
+ max: [254, 19, 12]
563
+ }
564
+ }, {
565
+ key: "cloud_cover",
566
+ name: "云量",
567
+ unit: "%",
568
+ icon: /*#__PURE__*/_jsx(WiCloudy, {
569
+ style: iconSizeFix(1.2)
570
+ }),
571
+ adaptivePalette: {
572
+ min: [239, 255, 45],
573
+ max: [255, 255, 255]
574
+ }
575
+ }, {
576
+ key: "dew_point_2m",
577
+ name: "露点",
578
+ unit: "℃",
579
+ icon: /*#__PURE__*/_jsx(MdDewPoint, {}),
580
+ adaptivePalette: TEMPERATURE_ADAPTIVE_PALETTE,
581
+ fixedPalette: TEMPERATURE_FIXED_PALETTE
582
+ }, {
583
+ key: "relative_humidity_2m",
584
+ name: "相对湿度",
585
+ unit: "%",
586
+ icon: /*#__PURE__*/_jsx(WiHumidity, {
587
+ style: iconSizeFix(1.3)
588
+ }),
589
+ adaptivePalette: {
590
+ min: [128, 65, 157],
591
+ zero: [239, 255, 45],
592
+ zeroPoint: 0.5,
593
+ max: [254, 19, 12]
594
+ }
595
+ }, {
596
+ key: "wind_speed_10m",
597
+ name: "风速",
598
+ unit: "m/s",
599
+ icon: /*#__PURE__*/_jsx(WiStrongWind, {}),
600
+ adaptivePalette: {
601
+ min: [239, 255, 45],
602
+ max: [128, 65, 157]
603
+ }
604
+ }, {
605
+ key: "rain",
606
+ name: "降雨量",
607
+ unit: "mm",
608
+ icon: /*#__PURE__*/_jsx(WiRain, {
609
+ style: iconSizeFix(1.1)
610
+ }),
611
+ adaptivePalette: {
612
+ min: [80, 202, 75],
613
+ max: [254, 19, 12]
614
+ }
615
+ }];
616
+ function lerpVec(min, max, pos) {
617
+ return min.map((min, i) => min + pos * (max[i] - min));
618
+ }
619
+ // 参考 https://www.cma.gov.cn/zfxxgk/gknr/flfgbz/bz/202209/P020220921555079517928.pdf
620
+ function adaptiveColorCoding(min, max, base) {
621
+ if (base.zero) {
622
+ const palette = [];
623
+ const zeroPoint = base.zeroPoint ?? 0;
624
+ if (min < zeroPoint) {
625
+ palette.push([min, lerpVec(base.zero, base.min, Math.min(1, Math.abs((min - zeroPoint) / (max - zeroPoint))))]);
626
+ } else {
627
+ palette.push([min, base.zero]);
628
+ }
629
+ if (min < zeroPoint && max > zeroPoint) {
630
+ palette.push([zeroPoint, base.zero]);
631
+ }
632
+ if (max > zeroPoint) {
633
+ palette.push([max, lerpVec(base.zero, base.max, Math.min(1, Math.abs((max - zeroPoint) / (min - zeroPoint))))]);
634
+ } else {
635
+ palette.push([max, base.zero]);
636
+ }
637
+ return palette;
638
+ } else {
639
+ return [[min, base.min], [max, base.max]];
640
+ }
641
+ }
642
+
643
+ // 参考 https://dbba.sacinfo.org.cn/attachment/downloadStdFile?pk=dda6960be9435ed7ab01e336e197cd67a072a28725f03685bfbdaf19cbfeb267
644
+ // @ts-expect-error no unused vars
645
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
646
+ function fixedColorCoding(min, max, palette) {
647
+ let minIdx = palette.findIndex(([value]) => value > min) - 1;
648
+ if (minIdx < -1) {
649
+ minIdx = palette.length - 1;
650
+ } else if (minIdx === -1) {
651
+ minIdx = 0;
652
+ }
653
+ let maxIdx = palette.findIndex(([value]) => value >= max);
654
+ if (maxIdx < 0) {
655
+ maxIdx = 0;
656
+ }
657
+ return palette.slice(minIdx, maxIdx + 1);
658
+ }
@@ -0,0 +1,13 @@
1
+ import { CompositeLayer } from "deck.gl";
2
+ import type { DefaultProps } from "@deck.gl/core";
3
+ import { TileLayer } from "@deck.gl/geo-layers";
4
+ export interface TiandituLayerProps {
5
+ tiandituTk: string;
6
+ type: "vec" | "img" | "ter";
7
+ layer: "base" | "annotation";
8
+ }
9
+ export default class TiandituLayer extends CompositeLayer<TiandituLayerProps> {
10
+ static readonly layerName = "TiandituLayer";
11
+ static readonly defaultProps: DefaultProps<TiandituLayerProps>;
12
+ renderLayers(): TileLayer;
13
+ }
@@ -0,0 +1,44 @@
1
+ import { BitmapLayer, CompositeLayer } from "deck.gl";
2
+ import { TileLayer } from "@deck.gl/geo-layers";
3
+ export default class TiandituLayer extends CompositeLayer {
4
+ static layerName = "TiandituLayer";
5
+ static defaultProps = {
6
+ type: {
7
+ type: "object",
8
+ value: "vec"
9
+ },
10
+ layer: {
11
+ type: "object",
12
+ value: "base"
13
+ }
14
+ };
15
+ renderLayers() {
16
+ const {
17
+ tiandituTk,
18
+ type,
19
+ layer
20
+ } = this.props;
21
+ const actualType = layer === "base" ? type : "c" + type[0] + "a";
22
+ return new TileLayer(this.getSubLayerProps({
23
+ id: actualType,
24
+ data: makeUrlTemplate(tiandituTk, actualType),
25
+ maxZoom: 18,
26
+ zoomOffset: 1,
27
+ renderSubLayers
28
+ }));
29
+ }
30
+ }
31
+ const makeUrlTemplate = (tiandituTk, type) => Array.from({
32
+ length: 8
33
+ }, (_, i) => `https://t${i}.tianditu.gov.cn/${type}_w/wmts` + `?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0` + `&LAYER=${type}&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles` + `&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}` + `&tk=${tiandituTk}`);
34
+ const renderSubLayers = props => {
35
+ const {
36
+ boundingBox
37
+ } = props.tile;
38
+ return new BitmapLayer({
39
+ ...props,
40
+ data: undefined,
41
+ image: props.data,
42
+ bounds: [boundingBox[0][0], boundingBox[0][1], boundingBox[1][0], boundingBox[1][1]]
43
+ });
44
+ };