|
@@ -44,21 +44,13 @@ export default class MoveRoad {
|
|
|
// }
|
|
|
this.adsorbPointRoads = {};
|
|
|
this.splitRoadId = null;
|
|
|
- let flag = this.canMoveForPoint(
|
|
|
- pointId,
|
|
|
- position,
|
|
|
- linkedRoadPointId,
|
|
|
- linkedRoadId
|
|
|
- );
|
|
|
+ let flag = this.canMoveForPoint(pointId, position, linkedRoadPointId, linkedRoadId);
|
|
|
|
|
|
if (!flag) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (
|
|
|
- this.splitRoadId == null &&
|
|
|
- Object.keys(this.adsorbPointRoads).length > 0
|
|
|
- ) {
|
|
|
+ if (this.splitRoadId == null && Object.keys(this.adsorbPointRoads).length > 0) {
|
|
|
//要吸附一下
|
|
|
const adsorbPointId = Object.keys(this.adsorbPointRoads)[0];
|
|
|
const road = dataService.getRoad(this.adsorbPointRoads[adsorbPointId]);
|
|
@@ -74,14 +66,8 @@ export default class MoveRoad {
|
|
|
point.setPosition(position);
|
|
|
}
|
|
|
// 与别的墙角重合
|
|
|
- else if (
|
|
|
- modifyPoint.hasOwnProperty("linkedRoadPointId") &&
|
|
|
- modifyPoint.linkedRoadPointId != null
|
|
|
- ) {
|
|
|
- const roadId = roadService.getRoadId(
|
|
|
- pointId,
|
|
|
- modifyPoint.linkedRoadPointId
|
|
|
- );
|
|
|
+ else if (modifyPoint.hasOwnProperty("linkedRoadPointId") && modifyPoint.linkedRoadPointId != null) {
|
|
|
+ const roadId = roadService.getRoadId(pointId, modifyPoint.linkedRoadPointId);
|
|
|
// pointId与linkedPointId属于同一堵墙,不允许,所以不移动
|
|
|
if (roadId != null) {
|
|
|
return false;
|
|
@@ -97,24 +83,15 @@ export default class MoveRoad {
|
|
|
const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
|
|
|
// 与其余墙角的距离过短,不允许拖动
|
|
|
- if (
|
|
|
- mathUtil.getDistance(startPoint, position) < Constant.minRealDis ||
|
|
|
- mathUtil.getDistance(endPoint, position) < Constant.minRealDis
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(startPoint, position) < Constant.minRealDis || mathUtil.getDistance(endPoint, position) < Constant.minRealDis) {
|
|
|
return false;
|
|
|
}
|
|
|
point.setPosition(modifyPoint);
|
|
|
} else if (modifyPoint.hasOwnProperty("linkedCurveRoadPointId")) {
|
|
|
point.setPosition(position);
|
|
|
- } else if (
|
|
|
- modifyPoint.hasOwnProperty("linkedRoadPointIdX") &&
|
|
|
- modifyPoint.linkedRoadPointIdX
|
|
|
- ) {
|
|
|
+ } else if (modifyPoint.hasOwnProperty("linkedRoadPointIdX") && modifyPoint.linkedRoadPointIdX) {
|
|
|
point.setPosition(position);
|
|
|
- } else if (
|
|
|
- modifyPoint.hasOwnProperty("linkedRoadPointIdY") &&
|
|
|
- modifyPoint.linkedRoadPointIdY
|
|
|
- ) {
|
|
|
+ } else if (modifyPoint.hasOwnProperty("linkedRoadPointIdY") && modifyPoint.linkedRoadPointIdY) {
|
|
|
point.setPosition(position);
|
|
|
} else {
|
|
|
return false;
|
|
@@ -134,38 +111,52 @@ export default class MoveRoad {
|
|
|
// point.setPosition(position);
|
|
|
// }
|
|
|
// }
|
|
|
- roadService.initRoadWidthTipsPos(road);
|
|
|
+ // roadService.initRoadWidthTipsPos(road);
|
|
|
edgeService.updateEdgeForMovePoint(pointId);
|
|
|
- if (leftEdge.roadSide) {
|
|
|
- leftEdge.initRoadSide();
|
|
|
- }
|
|
|
- if (rightEdge.roadSide) {
|
|
|
- rightEdge.initRoadSide();
|
|
|
- }
|
|
|
+ // console.error(point);
|
|
|
+ // if (Object.keys(point.parent).length == 1) {
|
|
|
+ let centerPointId = null;
|
|
|
+ Object.keys(point.parent).forEach((item) => {
|
|
|
+ const road = dataService.getRoad(item);
|
|
|
+ if (pointId == road.startId) {
|
|
|
+ centerPointId = road.endId;
|
|
|
+ }
|
|
|
+ if (pointId == road.endId) {
|
|
|
+ centerPointId = road.startId;
|
|
|
+ }
|
|
|
+
|
|
|
+ let centerPoint = dataService.getRoadPoint(centerPointId);
|
|
|
+ Object.keys(centerPoint.parent).forEach((item) => {
|
|
|
+ const newRoad = dataService.getRoad(item);
|
|
|
+ roadService.initRoadWidthTipsPos(newRoad);
|
|
|
+ let newLeftEdge = dataService.getRoadEdge(newRoad.leftEdgeId);
|
|
|
+ let newRightEdge = dataService.getRoadEdge(newRoad.rightEdgeId);
|
|
|
+
|
|
|
+ if (newLeftEdge.roadSide) {
|
|
|
+ newLeftEdge.initRoadSide();
|
|
|
+ }
|
|
|
+ if (newRightEdge.roadSide) {
|
|
|
+ newRightEdge.initRoadSide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // }
|
|
|
+ // if (leftEdge.roadSide) {
|
|
|
+ // leftEdge.initRoadSide();
|
|
|
+ // }
|
|
|
+ // if (rightEdge.roadSide) {
|
|
|
+ // rightEdge.initRoadSide();
|
|
|
+ // }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
finishByMoveRoadPoint(point) {
|
|
|
- if (
|
|
|
- listenLayer.modifyPoint &&
|
|
|
- listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")
|
|
|
- ) {
|
|
|
+ if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")) {
|
|
|
this.moveTo(point.vectorId, listenLayer.modifyPoint.linkedRoadPointId);
|
|
|
- } else if (
|
|
|
- listenLayer.modifyPoint &&
|
|
|
- (listenLayer.modifyPoint.linkedRoadPointIdX ||
|
|
|
- listenLayer.modifyPoint.linkedRoadPointIdY)
|
|
|
- ) {
|
|
|
+ } else if (listenLayer.modifyPoint && (listenLayer.modifyPoint.linkedRoadPointIdX || listenLayer.modifyPoint.linkedRoadPointIdY)) {
|
|
|
mathUtil.clonePoint(point, listenLayer.modifyPoint);
|
|
|
- } else if (
|
|
|
- listenLayer.modifyPoint &&
|
|
|
- listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")
|
|
|
- ) {
|
|
|
- roadService.splitRoad(
|
|
|
- listenLayer.modifyPoint.linkedRoadId,
|
|
|
- point.vectorId,
|
|
|
- "start"
|
|
|
- );
|
|
|
+ } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")) {
|
|
|
+ roadService.splitRoad(listenLayer.modifyPoint.linkedRoadId, point.vectorId, "start");
|
|
|
edgeService.updateEdgeForMovePoint(point.vectorId);
|
|
|
}
|
|
|
// else if (this.splitRoadId != null) {
|
|
@@ -215,10 +206,7 @@ export default class MoveRoad {
|
|
|
const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
|
|
|
function sortNumber(a, b) {
|
|
|
- return (
|
|
|
- mathUtil.getDistance(startPoint, a.join) -
|
|
|
- mathUtil.getDistance(startPoint, b.join)
|
|
|
- );
|
|
|
+ return mathUtil.getDistance(startPoint, a.join) - mathUtil.getDistance(startPoint, b.join);
|
|
|
}
|
|
|
|
|
|
joins = joins.sort(sortNumber.bind(this));
|
|
@@ -236,10 +224,7 @@ export default class MoveRoad {
|
|
|
let splitRoad = dataService.getRoad(this.splitRoadId);
|
|
|
let splitRoadStartPoint = dataService.getRoadPoint(splitRoad.startId);
|
|
|
let splitRoadEndPoint = dataService.getRoadPoint(splitRoad.endId);
|
|
|
- let splitLine = mathUtil.createLine1(
|
|
|
- splitRoadStartPoint,
|
|
|
- splitRoadEndPoint
|
|
|
- );
|
|
|
+ let splitLine = mathUtil.createLine1(splitRoadStartPoint, splitRoadEndPoint);
|
|
|
let parent = point.getParent();
|
|
|
for (let key in parent) {
|
|
|
let road = dataService.getRoad(key);
|
|
@@ -247,17 +232,10 @@ export default class MoveRoad {
|
|
|
let endPoint = dataService.getRoadPoint(road.endId);
|
|
|
let line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
let join = mathUtil.getIntersectionPoint(splitLine, line);
|
|
|
- if (
|
|
|
- mathUtil.isContainForSegment(join, startPoint, endPoint) &&
|
|
|
- mathUtil.getDistance(join, splitRoadStartPoint) <
|
|
|
- Constant.minAdsorbPix
|
|
|
- ) {
|
|
|
+ if (mathUtil.isContainForSegment(join, startPoint, endPoint) && mathUtil.getDistance(join, splitRoadStartPoint) < Constant.minAdsorbPix) {
|
|
|
roadService.splitRoad(key, splitRoadStartPoint.vectorId, "start");
|
|
|
return splitRoadStartPoint.vectorId;
|
|
|
- } else if (
|
|
|
- mathUtil.isContainForSegment(join, startPoint, endPoint) &&
|
|
|
- mathUtil.getDistance(join, splitRoadEndPoint) < Constant.minAdsorbPix
|
|
|
- ) {
|
|
|
+ } else if (mathUtil.isContainForSegment(join, startPoint, endPoint) && mathUtil.getDistance(join, splitRoadEndPoint) < Constant.minAdsorbPix) {
|
|
|
roadService.splitRoad(key, splitRoadEndPoint.vectorId, "end");
|
|
|
return splitRoadEndPoint.vectorId;
|
|
|
}
|
|
@@ -326,16 +304,8 @@ export default class MoveRoad {
|
|
|
const startPoint2 = dataService.getRoadPoint(road2.startId);
|
|
|
const endPoint2 = dataService.getRoadPoint(road2.endId);
|
|
|
|
|
|
- const join1 = mathUtil.getIntersectionPoint4(
|
|
|
- startPoint1,
|
|
|
- endPoint1,
|
|
|
- newLine
|
|
|
- );
|
|
|
- const join2 = mathUtil.getIntersectionPoint4(
|
|
|
- startPoint2,
|
|
|
- endPoint2,
|
|
|
- newLine
|
|
|
- );
|
|
|
+ const join1 = mathUtil.getIntersectionPoint4(startPoint1, endPoint1, newLine);
|
|
|
+ const join2 = mathUtil.getIntersectionPoint4(startPoint2, endPoint2, newLine);
|
|
|
|
|
|
// 取角度大的
|
|
|
if (join1 == null && join2 == null) {
|
|
@@ -374,10 +344,7 @@ export default class MoveRoad {
|
|
|
let join = mathUtil.getIntersectionPoint(startLimitLine, newLine);
|
|
|
const tempStartPoint = dataService.getRoadPoint(tempRoad.startId);
|
|
|
const tempEndPoint = dataService.getRoadPoint(tempRoad.endId);
|
|
|
- if (
|
|
|
- angle > Constant.maxAngle ||
|
|
|
- !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)
|
|
|
- ) {
|
|
|
+ if (angle > Constant.maxAngle || !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)) {
|
|
|
startLimitLine = mathUtil.getVerticalLine(roadLine, startPoint);
|
|
|
limitInfos.startRoadId = null;
|
|
|
limitInfos.newStartRoadId = true;
|
|
@@ -413,16 +380,8 @@ export default class MoveRoad {
|
|
|
const startPoint2 = dataService.getRoadPoint(road2.startId);
|
|
|
const endPoint2 = dataService.getRoadPoint(road2.endId);
|
|
|
|
|
|
- const join1 = mathUtil.getIntersectionPoint4(
|
|
|
- startPoint1,
|
|
|
- endPoint1,
|
|
|
- newLine
|
|
|
- );
|
|
|
- const join2 = mathUtil.getIntersectionPoint4(
|
|
|
- startPoint2,
|
|
|
- endPoint2,
|
|
|
- newLine
|
|
|
- );
|
|
|
+ const join1 = mathUtil.getIntersectionPoint4(startPoint1, endPoint1, newLine);
|
|
|
+ const join2 = mathUtil.getIntersectionPoint4(startPoint2, endPoint2, newLine);
|
|
|
|
|
|
// 取角度大的
|
|
|
if (join1 == null && join2 == null) {
|
|
@@ -461,10 +420,7 @@ export default class MoveRoad {
|
|
|
const tempStartPoint = dataService.getRoadPoint(tempRoad.start);
|
|
|
const tempEndPoint = dataService.getRoadPoint(tempRoad.end);
|
|
|
|
|
|
- if (
|
|
|
- angle > Constant.maxAngle ||
|
|
|
- !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)
|
|
|
- ) {
|
|
|
+ if (angle > Constant.maxAngle || !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)) {
|
|
|
endLimitLine = mathUtil.getVerticalLine(roadLine, endPoint);
|
|
|
limitInfos.endRoadId = null;
|
|
|
limitInfos.newEndRoadId = true;
|
|
@@ -484,13 +440,7 @@ export default class MoveRoad {
|
|
|
// 开始考虑第一点
|
|
|
if (flag) {
|
|
|
// 不仅仅角度,还有相交
|
|
|
- flag = this.isOKForCross(
|
|
|
- pointId,
|
|
|
- position,
|
|
|
- point.parent,
|
|
|
- linkedRoadPointId,
|
|
|
- linkedRoadId
|
|
|
- );
|
|
|
+ flag = this.isOKForCross(pointId, position, point.parent, linkedRoadPointId, linkedRoadId);
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
@@ -646,14 +596,7 @@ export default class MoveRoad {
|
|
|
const otherPointId = _road.getOtherPointId(pointId);
|
|
|
const otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
|
|
|
- const flag = this.isOKForCrossTwoRoad(
|
|
|
- position,
|
|
|
- otherPoint,
|
|
|
- key,
|
|
|
- linkedRoadPointId,
|
|
|
- linkedRoadId,
|
|
|
- _road.vectorId
|
|
|
- );
|
|
|
+ const flag = this.isOKForCrossTwoRoad(position, otherPoint, key, linkedRoadPointId, linkedRoadId, _road.vectorId);
|
|
|
// 交叉
|
|
|
if (!flag) {
|
|
|
this.adsorbPointRoads = {};
|
|
@@ -674,28 +617,12 @@ export default class MoveRoad {
|
|
|
// position1表示拖拽的点的坐标(修复过了的)
|
|
|
// position2对应墙的另一头坐标
|
|
|
// roadId表示其余的墙(与position1无关的墙)
|
|
|
- isOKForCrossTwoRoad(
|
|
|
- position1,
|
|
|
- position2,
|
|
|
- roadId,
|
|
|
- linkedRoadPointId,
|
|
|
- linkedRoadId,
|
|
|
- dragRoadId
|
|
|
- ) {
|
|
|
+ isOKForCrossTwoRoad(position1, position2, roadId, linkedRoadPointId, linkedRoadId, dragRoadId) {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
- const join = mathUtil.getIntersectionPoint3(
|
|
|
- position1,
|
|
|
- position2,
|
|
|
- startPoint,
|
|
|
- endPoint
|
|
|
- );
|
|
|
- if (
|
|
|
- join &&
|
|
|
- road.startId != linkedRoadPointId &&
|
|
|
- road.endId != linkedRoadPointId
|
|
|
- ) {
|
|
|
+ const join = mathUtil.getIntersectionPoint3(position1, position2, startPoint, endPoint);
|
|
|
+ if (join && road.startId != linkedRoadPointId && road.endId != linkedRoadPointId) {
|
|
|
// 交叉了
|
|
|
this.splitRoadId = roadId;
|
|
|
return true;
|
|
@@ -707,20 +634,14 @@ export default class MoveRoad {
|
|
|
let join1 = mathUtil.getJoinLinePoint(startPoint, line);
|
|
|
let join2 = mathUtil.getJoinLinePoint(endPoint, line);
|
|
|
|
|
|
- if (
|
|
|
- mathUtil.getDistance(join1, startPoint) < Constant.minRealDis &&
|
|
|
- mathUtil.PointInSegment(join1, position1, position2)
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(join1, startPoint) < Constant.minRealDis && mathUtil.PointInSegment(join1, position1, position2)) {
|
|
|
if (road.startId != linkedRoadPointId) {
|
|
|
// 交叉了
|
|
|
this.adsorbPointRoads[startPoint.vectorId] = dragRoadId;
|
|
|
//为了找到全部的吸附点,暂时返回true,在外面一层再做判断
|
|
|
return true;
|
|
|
}
|
|
|
- } else if (
|
|
|
- mathUtil.getDistance(join2, endPoint) < Constant.minRealDis &&
|
|
|
- mathUtil.PointInSegment(join2, position1, position2)
|
|
|
- ) {
|
|
|
+ } else if (mathUtil.getDistance(join2, endPoint) < Constant.minRealDis && mathUtil.PointInSegment(join2, position1, position2)) {
|
|
|
if (road.endId != linkedRoadPointId) {
|
|
|
// 交叉了
|
|
|
this.adsorbPointRoads[endPoint.vectorId] = dragRoadId;
|
|
@@ -732,28 +653,14 @@ export default class MoveRoad {
|
|
|
line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
join1 = mathUtil.getJoinLinePoint(position1, line);
|
|
|
join2 = mathUtil.getJoinLinePoint(position2, line);
|
|
|
- if (
|
|
|
- mathUtil.getDistance(join1, position1) < Constant.minRealDis &&
|
|
|
- mathUtil.PointInSegment(join1, startPoint, endPoint)
|
|
|
- ) {
|
|
|
- if (
|
|
|
- road.startId != linkedRoadPointId &&
|
|
|
- road.endId != linkedRoadPointId &&
|
|
|
- roadId != linkedRoadId
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(join1, position1) < Constant.minRealDis && mathUtil.PointInSegment(join1, startPoint, endPoint)) {
|
|
|
+ if (road.startId != linkedRoadPointId && road.endId != linkedRoadPointId && roadId != linkedRoadId) {
|
|
|
// 交叉了
|
|
|
//return false
|
|
|
return true;
|
|
|
}
|
|
|
- } else if (
|
|
|
- mathUtil.getDistance(join2, position2) < Constant.minRealDis &&
|
|
|
- mathUtil.PointInSegment(join2, startPoint, endPoint)
|
|
|
- ) {
|
|
|
- if (
|
|
|
- road.startId != linkedRoadPointId &&
|
|
|
- road.endId != linkedRoadPointId &&
|
|
|
- roadId != linkedRoadId
|
|
|
- ) {
|
|
|
+ } else if (mathUtil.getDistance(join2, position2) < Constant.minRealDis && mathUtil.PointInSegment(join2, startPoint, endPoint)) {
|
|
|
+ if (road.startId != linkedRoadPointId && road.endId != linkedRoadPointId && roadId != linkedRoadId) {
|
|
|
// 交叉了
|
|
|
//return false
|
|
|
return true;
|
|
@@ -768,13 +675,7 @@ export default class MoveRoad {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
- let flag = mathUtil.crossTwoLines(
|
|
|
- position1,
|
|
|
- position2,
|
|
|
- startPoint,
|
|
|
- endPoint,
|
|
|
- 0.01
|
|
|
- );
|
|
|
+ let flag = mathUtil.crossTwoLines(position1, position2, startPoint, endPoint, 0.01);
|
|
|
if (flag) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
@@ -795,13 +696,7 @@ export default class MoveRoad {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
- const flag = mathUtil.crossTwoLines(
|
|
|
- position1,
|
|
|
- position2,
|
|
|
- startPoint,
|
|
|
- endPoint,
|
|
|
- 0.01
|
|
|
- );
|
|
|
+ const flag = mathUtil.crossTwoLines(position1, position2, startPoint, endPoint, 0.01);
|
|
|
if (flag) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
@@ -813,26 +708,17 @@ export default class MoveRoad {
|
|
|
let join1 = mathUtil.getJoinLinePoint(startPoint, line);
|
|
|
const join2 = mathUtil.getJoinLinePoint(endPoint, line);
|
|
|
|
|
|
- if (
|
|
|
- mathUtil.getDistance(join1, startPoint) < Constant.minRealDis &&
|
|
|
- mathUtil.isPointOnSegment(join1, position1, position2)
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(join1, startPoint) < Constant.minRealDis && mathUtil.isPointOnSegment(join1, position1, position2)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
- } else if (
|
|
|
- mathUtil.getDistance(join2, endPoint) < Constant.minRealDis &&
|
|
|
- mathUtil.isPointOnSegment(join2, position1, position2)
|
|
|
- ) {
|
|
|
+ } else if (mathUtil.getDistance(join2, endPoint) < Constant.minRealDis && mathUtil.isPointOnSegment(join2, position1, position2)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
join1 = mathUtil.getJoinLinePoint(position1, line);
|
|
|
- if (
|
|
|
- mathUtil.getDistance(join1, position1) < Constant.minRealDis &&
|
|
|
- roadService.isContain(road, join1)
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(join1, position1) < Constant.minRealDis && roadService.isContain(road, join1)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
}
|
|
@@ -848,16 +734,10 @@ export default class MoveRoad {
|
|
|
let line = mathUtil.createLine1(position1, position2);
|
|
|
let join1 = mathUtil.getJoinLinePoint(startPoint, line);
|
|
|
let join2 = mathUtil.getJoinLinePoint(endPoint, line);
|
|
|
- if (
|
|
|
- mathUtil.getDistance(join1, startPoint) < Constant.minRealDis &&
|
|
|
- mathUtil.PointInSegment(join1, position1, position2)
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(join1, startPoint) < Constant.minRealDis && mathUtil.PointInSegment(join1, position1, position2)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
- } else if (
|
|
|
- mathUtil.getDistance(join2, endPoint) < Constant.minRealDis &&
|
|
|
- mathUtil.PointInSegment(join2, position1, position2)
|
|
|
- ) {
|
|
|
+ } else if (mathUtil.getDistance(join2, endPoint) < Constant.minRealDis && mathUtil.PointInSegment(join2, position1, position2)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
}
|
|
@@ -866,16 +746,10 @@ export default class MoveRoad {
|
|
|
join1 = mathUtil.getJoinLinePoint(position1, line);
|
|
|
join2 = mathUtil.getJoinLinePoint(position2, line);
|
|
|
|
|
|
- if (
|
|
|
- mathUtil.getDistance(join1, position1) < Constant.minRealDis &&
|
|
|
- roadService.isContain(road, join1)
|
|
|
- ) {
|
|
|
+ if (mathUtil.getDistance(join1, position1) < Constant.minRealDis && roadService.isContain(road, join1)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
- } else if (
|
|
|
- mathUtil.getDistance(join2, position2) < Constant.minRealDis &&
|
|
|
- roadService.isContain(road, join2)
|
|
|
- ) {
|
|
|
+ } else if (mathUtil.getDistance(join2, position2) < Constant.minRealDis && roadService.isContain(road, join2)) {
|
|
|
// 交叉了
|
|
|
return false;
|
|
|
}
|
|
@@ -895,11 +769,8 @@ export default class MoveRoad {
|
|
|
otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
// 会吸附另一头
|
|
|
if (
|
|
|
- mathUtil.getDistance(virtualPosition, otherPoint) <
|
|
|
- Constant.minRealDis ||
|
|
|
- (!roadService.isContain(limitRoad, virtualPosition) &&
|
|
|
- mathUtil.getDistance(virtualPosition, otherPoint) <
|
|
|
- mathUtil.getDistance(virtualPosition, point))
|
|
|
+ mathUtil.getDistance(virtualPosition, otherPoint) < Constant.minRealDis ||
|
|
|
+ (!roadService.isContain(limitRoad, virtualPosition) && mathUtil.getDistance(virtualPosition, otherPoint) < mathUtil.getDistance(virtualPosition, point))
|
|
|
) {
|
|
|
mathUtil.clonePoint(virtualPosition, otherPoint);
|
|
|
adsorb = true;
|
|
@@ -994,15 +865,7 @@ export default class MoveRoad {
|
|
|
// position5和position6表示road的end一边的线段(endPoint——virtualEndPoint)
|
|
|
// adsorbPointId1对应start那一头的吸附点
|
|
|
// adsorbPointId2对应end那一头的吸附点
|
|
|
- isOKForCrossForMoveRoad(
|
|
|
- position1,
|
|
|
- position2,
|
|
|
- roadId,
|
|
|
- startPointId,
|
|
|
- endPointId,
|
|
|
- adsorbPointId1,
|
|
|
- adsorbPointId2
|
|
|
- ) {
|
|
|
+ isOKForCrossForMoveRoad(position1, position2, roadId, startPointId, endPointId, adsorbPointId1, adsorbPointId2) {
|
|
|
const startPoint = dataService.getRoadPoint(startPointId);
|
|
|
const endPoint = dataService.getRoadPoint(endPointId);
|
|
|
let flag = true;
|
|
@@ -1016,16 +879,10 @@ export default class MoveRoad {
|
|
|
let flag2 = true;
|
|
|
|
|
|
const _road = dataService.getRoad(key);
|
|
|
- if (
|
|
|
- adsorbPointId1 &&
|
|
|
- (adsorbPointId1 == _road.startId || adsorbPointId1 == _road.endId)
|
|
|
- ) {
|
|
|
+ if (adsorbPointId1 && (adsorbPointId1 == _road.startId || adsorbPointId1 == _road.endId)) {
|
|
|
flag1 = false;
|
|
|
}
|
|
|
- if (
|
|
|
- adsorbPointId2 &&
|
|
|
- (adsorbPointId2 == _road.startId || adsorbPointId2 == _road.endId)
|
|
|
- ) {
|
|
|
+ if (adsorbPointId2 && (adsorbPointId2 == _road.startId || adsorbPointId2 == _road.endId)) {
|
|
|
flag2 = false;
|
|
|
}
|
|
|
|
|
@@ -1045,11 +902,7 @@ export default class MoveRoad {
|
|
|
if (!flag) {
|
|
|
return false;
|
|
|
}
|
|
|
- if (
|
|
|
- flag1 &&
|
|
|
- _road.startId != startPointId &&
|
|
|
- _road.endId != startPointId
|
|
|
- ) {
|
|
|
+ if (flag1 && _road.startId != startPointId && _road.endId != startPointId) {
|
|
|
flag = this.isOKForCrossTwoRoad3(position1, startPoint, key);
|
|
|
}
|
|
|
|
|
@@ -1075,10 +928,7 @@ export default class MoveRoad {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
- if (
|
|
|
- Object.keys(startPoint.getParent()).length == 1 &&
|
|
|
- Object.keys(endPoint.getParent()).length == 1
|
|
|
- ) {
|
|
|
+ if (Object.keys(startPoint.getParent()).length == 1 && Object.keys(endPoint.getParent()).length == 1) {
|
|
|
const p1 = { x: startPoint.x + dx, y: startPoint.y + dy };
|
|
|
const p2 = { x: endPoint.x + dx, y: endPoint.y + dy };
|
|
|
|
|
@@ -1231,9 +1081,7 @@ export default class MoveRoad {
|
|
|
road1.endId = pointId2;
|
|
|
point2.setPointParent(roadId1, "end");
|
|
|
} else {
|
|
|
- console.error(
|
|
|
- "roadService.moveTo****************************************************"
|
|
|
- );
|
|
|
+ console.error("roadService.moveTo****************************************************");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1301,38 +1149,54 @@ export default class MoveRoad {
|
|
|
const line2 = mathUtil.createLine1(rightEdge.start, rightEdge.end);
|
|
|
let rightJoin = mathUtil.getJoinLinePoint(position, line2);
|
|
|
|
|
|
- if (
|
|
|
- dir == "left" &&
|
|
|
- (mathUtil.isContainForSegment(position, join, rightJoin) ||
|
|
|
- mathUtil.isContainForSegment(rightJoin, join, position))
|
|
|
- ) {
|
|
|
+ if (dir == "left" && (mathUtil.isContainForSegment(position, join, rightJoin) || mathUtil.isContainForSegment(rightJoin, join, position))) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (
|
|
|
- dir == "right" &&
|
|
|
- (mathUtil.isContainForSegment(position, join, leftJoin) ||
|
|
|
- mathUtil.isContainForSegment(leftJoin, join, position))
|
|
|
- ) {
|
|
|
+ if (dir == "right" && (mathUtil.isContainForSegment(position, join, leftJoin) || mathUtil.isContainForSegment(leftJoin, join, position))) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const newWidth = mathUtil.getDisForPoinLine(position, line);
|
|
|
- if (
|
|
|
- newWidth > Constant.minRoadSideWidth &&
|
|
|
- newWidth < Constant.maxRoadSideWidth
|
|
|
- ) {
|
|
|
+ if (newWidth > Constant.minRoadSideWidth && newWidth < Constant.maxRoadSideWidth) {
|
|
|
roadService.updateForWidth(parent, newWidth, dir);
|
|
|
}
|
|
|
- roadService.initRoadWidthTipsPos(road);
|
|
|
- // if (edge.roadSide) {
|
|
|
- // edge.initRoadSide();
|
|
|
- // }
|
|
|
- if(leftEdge.roadSide){
|
|
|
- leftEdge.initRoadSide();
|
|
|
+ // roadService.initRoadWidthTipsPos(road);
|
|
|
+
|
|
|
+ let centerPointId = null;
|
|
|
+ let startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ let endPoint = dataService.getRoadPoint(road.endId);
|
|
|
+
|
|
|
+ if (Object.keys(startPoint.parent).length > 1) {
|
|
|
+ centerPointId = road.startId;
|
|
|
}
|
|
|
- if(rightEdge.roadSide){
|
|
|
- rightEdge.initRoadSide();
|
|
|
+ if (Object.keys(endPoint.parent).length > 1) {
|
|
|
+ centerPointId = road.endId;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (centerPointId) {
|
|
|
+ let centerPoint = dataService.getRoadPoint(centerPointId);
|
|
|
+ Object.keys(centerPoint.parent).forEach((item) => {
|
|
|
+ const newRoad = dataService.getRoad(item);
|
|
|
+
|
|
|
+ let newLeftEdge = dataService.getRoadEdge(newRoad.leftEdgeId);
|
|
|
+ let newRightEdge = dataService.getRoadEdge(newRoad.rightEdgeId);
|
|
|
+ roadService.initRoadWidthTipsPos(newRoad);
|
|
|
+ if (newLeftEdge.roadSide) {
|
|
|
+ newLeftEdge.initRoadSide();
|
|
|
+ }
|
|
|
+ if (newRightEdge.roadSide) {
|
|
|
+ newRightEdge.initRoadSide();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ roadService.initRoadWidthTipsPos(road);
|
|
|
+ if (leftEdge.roadSide) {
|
|
|
+ leftEdge.initRoadSide();
|
|
|
+ }
|
|
|
+ if (rightEdge.roadSide) {
|
|
|
+ rightEdge.initRoadSide();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1362,70 +1226,25 @@ export default class MoveRoad {
|
|
|
|
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
|
- let joinInfo = mathUtil.getHitInfoForCurve(
|
|
|
- position,
|
|
|
- curveRoad.curves[index],
|
|
|
- Math.max(curveRoad.leftWidth, curveRoad.rightWidth)
|
|
|
- );
|
|
|
-
|
|
|
- let leftJoinInfo = mathUtil.getHitInfoForCurve(
|
|
|
- position,
|
|
|
- leftCurveEdge.curves[index],
|
|
|
- curveRoad.leftWidth
|
|
|
- );
|
|
|
- let leftLine = mathUtil.createLine1(
|
|
|
- leftJoinInfo.position,
|
|
|
- joinInfo.position
|
|
|
- );
|
|
|
+ let joinInfo = mathUtil.getHitInfoForCurve(position, curveRoad.curves[index], Math.max(curveRoad.leftWidth, curveRoad.rightWidth));
|
|
|
+
|
|
|
+ let leftJoinInfo = mathUtil.getHitInfoForCurve(position, leftCurveEdge.curves[index], curveRoad.leftWidth);
|
|
|
+ let leftLine = mathUtil.createLine1(leftJoinInfo.position, joinInfo.position);
|
|
|
let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
|
|
|
|
- let rightJoinInfo = mathUtil.getHitInfoForCurve(
|
|
|
- position,
|
|
|
- rightCurveEdge.curves[index],
|
|
|
- curveRoad.rightWidth
|
|
|
- );
|
|
|
- let rightLine = mathUtil.createLine1(
|
|
|
- rightJoinInfo.position,
|
|
|
- joinInfo.position
|
|
|
- );
|
|
|
+ let rightJoinInfo = mathUtil.getHitInfoForCurve(position, rightCurveEdge.curves[index], curveRoad.rightWidth);
|
|
|
+ let rightLine = mathUtil.createLine1(rightJoinInfo.position, joinInfo.position);
|
|
|
let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
|
- if (
|
|
|
- dir == "left" &&
|
|
|
- (mathUtil.isContainForSegment(
|
|
|
- rightJoin,
|
|
|
- rightJoinInfo.position,
|
|
|
- joinInfo.position
|
|
|
- ) ||
|
|
|
- mathUtil.isContainForSegment(
|
|
|
- rightJoinInfo.position,
|
|
|
- rightJoin,
|
|
|
- joinInfo.position
|
|
|
- ))
|
|
|
- ) {
|
|
|
+ if (dir == "left" && (mathUtil.isContainForSegment(rightJoin, rightJoinInfo.position, joinInfo.position) || mathUtil.isContainForSegment(rightJoinInfo.position, rightJoin, joinInfo.position))) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (
|
|
|
- dir == "right" &&
|
|
|
- (mathUtil.isContainForSegment(
|
|
|
- leftJoin,
|
|
|
- leftJoinInfo.position,
|
|
|
- joinInfo.position
|
|
|
- ) ||
|
|
|
- mathUtil.isContainForSegment(
|
|
|
- leftJoinInfo.position,
|
|
|
- leftJoin,
|
|
|
- joinInfo.position
|
|
|
- ))
|
|
|
- ) {
|
|
|
+ if (dir == "right" && (mathUtil.isContainForSegment(leftJoin, leftJoinInfo.position, joinInfo.position) || mathUtil.isContainForSegment(leftJoinInfo.position, leftJoin, joinInfo.position))) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
const newWidth = mathUtil.getDistance(joinInfo.position, position);
|
|
|
- if (
|
|
|
- newWidth > Constant.minRoadSideWidth &&
|
|
|
- newWidth < Constant.maxRoadSideWidth
|
|
|
- ) {
|
|
|
+ if (newWidth > Constant.minRoadSideWidth && newWidth < Constant.maxRoadSideWidth) {
|
|
|
curveRoadService.updateForWidth(parent, newWidth, dir);
|
|
|
}
|
|
|
if (curveEdge.roadSide) {
|