跳到主要内容

开启连通性分析

开启管线连通性分析。

涉及接口
  1. 设置管线点击事件监听
  2. 高亮管线
  3. 添加Marker
代码示例
let startGuid = null;
let endGuid = null;

mapmostUE.setOnPipelineClickListener(function (val) {
let {location, type} = val;

if (type.indexOf('_point') > -1){
var notyf = new Notyf({
position:{
x:'center',
y:'top'
}
});
notyf.error('连通性不支持点选管点,请重新选择管段')
return;
}

if (type.indexOf('_line') > -1){
type = type.substring(0,type.indexOf('_line'));
} else if (type.indexOf('_point') > -1){
type = type.substring(0,type.indexOf('_point'));
} else {
return;
}
if (startGuid === null){
mapmostUE.unhighlightPipeline();
mapmostUE.removeMarker("startMarker");
mapmostUE.removeMarker("endMarker");
mapmostUE.addMarker("startMarker",{
"name": "检测点1",
"type": "classic",
"location": [location[0],location[1],location[2]],
"iconImage": "http://xxx.xxx.xx.xxx/XiXi/icon/monitor.png",
"bgColor": "#669966",
"enableAutoFlyTo": false,
"imageUrl":""
})
// 管线信息查询接口,返回包括guid,起始点,形状,管径
let url = "http://xxx.xxx.xx.xxx/SIPPipe/SIPPipe/getPipeLineInfo?lng=" + location[0] + "&lat=" + location[1] + "&height=" + location[2] + "&type=" + val.type;
fetch(url).then(res => res.json()).then(response => {
console.log(url)
startGuid = response.data[0].guid;
});
} else if (endGuid === null){
mapmostUE.removeMarker("endMarker");
mapmostUE.addMarker("endMarker",{
"name": "检测点2",
"type": "classic",
"location": [location[0],location[1],location[2]],
"iconImage": "http://xxx.xxx.xx.xxx/XiXi/icon/monitor.png",
"bgColor": "#669966",
"enableAutoFlyTo": false,
"imageUrl":""
})
// 管线信息查询接口,返回包括guid,起始点,形状,管径
let url = "http://xxx.xxx.xx.xxx/SIPPipe/SIPPipe/getPipeLineInfo?lng=" + location[0] + "&lat=" + location[1] + "&height=" + location[2] + "&type=" + val.type;
fetch(url).then(res => res.json()).then(response => {
console.log(response.data)
endGuid = response.data[0].guid;

// 判断是否为同一管段,如果是,不查询,给出提示
if (startGuid === endGuid) {
var notyf = new Notyf({
position:{
x:'center',
y:'top'
}
});
notyf.error('2个检测点为同一管段,请重新选择')
startGuid = null
endGuid = null
return;
}

// 查询连通性
let url = "http://xxx.xxx.xx.xxx/SIPPipe/SIPPipe/pipelineAnls/getConnectivity?startGuid=" + startGuid + "&endGuid=" + endGuid + "&pipeType=" + type;
console.log(url)
fetch(url).then(res => res.json()).then(response => {
console.log(response.data)
if (response.data.length === 0){
var notyf = new Notyf({
position:{
x:'center',
y:'top'
}
});
notyf.error('该两点不连通')
return
}
for (let i = 0; i < response.data.length; i++) {
console.log(response.data[i])
// 高亮所有返回的管段
mapmostUE.highlightPipeline(response.data[i])
}
});

startGuid = null;
endGuid = null;
});
}

});
效果
show