bluestar-maplibre 1.1.3 → 1.1.5

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/index.js CHANGED
@@ -2125,6 +2125,20 @@ function hr(r, e) {
2125
2125
  source: "baselayersource__bing-map",
2126
2126
  minzoom: 2,
2127
2127
  maxzoom: 18
2128
+ }), t.addSource("addsource__bing-map", {
2129
+ type: "raster",
2130
+ tiles: ["http://localhost:8780/geoq/{z}/{x}/{y}.png"],
2131
+ tileSize: 256
2132
+ }), t.addLayer({
2133
+ id: "addlayer__bing-map-layer",
2134
+ type: "raster",
2135
+ source: "addsource__bing-map",
2136
+ minzoom: 2,
2137
+ maxzoom: 13,
2138
+ //透明度
2139
+ paint: {
2140
+ "raster-opacity": 0.8
2141
+ }
2128
2142
  }), n && t.setLayoutProperty("baselayer__bing-map-layer", "visibility", "none"), t.setMinZoom(2);
2129
2143
  }), t;
2130
2144
  }
@@ -2419,11 +2433,11 @@ class qt {
2419
2433
  }), P(() => this.state.direction, (e) => {
2420
2434
  this.vectorLayerId && this.viewer.setLayoutProperty(this.vectorLayerId, "visibility", e ? "visible" : "none");
2421
2435
  }), P(() => this.state.level, (e) => {
2422
- this.vectorLayer && this.vectorLayer.setOptions({ level: e, color: this.state.vectorColor });
2436
+ this.vectorLayer && this.vectorLayer.setOptions({ level: [...this.state.level], color: this.state.vectorColor });
2423
2437
  }), P(() => this.state.vectorColor, (e) => {
2424
- this.vectorLayer && this.vectorLayer.setOptions({ color: e, level: this.state.level, cell: this.state.cell });
2438
+ this.vectorLayer && this.vectorLayer.setOptions({ color: e, level: [...this.state.level], cell: this.state.cell });
2425
2439
  }), P(() => this.state.cell, (e) => {
2426
- this.vectorLayer && this.vectorLayer.setOptions({ cell: e, level: this.state.level, color: this.state.vectorColor }), this.gridValueLayer && this.gridValueLayer.setOptions({ cell: e ?? 4 });
2440
+ this.vectorLayer && this.vectorLayer.setOptions({ cell: e, level: [...this.state.level], color: this.state.vectorColor }), this.gridValueLayer && this.gridValueLayer.setOptions({ cell: e ?? 4 });
2427
2441
  }), P(() => this.state.colorRamp, () => this.updateHeatmapLayer()), P(() => this.state.colorRampDefaultColor, () => this.updateHeatmapLayer()), P(() => this.state.alpha, () => this.updateHeatmapLayer()), P(() => this.state.linearValue, () => this.updateHeatmapLayer()), P(() => this.state.contour, () => this.updateIsolineLayer(), { deep: !0 }), P(() => this.state.contourStyle, () => this.updateIsolineLayer(), { deep: !0 }), P(() => this.state.contourLabel, () => this.updateIsolineLayer(), { deep: !0 }), P(() => this.state.gridValueStyle, () => this.updateTextLayer(), { deep: !0 }), P(() => this.state.gridValueFormat, () => this.updateTextLayer()));
2428
2442
  }
2429
2443
  // ======================== 图层更新方法 ========================
@@ -2951,13 +2965,9 @@ async function fr(r, e = 1) {
2951
2965
  const h = c.createImageData(t, n), d = h.data;
2952
2966
  for (let f = 0; f < t * n; f++) {
2953
2967
  const v = f * 3, y = f * 4, x = l[v], A = l[v + 1], I = l[v + 2];
2954
- if (isNaN(x) || isNaN(A) || isNaN(I))
2955
- d[y] = 0, d[y + 1] = 0, d[y + 2] = 0, d[y + 3] = 0;
2956
- else {
2957
- d[y] = Math.round(x ?? 0), d[y + 1] = Math.round(A ?? 0), d[y + 2] = Math.round(I ?? 0);
2958
- let g = 255;
2959
- e !== 1 && (g = Math.round(255 * e)), g = Math.min(255, Math.max(0, g)), d[y + 3] = g;
2960
- }
2968
+ d[y] = isNaN(x) ? 0 : Math.round(x), d[y + 1] = isNaN(A) ? 0 : Math.round(A), d[y + 2] = isNaN(I) ? 0 : Math.round(I);
2969
+ let g = 255;
2970
+ e !== 1 && (g = Math.round(255 * e)), g = Math.min(255, Math.max(0, g)), d[y + 3] = g;
2961
2971
  }
2962
2972
  return c.putImageData(h, 0, 0), {
2963
2973
  uri: await ea(u),
@@ -3001,6 +3011,10 @@ class ta {
3001
3011
  * 是否使用线性插值
3002
3012
  */
3003
3013
  b(this, "linerValue", !0);
3014
+ /**
3015
+ * 当前 WegFile 数据(用于 getter 返回)
3016
+ */
3017
+ b(this, "_wegFile", null);
3004
3018
  /**
3005
3019
  * 当前图片 URI(用于内存管理)
3006
3020
  */
@@ -3028,7 +3042,7 @@ class ta {
3028
3042
  const t = this.map;
3029
3043
  let n, o;
3030
3044
  if ("dtype" in e)
3031
- o = await fr(e), n = o.uri, this.uri = n;
3045
+ this._wegFile = e, o = await fr(e), n = o.uri, this.uri = n;
3032
3046
  else {
3033
3047
  if (o = e, !o.url) throw new Error("url is required");
3034
3048
  n = o.url;
@@ -3092,23 +3106,30 @@ class ta {
3092
3106
  ]
3093
3107
  }));
3094
3108
  }
3109
+ /**
3110
+ * 获取当前 WegFile 数据
3111
+ * @returns 当前 WegFile 对象,如非 WegFile 数据则返回 null
3112
+ */
3113
+ get wegData() {
3114
+ return this._wegFile;
3115
+ }
3095
3116
  /**
3096
3117
  * 设置 WegFile 数据(setter 语法糖)
3097
3118
  * @param wegFile - WegFile 对象
3098
3119
  */
3099
- set data(e) {
3120
+ set wegData(e) {
3100
3121
  this.setWegData(e);
3101
3122
  }
3102
3123
  /**
3103
3124
  * 设置 WegFile 数据并重新渲染
3104
- *
3125
+ *
3105
3126
  * @param wegFile - WegFile 格式的气象网格数据
3106
- *
3127
+ *
3107
3128
  * @example
3108
3129
  * ```typescript
3109
3130
  * // 方式 1:使用 setter 语法
3110
- * imageRender.data = wegFile;
3111
- *
3131
+ * imageRender.wegData = wegFile;
3132
+ *
3112
3133
  * // 方式 2:直接调用方法
3113
3134
  * await imageRender.setWegData(wegFile);
3114
3135
  * ```
@@ -3117,7 +3138,7 @@ class ta {
3117
3138
  if (!("dtype" in e))
3118
3139
  throw new Error("数据不是 weg");
3119
3140
  const t = await fr(e);
3120
- this.uri && URL.revokeObjectURL(this.uri), this.uri = t.uri, this.setImage(t.uri, t);
3141
+ this._wegFile = e, this.setImage(t.uri, t), this.uri = t.uri;
3121
3142
  }
3122
3143
  /**
3123
3144
  * 设置图片透明度
@@ -132,6 +132,10 @@ export declare class ImageRender {
132
132
  * 是否使用线性插值
133
133
  */
134
134
  linerValue: boolean;
135
+ /**
136
+ * 当前 WegFile 数据(用于 getter 返回)
137
+ */
138
+ private _wegFile;
135
139
  /**
136
140
  * 当前图片 URI(用于内存管理)
137
141
  */
@@ -175,11 +179,16 @@ export declare class ImageRender {
175
179
  * - bound 参数是可选的,不传则保持原有地理范围
176
180
  */
177
181
  setImage(imageUrl: string, bound?: RectangleRange): void;
182
+ /**
183
+ * 获取当前 WegFile 数据
184
+ * @returns 当前 WegFile 对象,如非 WegFile 数据则返回 null
185
+ */
186
+ get wegData(): WegFile | null;
178
187
  /**
179
188
  * 设置 WegFile 数据(setter 语法糖)
180
189
  * @param wegFile - WegFile 对象
181
190
  */
182
- set data(wegFile: WegFile);
191
+ set wegData(wegFile: WegFile);
183
192
  /**
184
193
  * 设置 WegFile 数据并重新渲染
185
194
  *
@@ -188,7 +197,7 @@ export declare class ImageRender {
188
197
  * @example
189
198
  * ```typescript
190
199
  * // 方式 1:使用 setter 语法
191
- * imageRender.data = wegFile;
200
+ * imageRender.wegData = wegFile;
192
201
  *
193
202
  * // 方式 2:直接调用方法
194
203
  * await imageRender.setWegData(wegFile);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bluestar-maplibre",
3
3
  "author": "awayel",
4
- "version": "1.1.3",
4
+ "version": "1.1.5",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -1,7 +1,10 @@
1
1
  # bluestar-maplibre
2
2
 
3
- ### 1.1.3
4
- - 修复wegRender修改wegData的bug
3
+ ### 1.1.5
4
+ - 修复imageRender调用修改wegFile数据源的错误
5
+
6
+ ### 1.1.4
7
+ - 修复wegRender修改wegData和level的bug
5
8
 
6
9
  ### 1.1.2
7
10
  - 增加对grib数据的支持和解析渲染