|
@@ -3,7 +3,9 @@ import * as layer from "ol/layer";
|
|
|
import * as style from "ol/style";
|
|
|
import * as ol from "ol";
|
|
|
import * as format from "ol/format";
|
|
|
+import * as geom from 'ol/geom'
|
|
|
import CommonStyle from "@/views/gis/map-info/style/common";
|
|
|
+import QyStyle from "@/views/gis/map-info/style/qy";
|
|
|
import SbStyle from "@/views/gis/map-info/style/sb";
|
|
|
import JqStyle from "@/views/gis/map-info/style/jq";
|
|
|
import LgStyle from "@/views/gis/map-info/style/lg";
|
|
@@ -11,6 +13,8 @@ import CzwStyle from "@/views/gis/map-info/style/czw";
|
|
|
import HczStyle from "@/views/gis/map-info/style/hcz";
|
|
|
import store from "@/store";
|
|
|
import axios from "axios";
|
|
|
+import {geometry} from "@turf/turf";
|
|
|
+import {formatPosition} from "@/utils/easyMap";
|
|
|
|
|
|
const state = {
|
|
|
menuRootName: '9cd5fbf9-35fd-4fb2-8c24-1f871afd67be',
|
|
@@ -30,6 +34,17 @@ const state = {
|
|
|
feature: null,
|
|
|
type: '',
|
|
|
info: {}
|
|
|
+ },
|
|
|
+ qy: {
|
|
|
+ layer: null,
|
|
|
+ source: null,
|
|
|
+ overlay: null,
|
|
|
+ feature: null,
|
|
|
+ type: '',
|
|
|
+ info: {},
|
|
|
+ analysisLayer: null,
|
|
|
+ analysisSource: null,
|
|
|
+ analysisCircle: null,
|
|
|
}
|
|
|
},
|
|
|
element: {
|
|
@@ -78,7 +93,9 @@ const state = {
|
|
|
// },
|
|
|
],
|
|
|
layer: null,
|
|
|
- }
|
|
|
+ },
|
|
|
+ l: null,
|
|
|
+ s: null
|
|
|
}
|
|
|
|
|
|
const getters = {
|
|
@@ -95,8 +112,9 @@ const mutations = {
|
|
|
const { show, name = null, code = null } = data
|
|
|
state.videoParams = { show, name, code }
|
|
|
},
|
|
|
- SET_GIS_MAP(state, {map, defaultDom}) {
|
|
|
+ SET_GIS_MAP(state, {map, defaultDom, qyDom}) {
|
|
|
state.map = map
|
|
|
+ // 基本要素
|
|
|
state.gisParams.default.source = new source.Vector()
|
|
|
state.gisParams.default.layer = new layer.Vector({
|
|
|
zIndex: 200,
|
|
@@ -116,6 +134,130 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
state.map.addOverlay(state.gisParams.default.overlay)
|
|
|
+ // 企业要素
|
|
|
+ state.gisParams.qy.source = new source.Vector()
|
|
|
+ state.gisParams.qy.layer = new layer.Vector({
|
|
|
+ zIndex: 202,
|
|
|
+ source: state.gisParams.qy.source,
|
|
|
+ })
|
|
|
+ state.gisParams.qy.layer.set('layerName', 'gisQy')
|
|
|
+ state.map.addLayer(state.gisParams.qy.layer)
|
|
|
+ state.gisParams.qy.overlay = new ol.Overlay({
|
|
|
+ id: 'gisQyDom',
|
|
|
+ element: qyDom.ref_dom,
|
|
|
+ autoPan: false,
|
|
|
+ offset: [0, -60],
|
|
|
+ positioning: 'bottom-center',
|
|
|
+ stopEvent: true,
|
|
|
+ autoPanAnimation: {
|
|
|
+ duration: 250
|
|
|
+ }
|
|
|
+ })
|
|
|
+ state.map.addOverlay(state.gisParams.qy.overlay)
|
|
|
+ // 企业-周边设备
|
|
|
+ state.gisParams.qy.analysisSource = new source.Vector()
|
|
|
+ state.gisParams.qy.analysisLayer = new layer.Vector({
|
|
|
+ zIndex: 202,
|
|
|
+ source: state.gisParams.qy.analysisSource,
|
|
|
+ style: [
|
|
|
+ new style.Style({
|
|
|
+ stroke: new style.Stroke({
|
|
|
+ color: '#2860F1',
|
|
|
+ width: 2,
|
|
|
+ lineDash: [10, 10]
|
|
|
+ }),
|
|
|
+ fill: new style.Fill({
|
|
|
+ color: 'rgba(20, 129, 241, 0.1)',
|
|
|
+ }),
|
|
|
+ })
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ state.gisParams.qy.analysisCircle = new ol.Feature()
|
|
|
+ state.map.addLayer(state.gisParams.qy.analysisLayer)
|
|
|
+
|
|
|
+
|
|
|
+ // mock
|
|
|
+ state.s = new source.Vector()
|
|
|
+ state.l = new layer.Vector({
|
|
|
+ zIndex: 9999,
|
|
|
+ source: state.s,
|
|
|
+ style: [
|
|
|
+ new style.Style({
|
|
|
+ stroke: new style.Stroke({
|
|
|
+ color: '#000000',
|
|
|
+ width: 2,
|
|
|
+ lineDash: [10, 10]
|
|
|
+ }),
|
|
|
+ fill: new style.Fill({
|
|
|
+ color: 'rgba(20, 129, 241, 0.1)',
|
|
|
+ }),
|
|
|
+ })
|
|
|
+ ]
|
|
|
+ });
|
|
|
+ state.map.addLayer(state.l)
|
|
|
+ },
|
|
|
+ SET_GIS_PARAMS_QY(state, {wkt, id, info, config = {}}: any) {
|
|
|
+ const {
|
|
|
+ isAnalysis = false
|
|
|
+ } = config
|
|
|
+ if (state.gisParams.qy.layer) {
|
|
|
+ state.gisParams.qy.source?.clear()
|
|
|
+ try {
|
|
|
+ const newFeat: any = new format.WKT().readFeature(wkt)
|
|
|
+ const obj = {
|
|
|
+ coordinates: newFeat.getGeometry().getCoordinates(),
|
|
|
+ tab: '1',
|
|
|
+ name: info.name,
|
|
|
+ 1: {
|
|
|
+ name: info.name,
|
|
|
+ people: info.lerep,
|
|
|
+ number: info.uniscid,
|
|
|
+ address: info.dom
|
|
|
+ },
|
|
|
+ 2: {},
|
|
|
+ 3: {},
|
|
|
+ 4: {},
|
|
|
+ 5: {
|
|
|
+ radius: 10,
|
|
|
+ center: newFeat.getGeometry().getCoordinates(),
|
|
|
+ tableData: [],
|
|
|
+ loading: false,
|
|
|
+ radiusTips: false
|
|
|
+ },
|
|
|
+ }
|
|
|
+ state.gisParams.qy.type = 'qy'
|
|
|
+ state.gisParams.qy.info = JSON.parse(JSON.stringify(obj))
|
|
|
+ let type
|
|
|
+ if (info.typeValue === 'lgszyjkscsb') {
|
|
|
+ type = 'lgszyjkscsb'
|
|
|
+ } else if (info.typeValue === 'jgzzmgs') {
|
|
|
+ type = 'jgzzmgs'
|
|
|
+ } else if (info.typeValue === 'lgsjkfzl') {
|
|
|
+ type = 'lgsjkyfl'
|
|
|
+ }
|
|
|
+ newFeat.set('defaultStyle', QyStyle.qyStyle(type))
|
|
|
+ newFeat.set('activeStyle', [...CommonStyle.activeStyle(), ...QyStyle.qyStyle(type)])
|
|
|
+ newFeat.set('analysisStyle', [...CommonStyle.analysisStyle(), ...QyStyle.qyStyle(type)])
|
|
|
+ newFeat.set('analysisActiveStyle', [...CommonStyle.activeStyle(), ...CommonStyle.analysisStyle(), ...QyStyle.qyStyle(type)])
|
|
|
+ newFeat.set('isAnalysis', isAnalysis)
|
|
|
+ newFeat.set('resetStyle', () => {
|
|
|
+ if (newFeat.get('isAnalysis')) {
|
|
|
+ newFeat.setStyle(newFeat.get('analysisStyle'))
|
|
|
+ } else {
|
|
|
+ newFeat.setStyle(newFeat.get('defaultStyle'))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ newFeat.get('resetStyle')()
|
|
|
+ newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.qy.type)))
|
|
|
+ newFeat.set('info', JSON.parse(JSON.stringify(state.gisParams.qy.info)))
|
|
|
+ newFeat.set('apiData', JSON.parse(JSON.stringify(info)))
|
|
|
+ newFeat.setId(id)
|
|
|
+ state.gisParams.qy.source.addFeature(newFeat)
|
|
|
+ state.gisParams.qy.overlay.setPosition(newFeat.getGeometry().getCoordinates())
|
|
|
+ } catch (e) {
|
|
|
+ console.log('异常数据:', wkt, info, e)
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
SET_GIS_PARAMS_DEFAULT_SB(state, {wkt, id, info, config}) {
|
|
|
const {
|
|
@@ -150,6 +292,7 @@ const mutations = {
|
|
|
newFeat.get('resetStyle')()
|
|
|
newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
newFeat.set('info', JSON.parse(JSON.stringify(state.gisParams.default.info)))
|
|
|
+ newFeat.set('apiData', JSON.parse(JSON.stringify(info)))
|
|
|
newFeat.setId(id)
|
|
|
state.gisParams.default.source.addFeature(newFeat)
|
|
|
state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
|
|
@@ -183,6 +326,7 @@ const mutations = {
|
|
|
newFeat.get('resetStyle')()
|
|
|
newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
newFeat.set('info', JSON.parse(JSON.stringify(state.gisParams.default.info)))
|
|
|
+ newFeat.set('apiData', JSON.parse(JSON.stringify(info)))
|
|
|
newFeat.setId(id)
|
|
|
state.gisParams.default.source.addFeature(newFeat)
|
|
|
state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
|
|
@@ -216,6 +360,7 @@ const mutations = {
|
|
|
newFeat.get('resetStyle')()
|
|
|
newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
newFeat.set('info', JSON.parse(JSON.stringify(state.gisParams.default.info)))
|
|
|
+ newFeat.set('apiData', JSON.parse(JSON.stringify(info)))
|
|
|
newFeat.setId(id)
|
|
|
state.gisParams.default.source.addFeature(newFeat)
|
|
|
state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
|
|
@@ -249,6 +394,7 @@ const mutations = {
|
|
|
newFeat.get('resetStyle')()
|
|
|
newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
newFeat.set('info', JSON.parse(JSON.stringify(state.gisParams.default.info)))
|
|
|
+ newFeat.set('apiData', JSON.parse(JSON.stringify(info)))
|
|
|
newFeat.setId(id)
|
|
|
state.gisParams.default.source.addFeature(newFeat)
|
|
|
state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
|
|
@@ -282,6 +428,7 @@ const mutations = {
|
|
|
newFeat.get('resetStyle')()
|
|
|
newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
newFeat.set('info', JSON.parse(JSON.stringify(state.gisParams.default.info)))
|
|
|
+ newFeat.set('apiData', JSON.parse(JSON.stringify(info)))
|
|
|
newFeat.setId(id)
|
|
|
state.gisParams.default.source.addFeature(newFeat)
|
|
|
state.gisParams.default.overlay.setPosition(newFeat.getGeometry().getCoordinates())
|
|
@@ -299,7 +446,7 @@ const mutations = {
|
|
|
}
|
|
|
},
|
|
|
SET_GIS_ELEMENT(state) {
|
|
|
- const arr = []
|
|
|
+ const arr: any = []
|
|
|
state.element.list.forEach(p => {
|
|
|
if (p.children?.length > 0) {
|
|
|
p.children.forEach(s => {
|
|
@@ -321,7 +468,7 @@ const mutations = {
|
|
|
'VERSION': '1.1.1',
|
|
|
"exceptions": 'application/vnd.ogc.se_inimage',
|
|
|
refresh: new Date().getTime(),
|
|
|
- LAYERS: 'mysqlGeo:socialManagementEement',
|
|
|
+ LAYERS: 'mysqlGeo:socialManagementElement',
|
|
|
CQL_FILTER: cql
|
|
|
}
|
|
|
})
|
|
@@ -334,26 +481,51 @@ const mutations = {
|
|
|
state.map.on('singleclick', e => {
|
|
|
if (state.element.list.some(v => v.active)) {
|
|
|
let isFeature = false
|
|
|
- e.map.forEachFeatureAtPixel(e.pixel, (feature) => {
|
|
|
- console.log(feature)
|
|
|
- isFeature = true
|
|
|
- }, {
|
|
|
- hitTolerance: 0,
|
|
|
- });
|
|
|
- axios.get(`/${store.state.app.apiProxy.geoserverApi}/geoserver/rest/layers`)
|
|
|
+ // e.map.forEachFeatureAtPixel(e.pixel, (feature) => {
|
|
|
+ // console.log(feature)
|
|
|
+ // isFeature = true
|
|
|
+ // }, {
|
|
|
+ // hitTolerance: 0,
|
|
|
+ // });
|
|
|
if (!isFeature) {
|
|
|
const viewResolution = e.map.getView().getResolution()
|
|
|
+ console.log(viewResolution)
|
|
|
const url = state.element.layer.getSource().getFeatureInfoUrl(e.coordinate, viewResolution, 'EPSG:4326', {
|
|
|
'INFO_FORMAT': 'application/json',
|
|
|
'FEATURE_COUNT': 10000
|
|
|
})
|
|
|
+ console.log(url)
|
|
|
+ const BBOX = decodeURIComponent(url.split('?')[1].split('&').filter(v => v.includes('BBOX'))[0].split('=')[1]).split(',')
|
|
|
+ const wkt = [
|
|
|
+ [BBOX[0], BBOX[3]],
|
|
|
+ [BBOX[2], BBOX[3]],
|
|
|
+ [BBOX[2], BBOX[1]],
|
|
|
+ [BBOX[0], BBOX[1]],
|
|
|
+ [BBOX[0], BBOX[3]],
|
|
|
+ ]
|
|
|
+
|
|
|
+ const f = new format.WKT().readFeature(formatPosition.cpnTwpn([wkt]))
|
|
|
+
|
|
|
+ state.s.clear()
|
|
|
+ state.s.addFeature(f)
|
|
|
+
|
|
|
+ console.log(BBOX)
|
|
|
if (url) {
|
|
|
axios.get(url).then(res => {
|
|
|
if (res.status === 200) {
|
|
|
- console.log(res.data.features.length)
|
|
|
const item = res.data?.features?.[res.data?.features?.length - 1]
|
|
|
- console.log(item)
|
|
|
if (item) {
|
|
|
+ console.log(item)
|
|
|
+ if (['lgszyjkscsb', 'jgzzmgs', 'lgsjkfzl'].includes(item.properties.typeValue)) {
|
|
|
+ console.log('企业')
|
|
|
+ store.commit('gis/SET_GIS_PARAMS_QY', {
|
|
|
+ wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
|
|
|
+ id: item.properties.id,
|
|
|
+ info: item.properties
|
|
|
+ })
|
|
|
+ } else if (['gal', 'shl', 'myl'].includes(item.properties.typeValue)) {
|
|
|
+ console.log('设备')
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -371,9 +543,9 @@ const actions = {
|
|
|
LOAD_ACTIVE_QY_ID({ commit }: any, id: any) {
|
|
|
commit('SET_ACTIVE_QY_ID', id)
|
|
|
},
|
|
|
- LOAD_GIS_MAP({ commit }: any, {map, defaultDom}: any) {
|
|
|
+ LOAD_GIS_MAP({ commit }: any, {map, defaultDom, qyDom}: any) {
|
|
|
if (!state.map) {
|
|
|
- commit('SET_GIS_MAP', {map, defaultDom})
|
|
|
+ commit('SET_GIS_MAP', {map, defaultDom, qyDom})
|
|
|
}
|
|
|
},
|
|
|
LOAD_GIS_PARAMS_DEFAULT({ commit }: any, {type, wkt, id, info, config = {}}: any) {
|