|
@@ -66,6 +66,8 @@ export default class CurveRoadService extends RoadService {
|
|
|
);
|
|
|
curveRoad.leftLanes = lanes.leftLanes;
|
|
|
curveRoad.rightLanes = lanes.rightLanes;
|
|
|
+ curveRoad.leftLanesCurves = lanes.leftLanesCurves;
|
|
|
+ curveRoad.rightLanesCurves = lanes.rightLanesCurves;
|
|
|
|
|
|
this.addCPoint(
|
|
|
curveRoad,
|
|
@@ -110,6 +112,23 @@ export default class CurveRoadService extends RoadService {
|
|
|
this.insertCPointToLanes(curveRoad, position, startIndex);
|
|
|
}
|
|
|
|
|
|
+ subCPoint(curveRoad, index) {
|
|
|
+ curveRoad.points.splice(index, 1);
|
|
|
+ for (let i = index; i < curveRoad.points.length; ++i) {
|
|
|
+ curveRoad.points[i].setIndex(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ const leftCurveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
|
|
|
+ leftCurveEdge.points.splice(index, 1);
|
|
|
+ curveEdgeService.setCurves(leftCurveEdge);
|
|
|
+
|
|
|
+ const rightCurveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
|
|
|
+ rightCurveEdge.points.splice(index, 1);
|
|
|
+ curveEdgeService.setCurves(rightCurveEdge);
|
|
|
+
|
|
|
+ this.removeCPointToLanes(curveRoad, index);
|
|
|
+ }
|
|
|
+
|
|
|
insertCPointToLanes(curveRoad, position, index) {
|
|
|
for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
|
let leftLine = mathUtil.createLine1(
|
|
@@ -118,6 +137,9 @@ export default class CurveRoadService extends RoadService {
|
|
|
);
|
|
|
const leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
|
|
|
curveRoad.leftLanes[i].splice(index + 1, 0, leftJoin);
|
|
|
+ curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ curveRoad.leftLanes[i]
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
@@ -127,6 +149,18 @@ export default class CurveRoadService extends RoadService {
|
|
|
);
|
|
|
const rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
|
|
|
curveRoad.rightLanes[i].splice(index + 1, 0, rightJoin);
|
|
|
+ curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ curveRoad.rightLanes[i]
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ removeCPointToLanes(curveRoad, index) {
|
|
|
+ for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
|
+ curveRoad.leftLanes[i].splice(index, 1);
|
|
|
+ }
|
|
|
+ for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
|
+ curveRoad.rightLanes[i].splice(index, 1);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -150,7 +184,9 @@ export default class CurveRoadService extends RoadService {
|
|
|
//points的第一个元素是start,最后一个是end
|
|
|
setLanes(points, leftEdgePoints, rightEdgePoints, leftCount, rightCount) {
|
|
|
let leftLanes = [];
|
|
|
+ let leftLanesCurves = [];
|
|
|
let rightLanes = [];
|
|
|
+ let rightLanesCurves = [];
|
|
|
|
|
|
const len = points.length;
|
|
|
let leftdx1 = leftEdgePoints[0].x - points[0].x;
|
|
@@ -208,6 +244,7 @@ export default class CurveRoadService extends RoadService {
|
|
|
leftLanes[i][j].y = join.y;
|
|
|
}
|
|
|
}
|
|
|
+ leftLanesCurves[i] = mathUtil.getCurvesByPoints(leftLanes[i]);
|
|
|
}
|
|
|
|
|
|
let rightdx1 = rightEdgePoints[0].x - points[0].x;
|
|
@@ -265,11 +302,14 @@ export default class CurveRoadService extends RoadService {
|
|
|
rightLanes[i][j].y = join.y;
|
|
|
}
|
|
|
}
|
|
|
+ rightLanesCurves[i] = mathUtil.getCurvesByPoints(rightLanes[i]);
|
|
|
}
|
|
|
|
|
|
return {
|
|
|
leftLanes: leftLanes,
|
|
|
rightLanes: rightLanes,
|
|
|
+ leftLanesCurves: leftLanesCurves,
|
|
|
+ rightLanesCurves: rightLanesCurves,
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -437,6 +477,9 @@ export default class CurveRoadService extends RoadService {
|
|
|
for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
|
|
|
curveRoad.leftLanes[i][index].x += dx;
|
|
|
curveRoad.leftLanes[i][index].y += dy;
|
|
|
+ curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ curveRoad.leftLanes[i]
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
const rightCurveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
|
|
@@ -445,6 +488,9 @@ export default class CurveRoadService extends RoadService {
|
|
|
for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
|
|
|
curveRoad.rightLanes[i][index].x += dx;
|
|
|
curveRoad.rightLanes[i][index].y += dy;
|
|
|
+ curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
|
|
|
+ curveRoad.rightLanes[i]
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
this.setCurves(curveRoad);
|