import {
|
getProperty
|
} from '@/api/gisserverApi.js'
|
const identifyTool = {
|
handle: null,
|
storeyHighlights: [],
|
start: (callback) => {
|
// identifyTool.close()
|
|
identifyTool.handle = sgworld.coreMap.screenSpaceEventHandler.setInputAction(click => {
|
console.log("console")
|
var pickedFeature = sgworld.coreMap.scene.pick(click.position);
|
window.sgworld.coreMap.scene.bim.PickId(click.position.x, click.position.y).then(idArr => {
|
if (!pickedFeature) {
|
callback()
|
return
|
}
|
if (identifyTool.checkModelisNull(idArr)) {
|
if (!pickedFeature._content) {
|
callback()
|
return
|
}
|
if (pickedFeature._content._model) {
|
callback(pickedFeature, pickedFeature._content._model.type)
|
return
|
}
|
} else {
|
let modelId = idArr[0]
|
let instancesId = idArr[1]
|
let componentId = idArr[2]
|
|
if (identifyTool.storeyHighlights.length > 0) {
|
identifyTool.storeyHighlights.forEach(highlight => {
|
let idInt32Array = new Int32Array(highlight)
|
window.sgworld.coreMap.scene.bim.SetComponentStatus(1, idInt32Array, false)
|
});
|
identifyTool.storeyHighlights = []
|
}
|
|
let idInt32Array = new Int32Array([modelId, componentId])
|
window.sgworld.coreMap.scene.bim.SetComponentStatus(2, idInt32Array, false)
|
identifyTool.storeyHighlights.push([modelId, componentId])
|
getProperty({
|
id: componentId
|
}, modelId).then(res => {
|
callback(res, 'bim')
|
})
|
}
|
|
})
|
sgworld.coreMap.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
identifyTool.handle = null
|
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
},
|
close: () => {
|
if (identifyTool.handle) {
|
sgworld.coreMap.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
identifyTool.handle = null
|
}
|
|
if (identifyTool.storeyHighlights.length > 0) {
|
identifyTool.storeyHighlights.forEach(highlight => {
|
let idInt32Array = new Int32Array(highlight)
|
window.sgworld.coreMap.scene.bim.SetComponentStatus(1, idInt32Array, false)
|
});
|
identifyTool.storeyHighlights = []
|
}
|
},
|
checkModelisNull(array) {
|
return (array[0] === 0 && array[1] === 0 && array[2] === 0 && array[3] === 0)
|
}
|
}
|
|
export default identifyTool
|