|
@@ -75,12 +75,12 @@
|
|
|
center:[25.222903, 113.25383],
|
|
center:[25.222903, 113.25383],
|
|
|
zoom:10, // 调小缩放级别,显示更大范围
|
|
zoom:10, // 调小缩放级别,显示更大范围
|
|
|
// 获取所有点的 API 地址
|
|
// 获取所有点的 API 地址
|
|
|
- getPoint:'/api/vector/export/all?table_name=le_data_block_map&format=geojson',
|
|
|
|
|
|
|
+ getPoint:'/api/vector/export/all?table_name=le_origin_ph_map&format=geojson',
|
|
|
geoserver:{
|
|
geoserver:{
|
|
|
url:'/geoserver',
|
|
url:'/geoserver',
|
|
|
workspace:'acidmap',
|
|
workspace:'acidmap',
|
|
|
layerGroup:'leshujukanbanmap',
|
|
layerGroup:'leshujukanbanmap',
|
|
|
- dataLayer:'le_data_block_map',
|
|
|
|
|
|
|
+ dataLayer:'le_origin_ph_map',
|
|
|
wmsUrl:'/geoserver/acidmap/wms',
|
|
wmsUrl:'/geoserver/acidmap/wms',
|
|
|
phField: 'ph_mean'
|
|
phField: 'ph_mean'
|
|
|
},
|
|
},
|
|
@@ -91,6 +91,22 @@
|
|
|
dataLayer:'le_data_reflux_result',
|
|
dataLayer:'le_data_reflux_result',
|
|
|
wmsUrl:'/geoserver/acidmap/wms',
|
|
wmsUrl:'/geoserver/acidmap/wms',
|
|
|
phField: 'le_data__4'
|
|
phField: 'le_data__4'
|
|
|
|
|
+ },
|
|
|
|
|
+ cdGeoserver:{
|
|
|
|
|
+ url:'/geoserver',
|
|
|
|
|
+ workspace:'acidmap',
|
|
|
|
|
+ layerGroup:'CropCd_block_map_with_boundary',
|
|
|
|
|
+ dataLayer:'Crop_cd_block_map',
|
|
|
|
|
+ wmsUrl:'/geoserver/acidmap/wms',
|
|
|
|
|
+ cdField: 'CropCd_mea'
|
|
|
|
|
+ },
|
|
|
|
|
+ reboundCdGeoserver:{
|
|
|
|
|
+ url:'/geoserver',
|
|
|
|
|
+ workspace:'acidmap',
|
|
|
|
|
+ layerGroup:'PrediCropCd_block_with_boundary',
|
|
|
|
|
+ dataLayer:'Predi_Cropcd_block',
|
|
|
|
|
+ wmsUrl:'/geoserver/acidmap/wms',
|
|
|
|
|
+ cdField: 'sceCropCd_'
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 图层配置已验证:正常地图使用 le_data_block_map,反酸地图使用 le_data_reflux_result
|
|
// 图层配置已验证:正常地图使用 le_data_block_map,反酸地图使用 le_data_reflux_result
|
|
@@ -154,9 +170,9 @@ function getPHComment(avgPH) {
|
|
|
if(!mapRef2.value) return
|
|
if(!mapRef2.value) return
|
|
|
map2 = L.map(mapRef2.value).setView(CONFIG.center,CONFIG.zoom)
|
|
map2 = L.map(mapRef2.value).setView(CONFIG.center,CONFIG.zoom)
|
|
|
|
|
|
|
|
- // 第二个地图展示 CropCd_block_map_with_boundary 图层
|
|
|
|
|
- wmsLayer2 = L.tileLayer.wms(CONFIG.geoserver.wmsUrl, {
|
|
|
|
|
- layers: `${CONFIG.geoserver.workspace}:CropCd_block_map_with_boundary`,
|
|
|
|
|
|
|
+ // 第二个地图展示 CD 图层
|
|
|
|
|
+ wmsLayer2 = L.tileLayer.wms(CONFIG.cdGeoserver.wmsUrl, {
|
|
|
|
|
+ layers: `${CONFIG.cdGeoserver.workspace}:${CONFIG.cdGeoserver.layerGroup}`,
|
|
|
format: 'image/png',
|
|
format: 'image/png',
|
|
|
transparent: true,
|
|
transparent: true,
|
|
|
version: '1.1.0',
|
|
version: '1.1.0',
|
|
@@ -168,15 +184,19 @@ function getPHComment(avgPH) {
|
|
|
|
|
|
|
|
async function switchMap(mapType) {
|
|
async function switchMap(mapType) {
|
|
|
if (!map || !wmsLayer) return
|
|
if (!map || !wmsLayer) return
|
|
|
|
|
+ if (!map2 || !wmsLayer2) return
|
|
|
|
|
+
|
|
|
|
|
+ console.log('🔄 开始切换地图,目标类型:', mapType)
|
|
|
|
|
+ console.log('️ map2 存在:', !!map2, 'wmsLayer2 存在:', !!wmsLayer2)
|
|
|
|
|
|
|
|
currentMapType.value = mapType
|
|
currentMapType.value = mapType
|
|
|
|
|
|
|
|
|
|
+ // 切换 pH 地图
|
|
|
const config = mapType === 'rebound' ? CONFIG.reboundGeoserver : CONFIG.geoserver
|
|
const config = mapType === 'rebound' ? CONFIG.reboundGeoserver : CONFIG.geoserver
|
|
|
|
|
+ console.log('📊 pH 配置:', config.layerGroup, config.dataLayer)
|
|
|
|
|
|
|
|
- // 移除旧的 WMS 图层
|
|
|
|
|
map.removeLayer(wmsLayer)
|
|
map.removeLayer(wmsLayer)
|
|
|
|
|
|
|
|
- // 创建新的 WMS 图层
|
|
|
|
|
wmsLayer = L.tileLayer.wms(config.wmsUrl, {
|
|
wmsLayer = L.tileLayer.wms(config.wmsUrl, {
|
|
|
layers: `${config.workspace}:${config.layerGroup}`,
|
|
layers: `${config.workspace}:${config.layerGroup}`,
|
|
|
format: 'image/png',
|
|
format: 'image/png',
|
|
@@ -186,11 +206,46 @@ function getPHComment(avgPH) {
|
|
|
attribution: '© GeoServer - Acidmap'
|
|
attribution: '© GeoServer - Acidmap'
|
|
|
}).addTo(map)
|
|
}).addTo(map)
|
|
|
|
|
|
|
|
- // console.log(`地图已切换到:${mapType === 'rebound' ? '反酸一周期后' : '实施降酸措施'}`)
|
|
|
|
|
- // console.log('新图层:', `${config.workspace}:${config.layerGroup}`)
|
|
|
|
|
|
|
+ console.log('✅ pH 地图图层已切换')
|
|
|
|
|
+
|
|
|
|
|
+ // 切换 CD 地图
|
|
|
|
|
+ const cdConfig = mapType === 'rebound' ? CONFIG.reboundCdGeoserver : CONFIG.cdGeoserver
|
|
|
|
|
+ console.log(' CD 配置:', cdConfig.layerGroup, cdConfig.dataLayer, cdConfig.cdField)
|
|
|
|
|
+ console.log('🔗 CD WMS 完整图层名:', `${cdConfig.workspace}:${cdConfig.layerGroup}`)
|
|
|
|
|
+
|
|
|
|
|
+ // 移除旧图层(和 pH 地图使用相同的方式)
|
|
|
|
|
+ map2.removeLayer(wmsLayer2)
|
|
|
|
|
+
|
|
|
|
|
+ // 创建新图层并添加到地图
|
|
|
|
|
+ wmsLayer2 = L.tileLayer.wms(cdConfig.wmsUrl, {
|
|
|
|
|
+ layers: `${cdConfig.workspace}:${cdConfig.layerGroup}`,
|
|
|
|
|
+ format: 'image/png',
|
|
|
|
|
+ transparent: true,
|
|
|
|
|
+ version: '1.1.0',
|
|
|
|
|
+ srs:'EPSG:4326',
|
|
|
|
|
+ attribution: '© GeoServer - Crop CD'
|
|
|
|
|
+ }).addTo(map2)
|
|
|
|
|
+
|
|
|
|
|
+ // 监听瓦片加载事件
|
|
|
|
|
+ wmsLayer2.on('tileload', function(e) {
|
|
|
|
|
+ console.log(' CD 瓦片加载成功:', e.tile.src)
|
|
|
|
|
+ })
|
|
|
|
|
+ wmsLayer2.on('tileerror', function(e) {
|
|
|
|
|
+ console.error(' CD 瓦片加载失败! 完整URL:', e.tile.src, '错误信息:', e.error)
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log('✅ CD 地图图层已切换,新图层:', wmsLayer2.options.layers)
|
|
|
|
|
+
|
|
|
|
|
+ // 刷新地图渲染
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ map2.invalidateSize()
|
|
|
|
|
+ wmsLayer2.redraw()
|
|
|
|
|
|
|
|
- // 重新加载对应地图的数据和统计
|
|
|
|
|
|
|
+ // 重新加载 pH 地图的数据和统计
|
|
|
await loadMapData()
|
|
await loadMapData()
|
|
|
|
|
+
|
|
|
|
|
+ // 重新加载 CD 地图的数据和统计
|
|
|
|
|
+ await loadCDData()
|
|
|
|
|
+ console.log('🎉 地图切换完成')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 加载当前地图类型的数据
|
|
// 加载当前地图类型的数据
|
|
@@ -354,6 +409,8 @@ async function loadCDStatistics() {
|
|
|
// 等待数据加载完成
|
|
// 等待数据加载完成
|
|
|
if (cdSampleData.value.length === 0) return;
|
|
if (cdSampleData.value.length === 0) return;
|
|
|
|
|
|
|
|
|
|
+ const cdConfig = currentMapType.value === 'rebound' ? CONFIG.reboundCdGeoserver : CONFIG.cdGeoserver
|
|
|
|
|
+
|
|
|
let cdCount = 0
|
|
let cdCount = 0
|
|
|
let avgCD = 0
|
|
let avgCD = 0
|
|
|
let safeCount = 0 // 0.0-0.2 mg/kg
|
|
let safeCount = 0 // 0.0-0.2 mg/kg
|
|
@@ -368,7 +425,7 @@ async function loadCDStatistics() {
|
|
|
|
|
|
|
|
cdSampleData.value.forEach(feature => {
|
|
cdSampleData.value.forEach(feature => {
|
|
|
// 获取 CD 含量和面积
|
|
// 获取 CD 含量和面积
|
|
|
- const cdValue = feature.properties.CropCd_mea
|
|
|
|
|
|
|
+ const cdValue = feature.properties[cdConfig.cdField]
|
|
|
const numericCd = typeof cdValue === 'string' ? parseFloat(cdValue) : cdValue
|
|
const numericCd = typeof cdValue === 'string' ? parseFloat(cdValue) : cdValue
|
|
|
const area = parseFloat(feature.properties.area) || 0
|
|
const area = parseFloat(feature.properties.area) || 0
|
|
|
|
|
|
|
@@ -441,7 +498,9 @@ async function loadCDStatistics() {
|
|
|
// 加载第二个地图的 CD 数据
|
|
// 加载第二个地图的 CD 数据
|
|
|
async function loadCDData() {
|
|
async function loadCDData() {
|
|
|
try {
|
|
try {
|
|
|
- const url = `${CONFIG.geoserver.url}/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${CONFIG.geoserver.workspace}:Crop_cd_block_map&outputFormat=application/json`
|
|
|
|
|
|
|
+ const cdConfig = currentMapType.value === 'rebound' ? CONFIG.reboundCdGeoserver : CONFIG.cdGeoserver
|
|
|
|
|
+
|
|
|
|
|
+ const url = `${cdConfig.url}/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${cdConfig.workspace}:${cdConfig.dataLayer}&outputFormat=application/json`
|
|
|
|
|
|
|
|
const response = await fetch(url);
|
|
const response = await fetch(url);
|
|
|
|
|
|