|
|
@@ -208,23 +208,25 @@ export default {
|
|
|
// 将真实路口数据按状态类型分类
|
|
|
classifyIntersectionsByStatus() {
|
|
|
const remainingData = this.intersectionData;
|
|
|
- const normalStatusCount = 6;
|
|
|
- const abnormalStatusCount = 3;
|
|
|
- const chunkSize = Math.floor(remainingData.length / (normalStatusCount + abnormalStatusCount));
|
|
|
const maxAbnormalCount = 4;
|
|
|
+ // 异常状态各取4个,剩余全部按比例分配给6个正常状态
|
|
|
+ const abnormalTotal = maxAbnormalCount * 3;
|
|
|
+ const normalData = remainingData.slice(0, remainingData.length - abnormalTotal);
|
|
|
+ const abnormalData = remainingData.slice(remainingData.length - abnormalTotal);
|
|
|
+ const normalChunk = Math.ceil(normalData.length / 6);
|
|
|
|
|
|
this.statusIntersections = {
|
|
|
- "中心计划": remainingData.slice(0, 20),
|
|
|
+ "中心计划": normalData.slice(0, normalChunk),
|
|
|
"干线协调": [], // 清空,改为动态生成
|
|
|
"勤务路线": [], // 清空,改为动态生成
|
|
|
- "定周期控制": remainingData.slice(chunkSize, chunkSize * 2),
|
|
|
- "感应控制": remainingData.slice(chunkSize * 2, chunkSize * 3),
|
|
|
- "自适应控制": remainingData.slice(chunkSize * 3, chunkSize * 4),
|
|
|
- "手动控制": remainingData.slice(chunkSize * 4, chunkSize * 5),
|
|
|
- "特殊控制": remainingData.slice(chunkSize * 5, chunkSize * 6),
|
|
|
- "离线": remainingData.slice(chunkSize * 6, Math.min(chunkSize * 7, chunkSize * 6 + maxAbnormalCount)),
|
|
|
- "降级": remainingData.slice(chunkSize * 7, Math.min(chunkSize * 8, chunkSize * 7 + maxAbnormalCount)),
|
|
|
- "故障": remainingData.slice(chunkSize * 8, Math.min(chunkSize * 9, chunkSize * 8 + maxAbnormalCount))
|
|
|
+ "定周期控制": normalData.slice(normalChunk, normalChunk * 2),
|
|
|
+ "感应控制": normalData.slice(normalChunk * 2, normalChunk * 3),
|
|
|
+ "自适应控制": normalData.slice(normalChunk * 3, normalChunk * 4),
|
|
|
+ "手动控制": normalData.slice(normalChunk * 4, normalChunk * 5),
|
|
|
+ "特殊控制": normalData.slice(normalChunk * 5),
|
|
|
+ "离线": abnormalData.slice(0, maxAbnormalCount),
|
|
|
+ "降级": abnormalData.slice(maxAbnormalCount, maxAbnormalCount * 2),
|
|
|
+ "故障": abnormalData.slice(maxAbnormalCount * 2, maxAbnormalCount * 3)
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -336,6 +338,7 @@ export default {
|
|
|
const markers = intersections.map(item =>
|
|
|
this.createTrafficLightMarker([item["位置-经度"], item["位置-纬度"]], {
|
|
|
...config,
|
|
|
+ id: item["路口编号"],
|
|
|
road: item["路口名称"] || '规划路口'
|
|
|
})
|
|
|
).filter(Boolean);
|
|
|
@@ -1135,13 +1138,13 @@ export default {
|
|
|
const dx = markerPos[0] - targetLng;
|
|
|
const dy = markerPos[1] - targetLat;
|
|
|
const distSq = dx * dx + dy * dy;
|
|
|
-
|
|
|
+
|
|
|
// 容差范围内(约 20 米),寻找最接近的点
|
|
|
if (distSq < 0.000001) {
|
|
|
// 优先规则:如果距离相同或非常接近,优先选择异常状态点(离线/降级/故障)
|
|
|
const isAbnormal = ["离线", "降级", "故障"].includes(markerExt.name);
|
|
|
const currentIsAbnormal = bestMarker ? ["离线", "降级", "故障"].includes(bestMarker.getExtData().name) : false;
|
|
|
-
|
|
|
+
|
|
|
if (distSq < minDistanceSq || (isAbnormal && !currentIsAbnormal)) {
|
|
|
minDistanceSq = distSq;
|
|
|
bestMarker = item;
|
|
|
@@ -1162,6 +1165,34 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 通过路口编号定位到对应的 marker,弹出信息窗
|
|
|
+ focusById(id) {
|
|
|
+ if (!this.isMapReady() || !id) return null;
|
|
|
+
|
|
|
+ let bestMarker = null;
|
|
|
+ Object.values(this.routeGroups).forEach(group => {
|
|
|
+ if (!Array.isArray(group) || bestMarker) return;
|
|
|
+ group.forEach(item => {
|
|
|
+ if (bestMarker) return;
|
|
|
+ if (!(item instanceof this.AMap.Marker)) return;
|
|
|
+ const ext = item.getExtData();
|
|
|
+ if (ext.id === id || ext['路口编号'] === id) {
|
|
|
+ bestMarker = item;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ if (bestMarker) {
|
|
|
+ const finalPos = bestMarker.getPosition();
|
|
|
+ this.map.setZoomAndCenter(17, finalPos, false, 500);
|
|
|
+ setTimeout(() => {
|
|
|
+ if (!this.isComponentDestroyed) this.openLightInfo(bestMarker.getExtData(), finalPos);
|
|
|
+ }, 600);
|
|
|
+ return finalPos;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ },
|
|
|
+
|
|
|
toggleLegend() {
|
|
|
this.legendVisible = !this.legendVisible;
|
|
|
},
|