xsh_1997 1 miesiąc temu
rodzic
commit
b7c9ff9c54

+ 1 - 1
ruoyi-screen/.env.development

@@ -21,7 +21,7 @@ VITE_GIS_ACCESS_TOKEN=8XughK9JVapV1pqaE7HnxfHiKGrLy21L9LbsKskL
21 21
 VITE_GIS_WMTS_LAYER=baqing_wp
22 22
 # 瓦片边长:256 
23 23
 VITE_GIS_TILE_SIZE=256
24
-VITE_GIS_DEFAULT_CENTER=94.046223,31.920382
24
+VITE_GIS_DEFAULT_CENTER=94.054094,31.920244
25 25
 VITE_GIS_DEFAULT_ZOOM=14
26 26
 VITE_GIS_MIN_ZOOM=7
27 27
 # 地图最大缩放;建议与瓦片最高级别一致,避免放到顶过采样缺图

+ 1 - 1
ruoyi-screen/.env.production

@@ -20,7 +20,7 @@ VITE_GIS_BASE_URL=https://bqxm.alafarms.com/agis-api
20 20
 VITE_GIS_ACCESS_TOKEN=8XughK9JVapV1pqaE7HnxfHiKGrLy21L9LbsKskL
21 21
 VITE_GIS_WMTS_LAYER=baqing_wp
22 22
 VITE_GIS_TILE_SIZE=256
23
-VITE_GIS_DEFAULT_CENTER=94.046223,31.920382
23
+VITE_GIS_DEFAULT_CENTER=94.052462,31.921188
24 24
 VITE_GIS_DEFAULT_ZOOM=14
25 25
 VITE_GIS_MIN_ZOOM=7
26 26
 VITE_GIS_MAX_ZOOM=20

+ 1 - 1
ruoyi-screen/src/api/weather.js

@@ -1,6 +1,6 @@
1 1
 import axios from 'axios'
2 2
 
3
-const WEATHER_API_URL = 'http://gfeljm.tianqiapi.com/api'
3
+const WEATHER_API_URL = 'https://gfeljm.tianqiapi.com/api'
4 4
 
5 5
 /** 将 win_meter(如 10km/h)转为 m/s 展示 */
6 6
 export function parseWinMeterToMs(winMeter) {

+ 14 - 58
ruoyi-screen/src/components/GisMap.vue

@@ -47,8 +47,6 @@ const containerRef = ref(null)
47 47
 
48 48
 let map = null
49 49
 let cmmapglRef = null
50
-let zoomLogTimer = null
51
-let lastMouseZoomLogAt = 0
52 50
 let clampingZoom = false
53 51
 let unbindWheelZoom = null
54 52
 
@@ -61,62 +59,30 @@ let wheelDebounceTimer = null
61 59
 let lastWheelAround = null
62 60
 let poiMarkers = []
63 61
 
64
-function formatLngLat(lngLat) {
62
+function logClickCoordinate(lngLat) {
65 63
   if (!lngLat) {
66
-    return '—'
64
+    return
67 65
   }
68 66
   const lng = Number(lngLat.lng ?? lngLat[0])
69 67
   const lat = Number(lngLat.lat ?? lngLat[1])
70 68
   if (!Number.isFinite(lng) || !Number.isFinite(lat)) {
71
-    return '—'
72
-  }
73
-  return `[${lng.toFixed(6)}, ${lat.toFixed(6)}]`
74
-}
75
-
76
-function logMapState(source, cursorLngLat) {
77
-  if (!map || typeof map.getZoom !== 'function') {
78 69
     return
79 70
   }
80
-  const z = map.getZoom()
81
-  const zoomText = Number.isFinite(z) ? z.toFixed(2) : String(z)
82
-  const center = typeof map.getCenter === 'function' ? map.getCenter() : null
83
-  const parts = [
84
-    `[GIS] ${source}`,
85
-    `zoom: ${zoomText}`,
86
-    `center: ${formatLngLat(center)}`
87
-  ]
88
-  if (cursorLngLat) {
89
-    parts.push(`point: ${formatLngLat(cursorLngLat)}`)
90
-  }
91
-  console.log(parts.join(' | '))
71
+  console.log(
72
+    `[GIS] click | lng: ${lng.toFixed(6)}, lat: ${lat.toFixed(6)} | [${lng.toFixed(6)}, ${lat.toFixed(6)}]`
73
+  )
92 74
 }
93 75
 
94
-function bindZoomDebugListeners() {
76
+function bindMapListeners() {
95 77
   if (!map) {
96 78
     return
97 79
   }
98
-  map.on('load', () => logMapState('load'))
99 80
   map.on('zoomend', () => {
100 81
     snapZoomToLimits()
101
-    logMapState('zoomend')
102
-  })
103
-  map.on('moveend', () => logMapState('moveend'))
104
-  map.on('wheel', () => {
105
-    if (zoomLogTimer) {
106
-      clearTimeout(zoomLogTimer)
107
-    }
108
-    zoomLogTimer = setTimeout(() => logMapState('wheel'), 80)
109
-  })
110
-  map.on('mousemove', (e) => {
111
-    const now = Date.now()
112
-    if (now - lastMouseZoomLogAt < 300) {
113
-      return
114
-    }
115
-    lastMouseZoomLogAt = now
116
-    logMapState('mousemove', e.lngLat)
117 82
   })
118 83
   map.on('click', (e) => {
119
-    logMapState('click', e.lngLat)
84
+    logClickCoordinate(e.lngLat)
85
+    emit('click', e)
120 86
   })
121 87
 }
122 88
 
@@ -172,20 +138,16 @@ function createPoiMarkerElement(name) {
172 138
   return wrap
173 139
 }
174 140
 
175
-async function renderNearbyPoiMarkers() {
141
+async function renderPoiMarkers() {
176 142
   if (!props.showPoiMarkers || !map || !cmmapglRef) {
177 143
     return
178 144
   }
179 145
   clearPoiMarkers()
180 146
 
181
-  const center = resolveCenter()
182 147
   let pois = []
183 148
   try {
184 149
     pois = await searchNearbyPois({
185
-      center,
186
-      radius: 5000,
187
-      pageSize: 50,
188
-      pageNum: 1
150
+      center: resolveCenter()
189 151
     })
190 152
   } catch {
191 153
     return
@@ -220,17 +182,12 @@ async function renderNearbyPoiMarkers() {
220 182
 }
221 183
 
222 184
 function destroyMap() {
223
-  if (zoomLogTimer) {
224
-    clearTimeout(zoomLogTimer)
225
-    zoomLogTimer = null
226
-  }
227 185
   if (typeof unbindWheelZoom === 'function') {
228 186
     unbindWheelZoom()
229 187
     unbindWheelZoom = null
230 188
   }
231 189
   wheelDeltaAccum = 0
232 190
   lastWheelAround = null
233
-  lastMouseZoomLogAt = 0
234 191
   clampingZoom = false
235 192
   clearPoiMarkers()
236 193
   if (map) {
@@ -461,7 +418,7 @@ async function initMap() {
461 418
     if (props.showScale) {
462 419
       map.addControl(new cmmapgl.ScaleControl({ unit: 'metric' }), 'bottom-left')
463 420
     }
464
-    bindZoomDebugListeners()
421
+    bindMapListeners()
465 422
     bindZoomClampListener()
466 423
     unbindWheelZoom = bindDebouncedWheelZoom()
467 424
     configureScrollZoom()
@@ -470,10 +427,9 @@ async function initMap() {
470 427
       configureScrollZoom()
471 428
       snapZoomToLimits()
472 429
       resizeMap()
473
-      renderNearbyPoiMarkers()
430
+      renderPoiMarkers()
474 431
       emit('ready', map)
475 432
     })
476
-    map.on('click', (e) => emit('click', e))
477 433
     // 瓦片/遥测等非致命错误不向页面报错
478 434
     map.on('error', () => {})
479 435
   } catch {
@@ -490,7 +446,7 @@ watch(
490 446
       zoom: resolveZoom()
491 447
     })
492 448
     if (props.showPoiMarkers) {
493
-      renderNearbyPoiMarkers()
449
+      renderPoiMarkers()
494 450
     }
495 451
   },
496 452
   { deep: true }
@@ -501,7 +457,7 @@ watch(
501 457
   (show) => {
502 458
     if (!map || !cmmapglRef) return
503 459
     if (show) {
504
-      renderNearbyPoiMarkers()
460
+      renderPoiMarkers()
505 461
     } else {
506 462
       clearPoiMarkers()
507 463
     }

+ 20 - 10
ruoyi-screen/src/utils/gisPoiSearch.js

@@ -18,6 +18,15 @@ export function parsePoiLngLat(location) {
18 18
   return [lng, lat]
19 19
 }
20 20
 
21
+function normalizePoiList(data) {
22
+  if (data?.status !== POI_STATUS_OK || !Array.isArray(data?.body?.pois)) {
23
+    return []
24
+  }
25
+  return data.body.pois
26
+    .map((row) => row?.poi || row)
27
+    .filter((poi) => poi && typeof poi === 'object')
28
+}
29
+
21 30
 /**
22 31
  * 周边搜索(GIS 接口文档 §2.2 /agis/search/v1/pois/region)
23 32
  * @param {{ center?: [number, number], radius?: number, pageNum?: number, pageSize?: number }} [options]
@@ -31,9 +40,9 @@ export async function searchNearbyPois(options = {}) {
31 40
 
32 41
   const center = options.center || getGisDefaultCenter()
33 42
   const [longitude, latitude] = center
34
-  const radius = options.radius ?? 3000
43
+  const radius = options.radius ?? 5000
35 44
   const pageNum = options.pageNum ?? 1
36
-  const pageSize = options.pageSize ?? 20
45
+  const pageSize = options.pageSize ?? 1000
37 46
 
38 47
   const params = new URLSearchParams({
39 48
     longitude: String(longitude),
@@ -50,12 +59,13 @@ export async function searchNearbyPois(options = {}) {
50 59
     return []
51 60
   }
52 61
 
53
-  const data = await res.json()
54
-  if (data?.status !== POI_STATUS_OK || !Array.isArray(data?.body?.pois)) {
55
-    return []
56
-  }
57
-
58
-  return data.body.pois
59
-    .map((row) => row?.poi || row)
60
-    .filter((poi) => poi && typeof poi === 'object')
62
+  return normalizePoiList(await res.json())
61 63
 }
64
+
65
+/*
66
+ * 多边形区域搜索(GIS 接口文档 §2.3)— 暂不使用
67
+ *
68
+ * export const BA_QING_POI_POLYGON = [...]
69
+ * export function formatPolygonParam(points) { ... }
70
+ * export async function searchPolygonPois(options = {}) { ... }
71
+ */

+ 1 - 1
scripts/parse-gis-api-doc.mjs

@@ -18,7 +18,7 @@ function strip(chunk) {
18 18
 }
19 19
 
20 20
 const text = strip(x)
21
-const keys = ['周边', '2.2', 'longitude', 'latitude', 'radius', 'page_size', 'pageSize', 'POI', '搜索', 'nearby', 'agis']
21
+const keys = ['多边形', 'polygon', '周边', '2.2', '2.3', 'longitude', 'latitude', 'radius', 'page_size', 'pageSize', 'POI', '搜索', 'nearby', 'agis/pois']
22 22
 
23 23
 for (const k of keys) {
24 24
   const i = text.indexOf(k)