| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2022-08-18 17:00:30 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2023-04-18 18:11:01 |
| | | * @LastEditTime: 2023-04-18 19:31:36 |
| | | * @FilePath: \srs-police-affairs\src\components\map\index.vue |
| | | * @Description: 公用地图组件 |
| | | * |
| | |
| | | // global.viewer.addTerrain(terrain) |
| | | |
| | | // 内网 |
| | | that.switchImg() |
| | | // that.switchImg() |
| | | |
| | | // 地形数据添加 |
| | | that.addTerrain() |
| | | // that.addTerrain() |
| | | |
| | | // 外网 |
| | | // global.viewer.imageryLayers.addImageryProvider( |
| | | // new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | // url: 'http://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=d083e4cf30bfc438ef93436c10c2c20a', |
| | | // subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], |
| | | // format: 'image/jpeg', |
| | | // show: true, |
| | | // maximumLevel: 18 |
| | | // }) |
| | | // ) |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | url: 'http://t{s}.tianditu.gov.cn/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=d083e4cf30bfc438ef93436c10c2c20a', |
| | | subdomains: ['0', '1', '2', '3', '4', '5', '6', '7'], |
| | | format: 'image/jpeg', |
| | | show: true, |
| | | maximumLevel: 18 |
| | | }) |
| | | ) |
| | | |
| | | // 设置地图初始位置,角度等 |
| | | global.viewer.camera.setView({ |
| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2023-03-31 10:52:25 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2023-04-04 15:55:33 |
| | | * @LastEditTime: 2023-04-18 20:13:04 |
| | | * @FilePath: \srs-police-affairs\src\utils\turfPolygon.js |
| | | * @Description: |
| | | * |
| | |
| | | */ |
| | | import * as turf from '@turf/turf' |
| | | |
| | | export const computerCapacity = (data, type) => { |
| | | if (type == 'region') { |
| | | console.log('computerCapacity', data) |
| | | const pointArr = data.reduce((pre, cur) => { |
| | | cur.position && JSON.parse(cur.position).coordinates[0][0].forEach(item => { |
| | | console.log(item, 959) |
| | | item[0] && item[1] && pre.push(turf.point(item)) |
| | | }) |
| | | function getAllRegionCenter (data) { |
| | | let arr = [] |
| | | |
| | | return pre |
| | | }, []) |
| | | data.forEach(item => { |
| | | if (item.position && item.position.length > 0) { |
| | | arr.push(getRegionCenter(item.position)) |
| | | } |
| | | }) |
| | | |
| | | arr.push(arr[0]) |
| | | |
| | | if (arr.length == 1) { |
| | | return arr[0] |
| | | } else if (arr.length == 2) { |
| | | |
| | | return turf.centroid(turf.midpoint(turf.point(arr[0]), turf.point(arr[1]))).geometry.coordinates |
| | | } else { |
| | | arr.push(arr[0]) |
| | | |
| | | return turf.centroid(turf.polygon([arr])).geometry.coordinates |
| | | } |
| | | } |
| | | |
| | | function getRegionCenter (params) { |
| | | let arr = [] |
| | | |
| | | params.forEach(areaArray => { |
| | | JSON.parse(areaArray).coordinates.forEach(item => { |
| | | arr.push(turf.centroid(turf.polygon([item[0]])).geometry.coordinates) |
| | | }) |
| | | }) |
| | | |
| | | if (arr.length == 1) { |
| | | return arr[0] |
| | | } else if (arr.length == 2) { |
| | | |
| | | return turf.centroid(turf.midpoint(turf.point(arr[0]), turf.point(arr[1]))).geometry.coordinates |
| | | } else { |
| | | arr.push(arr[0]) |
| | | |
| | | return turf.centroid(turf.polygon([arr])).geometry.coordinates |
| | | } |
| | | } |
| | | |
| | | |
| | | const features = turf.featureCollection(pointArr) |
| | | |
| | | const scope = turf.envelope(features).bbox |
| | | export const computerCapacity = (data, type = '') => { |
| | | |
| | | const poly = turf.polygon([[[scope[0], scope[1]], [scope[0], scope[3]], [scope[2], scope[1]], [scope[2], scope[3]]]]) |
| | | if (type != '') { |
| | | |
| | | const scaledPoly = turf.transformScale(poly, 3) |
| | | const center = getAllRegionCenter(data) |
| | | |
| | | console.log(scope, scaledPoly, 5555) |
| | | if (type == 'all') { |
| | | |
| | | global.viewer.flyToPosition( |
| | | new global.DC.Position( |
| | | Number(center[0] + 0.03), |
| | | Number(center[1] - 0.30), |
| | | Number(36000), |
| | | Number(-3), |
| | | Number(-45), |
| | | Number(0) |
| | | ), |
| | | function () { }, |
| | | 3 |
| | | ) |
| | | |
| | | } else { |
| | | |
| | | global.viewer.flyToPosition( |
| | | new global.DC.Position( |
| | | Number(center[0] + 0.0046), |
| | | Number(center[1] - 0.04), |
| | | Number(4000), |
| | | Number(-3), |
| | | Number(-45), |
| | | Number(0) |
| | | ), |
| | | function () { }, |
| | | 3 |
| | | ) |
| | | |
| | | } |
| | | } else { |
| | | let pointArr = [] |
| | | console.log('data', data) |
| | | data.forEach(item => { |
| | | if (item.longitude && item.latitude) { |
| | | pointArr.push(turf.point([item.longitude, item.latitude])) |
| | |
| | | const features = turf.featureCollection(pointArr) |
| | | |
| | | const scope = turf.envelope(features).bbox |
| | | |
| | | console.log(scope, 5555) |
| | | |
| | | // const poly = turf.polygon([[[0, 29], [3.5, 29], [2.5, 32], [0, 29]]]) |
| | | |
| | |
| | | * @Author: shuishen 1109946754@qq.com |
| | | * @Date: 2023-03-24 16:36:55 |
| | | * @LastEditors: shuishen 1109946754@qq.com |
| | | * @LastEditTime: 2023-04-17 17:32:41 |
| | | * @LastEditTime: 2023-04-18 20:12:05 |
| | | * @FilePath: \srs-police-affairs\src\views\activity\index.vue |
| | | * @Description: |
| | | * |
| | |
| | | import publicIndex from './components/publicIndex.vue' |
| | | import { initMapPosition } from '@/utils/mapPositionInit' |
| | | import { computerCapacity } from "@/utils/turfPolygon.js" |
| | | import { getPoliceStationTree } from '@/api/home/' |
| | | |
| | | |
| | | let regionAllData = [] |
| | | let loading = null |
| | | |
| | | let cameraList = [] |
| | |
| | | this.activeDeleteLineOrPoint(type) |
| | | }) |
| | | |
| | | getPoliceStationTree(1).then(res => { |
| | | regionAllData = res.data.data |
| | | }) |
| | | }, |
| | | |
| | | mounted () { |
| | |
| | | type: 'HeatLayer' |
| | | }) |
| | | |
| | | if (e2.checkedNodes.some(item => item.$treeNodeId == e1.$treeNodeId)) { |
| | | if (this.userInfo.dept_id == '1123598813738675201') { |
| | | |
| | | computerCapacity(regionAllData, 'all') |
| | | } else { |
| | | let arr = regionAllData.find(item => item.id == this.userInfo.dept_id) |
| | | |
| | | // 获取图标中心跳转 |
| | | computerCapacity([arr], 'single') |
| | | } |
| | | } |
| | | |
| | | |
| | | if (e1.label == '热力图' && e2.checkedKeys.some(item => { |
| | | return item == 777 |
| | | })) { |
| | |
| | | } else if (e1.label == '执法记录仪') { |
| | | iconArr = policeCarmeraList |
| | | } |
| | | // 获取图标中心跳转 |
| | | computerCapacity(iconArr, 'icon') |
| | | |
| | | } |
| | | }, |