xushiting 2 éve
szülő
commit
37de363853

+ 1 - 0
src/graphic/Geometry/Road.js

@@ -11,6 +11,7 @@ export default class Road extends Geometry {
     this.rightEdgeId = null;
     this.leftLanes = []; //二维数组。第一维表示第几个车道,第二维是一组点
     this.rightLanes = [];
+    this.midDivide = null; //道路中间隔离栏
     this.leftDrivewayCount = 1; //左边的车道个数
     this.rightDrivewayCount = 1; //右边的车道个数
     this.geoType = VectorType.Road;

+ 63 - 22
src/graphic/Layer.js

@@ -24,6 +24,7 @@ import mitt from "mitt";
 import { roadService } from "./Service/RoadService";
 import { edgeService } from "./Service/EdgeService";
 import { pointService } from "./Service/PointService";
+import { curveRoadService } from "./Service/CurveRoadService";
 
 const minDragDis = 10;
 
@@ -529,6 +530,7 @@ export default class Layer {
         road.width += 100;
         edgeService.updateEdgeForMovePoint(road.startId);
         edgeService.updateEdgeForMovePoint(road.endId);
+        roadService.setLanes(road.vectorId);
         this.renderer.autoRedraw();
         this.history.save();
       }
@@ -538,48 +540,87 @@ export default class Layer {
         road.width -= 50;
         edgeService.updateEdgeForMovePoint(road.startId);
         edgeService.updateEdgeForMovePoint(road.endId);
+        roadService.setLanes(road.vectorId);
         this.renderer.autoRedraw();
         this.history.save();
       }
       //添加左车道
       else if (e.code == "KeyQ") {
-        let road = null;
-        if (focusItem.type == VectorType.Road) {
-          road = dataService.getRoad(focusItem.vectorId);
-        } else if (focusItem.type == VectorType.CurveRoad) {
-          road = dataService.getCurveRoad(focusItem.vectorId);
-        }
-
+        let road = dataService.getRoad(focusItem.vectorId);
         if (road) {
-          sd;
-          this.renderer.autoRedraw();
-          this.history.save();
+          roadService.updateForAddSubtractLanesCount(
+            focusItem.vectorId,
+            road.leftDrivewayCount + 1,
+            "left"
+          );
+        } else {
+          road = dataService.getCurveRoad(focusItem.vectorId);
+          curveRoadService.updateForAddSubtractLanesCount(
+            road,
+            road.leftDrivewayCount + 1, //rightDrivewayCount
+            "left"
+          );
         }
+        this.renderer.autoRedraw();
+        this.history.save();
       }
       //减少左车道
       else if (e.code == "KeyW") {
-        const road = dataService.getRoad(focusItem.vectorId);
-        road.width -= 50;
-        edgeService.updateEdgeForMovePoint(road.startId);
-        edgeService.updateEdgeForMovePoint(road.endId);
+        let road = dataService.getRoad(focusItem.vectorId);
+        if (road) {
+          roadService.updateForAddSubtractLanesCount(
+            focusItem.vectorId,
+            road.leftDrivewayCount - 1,
+            "left"
+          );
+        } else {
+          road = dataService.getCurveRoad(focusItem.vectorId);
+          curveRoadService.updateForAddSubtractLanesCount(
+            road,
+            road.leftDrivewayCount - 1, //rightDrivewayCount
+            "left"
+          );
+        }
         this.renderer.autoRedraw();
         this.history.save();
       }
       //添加右车道
       else if (e.code == "KeyE") {
-        const road = dataService.getRoad(focusItem.vectorId);
-        road.width -= 50;
-        edgeService.updateEdgeForMovePoint(road.startId);
-        edgeService.updateEdgeForMovePoint(road.endId);
+        let road = dataService.getRoad(focusItem.vectorId);
+        if (road) {
+          roadService.updateForAddSubtractLanesCount(
+            focusItem.vectorId,
+            road.rightDrivewayCount + 1,
+            "right"
+          );
+        } else {
+          road = dataService.getCurveRoad(focusItem.vectorId);
+          curveRoadService.updateForAddSubtractLanesCount(
+            road,
+            road.rightDrivewayCount + 1, //rightDrivewayCount
+            "right"
+          );
+        }
         this.renderer.autoRedraw();
         this.history.save();
       }
       //减少右车道
       else if (e.code == "KeyR") {
-        const road = dataService.getRoad(focusItem.vectorId);
-        road.width -= 50;
-        edgeService.updateEdgeForMovePoint(road.startId);
-        edgeService.updateEdgeForMovePoint(road.endId);
+        let road = dataService.getRoad(focusItem.vectorId);
+        if (road) {
+          roadService.updateForAddSubtractLanesCount(
+            focusItem.vectorId,
+            road.rightDrivewayCount - 1,
+            "right"
+          );
+        } else {
+          road = dataService.getCurveRoad(focusItem.vectorId);
+          curveRoadService.updateForAddSubtractLanesCount(
+            road,
+            road.rightDrivewayCount - 1, //rightDrivewayCount
+            "right"
+          );
+        }
         this.renderer.autoRedraw();
         this.history.save();
       }

+ 1 - 1
src/graphic/ListenLayer.js

@@ -421,7 +421,7 @@ export default class ListenLayer {
   }
 
   updateSelectInfos(nearest, minDistance) {
-    console.log("实时监控:" + JSON.stringify(nearest));
+    //console.log("实时监控:" + JSON.stringify(nearest));
     // 墙角状态是否改变
     let flag1 = false;
     if (nearest.minPoint != null) {

+ 57 - 28
src/graphic/Renderer/Draw.js

@@ -69,6 +69,7 @@ export default class Draw {
       point2 = coordinate.getScreenXY(vector.end);
       this.drawEdge(vector, isTemp);
     } else {
+      this.context.globalAlpha = 1;
       let start = dataService.getPoint(vector.startId);
       let end = dataService.getPoint(vector.endId);
       point1 = coordinate.getScreenXY(start);
@@ -85,28 +86,48 @@ export default class Draw {
     this.context.lineTo(point2.x, point2.y);
     this.context.stroke();
     this.context.restore();
+
+    for (let i = 0; i < vector.leftLanes.length; ++i) {
+      this.drawPoint(vector.leftLanes[i].start);
+      this.drawPoint(vector.leftLanes[i].end);
+    }
+    for (let i = 0; i < vector.rightLanes.length; ++i) {
+      this.drawPoint(vector.rightLanes[i].start);
+      this.drawPoint(vector.rightLanes[i].end);
+    }
+
+    if (vector.midDivide != null && vector.midDivide.display) {
+      let midDivideStart = coordinate.getScreenXY(vector.midDivide.start);
+      let midDivideEnd = coordinate.getScreenXY(vector.midDivide.end);
+      this.context.save();
+      this.context.globalAlpha = 1;
+      this.context.strokeStyle = "blue";
+      this.context.beginPath();
+      this.context.setLineDash([10, 3, 1]); //设定实线与空白的大小
+      this.context.moveTo(midDivideStart.x, midDivideStart.y);
+      this.context.lineTo(midDivideEnd.x, midDivideEnd.y);
+      this.context.stroke();
+      this.context.restore();
+    }
   }
 
   drawCurveRoad(vector, isTemp) {
     const getStyleLines = () => {
       const styleLines = {
-        dotted: [
-          ...vector.leftLanes,
-          ...vector.rightLanes
-        ],
+        dotted: [...vector.leftLanes, ...vector.rightLanes],
         solid: [
           vector.points,
           dataService.getCurveEdge(vector.rightEdgeId).points,
-          dataService.getCurveEdge(vector.leftEdgeId).points
-        ]
-      }
+          dataService.getCurveEdge(vector.leftEdgeId).points,
+        ],
+      };
       return Object.entries(styleLines).reduce((t, [key, lines]) => {
-        t[key] = lines.map(
-          line => line.map(point => coordinate.getScreenXY(point))
-        )
+        t[key] = lines.map((line) =>
+          line.map((point) => coordinate.getScreenXY(point))
+        );
         return t;
-      }, {})
-    }
+      }, {});
+    };
 
     const draw = (points, drawPoints = false) => {
       if (drawPoints) {
@@ -114,7 +135,7 @@ export default class Draw {
         for (const point of points) {
           ctx.beginPath();
           ctx.arc(point.x, point.y, radius, 0, 2 * Math.PI);
-          ctx.fill()
+          ctx.fill();
         }
       }
 
@@ -127,42 +148,45 @@ export default class Draw {
           curve.end.x,
           curve.end.y,
           curve.control.x,
-          curve.control.y,
-        )
+          curve.control.y
+        );
       }
       ctx.stroke();
-    }
-
+    };
 
     const ctx = this.context;
     ctx.save();
 
     const itemsEntry = [
-      [stateService.getSelectItem(), 'Select'],
-      [stateService.getDraggingItem(), 'Select'],
-      [stateService.getFocusItem(), 'Focus']
-    ]
+      [stateService.getSelectItem(), "Select"],
+      [stateService.getDraggingItem(), "Select"],
+      [stateService.getFocusItem(), "Focus"],
+    ];
     const strokeStyle = itemsEntry.reduce((prev, [item, attr]) => {
-      if (item && item.type === VectorType.Road && vector.vectorId === item.vectorId) {
+      if (
+        item &&
+        item.type === VectorType.Road &&
+        vector.vectorId === item.vectorId
+      ) {
         return Style[attr].Road.strokeStyle;
       }
-    }, Style.Road.strokeStyle || "rgba(0,0,0,0.1)")
+    }, Style.Road.strokeStyle || "rgba(0,0,0,0.1)");
 
     ctx.lineWidth = 2;
-    ctx.lineCap = 'butt'
-    ctx.strokeStyle = strokeStyle
+    ctx.lineCap = "butt";
+    ctx.strokeStyle = strokeStyle;
 
     const styleLines = getStyleLines();
     for (const style in styleLines) {
-      const isSolid = style === 'solid';
+      const isSolid = style === "solid";
       ctx.setLineDash(isSolid ? [] : [15, 15]);
 
-      const lines = styleLines[style]
+      const lines = styleLines[style];
       for (const points of lines) {
         if (points.length < 2) {
           break;
         }
-        draw(points, isSolid)
+        draw(points, isSolid);
       }
     }
     ctx.restore();
@@ -397,6 +421,11 @@ export default class Draw {
       },
       vector.rightEdgeId
     );
+
+    this.drawPoint(leftEdge.start);
+    this.drawPoint(leftEdge.end);
+    this.drawPoint(rightEdge.start);
+    this.drawPoint(rightEdge.end);
   }
 
   drawPoint(vector) {

+ 150 - 5
src/graphic/Service/CurveRoadService.js

@@ -181,7 +181,7 @@ export default class CurveRoadService extends RoadService {
           let edgePoints1 = mathUtil.RectangleVertex(
             points[j],
             points[j - 1],
-            leftdx1
+            leftdx1 * (i + 1)
           );
           let line1 = mathUtil.createLine1(
             edgePoints1.leftEdgeStart,
@@ -191,7 +191,7 @@ export default class CurveRoadService extends RoadService {
           let edgePoints2 = mathUtil.RectangleVertex(
             points[j],
             points[j + 1],
-            leftdx1
+            leftdx1 * (i + 1)
           );
           let line2 = mathUtil.createLine1(
             edgePoints2.leftEdgeStart,
@@ -238,7 +238,7 @@ export default class CurveRoadService extends RoadService {
           let edgePoints1 = mathUtil.RectangleVertex(
             points[j],
             points[j - 1],
-            rightdx1
+            rightdx1 * (i + 1)
           );
           let line1 = mathUtil.createLine1(
             edgePoints1.rightEdgeStart,
@@ -248,7 +248,7 @@ export default class CurveRoadService extends RoadService {
           let edgePoints2 = mathUtil.RectangleVertex(
             points[j],
             points[j + 1],
-            rightdx1
+            rightdx1 * (i + 1)
           );
           let line2 = mathUtil.createLine1(
             edgePoints2.rightEdgeStart,
@@ -271,7 +271,152 @@ export default class CurveRoadService extends RoadService {
     };
   }
 
-  setLeftLanes(road, leftCount) {}
+  //删除或者减少车道
+  updateForAddSubtractLanesCount(curveRoad, newCount, dir) {
+    let curveEdge, oldCount, lanes;
+    if (dir == "left") {
+      curveEdge = dataService.getCurveEdge(curveRoad.leftEdgeId);
+      oldCount = curveRoad.leftDrivewayCount;
+      lanes = curveRoad.leftLanes;
+    } else if (dir == "right") {
+      curveEdge = dataService.getCurveEdge(curveRoad.rightEdgeId);
+      oldCount = curveRoad.rightDrivewayCount;
+      lanes = curveRoad.rightLanes;
+    }
+    if (newCount == oldCount) {
+      return;
+    }
+
+    const len = curveRoad.points.length;
+    let dx1 = curveEdge.points[0].x - curveRoad.points[0].x;
+    dx1 = dx1 / oldCount;
+    let dy1 = curveEdge.points[0].y - curveRoad.points[0].y;
+    dy1 = dy1 / oldCount;
+    let dx2 = curveEdge.points[len - 1].x - curveRoad.points[len - 1].x;
+    dx2 = dx2 / oldCount;
+    let dy2 = curveEdge.points[len - 1].y - curveRoad.points[len - 1].y;
+    dy2 = dy2 / oldCount;
+
+    if (newCount > oldCount) {
+      for (let i = oldCount; i < newCount; ++i) {
+        for (let j = 0; j < len; ++j) {
+          if (j == 0) {
+            lanes[i][j].x = curveRoad.points[j].x + dx1 * (i + 1);
+            lanes[i][j].y = curveRoad.points[j].y + dy1 * (i + 1);
+          } else if (j == curveRoad.points.length - 1) {
+            lanes[i][j].x = curveRoad.points[j].x + dx2 * (i + 1);
+            lanes[i][j].y = curveRoad.points[j].y + dy2 * (i + 1);
+          } else {
+            let edgePoints1 = mathUtil.RectangleVertex(
+              curveRoad.points[j],
+              curveRoad.points[j - 1],
+              dx1 * (i + 1)
+            );
+            let line1 = mathUtil.createLine1(
+              edgePoints1.leftEdgeStart,
+              edgePoints1.leftEdgeEnd
+            );
+            if (dir == "right") {
+              line1 = mathUtil.createLine1(
+                edgePoints1.rightEdgeStart,
+                edgePoints1.rightEdgeEnd
+              );
+            }
+
+            let edgePoints2 = mathUtil.RectangleVertex(
+              curveRoad.points[j],
+              curveRoad.points[j + 1],
+              dx1 * (i + 1)
+            );
+            let line2 = mathUtil.createLine1(
+              edgePoints2.leftEdgeStart,
+              edgePoints2.leftEdgeEnd
+            );
+            if (dir == "right") {
+              line2 = mathUtil.createLine1(
+                edgePoints2.rightEdgeStart,
+                edgePoints2.rightEdgeEnd
+              );
+            }
+
+            let join = mathUtil.getIntersectionPoint(line1, line2);
+            if (join == null) {
+              join = mathUtil.getLineForPoint(line1, curveRoad.points[j]);
+            }
+            lanes[i][j].x = join.x;
+            lanes[i][j].y = join.y;
+          }
+        }
+
+        curveEdge.points[0].x = curveRoad.points[0].x + dx1 * newCount;
+        curveEdge.points[0].y = curveRoad.points[0].y + dy1 * newCount;
+
+        curveEdge.points[len - 1].x =
+          curveRoad.points[len - 1].x + dx2 * newCount;
+        curveEdge.points[len - 1].y =
+          curveRoad.points[len - 1].y + dy2 * newCount;
+
+        for (let k = 1; k < len - 1; ++k) {
+          let edgePoints1 = mathUtil.RectangleVertex(
+            curveRoad.points[k],
+            curveRoad.points[k - 1],
+            dx1 * newCount
+          );
+          let line1 = mathUtil.createLine1(
+            edgePoints1.leftEdgeStart,
+            edgePoints1.leftEdgeEnd
+          );
+          if (dir == "right") {
+            line1 = mathUtil.createLine1(
+              edgePoints1.rightEdgeStart,
+              edgePoints1.rightEdgeEnd
+            );
+          }
+
+          let edgePoints2 = mathUtil.RectangleVertex(
+            curveRoad.points[k],
+            curveRoad.points[k + 1],
+            dx1 * newCount
+          );
+          let line2 = mathUtil.createLine1(
+            edgePoints2.leftEdgeStart,
+            edgePoints2.leftEdgeEnd
+          );
+          if (dir == "right") {
+            line2 = mathUtil.createLine1(
+              edgePoints2.rightEdgeStart,
+              edgePoints2.rightEdgeEnd
+            );
+          }
+
+          let join = mathUtil.getIntersectionPoint(line1, line2);
+          if (join == null) {
+            join = mathUtil.getLineForPoint(line1, curveRoad.points[j]);
+          }
+          curveEdge.points[k].x = join.x;
+          curveEdge.points[k].y = join.y;
+        }
+      }
+    } else if (newCount < oldCount) {
+      let count = lanes.length;
+      let lane = lanes.pop();
+      while (count == newCount) {
+        lane = lanes.pop();
+        count = lanes.length;
+      }
+      for (let i = 0; i < curveEdge.points.length; ++i) {
+        mathUtil.clonePoint(curveEdge.points[i], lane[i]);
+      }
+    }
+
+    if (dir == "left") {
+      curveRoad.leftLanes = lanes;
+      curveRoad.leftDrivewayCount = newCount;
+    } else if (dir == "right") {
+      curveRoad.rightLanes = lanes;
+      curveRoad.rightDrivewayCount = newCount;
+    }
+  }
 
   updateForMovePoint(pointId, position) {
     let curvePoint = dataService.getCurvePoint(pointId);

+ 185 - 15
src/graphic/Service/RoadService.js

@@ -41,6 +41,7 @@ export default class RoadService {
       rightEdge.setEdgeParent(road.vectorId);
     }
 
+    this.setLanes(road.vectorId);
     return road;
   }
 
@@ -876,27 +877,196 @@ export default class RoadService {
   //中心线添加控制点
   insert(roadId, cp) {}
 
-  updateDrivewayCount(roadId, dir, type) {
+  // updateDrivewayCount(roadId, dir, type) {
+  //   let road = dataService.getRoad(roadId);
+  //   if (dir == "left") {
+  //     if (type == "add") {
+  //       ++road.leftDrivewayCount;
+  //     } else if (type == "sub") {
+  //       --road.leftDrivewayCount;
+  //       if (road.leftDrivewayCount < 0) {
+  //         road.leftDrivewayCount = 0;
+  //       }
+  //     }
+  //   } else if (dir == "right") {
+  //     if (type == "add") {
+  //       ++road.rightDrivewayCount;
+  //     } else if (type == "sub") {
+  //       --road.rightDrivewayCount;
+  //       if (road.rightDrivewayCount < 0) {
+  //         road.rightDrivewayCount = 0;
+  //       }
+  //     }
+  //   }
+  // }
+
+  //设置车道
+  setLanes(roadId) {
     let road = dataService.getRoad(roadId);
+    let startPoint = dataService.getPoint(road.startId);
+    let endPoint = dataService.getPoint(road.endId);
+    let leftEdge = dataService.getEdge(road.leftEdgeId);
+    let rightEdge = dataService.getEdge(road.rightEdgeId);
+    const leftCount = road.leftDrivewayCount;
+    const rightCount = road.rightDrivewayCount;
+
+    let midPoint = {
+      x: (startPoint.x + endPoint.x) / 2,
+      y: (startPoint.y + endPoint.y) / 2,
+    };
+    let line = this.getMidLine(road);
+    let point1 = mathUtil.getJoinLinePoint(leftEdge.start, line);
+    let _point1 = mathUtil.getJoinLinePoint(rightEdge.start, line);
+    if (
+      mathUtil.getDistance(point1, midPoint) >
+      mathUtil.getDistance(_point1, midPoint)
+    ) {
+      point1 = _point1;
+    }
+
+    let point2 = mathUtil.getJoinLinePoint(leftEdge.end, line);
+    let _point2 = mathUtil.getJoinLinePoint(rightEdge.end, line);
+    if (
+      mathUtil.getDistance(point2, midPoint) >
+      mathUtil.getDistance(_point2, midPoint)
+    ) {
+      point2 = _point2;
+    }
+
+    road.midDivide = {
+      start: point1,
+      end: point2,
+      display: true,
+    };
+
+    let leftdx1 = leftEdge.start.x - point1.x;
+    leftdx1 = leftdx1 / leftCount;
+
+    let leftdy1 = leftEdge.start.y - point1.y;
+    leftdy1 = leftdy1 / leftCount;
+
+    let leftdx2 = leftEdge.end.x - point2.x;
+    leftdx2 = leftdx2 / leftCount;
+
+    let leftdy2 = leftEdge.end.y - point2.y;
+    leftdy2 = leftdy2 / leftCount;
+
+    let rightdx1 = rightEdge.start.x - point1.x;
+    rightdx1 = rightdx1 / rightCount;
+
+    let rightdy1 = rightEdge.start.y - point1.y;
+    rightdy1 = rightdy1 / rightCount;
+
+    let rightdx2 = rightEdge.end.x - point2.x;
+    rightdx2 = rightdx2 / rightCount;
+
+    let rightdy2 = rightEdge.end.y - point2.y;
+    rightdy2 = rightdy2 / rightCount;
+
+    for (let i = 1; i < leftCount; ++i) {
+      road.leftLanes[i] = {};
+      road.leftLanes[i].start = {};
+      road.leftLanes[i].start.x = point1.x + leftdx1 * i;
+      road.leftLanes[i].start.y = point1.y + leftdy1 * i;
+
+      road.leftLanes[i].end = {};
+      road.leftLanes[i].end.x = point2.x + leftdx2 * i;
+      road.leftLanes[i].end.y = point2.y + leftdy2 * i;
+    }
+
+    for (let i = 1; i < rightCount; ++i) {
+      road.rightLanes[i] = {};
+      road.rightLanes[i].start = {};
+      road.rightLanes[i].start.x = point1.x + leftdx1 * i;
+      road.rightLanes[i].start.y = point1.y + leftdy1 * i;
+
+      road.rightLanes[i].end = {};
+      road.rightLanes[i].end.x = point2.x + leftdx2 * i;
+      road.rightLanes[i].end.y = point2.y + leftdy2 * i;
+    }
+  }
+
+  //删除或者减少车道
+  //需要考虑车道个数是0(左或者右)的情况
+  updateForAddSubtractLanesCount(roadId, newCount, dir) {
+    let dx1, dy1, dx2, dy2, oldCount, lanes, edgeStartPosition, edgeEndPosition;
+    let road = dataService.getRoad(roadId);
+    if (newCount == 0) {
+      road.midDivide.display = false;
+      return;
+    }
+    let leftEdge = dataService.getEdge(road.leftEdgeId);
+    let rightEdge = dataService.getEdge(road.rightEdgeId);
+
     if (dir == "left") {
-      if (type == "add") {
-        ++road.leftDrivewayCount;
-      } else if (type == "sub") {
-        --road.leftDrivewayCount;
-        if (road.leftDrivewayCount < 0) {
-          road.leftDrivewayCount = 0;
-        }
+      oldCount = road.leftDrivewayCount;
+      if (oldCount != 0) {
+        dx1 = leftEdge.start.x - road.midDivide.start.x;
+        dx1 = dx1 / oldCount;
+        dy1 = leftEdge.start.y - road.midDivide.start.y;
+        dy1 = dy1 / oldCount;
+
+        dx2 = leftEdge.end.x - road.midDivide.end.x;
+        dx2 = dx2 / oldCount;
+        dy2 = leftEdge.end.y - road.midDivide.end.y;
+        dy2 = dy2 / oldCount;
+        road.midDivide.display = true;
       }
     } else if (dir == "right") {
-      if (type == "add") {
-        ++road.rightDrivewayCount;
-      } else if (type == "sub") {
-        --road.rightDrivewayCount;
-        if (road.rightDrivewayCount < 0) {
-          road.rightDrivewayCount = 0;
-        }
+      oldCount = road.rightDrivewayCount;
+      if (oldCount != 0) {
+        dx1 = rightEdge.start.x - road.midDivide.start.x;
+        dx1 = dx1 / oldCount;
+        dy1 = rightEdge.start.y - road.midDivide.start.y;
+        dy1 = dy1 / oldCount;
+
+        dx2 = rightEdge.end.x - road.midDivide.end.x;
+        dx2 = dx2 / oldCount;
+        dy2 = rightEdge.end.y - road.midDivide.end.y;
+        dy2 = dy2 / oldCount;
+        road.midDivide.display = true;
+      }
+    }
+
+    lanes = [];
+    for (let i = 0; i < newCount; ++i) {
+      if (i == newCount - 1) {
+        edgeStartPosition = {
+          x: road.midDivide.start.x + dx1 * newCount,
+          y: road.midDivide.start.y + dy1 * newCount,
+        };
+        edgeEndPosition = {
+          x: road.midDivide.end.x + dx2 * newCount,
+          y: road.midDivide.end.y + dy2 * newCount,
+        };
+      } else {
+        lanes[i] = {};
+        lanes[i].start = {};
+        lanes[i].start.x = road.midDivide.start.x + dx1 * (i + 1);
+        lanes[i].start.y = road.midDivide.start.y + dy1 * (i + 1);
+
+        lanes[i].end = {};
+        lanes[i].end.x = road.midDivide.end.x + dx2 * (i + 1);
+        lanes[i].end.y = road.midDivide.end.y + dy2 * (i + 1);
       }
     }
+
+    if (dir == "left") {
+      road.leftLanes = lanes;
+      mathUtil.clonePoint(leftEdge.start, edgeStartPosition);
+      mathUtil.clonePoint(leftEdge.end, edgeEndPosition);
+      road.leftDrivewayCount = newCount;
+    } else if (dir == "right") {
+      road.rightLanes = lanes;
+      mathUtil.clonePoint(rightEdge.start, edgeStartPosition);
+      mathUtil.clonePoint(rightEdge.end, edgeEndPosition);
+      road.rightDrivewayCount = newCount;
+    }
+    let join = mathUtil.getJoinLinePoint(
+      leftEdge.start,
+      mathUtil.createLine1(rightEdge.start, rightEdge.end)
+    );
+    road.width = mathUtil.getDistance(leftEdge.start, join);
   }
   /****************************************************************************************************************************************************************/
 }