| | |
| | | }); |
| | | }, intervalTime); |
| | | } |
| | | |
| | | // 获取隐患点清单 |
| | | export async function getDangerPoint(data) { |
| | | const response = await axios.post("/hp/sinoDzHiddenDangerPoint/getData", { |
| | | filterObject: { |
| | | year: 2024, // 动态传入的年份参数 |
| | | }, |
| | | }); |
| | | console.log("getDangerPoint:", response); |
| | | return response.data; |
| | | } |
| | | // 获取避险位置 |
| | | export async function getSafeLocation(data) { |
| | | const response = await axios.post("/hp/safeHavenLocation/getData", { |
| | | filterObject: { |
| | | year: 2024, // 动态传入的年份参数 |
| | | }, |
| | | }); |
| | | console.log("getSafeLocation:", response); |
| | | return response.data; |
| | | } |
| | | // 获取避险线路 |
| | | export async function getEscapeRoute(data) { |
| | | const response = await axios.post("/hp/escapeRoute/getData", { |
| | | filterObject: { |
| | | year: 2024, // 动态传入的年份参数 |
| | | }, |
| | | }); |
| | | console.log("getEscapeRoute:", response); |
| | | return response.data; |
| | | } |
| | | // 获取传感器列表 |
| | | export async function getSensor(data) { |
| | | const response = await axios.post("/hp/sensor/getData", { |
| | | filterObject: { |
| | | year: 2024, // 动态传入的年份参数 |
| | | }, |
| | | }); |
| | | console.log("getSensor:", response); |
| | | return response.data; |
| | | } |
| | | // 获取雨量数据 |
| | | export async function getRainfallData(year) { |
| | | try { |
| | | export async function getRainfallData(data) { |
| | | const response = await axios.post("/hp/rainfallCountyCity/getData", { |
| | | filterObject: { |
| | | year: 2024, // 动态传入的年份参数 |
| | | }, |
| | | }); |
| | | console.log("Response:", response); // 打印完整响应(调试用) |
| | | return response.data; // 假设后端返回的数据在 response.data 中 |
| | | } catch (error) { |
| | | console.error( |
| | | "Error fetching rainfall data:", |
| | | error.response ? error.response.data : error.message |
| | | ); |
| | | throw error; // 抛出错误以便调用方处理 |
| | | } |
| | | console.log("getRainfallData:", response); |
| | | return response.data; |
| | | } |
| | |
| | | /** |
| | | * 将普通经纬度数组转换为标准的 MULTIPOLYGON WKT 格式 |
| | | * @param {Array<Array<number>>} coordinates - 经纬度数组,每个元素是一个 [经度, 纬度] 的点 |
| | | * 将多个多边形的经纬度数组转换为标准的 MULTIPOLYGON WKT 格式 |
| | | * @param {Array<Array<Array<number>>>} multiPolygonCoordinates - 多个多边形的坐标数组 |
| | | * @returns {string} 标准化的 WKT 格式字符串 |
| | | */ |
| | | export function convertToWKT(coordinates) { |
| | | export function convertToWKT(multiPolygonCoordinates) { |
| | | // 检查输入是否为非空数组 |
| | | if (!Array.isArray(coordinates) || coordinates.length === 0) { |
| | | throw new Error("Invalid input: 'coordinates' must be a non-empty array of [longitude, latitude] points."); |
| | | if (!Array.isArray(multiPolygonCoordinates) || multiPolygonCoordinates.length === 0) { |
| | | throw new Error("Invalid input: 'multiPolygonCoordinates' must be a non-empty array of polygons."); |
| | | } |
| | | |
| | | // 转换每个多边形的坐标 |
| | | const polygons = multiPolygonCoordinates.map(polygon => { |
| | | if (!Array.isArray(polygon) || polygon.length === 0) { |
| | | throw new Error("Invalid input: Each polygon must be a non-empty array of [longitude, latitude] points."); |
| | | } |
| | | |
| | | // 检查每个点是否是有效的 [经度, 纬度] 数组 |
| | | for (const point of coordinates) { |
| | | for (const point of polygon) { |
| | | if (!Array.isArray(point) || point.length !== 2 || typeof point[0] !== "number" || typeof point[1] !== "number") { |
| | | throw new Error("Invalid input: Each coordinate must be an array of two numbers [longitude, latitude]."); |
| | | } |
| | | } |
| | | |
| | | // 将经纬度数组转换为 WKT 格式的坐标字符串 |
| | | const wktCoordinates = coordinates |
| | | .map(([longitude, latitude]) => `${longitude} ${latitude}`) |
| | | .join(","); |
| | | // 将每个多边形的坐标转换为 WKT 格式的字符串 |
| | | return `((${polygon.map(([lng, lat]) => `${lng} ${lat}`).join(",")}))`; |
| | | }); |
| | | |
| | | // 构建标准的 MULTIPOLYGON WKT 格式 |
| | | return `MULTIPOLYGON(((${wktCoordinates})))`; |
| | | return `MULTIPOLYGON(${polygons.join(",")})`; |
| | | } |
| | |
| | | } = storeToRefs(simStore); |
| | | const { init, startYHGL, startZHJC, startMNFZ, startMNPG } = simStore; |
| | | // 模拟的经纬度数组 |
| | | const coordinates = [ |
| | | const multiPolygonCoordinates = [ |
| | | [ |
| | | [120.123456, 30.654321], |
| | | [120.234567, 30.765432], |
| | | [120.345678, 30.876543], |
| | | [120.123456, 30.654321] |
| | | [120.123456, 30.654321] // 闭合点 |
| | | ], |
| | | [ |
| | | [121.111111, 31.222222], |
| | | [121.333333, 31.444444], |
| | | [121.555555, 31.666666], |
| | | [121.111111, 31.222222] // 闭合点 |
| | | ] |
| | | ]; |
| | | |
| | | |
| | |
| | | setupTokenRefresh()// 获取宏图token |
| | | getData() //测试tr后端 |
| | | try { |
| | | const wktResult = convertToWKT(coordinates); |
| | | const wktResult = convertToWKT(multiPolygonCoordinates); |
| | | console.log(wktResult); |
| | | // 输出: MULTIPOLYGON(((120.123456 30.654321,120.234567 30.765432,120.345678 30.876543,120.123456 30.654321))) |
| | | } catch (error) { |
| | |
| | | |
| | | /* 自定义 Dialog 的 z-index */ |
| | | .custom-dialog { |
| | | z-index: 3000 !important; |
| | | z-index: 5000 !important; |
| | | /* 确保对话框覆盖其他元素 */ |
| | | } |
| | | </style> |