Browse Source

修复bug

xushiting 2 năm trước cách đây
mục cha
commit
6068ad342b

+ 4 - 4
src/graphic/Controls/AddCrossRoad.js

@@ -420,7 +420,7 @@ export default class AddCrossRoad {
     rightEdge.points.push(edgePoints.rightEdgeEnd);
 
     let point1 = {
-      x: position.x + 200,
+      x: position.x + 250,
       y: position.y + height / 2,
     };
     let point2 = {
@@ -432,7 +432,7 @@ export default class AddCrossRoad {
       y: position.y - height / 2 + 50,
     };
     let point4 = {
-      x: position.x + 200,
+      x: position.x + 250,
       y: position.y - height / 2,
     };
 
@@ -476,7 +476,7 @@ export default class AddCrossRoad {
   }
 
   buildImportSmashedRoad(position) {
-    const roadLen = 600;
+    const roadLen = 800;
     let startPoint = {
       x: position.x,
       y: position.y - (roadLen * 3) / 5,
@@ -493,7 +493,7 @@ export default class AddCrossRoad {
     roadService.create(startPoint.vectorId, crossPoint.vectorId);
     roadService.create(crossPoint.vectorId, endPoint.vectorId);
     let startPoint2 = {
-      x: startPoint.x + roadLen / 4,
+      x: startPoint.x + roadLen / 3,
       y: startPoint.y,
     };
     startPoint2 = roadPointService.create(startPoint2);

+ 6 - 6
src/graphic/Layer.js

@@ -171,10 +171,9 @@ export default class Layer {
         }
         break;
       case LayerEvents.AddCircle:
-       
         stateService.setEventName(LayerEvents.AddingCircle);
         addCircle.setCenter(position);
-        
+
         break;
       case LayerEvents.AddText:
         stateService.setEventName(LayerEvents.MoveText);
@@ -307,10 +306,11 @@ export default class Layer {
               }
               curveRoadService.addCPoint(curveRoad, position, index);
             }
-            curveRoadService.updateForMovePoint(
-              curveRoad.points[index + 1].vectorId,
-              position
-            );
+            curveRoadService.setLanes(curveRoad.vectorId);
+            // curveRoadService.updateForMovePoint(
+            //   curveRoad.points[index + 1].vectorId,
+            //   position
+            // );
           } else if (focusItem.type == VectorType.Line) {
             let line = dataService.getLine(focusItem.vectorId);
             const weight = line.getWeight();

+ 90 - 57
src/graphic/Service/CurveRoadService.js

@@ -203,77 +203,110 @@ export default class CurveRoadService extends RoadService {
     let rightJoin = null;
     const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
     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 + 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 {
-      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[startIndex] = JSON.parse(
+        JSON.stringify(leftCurveEdge.end)
+      );
+      mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
       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[startIndex] = JSON.parse(
+        JSON.stringify(rightCurveEdge.end)
+      );
+      mathUtil.clonePoint(rightCurveEdge.end, rightJoin);
       curveEdgeService.setCurves(rightCurveEdge);
     }
+
     this.setCurves(curveRoad);
   }
 

+ 3 - 0
src/graphic/Util/MathUtil.js

@@ -644,6 +644,9 @@ export default class MathUtil {
   }
 
   equalPoints(points1, points2) {
+    if (points1.length != points2.length) {
+      return false;
+    }
     for (let i = 0; i < points1.length; ++i) {
       let flag = this.equalPoint(points1[i], points2[i]);
       if (!flag) {