Explorar el Código

Merge remote-tracking branch 'origin/master'

bill hace 2 años
padre
commit
3e095b030f
Se han modificado 1 ficheros con 104 adiciones y 1 borrados
  1. 104 1
      src/graphic/Service/CurveRoadService.js

+ 104 - 1
src/graphic/Service/CurveRoadService.js

@@ -465,12 +465,16 @@ export default class CurveRoadService extends RoadService {
     let curveRoadId = curvePoint.getParent();
     let curveRoad = dataService.getCurveRoad(curveRoadId);
 
+    let index = curvePoint.getIndex();
     let dx = position.x - curvePoint.x;
     let dy = position.y - curvePoint.y;
-    let index = curvePoint.getIndex();
 
     curvePoint.setPosition(position);
 
+    let line = null;
+    let join = null;
+    let len = curveRoad.points.length;
+
     const leftCurveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
     leftCurveEdge.points[index].x += dx;
     leftCurveEdge.points[index].y += dy;
@@ -480,6 +484,36 @@ export default class CurveRoadService extends RoadService {
       curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
         curveRoad.leftLanes[i]
       );
+
+      //需要修改端点
+      if (
+        index == 0 ||
+        index == 1 ||
+        index == curveRoad.points.length - 1 ||
+        index == curveRoad.points.length - 2
+      ) {
+        if (index == 0 || index == 1) {
+          line = mathUtil.createLine1(
+            curveRoad.leftLanes[i][0],
+            curveRoad.leftLanes[i][1]
+          );
+          join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
+          curveRoad.leftLanes[i][0].x = join.x;
+          curveRoad.leftLanes[i][0].y = join.y;
+        }
+        if (
+          index == curveRoad.points.length - 1 ||
+          index == curveRoad.points.length - 2
+        ) {
+          line = mathUtil.createLine1(
+            curveRoad.leftLanes[i][len - 2],
+            curveRoad.leftLanes[i][len - 1]
+          );
+          join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
+          curveRoad.leftLanes[i][len - 1].x = join.x;
+          curveRoad.leftLanes[i][len - 1].y = join.y;
+        }
+      }
     }
 
     const rightCurveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
@@ -491,6 +525,75 @@ export default class CurveRoadService extends RoadService {
       curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
         curveRoad.rightLanes[i]
       );
+
+      //需要修改端点
+      if (
+        index == 0 ||
+        index == 1 ||
+        index == curveRoad.points.length - 1 ||
+        index == curveRoad.points.length - 2
+      ) {
+        if (index == 0 || index == 1) {
+          line = mathUtil.createLine1(
+            curveRoad.rightLanes[i][0],
+            curveRoad.rightLanes[i][1]
+          );
+          join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
+          curveRoad.rightLanes[i][0].x = join.x;
+          curveRoad.rightLanes[i][0].y = join.y;
+        }
+        if (
+          index == curveRoad.points.length - 1 ||
+          index == curveRoad.points.length - 2
+        ) {
+          line = mathUtil.createLine1(
+            curveRoad.rightLanes[i][len - 2],
+            curveRoad.rightLanes[i][len - 1]
+          );
+          join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
+          curveRoad.rightLanes[i][len - 1].x = join.x;
+          curveRoad.rightLanes[i][len - 1].y = join.y;
+        }
+      }
+    }
+
+    if (index == 0 || index == 1) {
+      line = mathUtil.createLine1(
+        leftCurveEdge.points[0],
+        leftCurveEdge.points[1]
+      );
+      join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
+      leftCurveEdge.points[0].x = join.x;
+      leftCurveEdge.points[0].y = join.y;
+
+      line = mathUtil.createLine1(
+        rightCurveEdge.points[0],
+        rightCurveEdge.points[1]
+      );
+      join = mathUtil.getJoinLinePoint(curveRoad.points[0], line);
+      rightCurveEdge.points[0].x = join.x;
+      rightCurveEdge.points[0].y = join.y;
+    }
+
+    if (
+      index == curveRoad.points.length - 1 ||
+      index == curveRoad.points.length - 2
+    ) {
+      line = mathUtil.createLine1(
+        leftCurveEdge.points[len - 2],
+        leftCurveEdge.points[len - 1]
+      );
+      join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
+      leftCurveEdge.points[len - 1].x = join.x;
+      leftCurveEdge.points[len - 1].y = join.y;
+
+      line = mathUtil.createLine1(
+        rightCurveEdge.points[len - 2],
+        rightCurveEdge.points[len - 1]
+      );
+      join = mathUtil.getJoinLinePoint(curveRoad.points[len - 1], line);
+      rightCurveEdge.points[len - 1].x = join.x;
+      rightCurveEdge.points[len - 1].y = join.y;
     }
 
     this.setCurves(curveRoad);