合并代码

This commit is contained in:
yiqiuyang
2025-10-27 09:54:17 +08:00
parent 0ed458cb08
commit ffe45a240d

View File

@ -436,9 +436,7 @@ export default {
} }
}, },
async mounted() { async mounted() {
[...document.querySelectorAll('*')].forEach(n => ;[...document.querySelectorAll('*')].forEach((n) => console.log(window.getComputedStyle(n).fontFamily))
console.log(window.getComputedStyle(n).fontFamily)
)
this.viewer = null this.viewer = null
await this.getMapOption() await this.getMapOption()
this.$nextTick(async () => { this.$nextTick(async () => {
@ -481,7 +479,7 @@ export default {
}, },
defaultLabelStyle: { defaultLabelStyle: {
font: '16px "DengXian",sans-serif', font: '16px "DengXian",sans-serif',
} },
// basemaps: [ // basemaps: [
// { // {
// id: "image-tdss", // id: "image-tdss",
@ -1281,9 +1279,7 @@ export default {
this.viaPoints = this.viaPoints.filter((viaPoint) => viaPoint.style.time !== row.time) this.viaPoints = this.viaPoints.filter((viaPoint) => viaPoint.style.time !== row.time)
} else { } else {
if (this.viaPoints.length > 0) { if (this.viaPoints.length > 0) {
const graphic = this.viaPoints.find( const graphic = this.viaPoints.find((viaPoint) => viaPoint.style.time === row.time)
(viaPoint) => viaPoint.style.time === row.time
)
this.updatePointPosition(graphic, row.points) this.updatePointPosition(graphic, row.points)
} else { } else {
const time = new Date().getTime() const time = new Date().getTime()
@ -1304,9 +1300,7 @@ export default {
this.avoidPoints = this.avoidPoints.filter((avoidPoint) => avoidPoint.style.time !== row.time) this.avoidPoints = this.avoidPoints.filter((avoidPoint) => avoidPoint.style.time !== row.time)
} else { } else {
if (this.avoidPoints.length > 0) { if (this.avoidPoints.length > 0) {
const graphic = this.avoidPoints.find( const graphic = this.avoidPoints.find((avoidPoint) => avoidPoint.style.time === row.time)
(avoidPoint) => avoidPoint.style.time === row.time
)
this.updatePointPosition(graphic, row.points) this.updatePointPosition(graphic, row.points)
} else { } else {
const time = new Date().getTime() const time = new Date().getTime()
@ -1327,9 +1321,7 @@ export default {
this.avoidAreas = this.avoidAreas.filter((avoidArea) => avoidArea.style.time !== row.time) this.avoidAreas = this.avoidAreas.filter((avoidArea) => avoidArea.style.time !== row.time)
} else { } else {
if (this.avoidAreas.length > 0) { if (this.avoidAreas.length > 0) {
const graphic = this.avoidAreas.find( const graphic = this.avoidAreas.find((avoidArea) => avoidArea.style.time === row.time)
(avoidArea) => avoidArea.style.time === row.time
)
this.updatePolygonPosition(graphic, row.points) this.updatePolygonPosition(graphic, row.points)
} else { } else {
const time = new Date().getTime() const time = new Date().getTime()
@ -1910,93 +1902,15 @@ export default {
const coordsToUse = isForward ? segCoords : [...segCoords].reverse() const coordsToUse = isForward ? segCoords : [...segCoords].reverse()
// === 使用第一个版本的精细连接逻辑,但加入第二个版本的途经点切片 === // === 使用第一个版本的精细连接逻辑,但加入第二个版本的途经点切片 ===
const lastPt = segmentPath[segmentPath.length - 1];
const firstOfSeg = coordsToUse[0];
const lastPt = segmentPath[segmentPath.length - 1] const lastPt = segmentPath[segmentPath.length - 1]
const firstOfSeg = coordsToUse[0] const firstOfSeg = coordsToUse[0]
const distLastToFirst = this.calculateDistance(lastPt, firstOfSeg);
// 如果是途经点,需要找到终点垂足在当前位置
const endPerpNearest = this.findNearestPointWithIndex(coordsToUse, endConnection.perpendicularPoint);
const endNi = endPerpNearest.index;
const distLastToFirst = this.calculateDistance(lastPt, firstOfSeg) const distLastToFirst = this.calculateDistance(lastPt, firstOfSeg)
// 如果是途经点,需要找到终点垂足在当前位置 // 如果是途经点,需要找到终点垂足在当前位置
const endPerpNearest = this.findNearestPointWithIndex(coordsToUse, endConnection.perpendicularPoint) const endPerpNearest = this.findNearestPointWithIndex(coordsToUse, endConnection.perpendicularPoint)
const endNi = endPerpNearest.index const endNi = endPerpNearest.index
if (distLastToFirst < 1e-6) {
// 精度上相同,直接接上(跳过第一个)
// 如果是途经点,需要切片到垂足
if (endConnection.type === 'via') {
segmentPath.push(...coordsToUse.slice(1, endNi + 1));
// 保存垂直点之后的路网后半截
viaPerpRemainingCoords = coordsToUse.slice(endNi);
} else {
segmentPath.push(...coordsToUse.slice(1));
}
} else {
// 找到 coordsToUse 上与 lastPt 最近的索引
const nearestInfo = this.findNearestPointWithIndex(coordsToUse, lastPt);
const ni = nearestInfo.index;
// === 整合第二个版本的途经点切片逻辑 ===
if (endConnection.type === 'via') {
// 途经点处理:统一以终点垂足为切片终点
if (ni <= endNi) {
segmentPath.push(...coordsToUse.slice(ni, endNi + 1));
// 关键:保存垂直点之后的路网后半截(供后续路径延续)
viaPerpRemainingCoords = coordsToUse.slice(endNi);
} else {
const reversedSlice = coordsToUse.slice(endNi, ni + 1).reverse();
segmentPath.push(...reversedSlice);
// 关键:保存垂直点之后的路网后半截(反向场景需要反转回去)
const originalRemaining = coordsToUse.slice(endNi);
viaPerpRemainingCoords = originalRemaining.reverse();
}
} else {
// 非途经点:使用第一个版本的完整连接逻辑
if (ni === 0) {
// 从头开始接(直接接)
segmentPath.push(...coordsToUse);
} else if (ni === coordsToUse.length - 1) {
// 最近点是段尾 —— 说明我们需要反向接(取反转)
const rev = [...coordsToUse].reverse();
// 以 rev 的第一个点连接
if (this.calculateDistance(lastPt, rev[0]) < 1e-6) {
segmentPath.push(...rev.slice(1));
} else {
// 否则直接把最近点加入并向最近端延伸(避免断链)
segmentPath.push(coordsToUse[ni]);
// 选择靠近终点的方向延伸(更短的一侧)
const distToStart = this.calculateDistance(coordsToUse[ni], coordsToUse[0]);
const distToEnd = this.calculateDistance(coordsToUse[ni], coordsToUse[coordsToUse.length - 1]);
if (distToStart <= distToEnd) {
const toStart = coordsToUse.slice(0, ni).reverse();
segmentPath.push(...toStart);
} else {
const toEnd = coordsToUse.slice(ni + 1);
segmentPath.push(...toEnd);
}
}
} else {
// 最近点在中间:选择向起点或终点延伸,取较短的一侧
segmentPath.push(coordsToUse[ni]);
const distToStart = this.calculateDistance(coordsToUse[ni], coordsToUse[0]);
const distToEnd = this.calculateDistance(coordsToUse[ni], coordsToUse[coordsToUse.length - 1]);
if (distToStart <= distToEnd) {
const toStart = coordsToUse.slice(0, ni).reverse();
segmentPath.push(...toStart);
} else {
const toEnd = coordsToUse.slice(ni + 1);
segmentPath.push(...toEnd);
}
}
}
}
}
}
if (distLastToFirst < 1e-6) { if (distLastToFirst < 1e-6) {
// 精度上相同,直接接上(跳过第一个) // 精度上相同,直接接上(跳过第一个)
// 如果是途经点,需要切片到垂足 // 如果是途经点,需要切片到垂足