电站概览地图定位到 龙源

This commit is contained in:
mmc
2026-06-17 21:05:35 +08:00
parent ec4005c1f8
commit 47cd30da5c
4 changed files with 46 additions and 20 deletions

View File

@@ -401,7 +401,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
} }
function displayPublishedLayers(publishedLayers, baseUrl) { function displayPublishedLayers(publishedLayers, baseUrl) {
console.log('已发布的图层:', publishedLayers) //console.log('已发布的图层:', publishedLayers)
publishedLayers.forEach((layer, index) => { publishedLayers.forEach((layer, index) => {
const [workspace, layerName] = layer.name.split(':'); const [workspace, layerName] = layer.name.split(':');
if (workspace && layerName) { if (workspace && layerName) {
@@ -490,9 +490,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const layerIdentifier = `${workspace}:${layerName}`; const layerIdentifier = `${workspace}:${layerName}`;
let baseUrl = wmsUrl; let baseUrl = wmsUrl;
const cesiumLayers = []; const cesiumLayers = [];
//if (index == 2) { if (index == 2) {
// flyToLayer(layerIdentifier, baseUrl); flyToLayer(layerIdentifier, baseUrl, 100);
//} }
//getLayerBoundsAndFit(wmsUrl, layerName); //getLayerBoundsAndFit(wmsUrl, layerName);
if (baseUrl.includes('/gwc/service/wms')) { if (baseUrl.includes('/gwc/service/wms')) {
@@ -597,10 +597,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
} }
} }
function flyToLayer(layerIdentifier, baseUrl) { function flyToLayer(layerIdentifier, baseUrl, flyHeight = 1000) {
console.log('定位到图层范围:', layerIdentifier); //console.log('开始获取图层范围', layerIdentifier);
if (!viewerRef.current) return;
const url = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`; const url = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`;
fetch(url) fetch(url)
@@ -608,6 +606,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
.then(xmlText => { .then(xmlText => {
const xml = new DOMParser().parseFromString(xmlText, 'text/xml'); const xml = new DOMParser().parseFromString(xmlText, 'text/xml');
const layerElements = xml.getElementsByTagName('Layer'); const layerElements = xml.getElementsByTagName('Layer');
let targetBbox = null;
for (let i = 0; i < layerElements.length; i++) { for (let i = 0; i < layerElements.length; i++) {
const layer = layerElements[i]; const layer = layerElements[i];
@@ -620,16 +619,36 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const miny = parseFloat(bboxElement.getAttribute('miny')); const miny = parseFloat(bboxElement.getAttribute('miny'));
const maxx = parseFloat(bboxElement.getAttribute('maxx')); const maxx = parseFloat(bboxElement.getAttribute('maxx'));
const maxy = parseFloat(bboxElement.getAttribute('maxy')); const maxy = parseFloat(bboxElement.getAttribute('maxy'));
targetBbox = [minx, miny, maxx, maxy];
const rectangle = window.Cesium.Rectangle.fromDegrees(minx, miny, maxx, maxy); console.log('读取到图层bbox', targetBbox);
viewerRef.current.camera.flyTo({
destination: rectangle,
duration: 2
});
} }
break; break;
} }
} }
if (!targetBbox) {
console.warn('该图层未找到BoundingBox,无法飞行', layerIdentifier);
return;
}
const [minx, miny, maxx, maxy] = targetBbox;
// 取图层中心点
const centerLon = (minx + maxx) / 2;
const centerLat = (miny + maxy) / 2;
viewerRef.current.camera.flyTo({
// 固定高度,第三个参数就是高度(单位米)
destination: window.Cesium.Cartesian3.fromDegrees(centerLon, centerLat, flyHeight),
orientation: {
heading: 0,
pitch: window.Cesium.Math.toRadians(-90), // 垂直俯视
roll: 0
},
duration: 2
});
})
.catch(err => {
console.error('获取WMS Capabilities失败', err);
}); });
} }
@@ -998,7 +1017,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
viewer.scene.requestRender(); viewer.scene.requestRender();
return; return;
} }
console.log(tracePoints, tracePointRef.current.getMode(), "mode1111111111");
const validPoints = tracePoints.filter(p => { const validPoints = tracePoints.filter(p => {
const lng = Number(p.lng); const lng = Number(p.lng);

View File

@@ -266,7 +266,6 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
...persistentDroneData, ...persistentDroneData,
}; };
}, [selectedDevice, uavState, persistentHostData, persistentDroneData?.wind_speed]); }, [selectedDevice, uavState, persistentHostData, persistentDroneData?.wind_speed]);
console.log('实时设备数据:', realtimeDevice);
// MQTT消息处理 // MQTT消息处理
const handleMqttMessage = (topic, message) => { const handleMqttMessage = (topic, message) => {

View File

@@ -15,6 +15,7 @@ import {
RobotOutlined RobotOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import { Line, Bar, Pie } from '@ant-design/charts'; import { Line, Bar, Pie } from '@ant-design/charts';
import CesiumMap from '../components/Map';
import { getWeatherData, getWeatherType } from '../lib/utils'; import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather'; import WeatherDisplay from '../components/Weather';
import bgMain from '../assets/images/bgmain.jpg'; import bgMain from '../assets/images/bgmain.jpg';
@@ -335,13 +336,16 @@ export default function StationDashboard() {
bodyStyle={{ padding: 0, position: 'relative', overflow: 'hidden', height: 500 }} bodyStyle={{ padding: 0, position: 'relative', overflow: 'hidden', height: 500 }}
> >
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}> <div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
<iframe {/*<iframe
src="https://pvs.satabot.com/?platform=web" src="https://pvs.satabot.com/?platform=web"
style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }} style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen allowFullScreen
title="外部系统" title="外部系统"
/> />*/}
<CesiumMap />
</div> </div>
</Card> </Card>

View File

@@ -15,6 +15,7 @@ import {
import { Line, Bar, Pie } from '@ant-design/charts'; import { Line, Bar, Pie } from '@ant-design/charts';
import bgMain from '../assets/images/bgmain.jpg'; import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts'; import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
import CesiumMap from '../components/Map';
const { Option } = Select; const { Option } = Select;
const { Search } = Input; const { Search } = Input;
@@ -122,7 +123,7 @@ const RealTimeMonitorPage = () => {
bodyStyle={{ padding: 0, position: 'relative', height: 400, overflow: 'hidden' }} bodyStyle={{ padding: 0, position: 'relative', height: 400, overflow: 'hidden' }}
> >
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}> <div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
<iframe {/*<iframe
src="https://pvs.satabot.com/?platform=web" src="https://pvs.satabot.com/?platform=web"
style={{ style={{
width: '100%', width: '100%',
@@ -134,7 +135,11 @@ const RealTimeMonitorPage = () => {
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen allowFullScreen
title="外部系统" title="外部系统"
/> />*/}
<CesiumMap />
</div> </div>
</Card> </Card>