runbir-tools 1.0.14 → 1.0.16

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/README.md CHANGED
@@ -1,14 +1,21 @@
1
-
2
1
  # 软博工具包
2
+
3
3
  这是一个基于vue3开发的工具包,目前包依赖ol和@turf/turf。
4
+
4
5
  #### 安装包
6
+
5
7
  ```
6
8
  npm install runbir-tools
7
9
  ```
10
+
8
11
  ## 基于ol的快速开发组件
12
+
9
13
  主要是基于vue3,对ol的基本功能做双向绑定,以及提供气象相关的一些工具。
14
+
10
15
  ### 快速开始
16
+
11
17
  基于天地图,创建简单的GIS。
18
+
12
19
  ```typescript
13
20
  <script setup>
14
21
  import { VueOl } from "runbir-tools";
@@ -49,18 +56,26 @@ const options = ref({
49
56
  }
50
57
  </style>
51
58
  ```
59
+
52
60
  ### options配置
61
+
53
62
  #### 1. options.value.view 视图配置
63
+
54
64
  视图的options同[ol/view](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html)一致,由于基于vue做了双向绑定,故直接更改属性值即可刷新,免去ol原来的繁琐重渲染操作。
55
65
  例如,更改视图中心点
66
+
56
67
  ```
57
68
  options.value.view.center = [newlng,newlat]
58
69
  ```
59
70
 
60
71
  #### 2. options.value.layers 图层配置
72
+
61
73
  图层配置目前仅支持以下图层
62
- ##### 2.1 xyz配置
74
+
75
+ ##### 2.1 xyz配置
76
+
63
77
  xyz的options同[ol/layer/Tile](https://openlayers.org/en/latest/apidoc/module-ol_layer_Tile-TileLayer.html)和[ol/source/xyz](https://openlayers.org/en/latest/apidoc/module-ol_source_XYZ-XYZ.html)一致,必须配置type:"xyz"以及id(自定义命名),id是图层的唯一标记,示例如下:
78
+
64
79
  ```typescript
65
80
  <script setup>
66
81
  import { VueOl } from "runbir-tools";
@@ -71,6 +86,7 @@ const options = ref({
71
86
      {
72
87
        id: "radar",
73
88
        type: "xyz",
89
+ useInterimTilesWhenMissing: true, // 当为true时,错误瓦片用空白图代替
74
90
        source: {
75
91
          url: "https://xxxx/data/radar_cut/20250703093600/{z}/{x}/{y}.png",
76
92
          projection: "EPSG:4326",
@@ -80,19 +96,26 @@ const options = ref({
80
96
  });
81
97
  </script>
82
98
  ```
99
+
83
100
  更改图层配置项值,同样能够直接渲染到地图
101
+
84
102
  ```
85
103
      const radar = options.value.layers.find((l: any) => l.id === 'radar')
86
104
  radar.source.url = "新的url"
87
105
  ```
106
+
88
107
  删除图片则直接在layers删除即可
108
+
89
109
  ```
90
110
  const index = options.value.layers.findIndex((l: any) => l.id === 'radar')
91
111
  options.value.layers.splice(index, 1)
92
112
  ```
113
+
93
114
  ##### 2.2 imageStatic 静态图片配置
115
+
94
116
  imageStatic的options同[ol/layer/image](https://openlayers.org/en/latest/apidoc/module-ol_layer_Image-ImageLayer.html)和
95
117
  [ol/source/ImageStatic](https://openlayers.org/en/latest/apidoc/module-ol_source_ImageStatic-Static.html)一致,必须配置type:"imageStatic"以及id(自定义命名),id是图层的唯一标记,示例如下:
118
+
96
119
  ```typescript
97
120
  <script setup>
98
121
  import { VueOl } from "runbir-tools";
@@ -113,10 +136,14 @@ const options = ref({
113
136
  });
114
137
  </script>
115
138
  ```
139
+
116
140
  更新和删除同上
141
+
117
142
  ##### 2.3 point 散点配置
143
+
118
144
  point的options同[ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)和
119
145
  [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html)一致(仅支持ol/geom/Point,style样式除了ol内置style,还额外提供一个小组件风向杆),必须配置type:"point以及id(自定义命名),id是图层的唯一标记;示例如下:
146
+
120
147
  ```typescript
121
148
  <script setup>
122
149
  import { VueOl } from "runbir-tools";
@@ -160,37 +187,47 @@ const options = ref({
160
187
  });
161
188
  </script>
162
189
  ```
190
+
163
191
  更新删除同上
192
+
164
193
  ##### 2.3 typhoon 台风配置
194
+
165
195
  台风配置必须配置type:"typhoon以及id(自定义命名),id是图层的唯一标记,data数据格式只可以参考以下链接;示例如下:
196
+
166
197
  ```typescript
167
-     const typhoon = {
168
- "tsId": "764",
169
- "tscName": "罗莎",
170
- "tseName": "krosa",
171
- "intlId": "2509",
172
- "intId": "",
173
- "landOn": "",
174
- "origin": "",
175
- "meanings": "",
176
- "remark": "",
177
- "crtTime": "2025-08-03 15:54:22.0"
178
- }
179
-     const typhoonPath = (await getTyphoonPath('https://www.gzqxfw.com.cn/data/typhoon/2025/764.json')) as any
180
-     const data: any = { baseInfo: typhoon }
181
-     data.mainPath = 'BABJ' // 如果配置这项,则为单个台风单条路径(多用于面向公众系统);如果没有配置,则是单个台风多条路径(多用于内部系统)
182
-     typhoonPath.BABJ.color = '#ff0000'
183
-     typhoonPath.BCGZ.color = '#ff00ff'
184
-     typhoonPath.PGTW.color = '#91f4f5'
185
-     typhoonPath.RJTD.color = '#6eba39'
186
-     typhoonPath.VHHH.color = '#e39538'
187
-     data.data = typhoonPath
188
-     const ty = { id: 'typhoon', type: 'typhoon', data }
189
-     options.value.layers.push(ty)
198
+ const typhoon = {
199
+ tsId: '764',
200
+ tscName: '罗莎',
201
+ tseName: 'krosa',
202
+ intlId: '2509',
203
+ intId: '',
204
+ landOn: '',
205
+ origin: '',
206
+ meanings: '',
207
+ remark: '',
208
+ crtTime: '2025-08-03 15:54:22.0',
209
+ }
210
+ const typhoonPath = (await getTyphoonPath(
211
+ 'https://www.gzqxfw.com.cn/data/typhoon/2025/764.json',
212
+ )) as any
213
+ const data: any = { baseInfo: typhoon }
214
+ data.mainPath = 'BABJ' // 如果配置这项,则为单个台风单条路径(多用于面向公众系统);如果没有配置,则是单个台风多条路径(多用于内部系统)
215
+ typhoonPath.BABJ.color = '#ff0000'
216
+ typhoonPath.BCGZ.color = '#ff00ff'
217
+ typhoonPath.PGTW.color = '#91f4f5'
218
+ typhoonPath.RJTD.color = '#6eba39'
219
+ typhoonPath.VHHH.color = '#e39538'
220
+ data.data = typhoonPath
221
+ const ty = { id: 'typhoon', type: 'typhoon', data }
222
+ options.value.layers.push(ty)
190
223
  ```
224
+
191
225
  台风不提供更新、修改路径的功能(业务上很少有这种操作);删除同上
226
+
192
227
  #### 3. options.value.event 事件配置
228
+
193
229
  关于ol的事件,建议使用以下配置;由于包内部也应用了事件监听,为了节约系统开支,使用以下配置统一调度
230
+
194
231
  ```typescript
195
232
  const options = ref<any>({
196
233
      view: {....... },
@@ -203,9 +240,11 @@ const options = ref<any>({
203
240
      },
204
241
    })
205
242
  ```
243
+
206
244
  #### 4. 以上功能不满足的情况下,可以获取地图对象,进行自定义操作
207
245
 
208
246
  目前该组件只封装了一些常见的功能,在功能不满足使用的情况下,请获取地图对象,用原生ol编写代码;获取地图对象方法如下:
247
+
209
248
  ```typescript
210
249
  <script setup lang="ts">
211
250
    const getMapObject = (map: any) => {
@@ -215,4 +254,4 @@ const options = ref<any>({
215
254
  <template>
216
255
   <vue-ol :options="mapOptions" @ol-map="getMapObject" />
217
256
  </template>
218
- ```
257
+ ```
@@ -1,4 +1,4 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".map[data-v-fe2ef848]{width:100%;height:100%}@keyframes rotate-fe2ef848{0%{transform:rotate(0)}to{transform:rotate(360deg)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".map[data-v-92595ad3]{width:100%;height:100%}@keyframes rotate-92595ad3{0%{transform:rotate(0)}to{transform:rotate(360deg)}}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
2
  var ze = Object.defineProperty;
3
3
  var Ve = (s, e, t) => e in s ? ze(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
4
4
  var se = (s, e, t) => Ve(s, typeof e != "symbol" ? e + "" : e, t);
@@ -24189,7 +24189,7 @@ class Overlay extends BaseObject {
24189
24189
  const _hoisted_1 = {
24190
24190
  id: "map",
24191
24191
  class: "map"
24192
- }, _sfc_main = /* @__PURE__ */ defineComponent({
24192
+ }, transparentTile = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", _sfc_main = /* @__PURE__ */ defineComponent({
24193
24193
  __name: "VueOl",
24194
24194
  props: {
24195
24195
  options: {}
@@ -24249,8 +24249,8 @@ const _hoisted_1 = {
24249
24249
  "properties",
24250
24250
  "renderReprojectionEdges",
24251
24251
  "tileGridForProjection",
24252
- "tileUrlFunction"
24253
- // 'url', 当url资源为空时,页面不会显示为空
24252
+ "tileUrlFunction",
24253
+ "url"
24254
24254
  ]);
24255
24255
  }, updateImageStaticLayer = (s, e, t) => {
24256
24256
  updated(s, e, t, [
@@ -24337,7 +24337,7 @@ const _hoisted_1 = {
24337
24337
  for (const key in info)
24338
24338
  if (key === "source") {
24339
24339
  const keys = Object.keys(info.source), flag = keys.every((s) => sourceEffectiveFields.includes(s));
24340
- if (console.log(flag), flag)
24340
+ if (flag)
24341
24341
  for (const k in info.source)
24342
24342
  eval(`layer.getSource().set${capitalize(k)}(info.source[k])`);
24343
24343
  else {
@@ -24432,8 +24432,17 @@ const _hoisted_1 = {
24432
24432
  return delete i.data, new LayerGroup({ ...i, layers: t });
24433
24433
  }, getSource = (s) => {
24434
24434
  switch (s.type) {
24435
- case "xyz":
24436
- return new XYZ({ ...s.source });
24435
+ case "xyz": {
24436
+ const e = { ...s.source };
24437
+ return s.useInterimTilesWhenMissing && (e.transition = 0, e.tileLoadFunction = (t, i) => {
24438
+ const n = t.getImage(), r = document.createElement("img");
24439
+ e.crossOrigin !== void 0 && (r.crossOrigin = e.crossOrigin), r.onload = () => {
24440
+ n.src = i;
24441
+ }, r.onerror = () => {
24442
+ n.src = transparentTile;
24443
+ }, r.src = i;
24444
+ }), new XYZ(e);
24445
+ }
24437
24446
  case "imageStatic":
24438
24447
  return new Static({ ...s.source });
24439
24448
  case "point":
@@ -24652,7 +24661,7 @@ const _hoisted_1 = {
24652
24661
  for (const [i, n] of e)
24653
24662
  t[i] = n;
24654
24663
  return t;
24655
- }, VueOl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fe2ef848"]]), plugin = {
24664
+ }, VueOl = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-92595ad3"]]), plugin = {
24656
24665
  install(s) {
24657
24666
  s.component("VueOl", VueOl);
24658
24667
  }