|
@@ -9,6 +9,8 @@ import RoadService from "./RoadService";
|
|
|
import { lineService } from "./LineService";
|
|
|
import { uiService } from "./UIService";
|
|
|
|
|
|
+const offsetDis = 50;
|
|
|
+
|
|
|
export default class CurveRoadService extends RoadService {
|
|
|
constructor() {
|
|
|
super();
|
|
@@ -72,14 +74,16 @@ export default class CurveRoadService extends RoadService {
|
|
|
rightEdge.points.push(edgePoints.rightEdgeStart);
|
|
|
rightEdge.points.push(edgePoints.rightEdgeEnd);
|
|
|
|
|
|
- this.addCPoint(
|
|
|
- curveRoad,
|
|
|
- {
|
|
|
- x: (startPoint.x + endPoint.x) / 2,
|
|
|
- y: (startPoint.y + endPoint.y) / 2,
|
|
|
- },
|
|
|
- 0
|
|
|
- );
|
|
|
+ //得有点曲率
|
|
|
+ const midPoint = {
|
|
|
+ x: (startPoint.x + endPoint.x) / 2,
|
|
|
+ y: (startPoint.y + endPoint.y) / 2,
|
|
|
+ };
|
|
|
+ const line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
+ let parallelLines = mathUtil.getParallelLineForDistance(line, offsetDis);
|
|
|
+ const join = mathUtil.getJoinLinePoint(midPoint, parallelLines.line1);
|
|
|
+
|
|
|
+ this.addCPoint(curveRoad, join, 0);
|
|
|
this.setLanes(curveRoad.vectorId);
|
|
|
return curveRoad;
|
|
|
}
|
|
@@ -171,11 +175,11 @@ export default class CurveRoadService extends RoadService {
|
|
|
rightEdge.points.push(edgePoints.rightEdgeStart);
|
|
|
rightEdge.points.push(edgePoints.rightEdgeEnd);
|
|
|
|
|
|
- for (let i = 1; i < newCurveRoad.points.length - 1; ++i) {
|
|
|
+ for (let i = 1; i < curveRoad.points.length - 1; ++i) {
|
|
|
this.addCPoint(
|
|
|
newCurveRoad,
|
|
|
uiService.getNewPositionForPop(curveRoad.points[i]),
|
|
|
- curveRoad.points[i].getIndex()
|
|
|
+ curveRoad.points[i].getIndex() - 1
|
|
|
);
|
|
|
}
|
|
|
|