jinx 1 år sedan
förälder
incheckning
9d3efa10a4
2 ändrade filer med 189 tillägg och 668 borttagningar
  1. 76 297
      src/graphic/Controls/MoveRoad.js
  2. 113 371
      src/graphic/Service/RoadService.js

+ 76 - 297
src/graphic/Controls/MoveRoad.js

@@ -44,21 +44,13 @@ export default class MoveRoad {
     // }
     this.adsorbPointRoads = {};
     this.splitRoadId = null;
-    let flag = this.canMoveForPoint(
-      pointId,
-      position,
-      linkedRoadPointId,
-      linkedRoadId
-    );
+    let flag = this.canMoveForPoint(pointId, position, linkedRoadPointId, linkedRoadId);
 
     if (!flag) {
       return false;
     }
 
-    if (
-      this.splitRoadId == null &&
-      Object.keys(this.adsorbPointRoads).length > 0
-    ) {
+    if (this.splitRoadId == null && Object.keys(this.adsorbPointRoads).length > 0) {
       //要吸附一下
       const adsorbPointId = Object.keys(this.adsorbPointRoads)[0];
       const road = dataService.getRoad(this.adsorbPointRoads[adsorbPointId]);
@@ -74,14 +66,8 @@ export default class MoveRoad {
       point.setPosition(position);
     }
     // 与别的墙角重合
-    else if (
-      modifyPoint.hasOwnProperty("linkedRoadPointId") &&
-      modifyPoint.linkedRoadPointId != null
-    ) {
-      const roadId = roadService.getRoadId(
-        pointId,
-        modifyPoint.linkedRoadPointId
-      );
+    else if (modifyPoint.hasOwnProperty("linkedRoadPointId") && modifyPoint.linkedRoadPointId != null) {
+      const roadId = roadService.getRoadId(pointId, modifyPoint.linkedRoadPointId);
       // pointId与linkedPointId属于同一堵墙,不允许,所以不移动
       if (roadId != null) {
         return false;
@@ -97,24 +83,15 @@ export default class MoveRoad {
       const endPoint = dataService.getRoadPoint(road.endId);
 
       // 与其余墙角的距离过短,不允许拖动
-      if (
-        mathUtil.getDistance(startPoint, position) < Constant.minRealDis ||
-        mathUtil.getDistance(endPoint, position) < Constant.minRealDis
-      ) {
+      if (mathUtil.getDistance(startPoint, position) < Constant.minRealDis || mathUtil.getDistance(endPoint, position) < Constant.minRealDis) {
         return false;
       }
       point.setPosition(modifyPoint);
     } else if (modifyPoint.hasOwnProperty("linkedCurveRoadPointId")) {
       point.setPosition(position);
-    } else if (
-      modifyPoint.hasOwnProperty("linkedRoadPointIdX") &&
-      modifyPoint.linkedRoadPointIdX
-    ) {
+    } else if (modifyPoint.hasOwnProperty("linkedRoadPointIdX") && modifyPoint.linkedRoadPointIdX) {
       point.setPosition(position);
-    } else if (
-      modifyPoint.hasOwnProperty("linkedRoadPointIdY") &&
-      modifyPoint.linkedRoadPointIdY
-    ) {
+    } else if (modifyPoint.hasOwnProperty("linkedRoadPointIdY") && modifyPoint.linkedRoadPointIdY) {
       point.setPosition(position);
     } else {
       return false;
@@ -174,26 +151,12 @@ export default class MoveRoad {
   }
 
   finishByMoveRoadPoint(point) {
-    if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")
-    ) {
+    if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")) {
       this.moveTo(point.vectorId, listenLayer.modifyPoint.linkedRoadPointId);
-    } else if (
-      listenLayer.modifyPoint &&
-      (listenLayer.modifyPoint.linkedRoadPointIdX ||
-        listenLayer.modifyPoint.linkedRoadPointIdY)
-    ) {
+    } else if (listenLayer.modifyPoint && (listenLayer.modifyPoint.linkedRoadPointIdX || listenLayer.modifyPoint.linkedRoadPointIdY)) {
       mathUtil.clonePoint(point, listenLayer.modifyPoint);
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")
-    ) {
-      roadService.splitRoad(
-        listenLayer.modifyPoint.linkedRoadId,
-        point.vectorId,
-        "start"
-      );
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")) {
+      roadService.splitRoad(listenLayer.modifyPoint.linkedRoadId, point.vectorId, "start");
       edgeService.updateEdgeForMovePoint(point.vectorId);
       if (listenLayer.modifyPoint.linkedRoadId == this.splitRoadId) {
         this.splitRoadId = null;
@@ -225,6 +188,7 @@ export default class MoveRoad {
 
   //拖拽墙角/墙面,被其他墙角吸附
   updateForAbsorbRoadPoints() {
+    console.error(1);
     if (Object.keys(this.adsorbPointRoads).length == 0) {
       return;
     } else if (Object.keys(this.adsorbPointRoads).length == 2) {
@@ -246,10 +210,7 @@ export default class MoveRoad {
     const startPoint = dataService.getRoadPoint(road.startId);
 
     function sortNumber(a, b) {
-      return (
-        mathUtil.getDistance(startPoint, a.join) -
-        mathUtil.getDistance(startPoint, b.join)
-      );
+      return mathUtil.getDistance(startPoint, a.join) - mathUtil.getDistance(startPoint, b.join);
     }
 
     joins = joins.sort(sortNumber.bind(this));
@@ -267,10 +228,7 @@ export default class MoveRoad {
       let splitRoad = dataService.getRoad(this.splitRoadId);
       let splitRoadStartPoint = dataService.getRoadPoint(splitRoad.startId);
       let splitRoadEndPoint = dataService.getRoadPoint(splitRoad.endId);
-      let splitLine = mathUtil.createLine1(
-        splitRoadStartPoint,
-        splitRoadEndPoint
-      );
+      let splitLine = mathUtil.createLine1(splitRoadStartPoint, splitRoadEndPoint);
       let parent = point.getParent();
       for (let key in parent) {
         let road = dataService.getRoad(key);
@@ -278,22 +236,29 @@ export default class MoveRoad {
         let endPoint = dataService.getRoadPoint(road.endId);
         let line = mathUtil.createLine1(startPoint, endPoint);
         let join = mathUtil.getIntersectionPoint(splitLine, line);
-        if (
-          mathUtil.isContainForSegment(join, startPoint, endPoint) &&
-          mathUtil.getDistance(join, splitRoadStartPoint) <
-            Constant.minAdsorbPix
-        ) {
+        if (mathUtil.isContainForSegment(join, startPoint, endPoint) && mathUtil.getDistance(join, splitRoadStartPoint) < Constant.minAdsorbPix) {
           roadService.splitRoad(key, splitRoadStartPoint.vectorId, "start");
           return splitRoadStartPoint.vectorId;
-        } else if (
-          mathUtil.isContainForSegment(join, startPoint, endPoint) &&
-          mathUtil.getDistance(join, splitRoadEndPoint) < Constant.minAdsorbPix
-        ) {
+        } else if (mathUtil.isContainForSegment(join, startPoint, endPoint) && mathUtil.getDistance(join, splitRoadEndPoint) < Constant.minAdsorbPix) {
           roadService.splitRoad(key, splitRoadEndPoint.vectorId, "end");
           return splitRoadEndPoint.vectorId;
         }
       }
     }
+
+    //拖拽道路融合后在初始化
+    let roadEdges = dataService.getRoadEdges();
+    for (let key in roadEdges) {
+      if (roadEdges[key] && roadEdges[key].roadSide) {
+        roadEdges[key].initRoadSide();
+      }
+    }
+    //拖拽道路融合后在初始化
+    let roads = dataService.getRoads();
+    for (let key in roads) {
+      roadService.initRoadWidthTipsPos(roads[key]);
+    }
+
     return null;
   }
 
@@ -357,16 +322,8 @@ export default class MoveRoad {
       const startPoint2 = dataService.getRoadPoint(road2.startId);
       const endPoint2 = dataService.getRoadPoint(road2.endId);
 
-      const join1 = mathUtil.getIntersectionPoint4(
-        startPoint1,
-        endPoint1,
-        newLine
-      );
-      const join2 = mathUtil.getIntersectionPoint4(
-        startPoint2,
-        endPoint2,
-        newLine
-      );
+      const join1 = mathUtil.getIntersectionPoint4(startPoint1, endPoint1, newLine);
+      const join2 = mathUtil.getIntersectionPoint4(startPoint2, endPoint2, newLine);
 
       // 取角度大的
       if (join1 == null && join2 == null) {
@@ -405,10 +362,7 @@ export default class MoveRoad {
       let join = mathUtil.getIntersectionPoint(startLimitLine, newLine);
       const tempStartPoint = dataService.getRoadPoint(tempRoad.startId);
       const tempEndPoint = dataService.getRoadPoint(tempRoad.endId);
-      if (
-        angle > Constant.maxAngle ||
-        !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)
-      ) {
+      if (angle > Constant.maxAngle || !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)) {
         startLimitLine = mathUtil.getVerticalLine(roadLine, startPoint);
         limitInfos.startRoadId = null;
         limitInfos.newStartRoadId = true;
@@ -444,16 +398,8 @@ export default class MoveRoad {
       const startPoint2 = dataService.getRoadPoint(road2.startId);
       const endPoint2 = dataService.getRoadPoint(road2.endId);
 
-      const join1 = mathUtil.getIntersectionPoint4(
-        startPoint1,
-        endPoint1,
-        newLine
-      );
-      const join2 = mathUtil.getIntersectionPoint4(
-        startPoint2,
-        endPoint2,
-        newLine
-      );
+      const join1 = mathUtil.getIntersectionPoint4(startPoint1, endPoint1, newLine);
+      const join2 = mathUtil.getIntersectionPoint4(startPoint2, endPoint2, newLine);
 
       // 取角度大的
       if (join1 == null && join2 == null) {
@@ -492,10 +438,7 @@ export default class MoveRoad {
       const tempStartPoint = dataService.getRoadPoint(tempRoad.start);
       const tempEndPoint = dataService.getRoadPoint(tempRoad.end);
 
-      if (
-        angle > Constant.maxAngle ||
-        !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)
-      ) {
+      if (angle > Constant.maxAngle || !mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)) {
         endLimitLine = mathUtil.getVerticalLine(roadLine, endPoint);
         limitInfos.endRoadId = null;
         limitInfos.newEndRoadId = true;
@@ -515,13 +458,7 @@ export default class MoveRoad {
     // 开始考虑第一点
     if (flag) {
       // 不仅仅角度,还有相交
-      flag = this.isOKForCross(
-        pointId,
-        position,
-        point.parent,
-        linkedRoadPointId,
-        linkedRoadId
-      );
+      flag = this.isOKForCross(pointId, position, point.parent, linkedRoadPointId, linkedRoadId);
     }
     return flag;
   }
@@ -677,14 +614,7 @@ export default class MoveRoad {
         const otherPointId = _road.getOtherPointId(pointId);
         const otherPoint = dataService.getRoadPoint(otherPointId);
 
-        const flag = this.isOKForCrossTwoRoad(
-          position,
-          otherPoint,
-          key,
-          linkedRoadPointId,
-          linkedRoadId,
-          _road.vectorId
-        );
+        const flag = this.isOKForCrossTwoRoad(position, otherPoint, key, linkedRoadPointId, linkedRoadId, _road.vectorId);
         // 交叉
         if (!flag) {
           this.adsorbPointRoads = {};
@@ -705,28 +635,12 @@ export default class MoveRoad {
   // position1表示拖拽的点的坐标(修复过了的)
   // position2对应墙的另一头坐标
   // roadId表示其余的墙(与position1无关的墙)
-  isOKForCrossTwoRoad(
-    position1,
-    position2,
-    roadId,
-    linkedRoadPointId,
-    linkedRoadId,
-    dragRoadId
-  ) {
+  isOKForCrossTwoRoad(position1, position2, roadId, linkedRoadPointId, linkedRoadId, dragRoadId) {
     const road = dataService.getRoad(roadId);
     const startPoint = dataService.getRoadPoint(road.startId);
     const endPoint = dataService.getRoadPoint(road.endId);
-    const join = mathUtil.getIntersectionPoint3(
-      position1,
-      position2,
-      startPoint,
-      endPoint
-    );
-    if (
-      join &&
-      road.startId != linkedRoadPointId &&
-      road.endId != linkedRoadPointId
-    ) {
+    const join = mathUtil.getIntersectionPoint3(position1, position2, startPoint, endPoint);
+    if (join && road.startId != linkedRoadPointId && road.endId != linkedRoadPointId) {
       // 交叉了
       this.splitRoadId = roadId;
       return true;
@@ -738,20 +652,14 @@ export default class MoveRoad {
       let join1 = mathUtil.getJoinLinePoint(startPoint, line);
       let join2 = mathUtil.getJoinLinePoint(endPoint, line);
 
-      if (
-        mathUtil.getDistance(join1, startPoint) < Constant.minRealDis &&
-        mathUtil.PointInSegment(join1, position1, position2)
-      ) {
+      if (mathUtil.getDistance(join1, startPoint) < Constant.minRealDis && mathUtil.PointInSegment(join1, position1, position2)) {
         if (road.startId != linkedRoadPointId) {
           // 交叉了
           this.adsorbPointRoads[startPoint.vectorId] = dragRoadId;
           //为了找到全部的吸附点,暂时返回true,在外面一层再做判断
           return true;
         }
-      } else if (
-        mathUtil.getDistance(join2, endPoint) < Constant.minRealDis &&
-        mathUtil.PointInSegment(join2, position1, position2)
-      ) {
+      } else if (mathUtil.getDistance(join2, endPoint) < Constant.minRealDis && mathUtil.PointInSegment(join2, position1, position2)) {
         if (road.endId != linkedRoadPointId) {
           // 交叉了
           this.adsorbPointRoads[endPoint.vectorId] = dragRoadId;
@@ -763,28 +671,14 @@ export default class MoveRoad {
       line = mathUtil.createLine1(startPoint, endPoint);
       join1 = mathUtil.getJoinLinePoint(position1, line);
       join2 = mathUtil.getJoinLinePoint(position2, line);
-      if (
-        mathUtil.getDistance(join1, position1) < Constant.minRealDis &&
-        mathUtil.PointInSegment(join1, startPoint, endPoint)
-      ) {
-        if (
-          road.startId != linkedRoadPointId &&
-          road.endId != linkedRoadPointId &&
-          roadId != linkedRoadId
-        ) {
+      if (mathUtil.getDistance(join1, position1) < Constant.minRealDis && mathUtil.PointInSegment(join1, startPoint, endPoint)) {
+        if (road.startId != linkedRoadPointId && road.endId != linkedRoadPointId && roadId != linkedRoadId) {
           // 交叉了
           //return false
           return true;
         }
-      } else if (
-        mathUtil.getDistance(join2, position2) < Constant.minRealDis &&
-        mathUtil.PointInSegment(join2, startPoint, endPoint)
-      ) {
-        if (
-          road.startId != linkedRoadPointId &&
-          road.endId != linkedRoadPointId &&
-          roadId != linkedRoadId
-        ) {
+      } else if (mathUtil.getDistance(join2, position2) < Constant.minRealDis && mathUtil.PointInSegment(join2, startPoint, endPoint)) {
+        if (road.startId != linkedRoadPointId && road.endId != linkedRoadPointId && roadId != linkedRoadId) {
           // 交叉了
           //return false
           return true;
@@ -799,13 +693,7 @@ export default class MoveRoad {
     const road = dataService.getRoad(roadId);
     const startPoint = dataService.getRoadPoint(road.startId);
     const endPoint = dataService.getRoadPoint(road.endId);
-    let flag = mathUtil.crossTwoLines(
-      position1,
-      position2,
-      startPoint,
-      endPoint,
-      0.01
-    );
+    let flag = mathUtil.crossTwoLines(position1, position2, startPoint, endPoint, 0.01);
     if (flag) {
       // 交叉了
       return false;
@@ -826,13 +714,7 @@ export default class MoveRoad {
     const road = dataService.getRoad(roadId);
     const startPoint = dataService.getRoadPoint(road.startId);
     const endPoint = dataService.getRoadPoint(road.endId);
-    const flag = mathUtil.crossTwoLines(
-      position1,
-      position2,
-      startPoint,
-      endPoint,
-      0.01
-    );
+    const flag = mathUtil.crossTwoLines(position1, position2, startPoint, endPoint, 0.01);
     if (flag) {
       // 交叉了
       return false;
@@ -844,26 +726,17 @@ export default class MoveRoad {
       let join1 = mathUtil.getJoinLinePoint(startPoint, line);
       const join2 = mathUtil.getJoinLinePoint(endPoint, line);
 
-      if (
-        mathUtil.getDistance(join1, startPoint) < Constant.minRealDis &&
-        mathUtil.isPointOnSegment(join1, position1, position2)
-      ) {
+      if (mathUtil.getDistance(join1, startPoint) < Constant.minRealDis && mathUtil.isPointOnSegment(join1, position1, position2)) {
         // 交叉了
         return false;
-      } else if (
-        mathUtil.getDistance(join2, endPoint) < Constant.minRealDis &&
-        mathUtil.isPointOnSegment(join2, position1, position2)
-      ) {
+      } else if (mathUtil.getDistance(join2, endPoint) < Constant.minRealDis && mathUtil.isPointOnSegment(join2, position1, position2)) {
         // 交叉了
         return false;
       }
 
       line = mathUtil.createLine1(startPoint, endPoint);
       join1 = mathUtil.getJoinLinePoint(position1, line);
-      if (
-        mathUtil.getDistance(join1, position1) < Constant.minRealDis &&
-        roadService.isContain(road, join1)
-      ) {
+      if (mathUtil.getDistance(join1, position1) < Constant.minRealDis && roadService.isContain(road, join1)) {
         // 交叉了
         return false;
       }
@@ -879,16 +752,10 @@ export default class MoveRoad {
     let line = mathUtil.createLine1(position1, position2);
     let join1 = mathUtil.getJoinLinePoint(startPoint, line);
     let join2 = mathUtil.getJoinLinePoint(endPoint, line);
-    if (
-      mathUtil.getDistance(join1, startPoint) < Constant.minRealDis &&
-      mathUtil.PointInSegment(join1, position1, position2)
-    ) {
+    if (mathUtil.getDistance(join1, startPoint) < Constant.minRealDis && mathUtil.PointInSegment(join1, position1, position2)) {
       // 交叉了
       return false;
-    } else if (
-      mathUtil.getDistance(join2, endPoint) < Constant.minRealDis &&
-      mathUtil.PointInSegment(join2, position1, position2)
-    ) {
+    } else if (mathUtil.getDistance(join2, endPoint) < Constant.minRealDis && mathUtil.PointInSegment(join2, position1, position2)) {
       // 交叉了
       return false;
     }
@@ -897,16 +764,10 @@ export default class MoveRoad {
     join1 = mathUtil.getJoinLinePoint(position1, line);
     join2 = mathUtil.getJoinLinePoint(position2, line);
 
-    if (
-      mathUtil.getDistance(join1, position1) < Constant.minRealDis &&
-      roadService.isContain(road, join1)
-    ) {
+    if (mathUtil.getDistance(join1, position1) < Constant.minRealDis && roadService.isContain(road, join1)) {
       // 交叉了
       return false;
-    } else if (
-      mathUtil.getDistance(join2, position2) < Constant.minRealDis &&
-      roadService.isContain(road, join2)
-    ) {
+    } else if (mathUtil.getDistance(join2, position2) < Constant.minRealDis && roadService.isContain(road, join2)) {
       // 交叉了
       return false;
     }
@@ -926,11 +787,8 @@ export default class MoveRoad {
         otherPoint = dataService.getRoadPoint(otherPointId);
         // 会吸附另一头
         if (
-          mathUtil.getDistance(virtualPosition, otherPoint) <
-            Constant.minRealDis ||
-          (!roadService.isContain(limitRoad, virtualPosition) &&
-            mathUtil.getDistance(virtualPosition, otherPoint) <
-              mathUtil.getDistance(virtualPosition, point))
+          mathUtil.getDistance(virtualPosition, otherPoint) < Constant.minRealDis ||
+          (!roadService.isContain(limitRoad, virtualPosition) && mathUtil.getDistance(virtualPosition, otherPoint) < mathUtil.getDistance(virtualPosition, point))
         ) {
           mathUtil.clonePoint(virtualPosition, otherPoint);
           adsorb = true;
@@ -1025,15 +883,7 @@ export default class MoveRoad {
   // position5和position6表示road的end一边的线段(endPoint——virtualEndPoint)
   // adsorbPointId1对应start那一头的吸附点
   // adsorbPointId2对应end那一头的吸附点
-  isOKForCrossForMoveRoad(
-    position1,
-    position2,
-    roadId,
-    startPointId,
-    endPointId,
-    adsorbPointId1,
-    adsorbPointId2
-  ) {
+  isOKForCrossForMoveRoad(position1, position2, roadId, startPointId, endPointId, adsorbPointId1, adsorbPointId2) {
     const startPoint = dataService.getRoadPoint(startPointId);
     const endPoint = dataService.getRoadPoint(endPointId);
     let flag = true;
@@ -1047,16 +897,10 @@ export default class MoveRoad {
       let flag2 = true;
 
       const _road = dataService.getRoad(key);
-      if (
-        adsorbPointId1 &&
-        (adsorbPointId1 == _road.startId || adsorbPointId1 == _road.endId)
-      ) {
+      if (adsorbPointId1 && (adsorbPointId1 == _road.startId || adsorbPointId1 == _road.endId)) {
         flag1 = false;
       }
-      if (
-        adsorbPointId2 &&
-        (adsorbPointId2 == _road.startId || adsorbPointId2 == _road.endId)
-      ) {
+      if (adsorbPointId2 && (adsorbPointId2 == _road.startId || adsorbPointId2 == _road.endId)) {
         flag2 = false;
       }
 
@@ -1076,11 +920,7 @@ export default class MoveRoad {
       if (!flag) {
         return false;
       }
-      if (
-        flag1 &&
-        _road.startId != startPointId &&
-        _road.endId != startPointId
-      ) {
+      if (flag1 && _road.startId != startPointId && _road.endId != startPointId) {
         flag = this.isOKForCrossTwoRoad3(position1, startPoint, key);
       }
 
@@ -1106,10 +946,7 @@ export default class MoveRoad {
     const road = dataService.getRoad(roadId);
     const startPoint = dataService.getRoadPoint(road.startId);
     const endPoint = dataService.getRoadPoint(road.endId);
-    if (
-      Object.keys(startPoint.getParent()).length == 1 &&
-      Object.keys(endPoint.getParent()).length == 1
-    ) {
+    if (Object.keys(startPoint.getParent()).length == 1 && Object.keys(endPoint.getParent()).length == 1) {
       const p1 = { x: startPoint.x + dx, y: startPoint.y + dy };
       const p2 = { x: endPoint.x + dx, y: endPoint.y + dy };
 
@@ -1262,9 +1099,7 @@ export default class MoveRoad {
         road1.endId = pointId2;
         point2.setPointParent(roadId1, "end");
       } else {
-        console.error(
-          "roadService.moveTo****************************************************"
-        );
+        console.error("roadService.moveTo****************************************************");
       }
     }
 
@@ -1332,27 +1167,16 @@ export default class MoveRoad {
     const line2 = mathUtil.createLine1(rightEdge.start, rightEdge.end);
     let rightJoin = mathUtil.getJoinLinePoint(position, line2);
 
-    if (
-      dir == "left" &&
-      (mathUtil.isContainForSegment(position, join, rightJoin) ||
-        mathUtil.isContainForSegment(rightJoin, join, position))
-    ) {
+    if (dir == "left" && (mathUtil.isContainForSegment(position, join, rightJoin) || mathUtil.isContainForSegment(rightJoin, join, position))) {
       return;
     }
 
-    if (
-      dir == "right" &&
-      (mathUtil.isContainForSegment(position, join, leftJoin) ||
-        mathUtil.isContainForSegment(leftJoin, join, position))
-    ) {
+    if (dir == "right" && (mathUtil.isContainForSegment(position, join, leftJoin) || mathUtil.isContainForSegment(leftJoin, join, position))) {
       return;
     }
 
     const newWidth = mathUtil.getDisForPoinLine(position, line);
-    if (
-      newWidth > Constant.minRoadSideWidth &&
-      newWidth < Constant.maxRoadSideWidth
-    ) {
+    if (newWidth > Constant.minRoadSideWidth && newWidth < Constant.maxRoadSideWidth) {
       roadService.updateForWidth(parent, newWidth, dir);
     }
     // roadService.initRoadWidthTipsPos(road);
@@ -1420,70 +1244,25 @@ export default class MoveRoad {
 
     const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
     const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
-    let joinInfo = mathUtil.getHitInfoForCurve(
-      position,
-      curveRoad.curves[index],
-      Math.max(curveRoad.leftWidth, curveRoad.rightWidth)
-    );
-
-    let leftJoinInfo = mathUtil.getHitInfoForCurve(
-      position,
-      leftCurveEdge.curves[index],
-      curveRoad.leftWidth
-    );
-    let leftLine = mathUtil.createLine1(
-      leftJoinInfo.position,
-      joinInfo.position
-    );
+    let joinInfo = mathUtil.getHitInfoForCurve(position, curveRoad.curves[index], Math.max(curveRoad.leftWidth, curveRoad.rightWidth));
+
+    let leftJoinInfo = mathUtil.getHitInfoForCurve(position, leftCurveEdge.curves[index], curveRoad.leftWidth);
+    let leftLine = mathUtil.createLine1(leftJoinInfo.position, joinInfo.position);
     let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
 
-    let rightJoinInfo = mathUtil.getHitInfoForCurve(
-      position,
-      rightCurveEdge.curves[index],
-      curveRoad.rightWidth
-    );
-    let rightLine = mathUtil.createLine1(
-      rightJoinInfo.position,
-      joinInfo.position
-    );
+    let rightJoinInfo = mathUtil.getHitInfoForCurve(position, rightCurveEdge.curves[index], curveRoad.rightWidth);
+    let rightLine = mathUtil.createLine1(rightJoinInfo.position, joinInfo.position);
     let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
-    if (
-      dir == "left" &&
-      (mathUtil.isContainForSegment(
-        rightJoin,
-        rightJoinInfo.position,
-        joinInfo.position
-      ) ||
-        mathUtil.isContainForSegment(
-          rightJoinInfo.position,
-          rightJoin,
-          joinInfo.position
-        ))
-    ) {
+    if (dir == "left" && (mathUtil.isContainForSegment(rightJoin, rightJoinInfo.position, joinInfo.position) || mathUtil.isContainForSegment(rightJoinInfo.position, rightJoin, joinInfo.position))) {
       return;
     }
 
-    if (
-      dir == "right" &&
-      (mathUtil.isContainForSegment(
-        leftJoin,
-        leftJoinInfo.position,
-        joinInfo.position
-      ) ||
-        mathUtil.isContainForSegment(
-          leftJoinInfo.position,
-          leftJoin,
-          joinInfo.position
-        ))
-    ) {
+    if (dir == "right" && (mathUtil.isContainForSegment(leftJoin, leftJoinInfo.position, joinInfo.position) || mathUtil.isContainForSegment(leftJoinInfo.position, leftJoin, joinInfo.position))) {
       return;
     }
 
     const newWidth = mathUtil.getDistance(joinInfo.position, position);
-    if (
-      newWidth > Constant.minRoadSideWidth &&
-      newWidth < Constant.maxRoadSideWidth
-    ) {
+    if (newWidth > Constant.minRoadSideWidth && newWidth < Constant.maxRoadSideWidth) {
       curveRoadService.updateForWidth(parent, newWidth, dir);
     }
     if (curveEdge.roadSide) {

+ 113 - 371
src/graphic/Service/RoadService.js

@@ -26,31 +26,13 @@ export default class RoadService {
 
     let edgePoints;
     if (road.way == Constant.oneWay) {
-      edgePoints = mathUtil.RectangleVertex(
-        startPoint,
-        endPoint,
-        road.singleRoadWidth
-      );
+      edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, road.singleRoadWidth);
     } else {
-      edgePoints = mathUtil.RectangleVertex(
-        startPoint,
-        endPoint,
-        road.leftWidth + road.rightWidth + road.midDivide.midDivideWidth
-      );
+      edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, road.leftWidth + road.rightWidth + road.midDivide.midDivideWidth);
     }
-    let leftEdge = edgeService.create(
-      edgePoints.leftEdgeStart,
-      edgePoints.leftEdgeEnd,
-      null,
-      vectorId
-    );
-
-    let rightEdge = edgeService.create(
-      edgePoints.rightEdgeStart,
-      edgePoints.rightEdgeEnd,
-      null,
-      vectorId
-    );
+    let leftEdge = edgeService.create(edgePoints.leftEdgeStart, edgePoints.leftEdgeEnd, null, vectorId);
+
+    let rightEdge = edgeService.create(edgePoints.rightEdgeStart, edgePoints.rightEdgeEnd, null, vectorId);
 
     road.setLeftEdge(leftEdge.vectorId);
     road.setRightEdge(rightEdge.vectorId);
@@ -100,31 +82,13 @@ export default class RoadService {
 
     let edgePoints;
     if (newRoad.way == Constant.oneWay) {
-      edgePoints = mathUtil.RectangleVertex(
-        newStartPoint,
-        newEndPoint,
-        road.singleRoadWidth
-      );
+      edgePoints = mathUtil.RectangleVertex(newStartPoint, newEndPoint, road.singleRoadWidth);
     } else {
-      edgePoints = mathUtil.RectangleVertex(
-        newStartPoint,
-        newEndPoint,
-        road.leftWidth + road.rightWidth + road.midDivide.midDivideWidth
-      );
+      edgePoints = mathUtil.RectangleVertex(newStartPoint, newEndPoint, road.leftWidth + road.rightWidth + road.midDivide.midDivideWidth);
     }
-    let leftEdge = edgeService.create(
-      edgePoints.leftEdgeStart,
-      edgePoints.leftEdgeEnd,
-      null,
-      vectorId
-    );
-
-    let rightEdge = edgeService.create(
-      edgePoints.rightEdgeStart,
-      edgePoints.rightEdgeEnd,
-      null,
-      vectorId
-    );
+    let leftEdge = edgeService.create(edgePoints.leftEdgeStart, edgePoints.leftEdgeEnd, null, vectorId);
+
+    let rightEdge = edgeService.create(edgePoints.rightEdgeStart, edgePoints.rightEdgeEnd, null, vectorId);
 
     newRoad.setLeftEdge(leftEdge.vectorId);
     newRoad.setRightEdge(rightEdge.vectorId);
@@ -160,6 +124,7 @@ export default class RoadService {
     }
     this.setLanes(newRoad.vectorId);
     this.initRoadWidthTipsPos(newRoad);
+
     return newRoad.vectorId;
   }
 
@@ -177,10 +142,7 @@ export default class RoadService {
     const startPoint = dataService.getRoadPoint(road.startId);
     const endPoint = dataService.getRoadPoint(road.endId);
     const point = dataService.getRoadPoint(pointId);
-    if (
-      mathUtil.getDistance(startPoint, point) < Constant.minAdsorbPix ||
-      mathUtil.getDistance(endPoint, point) < Constant.minAdsorbPix
-    ) {
+    if (mathUtil.getDistance(startPoint, point) < Constant.minAdsorbPix || mathUtil.getDistance(endPoint, point) < Constant.minAdsorbPix) {
     }
 
     let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
@@ -241,26 +203,22 @@ export default class RoadService {
       crossPointService.replaceEdgeId(cpt, road.leftEdgeId, newRoad.leftEdgeId);
 
       cpt = dataService.getCrossPointForEdgeId(road.rightEdgeId, "end");
-      crossPointService.replaceEdgeId(
-        cpt,
-        road.rightEdgeId,
-        newRoad.rightEdgeId
-      );
+      crossPointService.replaceEdgeId(cpt, road.rightEdgeId, newRoad.rightEdgeId);
 
       let newRoadLeftEdge = dataService.getRoadEdge(newRoad.leftEdgeId);
       mathUtil.clonePoint(newRoadLeftEdge.end, oldLeftEdgeEndPoint);
       //newRoadLeftEdge.roadSide = leftEdge.roadSide;
-      if(leftEdge.roadSide){
-        newRoadLeftEdge.initRoadSide()
-        newRoadLeftEdge.setRoadSideWidth(leftEdge.roadSide.width)
+      if (leftEdge.roadSide) {
+        newRoadLeftEdge.initRoadSide();
+        newRoadLeftEdge.setRoadSideWidth(leftEdge.roadSide.width);
       }
 
       let newRoadRightEdge = dataService.getRoadEdge(newRoad.rightEdgeId);
       mathUtil.clonePoint(newRoadRightEdge.end, oldRightEdgeEndPoint);
       //newRoadRightEdge.roadSide = rightEdge.roadSide;
-      if(rightEdge.roadSide){
-        newRoadRightEdge.initRoadSide()
-        newRoadRightEdge.setRoadSideWidth(rightEdge.roadSide.width)
+      if (rightEdge.roadSide) {
+        newRoadRightEdge.initRoadSide();
+        newRoadRightEdge.setRoadSideWidth(rightEdge.roadSide.width);
       }
 
       if (Object.keys(startPoint).length > 1) {
@@ -268,40 +226,35 @@ export default class RoadService {
         mathUtil.clonePoint(rightEdge.start, oldRightEdgeStartPoint);
       }
       //修改路缘线end
-      if(leftEdge.roadSide){
-        leftEdge.initRoadSide()
-        leftEdge.setRoadSideWidth(leftEdge.roadSide.width)
+      if (leftEdge.roadSide) {
+        leftEdge.initRoadSide();
+        leftEdge.setRoadSideWidth(leftEdge.roadSide.width);
       }
-      if(rightEdge.roadSide){
-        leftEdge.initRoadSide()
-        rightEdge.setRoadSideWidth(rightEdge.roadSide.width)
+      if (rightEdge.roadSide) {
+        leftEdge.initRoadSide();
+        rightEdge.setRoadSideWidth(rightEdge.roadSide.width);
       }
-
     } else if (dir == "end") {
       let cpt = dataService.getCrossPointForEdgeId(road.leftEdgeId, "start");
       crossPointService.replaceEdgeId(cpt, road.leftEdgeId, newRoad.leftEdgeId);
 
       cpt = dataService.getCrossPointForEdgeId(road.rightEdgeId, "start");
-      crossPointService.replaceEdgeId(
-        cpt,
-        road.rightEdgeId,
-        newRoad.rightEdgeId
-      );
+      crossPointService.replaceEdgeId(cpt, road.rightEdgeId, newRoad.rightEdgeId);
 
       let newRoadLeftEdge = dataService.getRoadEdge(newRoad.leftEdgeId);
       mathUtil.clonePoint(newRoadLeftEdge.start, oldLeftEdgeStartPoint);
       //newRoadLeftEdge.roadSide = leftEdge.roadSide;
-      if(leftEdge.roadSide){
-        newRoadLeftEdge.initRoadSide()
-        newRoadLeftEdge.setRoadSideWidth(leftEdge.roadSide.width)
+      if (leftEdge.roadSide) {
+        newRoadLeftEdge.initRoadSide();
+        newRoadLeftEdge.setRoadSideWidth(leftEdge.roadSide.width);
       }
 
       let newRoadRightEdge = dataService.getRoadEdge(newRoad.rightEdgeId);
       mathUtil.clonePoint(newRoadRightEdge.start, oldRightEdgeStartPoint);
       //newRoadRightEdge.roadSide = rightEdge.roadSide;
-      if(rightEdge.roadSide){
-        newRoadRightEdge.initRoadSide()
-        newRoadRightEdge.setRoadSideWidth(rightEdge.roadSide.width)
+      if (rightEdge.roadSide) {
+        newRoadRightEdge.initRoadSide();
+        newRoadRightEdge.setRoadSideWidth(rightEdge.roadSide.width);
       }
 
       if (Object.keys(endPoint).length > 1) {
@@ -309,13 +262,13 @@ export default class RoadService {
         mathUtil.clonePoint(rightEdge.end, oldRightEdgeEndPoint);
       }
       //修改路缘线start
-      if(leftEdge.roadSide){
-        leftEdge.initRoadSide()
-        leftEdge.setRoadSideWidth(leftEdge.roadSide.width)
+      if (leftEdge.roadSide) {
+        leftEdge.initRoadSide();
+        leftEdge.setRoadSideWidth(leftEdge.roadSide.width);
       }
-      if(rightEdge.roadSide){
-        rightEdge.initRoadSide()
-        rightEdge.setRoadSideWidth(rightEdge.roadSide.width)
+      if (rightEdge.roadSide) {
+        rightEdge.initRoadSide();
+        rightEdge.setRoadSideWidth(rightEdge.roadSide.width);
       }
     }
     // let newStartPoint = dataService.getRoadPoint(newRoad.startId);
@@ -333,6 +286,10 @@ export default class RoadService {
     //   let road = dataService.getRoad(key);
     //   this.initRoadWidthTipsPos(road);
     // }
+
+  
+    // console.error(newRoad)
+
     return newRoad.vectorId;
   }
 
@@ -382,12 +339,7 @@ export default class RoadService {
     const road1 = dataService.getRoad(id1);
     const road2 = dataService.getRoad(id2);
 
-    if (
-      road1 == null ||
-      road2 == null ||
-      typeof road1 === "undefined" ||
-      typeof road2 === "undefined"
-    ) {
+    if (road1 == null || road2 == null || typeof road1 === "undefined" || typeof road2 === "undefined") {
       return null;
     }
 
@@ -438,12 +390,7 @@ export default class RoadService {
     const road1 = dataService.getRoad(id1);
     const road2 = dataService.getRoad(id2);
 
-    if (
-      road1 == null ||
-      road2 == null ||
-      typeof road1 === "undefined" ||
-      typeof road2 === "undefined"
-    ) {
+    if (road1 == null || road2 == null || typeof road1 === "undefined" || typeof road2 === "undefined") {
       return null;
     }
 
@@ -498,12 +445,7 @@ export default class RoadService {
     const road1 = dataService.getRoad(id1);
     const road2 = dataService.getRoad(id2);
 
-    if (
-      road1 == null ||
-      road2 == null ||
-      typeof road1 === "undefined" ||
-      typeof road2 === "undefined"
-    ) {
+    if (road1 == null || road2 == null || typeof road1 === "undefined" || typeof road2 === "undefined") {
       return null;
     }
 
@@ -542,9 +484,7 @@ export default class RoadService {
       _start1.y = start1.y + end2.y - end1.y;
       return mathUtil.Angle(end2, _start1, start2);
     } else {
-      console.error(
-        "RoadService.AngleForRoad3************************************1"
-      );
+      console.error("RoadService.AngleForRoad3************************************1");
       return null;
     }
   }
@@ -622,9 +562,7 @@ export default class RoadService {
 
       return result;
     } else {
-      console.error(
-        "roadIdForMinAngle*********************************************************"
-      );
+      console.error("roadIdForMinAngle*********************************************************");
       return null;
     }
   }
@@ -633,12 +571,7 @@ export default class RoadService {
     let road1 = dataService.getRoad(roadId1);
     let road2 = dataService.getRoad(roadId2);
 
-    if (
-      road1.startId == road2.startId ||
-      road1.startId == road2.endId ||
-      road1.endId == road2.startId ||
-      road1.endId == road2.endId
-    ) {
+    if (road1.startId == road2.startId || road1.startId == road2.endId || road1.endId == road2.startId || road1.endId == road2.endId) {
       return true;
     } else {
       return false;
@@ -660,9 +593,7 @@ export default class RoadService {
     } else if (road.endId == pointId) {
       return "end";
     } else {
-      console.error(
-        "RoadService.getDirction*******************************************************************************************"
-      );
+      console.error("RoadService.getDirction*******************************************************************************************");
       return null;
     }
   }
@@ -676,10 +607,7 @@ export default class RoadService {
       return;
     } else if (Object.keys(parent).length > 2) {
       const info = this.roadIdForMinAngle(pointId, roadId);
-      edgeService.updateSingleEdgeForTwoRoad(
-        info.min0.roadId,
-        info.min1.roadId
-      );
+      edgeService.updateSingleEdgeForTwoRoad(info.min0.roadId, info.min1.roadId);
     }
 
     // 第一步先断开链接
@@ -716,10 +644,7 @@ export default class RoadService {
 
   setRoadInfo(vectorInfo) {
     const road = dataService.getRoad(vectorInfo.roadId);
-    if (
-      vectorInfo.hasOwnProperty("edgeId") &&
-      vectorInfo.hasOwnProperty("dir")
-    ) {
+    if (vectorInfo.hasOwnProperty("edgeId") && vectorInfo.hasOwnProperty("dir")) {
       if (vectorInfo.dir == "left") {
         road.leftEdgeId = vectorInfo.edgeId;
       } else if (vectorInfo.dir == "right") {
@@ -727,10 +652,7 @@ export default class RoadService {
       }
     }
 
-    if (
-      vectorInfo.hasOwnProperty("pointId") &&
-      vectorInfo.hasOwnProperty("dir")
-    ) {
+    if (vectorInfo.hasOwnProperty("pointId") && vectorInfo.hasOwnProperty("dir")) {
       if (vectorInfo.dir == "start") {
         road.startId = vectorInfo.pointId;
       } else if (vectorInfo.dir == "end") {
@@ -743,12 +665,7 @@ export default class RoadService {
     let road1 = dataService.getRoad(id1);
     let road2 = dataService.getRoad(id2);
 
-    if (
-      road1 == null ||
-      road2 == null ||
-      typeof road1 == "undefined" ||
-      typeof road2 == "undefined"
-    ) {
+    if (road1 == null || road2 == null || typeof road1 == "undefined" || typeof road2 == "undefined") {
       return null;
     }
 
@@ -871,9 +788,7 @@ export default class RoadService {
 
       return result;
     } else {
-      console.error(
-        "roadIdForMinAngle*********************************************************"
-      );
+      console.error("roadIdForMinAngle*********************************************************");
       return null;
     }
   }
@@ -885,9 +800,7 @@ export default class RoadService {
     } else if (road.endId == pointId) {
       return "end";
     } else {
-      console.error(
-        "getDirction*******************************************************************************************"
-      );
+      console.error("getDirction*******************************************************************************************");
       return null;
     }
   }
@@ -965,9 +878,7 @@ export default class RoadService {
 
       return result;
     } else {
-      console.error(
-        "roadIdForMinAngle*********************************************************"
-      );
+      console.error("roadIdForMinAngle*********************************************************");
       return null;
     }
   }
@@ -1045,40 +956,25 @@ export default class RoadService {
       if (road.way == Constant.twoWay) {
         //更新车道的起点和终点,因为车道的起点和终点的位置与中间隔离栏一致
         for (let i = 0; i < road.leftLanes.length; ++i) {
-          line = mathUtil.createLine1(
-            road.leftLanes[i].start,
-            road.leftLanes[i].end
-          );
+          line = mathUtil.createLine1(road.leftLanes[i].start, road.leftLanes[i].end);
           join = mathUtil.getJoinLinePoint(laneStart, line);
           mathUtil.clonePoint(road.leftLanes[i].start, join);
         }
         for (let i = 0; i < road.rightLanes.length; ++i) {
-          line = mathUtil.createLine1(
-            road.rightLanes[i].start,
-            road.rightLanes[i].end
-          );
+          line = mathUtil.createLine1(road.rightLanes[i].start, road.rightLanes[i].end);
           join = mathUtil.getJoinLinePoint(laneStart, line);
           mathUtil.clonePoint(road.rightLanes[i].start, join);
         }
-        line = mathUtil.createLine1(
-          road.midDivide.leftMidDivide.start,
-          road.midDivide.leftMidDivide.end
-        );
+        line = mathUtil.createLine1(road.midDivide.leftMidDivide.start, road.midDivide.leftMidDivide.end);
         join = mathUtil.getJoinLinePoint(laneStart, line);
         mathUtil.clonePoint(road.midDivide.leftMidDivide.start, join);
 
-        line = mathUtil.createLine1(
-          road.midDivide.rightMidDivide.start,
-          road.midDivide.rightMidDivide.end
-        );
+        line = mathUtil.createLine1(road.midDivide.rightMidDivide.start, road.midDivide.rightMidDivide.end);
         join = mathUtil.getJoinLinePoint(laneStart, line);
         mathUtil.clonePoint(road.midDivide.rightMidDivide.start, join);
       } else if (road.way == Constant.oneWay) {
         for (let i = 0; i < road.singleLanes.length; ++i) {
-          const line = mathUtil.createLine1(
-            road.singleLanes[i].start,
-            road.singleLanes[i].end
-          );
+          const line = mathUtil.createLine1(road.singleLanes[i].start, road.singleLanes[i].end);
           const join = mathUtil.getJoinLinePoint(laneStart, line);
           mathUtil.clonePoint(road.singleLanes[i].start, join);
         }
@@ -1105,40 +1001,25 @@ export default class RoadService {
       if (road.way == Constant.twoWay) {
         //更新车道的起点和终点,因为车道的起点和终点的位置与中间隔离栏一致
         for (let i = 0; i < road.leftLanes.length; ++i) {
-          line = mathUtil.createLine1(
-            road.leftLanes[i].start,
-            road.leftLanes[i].end
-          );
+          line = mathUtil.createLine1(road.leftLanes[i].start, road.leftLanes[i].end);
           join = mathUtil.getJoinLinePoint(laneEnd, line);
           mathUtil.clonePoint(road.leftLanes[i].end, join);
         }
         for (let i = 0; i < road.rightLanes.length; ++i) {
-          line = mathUtil.createLine1(
-            road.rightLanes[i].start,
-            road.rightLanes[i].end
-          );
+          line = mathUtil.createLine1(road.rightLanes[i].start, road.rightLanes[i].end);
           join = mathUtil.getJoinLinePoint(laneEnd, line);
           mathUtil.clonePoint(road.rightLanes[i].end, join);
         }
-        line = mathUtil.createLine1(
-          road.midDivide.leftMidDivide.start,
-          road.midDivide.leftMidDivide.end
-        );
+        line = mathUtil.createLine1(road.midDivide.leftMidDivide.start, road.midDivide.leftMidDivide.end);
         join = mathUtil.getJoinLinePoint(laneEnd, line);
         mathUtil.clonePoint(road.midDivide.leftMidDivide.end, join);
 
-        line = mathUtil.createLine1(
-          road.midDivide.rightMidDivide.start,
-          road.midDivide.rightMidDivide.end
-        );
+        line = mathUtil.createLine1(road.midDivide.rightMidDivide.start, road.midDivide.rightMidDivide.end);
         join = mathUtil.getJoinLinePoint(laneEnd, line);
         mathUtil.clonePoint(road.midDivide.rightMidDivide.end, join);
       } else if (road.way == Constant.oneWay) {
         for (let i = 0; i < road.singleLanes.length; ++i) {
-          const line = mathUtil.createLine1(
-            road.singleLanes[i].start,
-            road.singleLanes[i].end
-          );
+          const line = mathUtil.createLine1(road.singleLanes[i].start, road.singleLanes[i].end);
           const join = mathUtil.getJoinLinePoint(laneEnd, line);
           mathUtil.clonePoint(road.singleLanes[i].end, join);
         }
@@ -1209,10 +1090,8 @@ export default class RoadService {
 
     const leftCount = road.leftDrivewayCount;
     const rightCount = road.rightDrivewayCount;
-    const leftRatio =
-      road.leftWidth / (road.leftWidth + road.midDivide.midDivideWidth / 2);
-    const rightRatio =
-      road.rightWidth / (road.rightWidth + road.midDivide.midDivideWidth / 2);
+    const leftRatio = road.leftWidth / (road.leftWidth + road.midDivide.midDivideWidth / 2);
+    const rightRatio = road.rightWidth / (road.rightWidth + road.midDivide.midDivideWidth / 2);
 
     let leftdx1 = ((leftEdge.start.x - startPoint.x) * leftRatio) / leftCount;
     let leftdy1 = ((leftEdge.start.y - startPoint.y) * leftRatio) / leftCount;
@@ -1220,10 +1099,8 @@ export default class RoadService {
     let leftdx2 = ((leftEdge.end.x - endPoint.x) * leftRatio) / leftCount;
     let leftdy2 = ((leftEdge.end.y - endPoint.y) * leftRatio) / leftCount;
 
-    let rightdx1 =
-      ((rightEdge.start.x - startPoint.x) * rightRatio) / rightCount;
-    let rightdy1 =
-      ((rightEdge.start.y - startPoint.y) * rightRatio) / rightCount;
+    let rightdx1 = ((rightEdge.start.x - startPoint.x) * rightRatio) / rightCount;
+    let rightdy1 = ((rightEdge.start.y - startPoint.y) * rightRatio) / rightCount;
 
     let rightdx2 = ((rightEdge.end.x - endPoint.x) * rightRatio) / rightCount;
     let rightdy2 = ((rightEdge.end.y - endPoint.y) * rightRatio) / rightCount;
@@ -1284,10 +1161,8 @@ export default class RoadService {
 
         if (dir2 == "start" || !dir2) {
           road.rightLanes[i].start = {};
-          road.rightLanes[i].start.x =
-            startPoint.x + middx1 + rightdx1 * (i + 1);
-          road.rightLanes[i].start.y =
-            startPoint.y + middy1 + rightdy1 * (i + 1);
+          road.rightLanes[i].start.x = startPoint.x + middx1 + rightdx1 * (i + 1);
+          road.rightLanes[i].start.y = startPoint.y + middy1 + rightdy1 * (i + 1);
 
           road.midDivide.rightMidDivide.start = {};
           road.midDivide.rightMidDivide.start.x = startPoint.x + middx1;
@@ -1347,19 +1222,7 @@ export default class RoadService {
   //需要考虑车道个数是0(左或者右)的情况
   //单向车道不考虑dir,即:均匀的增加或者删除车道
   updateForAddSubtractLanesCount(roadId, newCount, dir) {
-    let dx1,
-      dy1,
-      dx2,
-      dy2,
-      oldCount,
-      edgeStartPosition,
-      edgeEndPosition,
-      leftRatio,
-      rightRatio,
-      middx1,
-      middy1,
-      middx2,
-      middy2;
+    let dx1, dy1, dx2, dy2, oldCount, edgeStartPosition, edgeEndPosition, leftRatio, rightRatio, middx1, middy1, middx2, middy2;
     let road = dataService.getRoad(roadId);
 
     if (newCount < 1) {
@@ -1372,10 +1235,8 @@ export default class RoadService {
     let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
 
     if (road.way == Constant.twoWay) {
-      leftRatio =
-        road.leftWidth / (road.leftWidth + road.midDivide.midDivideWidth / 2);
-      rightRatio =
-        road.rightWidth / (road.rightWidth + road.midDivide.midDivideWidth / 2);
+      leftRatio = road.leftWidth / (road.leftWidth + road.midDivide.midDivideWidth / 2);
+      rightRatio = road.rightWidth / (road.rightWidth + road.midDivide.midDivideWidth / 2);
       if (dir == "left") {
         oldCount = road.leftDrivewayCount;
         if (oldCount != 0) {
@@ -1441,18 +1302,10 @@ export default class RoadService {
       let line = this.getMidLine(road);
       if (dir == "left") {
         let join = mathUtil.getJoinLinePoint(leftEdge.start, line);
-        road.setWidth(
-          mathUtil.getDistance(leftEdge.start, join) -
-            road.midDivide.midDivideWidth / 2,
-          dir
-        );
+        road.setWidth(mathUtil.getDistance(leftEdge.start, join) - road.midDivide.midDivideWidth / 2, dir);
       } else if (dir == "right") {
         let join = mathUtil.getJoinLinePoint(rightEdge.start, line);
-        road.setWidth(
-          mathUtil.getDistance(rightEdge.start, join) -
-            road.midDivide.midDivideWidth / 2,
-          dir
-        );
+        road.setWidth(mathUtil.getDistance(rightEdge.start, join) - road.midDivide.midDivideWidth / 2, dir);
       }
     } else if (road.way == Constant.oneWay) {
       oldCount = road.singleRoadDrivewayCount;
@@ -1518,50 +1371,26 @@ export default class RoadService {
       road.setWidth(newWidth * 2);
     } else if (road.way == Constant.twoWay) {
       if (dir == "left") {
-        edgePoints = mathUtil.RectangleVertex(
-          startPoint,
-          endPoint,
-          newWidth + road.midDivide.midDivideWidth / 2
-        );
+        edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, newWidth + road.midDivide.midDivideWidth / 2);
         mathUtil.clonePoint(leftEdge.start, edgePoints.leftEdgeStart);
         mathUtil.clonePoint(leftEdge.end, edgePoints.leftEdgeEnd);
         road.setWidth(newWidth, dir);
       } else if (dir == "right") {
-        edgePoints = mathUtil.RectangleVertex(
-          startPoint,
-          endPoint,
-          newWidth + road.midDivide.midDivideWidth / 2
-        );
+        edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, newWidth + road.midDivide.midDivideWidth / 2);
         mathUtil.clonePoint(rightEdge.start, edgePoints.rightEdgeStart);
         mathUtil.clonePoint(rightEdge.end, edgePoints.rightEdgeEnd);
         road.setWidth(newWidth, dir);
       }
       //左右两边的edge同时变宽或者变窄
       else {
-        edgePoints = mathUtil.RectangleVertex(
-          startPoint,
-          endPoint,
-          (newWidth * road.leftWidth) / (road.leftWidth + road.rightWidth) +
-            road.midDivide.midDivideWidth / 2
-        );
+        edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, (newWidth * road.leftWidth) / (road.leftWidth + road.rightWidth) + road.midDivide.midDivideWidth / 2);
         mathUtil.clonePoint(leftEdge.start, edgePoints.leftEdgeStart);
         mathUtil.clonePoint(leftEdge.end, edgePoints.leftEdgeEnd);
-        road.setWidth(
-          (newWidth * road.leftWidth) / (road.leftWidth + road.rightWidth),
-          "left"
-        );
-        edgePoints = mathUtil.RectangleVertex(
-          startPoint,
-          endPoint,
-          (newWidth * road.rightWidth) / (road.leftWidth + road.rightWidth) +
-            road.midDivide.midDivideWidth / 2
-        );
+        road.setWidth((newWidth * road.leftWidth) / (road.leftWidth + road.rightWidth), "left");
+        edgePoints = mathUtil.RectangleVertex(startPoint, endPoint, (newWidth * road.rightWidth) / (road.leftWidth + road.rightWidth) + road.midDivide.midDivideWidth / 2);
         mathUtil.clonePoint(rightEdge.start, edgePoints.rightEdgeStart);
         mathUtil.clonePoint(rightEdge.end, edgePoints.rightEdgeEnd);
-        road.setWidth(
-          (newWidth * road.rightWidth) / (road.leftWidth + road.rightWidth),
-          "right"
-        );
+        road.setWidth((newWidth * road.rightWidth) / (road.leftWidth + road.rightWidth), "right");
       }
     }
 
@@ -1583,35 +1412,20 @@ export default class RoadService {
     rightLine.setWeight(rightEdge.getWeight());
     if (road.way == Constant.oneWay) {
       for (let i = 0; i < road.singleLanes.length; ++i) {
-        let laneLine = lineService.create(
-          road.singleLanes[i].start,
-          road.singleLanes[i].end
-        );
+        let laneLine = lineService.create(road.singleLanes[i].start, road.singleLanes[i].end);
         laneLine.setStyle(VectorStyle.SingleDashedLine);
       }
     } else if (road.way == Constant.twoWay) {
       for (let i = 0; i < road.leftLanes.length; ++i) {
-        let laneLine = lineService.create(
-          road.leftLanes[i].start,
-          road.leftLanes[i].end
-        );
+        let laneLine = lineService.create(road.leftLanes[i].start, road.leftLanes[i].end);
         laneLine.setStyle(VectorStyle.SingleDashedLine);
       }
       for (let i = 0; i < road.rightLanes.length; ++i) {
-        let laneLine = lineService.create(
-          road.rightLanes[i].start,
-          road.rightLanes[i].end
-        );
+        let laneLine = lineService.create(road.rightLanes[i].start, road.rightLanes[i].end);
         laneLine.setStyle(VectorStyle.SingleDashedLine);
       }
-      lineService.create(
-        road.midDivide.leftMidDivide.start,
-        road.midDivide.leftMidDivide.end
-      );
-      lineService.create(
-        road.midDivide.rightMidDivide.start,
-        road.midDivide.rightMidDivide.end
-      );
+      lineService.create(road.midDivide.leftMidDivide.start, road.midDivide.leftMidDivide.end);
+      lineService.create(road.midDivide.rightMidDivide.start, road.midDivide.rightMidDivide.end);
     }
   }
 
@@ -1633,56 +1447,26 @@ export default class RoadService {
       },
     };
 
-    let roadLine = mathUtil.createLine1(
-      dataService.getRoadPoint(road.startId),
-      dataService.getRoadPoint(road.endId)
-    );
-    let roadLineCrossPoint = mathUtil.getLineEndPointPos(
-      roadInfo.start,
-      roadInfo.end
-    );
-    let CrossPointStartDistance = mathUtil.getDistance(
-      roadStartPoint,
-      roadLineCrossPoint
-    );
+    let roadLine = mathUtil.createLine1(dataService.getRoadPoint(road.startId), dataService.getRoadPoint(road.endId));
+    let roadLineCrossPoint = mathUtil.getLineEndPointPos(roadInfo.start, roadInfo.end);
+    let CrossPointStartDistance = mathUtil.getDistance(roadStartPoint, roadLineCrossPoint);
     let leftEdgeDistance = mathUtil.getDistance(leftEdge.start, leftEdge.end);
-    let righttEdgeDistance = mathUtil.getDistance(
-      rightEdge.start,
-      rightEdge.end
-    );
-    if (
-      CrossPointStartDistance > leftEdgeDistance ||
-      CrossPointStartDistance > righttEdgeDistance
-    ) {
+    let righttEdgeDistance = mathUtil.getDistance(rightEdge.start, rightEdge.end);
+    if (CrossPointStartDistance > leftEdgeDistance || CrossPointStartDistance > righttEdgeDistance) {
       let satrtEdgeLine = mathUtil.createLine1(leftEdge.start, rightEdge.start);
       let endEdgeLine = mathUtil.createLine1(leftEdge.end, rightEdge.end);
-      let satrtEdgeCrossPoint = mathUtil.getIntersectionPoint(
-        satrtEdgeLine,
-        roadLine
-      );
-      let endEdgeCrossPoint = mathUtil.getIntersectionPoint(
-        endEdgeLine,
-        roadLine
-      );
-
-      roadLineCrossPoint = mathUtil.getLineEndPointPos(
-        satrtEdgeCrossPoint,
-        endEdgeCrossPoint
-      );
+      let satrtEdgeCrossPoint = mathUtil.getIntersectionPoint(satrtEdgeLine, roadLine);
+      let endEdgeCrossPoint = mathUtil.getIntersectionPoint(endEdgeLine, roadLine);
+
+      roadLineCrossPoint = mathUtil.getLineEndPointPos(satrtEdgeCrossPoint, endEdgeCrossPoint);
     }
     // if(roadLineCrossPoint){
     //   let lineLength = this.getDistance(startPoint, endPoint);
     // }
     let leftEdgeLine = mathUtil.createLine1(leftEdge.start, leftEdge.end);
     let rightEdgeLine = mathUtil.createLine1(rightEdge.start, rightEdge.end);
-    let leftEdgePoint = mathUtil.getJoinLinePoint(
-      roadLineCrossPoint,
-      leftEdgeLine
-    );
-    let rightEdgePoint = mathUtil.getJoinLinePoint(
-      roadLineCrossPoint,
-      rightEdgeLine
-    );
+    let leftEdgePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, leftEdgeLine);
+    let rightEdgePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, rightEdgeLine);
 
     // let rightEdgePoint = mathUtil.getLineEndPointPos(rightEdge.start, rightEdge.end);
     let edgeLine = mathUtil.createLine1(leftEdgePoint, rightEdgePoint);
@@ -1693,10 +1477,7 @@ export default class RoadService {
         //单向多车道
         let crossList = [];
         for (let i = 0; i < road.singleLanes.length; i++) {
-          let crossLine = mathUtil.createLine1(
-            road.singleLanes[i].start,
-            road.singleLanes[i].end
-          );
+          let crossLine = mathUtil.createLine1(road.singleLanes[i].start, road.singleLanes[i].end);
           // let crossPoint = mathUtil.getIntersectionPoint(edgeLine, crossLine);
           // crossList.push(crossPoint);
           crossList.push(crossLine);
@@ -1712,14 +1493,8 @@ export default class RoadService {
           } else {
             //以此类推
 
-            let middleEdgePoint1 = mathUtil.getJoinLinePoint(
-              roadLineCrossPoint,
-              crossList[i - 1]
-            );
-            let middleEdgePoint2 = mathUtil.getJoinLinePoint(
-              roadLineCrossPoint,
-              crossList[i]
-            );
+            let middleEdgePoint1 = mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i - 1]);
+            let middleEdgePoint2 = mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]);
             // roadWidthTipsPos.push({
             //   start: crossList[i - 1],
             //   end: crossList[i],
@@ -1736,10 +1511,7 @@ export default class RoadService {
         //   start: crossList[crossList.length - 1],
         //   end: leftEdgePoint,
         // });
-        let a = mathUtil.getJoinLinePoint(
-          roadLineCrossPoint,
-          crossList[crossList.length - 1]
-        );
+        let a = mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[crossList.length - 1]);
         roadWidthTipsPos.push({
           start: a,
           end: leftEdgePoint,
@@ -1756,31 +1528,16 @@ export default class RoadService {
       // let leftMidDividePoint = mathUtil.getLineEndPointPos(road.midDivide.leftMidDivide.start, road.midDivide.leftMidDivide.end);
       // let rightMidDividePoint = mathUtil.getLineEndPointPos(road.midDivide.rightMidDivide.start, road.midDivide.rightMidDivide.end);
 
-      let leftMidDivideLine = mathUtil.createLine1(
-        road.midDivide.leftMidDivide.start,
-        road.midDivide.leftMidDivide.end
-      );
-      let rightMidDividePointLine = mathUtil.createLine1(
-        road.midDivide.rightMidDivide.start,
-        road.midDivide.rightMidDivide.end
-      );
-      let leftMidDividePoint = mathUtil.getJoinLinePoint(
-        roadLineCrossPoint,
-        leftMidDivideLine
-      );
-      let rightMidDividePoint = mathUtil.getJoinLinePoint(
-        roadLineCrossPoint,
-        rightMidDividePointLine
-      );
+      let leftMidDivideLine = mathUtil.createLine1(road.midDivide.leftMidDivide.start, road.midDivide.leftMidDivide.end);
+      let rightMidDividePointLine = mathUtil.createLine1(road.midDivide.rightMidDivide.start, road.midDivide.rightMidDivide.end);
+      let leftMidDividePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, leftMidDivideLine);
+      let rightMidDividePoint = mathUtil.getJoinLinePoint(roadLineCrossPoint, rightMidDividePointLine);
 
       // leftLanes,rightLanes
       if (road.leftLanes.length) {
         let crossList = [];
         for (let i = 0; i < road.leftLanes.length; i++) {
-          let crossLine = mathUtil.createLine1(
-            road.leftLanes[i].start,
-            road.leftLanes[i].end
-          );
+          let crossLine = mathUtil.createLine1(road.leftLanes[i].start, road.leftLanes[i].end);
           // let crossPoint = mathUtil.getIntersectionPoint(edgeLine, crossLine);
           // crossList.push(crossPoint);
 
@@ -1805,10 +1562,7 @@ export default class RoadService {
             //   end: crossList[i],
             // });
             roadWidthTipsPos.push({
-              start: mathUtil.getJoinLinePoint(
-                roadLineCrossPoint,
-                crossList[i - 1]
-              ),
+              start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i - 1]),
               end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
             });
           }
@@ -1819,10 +1573,7 @@ export default class RoadService {
         //   end: leftEdgePoint,
         // });
         roadWidthTipsPos.push({
-          start: mathUtil.getJoinLinePoint(
-            roadLineCrossPoint,
-            crossList[crossList.length - 1]
-          ),
+          start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[crossList.length - 1]),
           end: leftEdgePoint,
         });
         road.setRoadWidthTipsPos(roadWidthTipsPos);
@@ -1836,10 +1587,7 @@ export default class RoadService {
       if (road.rightLanes.length) {
         let crossList = [];
         for (let i = 0; i < road.rightLanes.length; i++) {
-          let crossLine = mathUtil.createLine1(
-            road.rightLanes[i].start,
-            road.rightLanes[i].end
-          );
+          let crossLine = mathUtil.createLine1(road.rightLanes[i].start, road.rightLanes[i].end);
           // let crossPoint = mathUtil.getIntersectionPoint(edgeLine, crossLine);
           // crossList.push(crossPoint);
           crossList.push(crossLine);
@@ -1864,10 +1612,7 @@ export default class RoadService {
             // });
 
             roadWidthTipsPos.push({
-              start: mathUtil.getJoinLinePoint(
-                roadLineCrossPoint,
-                crossList[i - 1]
-              ),
+              start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i - 1]),
               end: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[i]),
             });
           }
@@ -1878,10 +1623,7 @@ export default class RoadService {
         //   end: rightEdgePoint,
         // });
         roadWidthTipsPos.push({
-          start: mathUtil.getJoinLinePoint(
-            roadLineCrossPoint,
-            crossList[crossList.length - 1]
-          ),
+          start: mathUtil.getJoinLinePoint(roadLineCrossPoint, crossList[crossList.length - 1]),
           end: rightEdgePoint,
         });