|
@@ -16,6 +16,11 @@ import axios from "axios";
|
|
|
import {geometry} from "@turf/turf";
|
|
|
import {formatPosition} from "@/utils/easyMap";
|
|
|
|
|
|
+const formatWkt = (wkt) => {
|
|
|
+ return wkt.split(',').join('\\\,')
|
|
|
+}
|
|
|
+const featureTypeKey = 'featureType'
|
|
|
+
|
|
|
const state = {
|
|
|
menuRootName: '9cd5fbf9-35fd-4fb2-8c24-1f871afd67be',
|
|
|
isTooling: false,
|
|
@@ -45,6 +50,8 @@ const state = {
|
|
|
analysisLayer: null,
|
|
|
analysisSource: null,
|
|
|
analysisCircle: null,
|
|
|
+ analysisWKT: '',
|
|
|
+ analysisDeviceLayer: null
|
|
|
}
|
|
|
},
|
|
|
element: {
|
|
@@ -112,10 +119,14 @@ const mutations = {
|
|
|
},
|
|
|
SET_GIS_MAP(state, {map, defaultDom, qyDom}) {
|
|
|
state.map = map
|
|
|
+ state.element.layer = new layer.Tile({
|
|
|
+ zIndex: 10,
|
|
|
+ })
|
|
|
+ state.map.addLayer(state.element.layer)
|
|
|
// 基本要素
|
|
|
state.gisParams.default.source = new source.Vector()
|
|
|
state.gisParams.default.layer = new layer.Vector({
|
|
|
- zIndex: 200,
|
|
|
+ zIndex: 40,
|
|
|
source: state.gisParams.default.source,
|
|
|
})
|
|
|
state.gisParams.default.layer.set('layerName', 'gisDefault')
|
|
@@ -135,7 +146,7 @@ const mutations = {
|
|
|
// 企业要素
|
|
|
state.gisParams.qy.source = new source.Vector()
|
|
|
state.gisParams.qy.layer = new layer.Vector({
|
|
|
- zIndex: 202,
|
|
|
+ zIndex: 50,
|
|
|
source: state.gisParams.qy.source,
|
|
|
})
|
|
|
state.gisParams.qy.layer.set('layerName', 'gisQy')
|
|
@@ -155,7 +166,7 @@ const mutations = {
|
|
|
// 企业-周边设备
|
|
|
state.gisParams.qy.analysisSource = new source.Vector()
|
|
|
state.gisParams.qy.analysisLayer = new layer.Vector({
|
|
|
- zIndex: 202,
|
|
|
+ zIndex: 20,
|
|
|
source: state.gisParams.qy.analysisSource,
|
|
|
style: [
|
|
|
new style.Style({
|
|
@@ -171,7 +182,102 @@ const mutations = {
|
|
|
]
|
|
|
});
|
|
|
state.gisParams.qy.analysisCircle = new ol.Feature()
|
|
|
+ state.gisParams.qy.analysisCircle.set(featureTypeKey, 'analysisCircle')
|
|
|
state.map.addLayer(state.gisParams.qy.analysisLayer)
|
|
|
+ state.gisParams.qy.analysisDeviceLayer = new layer.Tile({
|
|
|
+ zIndex: 30
|
|
|
+ })
|
|
|
+ state.map.addLayer(state.gisParams.qy.analysisDeviceLayer)
|
|
|
+ const clickQy = (e, feat) => {
|
|
|
+ if (state.gisParams.qy.overlay.getPosition() === undefined) {
|
|
|
+ state.gisParams.qy.overlay.setPosition(state.gisParams.qy.feature.getGeometry().getCoordinates())
|
|
|
+ } else {
|
|
|
+ state.gisParams.qy.overlay.setPosition(undefined)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const clickDefault = (e, feat) => {
|
|
|
+ if (state.gisParams.default.overlay.getPosition() === undefined) {
|
|
|
+ state.gisParams.default.overlay.setPosition(state.gisParams.default.feature.getGeometry().getCoordinates())
|
|
|
+ } else {
|
|
|
+ state.gisParams.default.overlay.setPosition(undefined)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const clickAnalysisCircle = (e, feat) => {
|
|
|
+ const viewResolution = e.map.getView().getResolution()
|
|
|
+ const url = state.gisParams.qy.analysisDeviceLayer.getSource().getFeatureInfoUrl(e.coordinate, viewResolution, 'EPSG:4326', {
|
|
|
+ 'INFO_FORMAT': 'application/json',
|
|
|
+ 'FEATURE_COUNT': 10000
|
|
|
+ })
|
|
|
+ if (url) {
|
|
|
+ axios.get(url).then(res => {
|
|
|
+ if (res.status === 200) {
|
|
|
+ const item = res.data?.features?.[res.data?.features?.length - 1]
|
|
|
+ if (item) {
|
|
|
+ store.commit('gis/SET_GIS_PARAMS_DEFAULT_SB', {
|
|
|
+ wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
|
|
|
+ id: item.properties.elementId,
|
|
|
+ info: item.properties,
|
|
|
+ config: {
|
|
|
+ isAnalysis: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ state.map.on('singleclick', e => {
|
|
|
+ let isFeature = false
|
|
|
+ e.map.forEachFeatureAtPixel(e.pixel, (feature) => {
|
|
|
+ if (!isFeature) {
|
|
|
+ switch (feature.get(featureTypeKey)) {
|
|
|
+ case 'qy': clickQy(e, feature)
|
|
|
+ break
|
|
|
+ case 'sb': clickDefault(e, feature)
|
|
|
+ break
|
|
|
+ case 'analysisCircle': clickAnalysisCircle(e, feature)
|
|
|
+ break
|
|
|
+ }
|
|
|
+ isFeature = true
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ hitTolerance: 0,
|
|
|
+ });
|
|
|
+ if (state.element.list.some(v => v.active)) {
|
|
|
+ if (!isFeature) {
|
|
|
+ const viewResolution = e.map.getView().getResolution()
|
|
|
+ const url = state.element.layer.getSource().getFeatureInfoUrl(e.coordinate, viewResolution, 'EPSG:4326', {
|
|
|
+ 'INFO_FORMAT': 'application/json',
|
|
|
+ 'FEATURE_COUNT': 10000
|
|
|
+ })
|
|
|
+ if (url) {
|
|
|
+ axios.get(url).then(res => {
|
|
|
+ if (res.status === 200) {
|
|
|
+ const item = res.data?.features?.[res.data?.features?.length - 1]
|
|
|
+ if (item) {
|
|
|
+ console.log(item)
|
|
|
+ if (['lgszyjkscsb', 'jgzzmgs', 'lgsjkfzl'].includes(item.properties.typeValue)) {
|
|
|
+ store.commit('gis/SET_GIS_PARAMS_QY_RESET')
|
|
|
+ store.commit('gis/SET_GIS_PARAMS_QY', {
|
|
|
+ wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
|
|
|
+ id: item.properties.elementId,
|
|
|
+ info: item.properties
|
|
|
+ })
|
|
|
+ } else if (['gal', 'shl', 'myl'].includes(item.properties.typeValue)) {
|
|
|
+ store.commit('gis/SET_GIS_PARAMS_DEFAULT_RESET')
|
|
|
+ store.commit('gis/SET_GIS_PARAMS_DEFAULT_SB', {
|
|
|
+ wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
|
|
|
+ id: item.properties.elementId,
|
|
|
+ info: item.properties
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
SET_GIS_PARAMS_QY(state, {wkt, id, info, config = {}}: any) {
|
|
|
const {
|
|
@@ -214,8 +320,8 @@ const mutations = {
|
|
|
}
|
|
|
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('analysisStyle', [...QyStyle.qyAnalysisStyle(type)])
|
|
|
+ newFeat.set('analysisActiveStyle', [...CommonStyle.activeStyle(), ...QyStyle.qyAnalysisStyle(type)])
|
|
|
newFeat.set('isAnalysis', isAnalysis)
|
|
|
newFeat.set('resetStyle', () => {
|
|
|
if (newFeat.get('isAnalysis')) {
|
|
@@ -225,7 +331,7 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
newFeat.get('resetStyle')()
|
|
|
- newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.qy.type)))
|
|
|
+ newFeat.set(featureTypeKey, 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)
|
|
@@ -247,11 +353,20 @@ const mutations = {
|
|
|
state.gisParams.qy.feature = null
|
|
|
// 周边设备清除样式
|
|
|
state.gisParams.qy.analysisSource.clear()
|
|
|
+ state.gisParams.qy.analysisDeviceLayer.setSource(null)
|
|
|
+ state.gisParams.qy.analysisWKT = ''
|
|
|
state.gisParams.default.feature?.set('isAnalysis', false)
|
|
|
state.gisParams.default.feature?.get('resetStyle')()
|
|
|
store.commit('gis/SET_GIS_ELEMENT')
|
|
|
}
|
|
|
},
|
|
|
+ SET_GIS_PARAMS_QY_ANALYSIS(state) {
|
|
|
+ if (state.gisParams.qy.analysisDeviceLayer) {
|
|
|
+ state.gisParams.qy.analysisWKT = formatPosition.cpnTwpn(state.gisParams.qy.analysisCircle.getGeometry().getCoordinates())
|
|
|
+ store.commit('gis/SET_GIS_ELEMENT')
|
|
|
+ store.commit('gis/SET_GIS_ANALYSIS_ELEMENT')
|
|
|
+ }
|
|
|
+ },
|
|
|
SET_GIS_PARAMS_DEFAULT_SB(state, {wkt, id, info, config = {}}: any) {
|
|
|
const {
|
|
|
isAnalysis = false
|
|
@@ -272,8 +387,8 @@ const mutations = {
|
|
|
}
|
|
|
newFeat.set('defaultStyle', SbStyle.sbStyle(type))
|
|
|
newFeat.set('activeStyle', [...CommonStyle.activeStyle(), ...SbStyle.sbStyle(type)])
|
|
|
- newFeat.set('analysisStyle', [...CommonStyle.analysisStyle(), ...SbStyle.sbStyle(type)])
|
|
|
- newFeat.set('analysisActiveStyle', [...CommonStyle.activeStyle(), ...CommonStyle.analysisStyle(), ...SbStyle.sbStyle(type)])
|
|
|
+ newFeat.set('analysisStyle', [...SbStyle.sbAnalysisStyle(type)])
|
|
|
+ newFeat.set('analysisActiveStyle', [...CommonStyle.activeStyle(), ...SbStyle.sbAnalysisStyle(type)])
|
|
|
newFeat.set('isAnalysis', isAnalysis)
|
|
|
newFeat.set('resetStyle', () => {
|
|
|
if (newFeat.get('isAnalysis')) {
|
|
@@ -283,7 +398,7 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
newFeat.get('resetStyle')()
|
|
|
- newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
+ newFeat.set(featureTypeKey, 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)
|
|
@@ -319,7 +434,7 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
newFeat.get('resetStyle')()
|
|
|
- newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
+ newFeat.set(featureTypeKey, 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)
|
|
@@ -355,7 +470,7 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
newFeat.get('resetStyle')()
|
|
|
- newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
+ newFeat.set(featureTypeKey, 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)
|
|
@@ -391,7 +506,7 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
newFeat.get('resetStyle')()
|
|
|
- newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
+ newFeat.set(featureTypeKey, 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)
|
|
@@ -427,7 +542,7 @@ const mutations = {
|
|
|
}
|
|
|
})
|
|
|
newFeat.get('resetStyle')()
|
|
|
- newFeat.set('featureType', JSON.parse(JSON.stringify(state.gisParams.default.type)))
|
|
|
+ newFeat.set(featureTypeKey, 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)
|
|
@@ -465,7 +580,7 @@ const mutations = {
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- const cql: any = []
|
|
|
+ const cql: any = ["(geoType = 2)"]
|
|
|
cql.push(`(typeValue in (${arr.length > 0 ? arr.join(',') : -1}))`)
|
|
|
const notIds: Array<string> = []
|
|
|
if (state.gisParams.default.feature) {
|
|
@@ -477,6 +592,10 @@ const mutations = {
|
|
|
if (notIds.length > 0) {
|
|
|
cql.push(`(elementId not in (${notIds.join(',')}))`)
|
|
|
}
|
|
|
+ let vp: null | string = null
|
|
|
+ if (state.gisParams.qy.analysisWKT) {
|
|
|
+ vp = `locationValue:${formatWkt(state.gisParams.qy.analysisWKT)}`
|
|
|
+ }
|
|
|
const tileWMS = new source.TileWMS({
|
|
|
url: `/${store.state.app.apiProxy.geoserverApi}/geoserver/mysqlGeo/wms`,
|
|
|
params: {
|
|
@@ -484,60 +603,41 @@ const mutations = {
|
|
|
'VERSION': '1.1.1',
|
|
|
"exceptions": 'application/vnd.ogc.se_inimage',
|
|
|
refresh: new Date().getTime(),
|
|
|
+ // LAYERS: 'mysqlGeo:gis-test',
|
|
|
LAYERS: 'mysqlGeo:socialManagementElement',
|
|
|
+ viewparams: vp,
|
|
|
CQL_FILTER: `(${cql.join(' and ')})`
|
|
|
}
|
|
|
})
|
|
|
- if (!state.element.layer) {
|
|
|
- state.element.layer = new layer.Tile({
|
|
|
- source: tileWMS,
|
|
|
- zIndex: 2,
|
|
|
- })
|
|
|
- state.map.addLayer(state.element.layer)
|
|
|
- state.map.on('singleclick', e => {
|
|
|
- if (state.element.list.some(v => v.active)) {
|
|
|
- let isFeature = false
|
|
|
- e.map.forEachFeatureAtPixel(e.pixel, (feature) => {
|
|
|
- isFeature = true
|
|
|
- }, {
|
|
|
- hitTolerance: 0,
|
|
|
- });
|
|
|
- if (!isFeature) {
|
|
|
- const viewResolution = e.map.getView().getResolution()
|
|
|
- const url = state.element.layer.getSource().getFeatureInfoUrl(e.coordinate, viewResolution, 'EPSG:4326', {
|
|
|
- 'INFO_FORMAT': 'application/json',
|
|
|
- 'FEATURE_COUNT': 10000
|
|
|
- })
|
|
|
- if (url) {
|
|
|
- axios.get(url).then(res => {
|
|
|
- if (res.status === 200) {
|
|
|
- const item = res.data?.features?.[res.data?.features?.length - 1]
|
|
|
- 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.elementId,
|
|
|
- info: item.properties
|
|
|
- })
|
|
|
- } else if (['gal', 'shl', 'myl'].includes(item.properties.typeValue)) {
|
|
|
- console.log('设备')
|
|
|
- store.commit('gis/SET_GIS_PARAMS_DEFAULT_SB', {
|
|
|
- wkt: `POINT(${item.geometry.coordinates.join(' ')})`,
|
|
|
- id: item.properties.elementId,
|
|
|
- info: item.properties
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
+ state.element.layer.setSource(tileWMS)
|
|
|
+ },
|
|
|
+ SET_GIS_ANALYSIS_ELEMENT(state) {
|
|
|
+ if (state.gisParams.qy.analysisWKT) {
|
|
|
+ const cql: any = ["(geoType = 1)", "(typeValue in ('gal', 'shl', 'myl'))"]
|
|
|
+ const notIds: Array<string> = []
|
|
|
+ if (state.gisParams.default.feature) {
|
|
|
+ notIds.push(`'${state.gisParams.default.feature.getId()}'`)
|
|
|
+ }
|
|
|
+ if (state.gisParams.qy.feature) {
|
|
|
+ notIds.push(`'${state.gisParams.qy.feature.getId()}'`)
|
|
|
+ }
|
|
|
+ if (notIds.length > 0) {
|
|
|
+ cql.push(`(elementId not in (${notIds.join(',')}))`)
|
|
|
+ }
|
|
|
+
|
|
|
+ const tileWMS = new source.TileWMS({
|
|
|
+ url: `/${store.state.app.apiProxy.geoserverApi}/geoserver/mysqlGeo/wms`,
|
|
|
+ params: {
|
|
|
+ 'FORMAT': 'image/png8',
|
|
|
+ 'VERSION': '1.1.1',
|
|
|
+ "exceptions": 'application/vnd.ogc.se_inimage',
|
|
|
+ refresh: new Date().getTime(),
|
|
|
+ LAYERS: 'mysqlGeo:socialManagementElement',
|
|
|
+ viewparams: `locationValue:${formatWkt(state.gisParams.qy.analysisWKT)}`,
|
|
|
+ CQL_FILTER: `(${cql.join(' and ')})`
|
|
|
}
|
|
|
})
|
|
|
- } else {
|
|
|
- state.element.layer.setSource(tileWMS)
|
|
|
+ state.gisParams.qy.analysisDeviceLayer.setSource(tileWMS)
|
|
|
}
|
|
|
}
|
|
|
}
|