|
@@ -203,77 +203,110 @@ export default class CurveRoadService extends RoadService {
|
|
let rightJoin = null;
|
|
let rightJoin = null;
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
- let line1 = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- curveRoad.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
- let line2 = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex + 1],
|
|
|
|
- curveRoad.points[startIndex + 2]
|
|
|
|
- );
|
|
|
|
|
|
|
|
- const leftLine = mathUtil.createLine1(
|
|
|
|
- leftCurveEdge.points[startIndex],
|
|
|
|
- leftCurveEdge.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
- let leftLine1 = mathUtil.createLine3(
|
|
|
|
- line1,
|
|
|
|
- leftCurveEdge.points[startIndex]
|
|
|
|
- );
|
|
|
|
- let leftLine2 = mathUtil.createLine3(
|
|
|
|
- line2,
|
|
|
|
- leftCurveEdge.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
|
|
+ if (curveRoad.points[startIndex + 2]) {
|
|
|
|
+ let line1 = mathUtil.createLine1(
|
|
|
|
+ curveRoad.points[startIndex],
|
|
|
|
+ curveRoad.points[startIndex + 1]
|
|
|
|
+ );
|
|
|
|
+ let line2 = mathUtil.createLine1(
|
|
|
|
+ curveRoad.points[startIndex + 1],
|
|
|
|
+ curveRoad.points[startIndex + 2]
|
|
|
|
+ );
|
|
|
|
|
|
- const rightLine = mathUtil.createLine1(
|
|
|
|
- rightCurveEdge.points[startIndex],
|
|
|
|
- rightCurveEdge.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
- let rightLine1 = mathUtil.createLine3(
|
|
|
|
- line1,
|
|
|
|
- rightCurveEdge.points[startIndex]
|
|
|
|
- );
|
|
|
|
- let rightLine2 = mathUtil.createLine3(
|
|
|
|
- line2,
|
|
|
|
- rightCurveEdge.points[startIndex + 1]
|
|
|
|
- );
|
|
|
|
|
|
+ const leftLine = mathUtil.createLine1(
|
|
|
|
+ leftCurveEdge.points[startIndex],
|
|
|
|
+ leftCurveEdge.points[startIndex + 1]
|
|
|
|
+ );
|
|
|
|
+ let leftLine1 = mathUtil.createLine3(
|
|
|
|
+ line1,
|
|
|
|
+ leftCurveEdge.points[startIndex]
|
|
|
|
+ );
|
|
|
|
+ let leftLine2 = mathUtil.createLine3(
|
|
|
|
+ line2,
|
|
|
|
+ leftCurveEdge.points[startIndex + 1]
|
|
|
|
+ );
|
|
|
|
|
|
- const line = mathUtil.createLine1(
|
|
|
|
- curveRoad.points[startIndex],
|
|
|
|
- curveRoad.points[startIndex + 2]
|
|
|
|
- );
|
|
|
|
|
|
+ const rightLine = mathUtil.createLine1(
|
|
|
|
+ rightCurveEdge.points[startIndex],
|
|
|
|
+ rightCurveEdge.points[startIndex + 1]
|
|
|
|
+ );
|
|
|
|
+ let rightLine1 = mathUtil.createLine3(
|
|
|
|
+ line1,
|
|
|
|
+ rightCurveEdge.points[startIndex]
|
|
|
|
+ );
|
|
|
|
+ let rightLine2 = mathUtil.createLine3(
|
|
|
|
+ line2,
|
|
|
|
+ rightCurveEdge.points[startIndex + 1]
|
|
|
|
+ );
|
|
|
|
|
|
- if (
|
|
|
|
- mathUtil.Angle(
|
|
|
|
- curveRoad.points[startIndex + 1],
|
|
|
|
|
|
+ const line = mathUtil.createLine1(
|
|
curveRoad.points[startIndex],
|
|
curveRoad.points[startIndex],
|
|
curveRoad.points[startIndex + 2]
|
|
curveRoad.points[startIndex + 2]
|
|
- ) > Constant.maxAngle
|
|
|
|
- ) {
|
|
|
|
- const join = mathUtil.getJoinLinePoint(position, line);
|
|
|
|
- let dx = position.x - join.x;
|
|
|
|
- let dy = position.y - join.y;
|
|
|
|
-
|
|
|
|
- leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
|
|
- leftJoin.x += dx;
|
|
|
|
- leftJoin.y += dy;
|
|
|
|
- leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
|
|
|
|
- curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
|
|
+ );
|
|
|
|
|
|
- rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
|
|
- rightJoin.x += dx;
|
|
|
|
- rightJoin.y += dy;
|
|
|
|
- rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
|
|
|
|
- curveEdgeService.setCurves(rightCurveEdge);
|
|
|
|
|
|
+ if (
|
|
|
|
+ mathUtil.Angle(
|
|
|
|
+ curveRoad.points[startIndex + 1],
|
|
|
|
+ curveRoad.points[startIndex],
|
|
|
|
+ curveRoad.points[startIndex + 2]
|
|
|
|
+ ) > Constant.maxAngle
|
|
|
|
+ ) {
|
|
|
|
+ const join = mathUtil.getJoinLinePoint(position, line);
|
|
|
|
+ let dx = position.x - join.x;
|
|
|
|
+ let dy = position.y - join.y;
|
|
|
|
+
|
|
|
|
+ leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
|
|
+ leftJoin.x += dx;
|
|
|
|
+ leftJoin.y += dy;
|
|
|
|
+ leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
|
|
|
|
+ curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
+
|
|
|
|
+ rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
|
|
+ rightJoin.x += dx;
|
|
|
|
+ rightJoin.y += dy;
|
|
|
|
+ rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
|
|
|
|
+ curveEdgeService.setCurves(rightCurveEdge);
|
|
|
|
+ } else {
|
|
|
|
+ leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
|
|
|
|
+ leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
|
|
|
|
+ curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
+
|
|
|
|
+ rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
|
|
|
|
+ rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
|
|
|
|
+ curveEdgeService.setCurves(rightCurveEdge);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
|
|
|
|
|
|
+ curveRoad.endId = point.vectorId;
|
|
|
|
+ let line = mathUtil.createLine1(
|
|
|
|
+ curveRoad.points[startIndex],
|
|
|
|
+ curveRoad.points[startIndex + 1]
|
|
|
|
+ );
|
|
|
|
+ let leftLine = mathUtil.createLine3(
|
|
|
|
+ line,
|
|
|
|
+ leftCurveEdge.points[startIndex]
|
|
|
|
+ );
|
|
|
|
+ let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
|
|
leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
|
|
|
|
+ leftCurveEdge.points[startIndex] = JSON.parse(
|
|
|
|
+ JSON.stringify(leftCurveEdge.end)
|
|
|
|
+ );
|
|
|
|
+ mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
curveEdgeService.setCurves(leftCurveEdge);
|
|
|
|
|
|
- rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
|
|
|
|
|
|
+ let rightLine = mathUtil.createLine3(
|
|
|
|
+ line,
|
|
|
|
+ rightCurveEdge.points[startIndex]
|
|
|
|
+ );
|
|
|
|
+ let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
|
|
rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
|
|
|
|
+ rightCurveEdge.points[startIndex] = JSON.parse(
|
|
|
|
+ JSON.stringify(rightCurveEdge.end)
|
|
|
|
+ );
|
|
|
|
+ mathUtil.clonePoint(rightCurveEdge.end, rightJoin);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
curveEdgeService.setCurves(rightCurveEdge);
|
|
}
|
|
}
|
|
|
|
+
|
|
this.setCurves(curveRoad);
|
|
this.setCurves(curveRoad);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -459,12 +492,13 @@ export default class CurveRoadService extends RoadService {
|
|
}
|
|
}
|
|
|
|
|
|
//删除或者减少车道
|
|
//删除或者减少车道
|
|
- updateForAddSubtractLanesCount(curveRoad, newCount, dir) {
|
|
|
|
|
|
+ updateForAddSubtractLanesCount(curveRoadId, newCount, dir) {
|
|
|
|
+ let curveRoad = dataService.getCurveRoad(curveRoadId);
|
|
let curveEdge, oldCount, lanes;
|
|
let curveEdge, oldCount, lanes;
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
|
|
- if (newCount < 0) {
|
|
|
|
- newCount = 0;
|
|
|
|
|
|
+ if (newCount < 1) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
let ratio = null;
|
|
let ratio = null;
|
|
@@ -584,10 +618,10 @@ export default class CurveRoadService extends RoadService {
|
|
//多车道转单车道
|
|
//多车道转单车道
|
|
mulToSinglelane(curveRoad) {
|
|
mulToSinglelane(curveRoad) {
|
|
if (curveRoad.leftDrivewayCount > 0) {
|
|
if (curveRoad.leftDrivewayCount > 0) {
|
|
- this.updateForAddSubtractLanesCount(curveRoad, 1, "left");
|
|
|
|
|
|
+ this.updateForAddSubtractLanesCount(curveRoad.vectorId, 1, "left");
|
|
}
|
|
}
|
|
if (curveRoad.rightDrivewayCount > 0) {
|
|
if (curveRoad.rightDrivewayCount > 0) {
|
|
- this.updateForAddSubtractLanesCount(curveRoad, 1, "right");
|
|
|
|
|
|
+ this.updateForAddSubtractLanesCount(curveRoad.vectorId, 1, "right");
|
|
}
|
|
}
|
|
curveRoad.leftDrivewayCount = 0;
|
|
curveRoad.leftDrivewayCount = 0;
|
|
curveRoad.rightDrivewayCount = 0;
|
|
curveRoad.rightDrivewayCount = 0;
|