Browse Source

修复bug

xushiting 2 years ago
parent
commit
a344da7da2

+ 1 - 1
src/graphic/Constant.js

@@ -24,7 +24,7 @@ const Constant = {
   // miniMap_Width: 1200,
   // miniMap_Width: 1200,
   // miniMap_Height: 1200,
   // miniMap_Height: 1200,
   minLen: 0.2, //挨着,比如:点是否在线段上
   minLen: 0.2, //挨着,比如:点是否在线段上
-  minAdsorbPix: 50, //最小吸附像素
+  minAdsorbPix: 25, //最小吸附像素
   minRealDis: 20,
   minRealDis: 20,
   defaultRoadWidth: 100, //默认公路宽度
   defaultRoadWidth: 100, //默认公路宽度
   ratio: 1,
   ratio: 1,

+ 9 - 7
src/graphic/Controls/UIControl.js

@@ -149,16 +149,15 @@ export default class UIControl {
         key = "setWeight";
         key = "setWeight";
       }
       }
 
 
-      if (focusItem.type == VectorType.Line ) {
+      if (focusItem.type == VectorType.Line) {
         let Line = dataService.getLine(focusItem.vectorId);
         let Line = dataService.getLine(focusItem.vectorId);
         // Line.setStyle(selectUI);
         // Line.setStyle(selectUI);
         Line[key](selectUI);
         Line[key](selectUI);
-      } else if( focusItem.type == VectorType.CurveLine){
+      } else if (focusItem.type == VectorType.CurveLine) {
         let Line = dataService.getCurveLine(focusItem.vectorId);
         let Line = dataService.getCurveLine(focusItem.vectorId);
         // Line.setStyle(selectUI);
         // Line.setStyle(selectUI);
         Line[key](selectUI);
         Line[key](selectUI);
-        
-      }else {
+      } else {
         let roadEdge = dataService.getRoadEdge(focusItem.vectorId);
         let roadEdge = dataService.getRoadEdge(focusItem.vectorId);
         if (roadEdge) {
         if (roadEdge) {
           // roadEdge.setStyle(selectUI);
           // roadEdge.setStyle(selectUI);
@@ -379,6 +378,9 @@ export default class UIControl {
       case VectorType.Road:
       case VectorType.Road:
         roadService.deleteRoadForLinked(vectorId);
         roadService.deleteRoadForLinked(vectorId);
         break;
         break;
+      case VectorType.CurveRoadPoint:
+        curveRoadPointService.deleteCurveRoadPoint(vectorId);
+        break;
       case VectorType.CurveRoad:
       case VectorType.CurveRoad:
         dataService.deleteCurveRoad(vectorId);
         dataService.deleteCurveRoad(vectorId);
         break;
         break;
@@ -548,10 +550,10 @@ export default class UIControl {
     elementService.hideAll();
     elementService.hideAll();
     this.layer.exit();
     this.layer.exit();
     this.layer.initLocation();
     this.layer.initLocation();
-    if(!isBack){
+    if (!isBack) {
       this.layer.history.save();
       this.layer.history.save();
-    }else{
-      historyService.clearHistoryRecord()
+    } else {
+      historyService.clearHistoryRecord();
       this.layer.uiControl.graphicStateUI.canRevoke = false;
       this.layer.uiControl.graphicStateUI.canRevoke = false;
       this.layer.uiControl.graphicStateUI.canRecovery = false;
       this.layer.uiControl.graphicStateUI.canRecovery = false;
     }
     }

+ 3 - 7
src/graphic/Coordinate.js

@@ -3,7 +3,7 @@ import { dataService } from "./Service/DataService";
 
 
 const defaultZoom = 100;
 const defaultZoom = 100;
 const defaultRes = 0.1;
 const defaultRes = 0.1;
-const minAdsorbPix = 30;
+const minAdsorbPix = 15;
 
 
 export default class Coordinate {
 export default class Coordinate {
   constructor() {
   constructor() {
@@ -69,21 +69,17 @@ export default class Coordinate {
     return point;
     return point;
   }
   }
 
 
-
   getXYFromScreenNotRatio(screenPoint) {
   getXYFromScreenNotRatio(screenPoint) {
     const point = {};
     const point = {};
     point.x =
     point.x =
-      ((screenPoint.x - this.width / 2) * defaultZoom) /
-      this.zoom +
+      ((screenPoint.x - this.width / 2) * defaultZoom) / this.zoom +
       this.center.x;
       this.center.x;
     point.y =
     point.y =
-      ((this.height / 2 - screenPoint.y) * defaultZoom) /
-      this.zoom +
+      ((this.height / 2 - screenPoint.y) * defaultZoom) / this.zoom +
       this.center.y;
       this.center.y;
     return point;
     return point;
   }
   }
 
 
-
   getPointForRevRotate(point, angle) {}
   getPointForRevRotate(point, angle) {}
 
 
   getVectorForRotate(point, angle) {}
   getVectorForRotate(point, angle) {}

+ 9 - 1
src/graphic/Geometry/Img.js

@@ -43,23 +43,31 @@ export default class Img extends Geometry {
   setBounding() {
   setBounding() {
     const width = this.imageData.width * coordinate.ratio;
     const width = this.imageData.width * coordinate.ratio;
     const height = this.imageData.height * coordinate.ratio;
     const height = this.imageData.height * coordinate.ratio;
+    this.scale = coordinate.width / width;
     this.bounding = [];
     this.bounding = [];
     this.bounding[0] = {
     this.bounding[0] = {
       x: this.center.x - width / 2,
       x: this.center.x - width / 2,
       y: this.center.y + height / 2,
       y: this.center.y + height / 2,
     };
     };
+    this.bounding[0].x = this.bounding[0].x * this.scale;
+    this.bounding[0].y = this.bounding[0].y * this.scale;
     this.bounding[1] = {
     this.bounding[1] = {
       x: this.center.x + width / 2,
       x: this.center.x + width / 2,
       y: this.center.y + height / 2,
       y: this.center.y + height / 2,
     };
     };
+    this.bounding[1].x = this.bounding[1].x * this.scale;
+    this.bounding[1].y = this.bounding[1].y * this.scale;
     this.bounding[2] = {
     this.bounding[2] = {
       x: this.center.x + width / 2,
       x: this.center.x + width / 2,
       y: this.center.y - height / 2,
       y: this.center.y - height / 2,
     };
     };
+    this.bounding[2].x = this.bounding[2].x * this.scale;
+    this.bounding[2].y = this.bounding[2].y * this.scale;
     this.bounding[3] = {
     this.bounding[3] = {
       x: this.center.x - width / 2,
       x: this.center.x - width / 2,
       y: this.center.y - height / 2,
       y: this.center.y - height / 2,
     };
     };
-    this.scale = coordinate.width / width;
+    this.bounding[3].x = this.bounding[3].x * this.scale;
+    this.bounding[3].y = this.bounding[3].y * this.scale;
   }
   }
 }
 }

+ 5 - 3
src/graphic/ListenLayer.js

@@ -760,7 +760,7 @@ export default class ListenLayer {
         //Constant.minAdsorbPix
         //Constant.minAdsorbPix
         Math.max(curveRoad.leftWidth, curveRoad.rightWidth)
         Math.max(curveRoad.leftWidth, curveRoad.rightWidth)
       );
       );
-
+      console.log("isSelectCurveRoad:" + JSON.stringify(joinInfo));
       //检查edge
       //检查edge
       const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
       const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
       const leftJoinInfo = this.distanceForBezier(
       const leftJoinInfo = this.distanceForBezier(
@@ -838,10 +838,13 @@ export default class ListenLayer {
       (!curveEdgeInfo.curveEdgeId ||
       (!curveEdgeInfo.curveEdgeId ||
         curveRoadInfo.distance < curveEdgeInfo.distance)
         curveRoadInfo.distance < curveEdgeInfo.distance)
     ) {
     ) {
+      console.log("选中的CurveRoad:" + curveRoadInfo.curveRoadId);
       return curveRoadInfo;
       return curveRoadInfo;
     } else if (curveEdgeInfo.curveEdgeId) {
     } else if (curveEdgeInfo.curveEdgeId) {
+      console.log("选中的CurveEdge:" + curveEdgeInfo.curveEdgeId);
       return curveEdgeInfo;
       return curveEdgeInfo;
     } else {
     } else {
+      console.log("既然没选中CurveRoad,也没选中CurveEdge");
       return {
       return {
         curveRoadId: null,
         curveRoadId: null,
         curveEdgeId: null,
         curveEdgeId: null,
@@ -1353,9 +1356,8 @@ export default class ListenLayer {
   }
   }
 
 
   distanceForBezier(position, curves, width) {
   distanceForBezier(position, curves, width) {
-
     const data = mathUtil.getHitInfoForCurves(position, curves, width);
     const data = mathUtil.getHitInfoForCurves(position, curves, width);
-    return data
+    return data;
   }
   }
 
 
   equalAndClone(info1, info2) {
   equalAndClone(info1, info2) {

+ 70 - 0
src/graphic/Service/CurveRoadPointService.js

@@ -1,6 +1,8 @@
 import CurveRoadPoint from "../Geometry/CurveRoadPoint.js";
 import CurveRoadPoint from "../Geometry/CurveRoadPoint.js";
 import { dataService } from "./DataService.js";
 import { dataService } from "./DataService.js";
 import { mathUtil } from "../Util/MathUtil.js";
 import { mathUtil } from "../Util/MathUtil.js";
+import { curveRoadService } from "./CurveRoadService.js";
+import { curveEdgeService } from "./CurveEdgeService.js";
 
 
 export default class CurveRoadPointService {
 export default class CurveRoadPointService {
   constructor() {}
   constructor() {}
@@ -10,6 +12,74 @@ export default class CurveRoadPointService {
     dataService.addCurveRoadPoint(point);
     dataService.addCurveRoadPoint(point);
     return point;
     return point;
   }
   }
+
+  deleteCurveRoadPoint(curveRoadPointId) {
+    let curveRoadPoint = dataService.getCurveRoadPoint(curveRoadPointId);
+    let curveRoadId = curveRoadPoint.getParent();
+    let curveRoad = dataService.getCurveRoad(curveRoadId);
+    let leftCurveRoadEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
+    let rightCurveRoadEdge = dataService.getCurveRoadEdge(
+      curveRoad.rightEdgeId
+    );
+    if (curveRoad.startId == curveRoadPointId) {
+      curveRoad.points.shift();
+      curveRoad.startId = curveRoad.points[0].vectorId;
+      for (let j = 0; j < curveRoad.points.length; ++j) {
+        let _curveRoadPoint = dataService.getCurveRoadPoint(
+          curveRoad.points[j].vectorId
+        );
+        const index = _curveRoadPoint.getIndex();
+        _curveRoadPoint.setIndex(index - 1);
+      }
+      leftCurveRoadEdge.points.shift();
+      leftCurveRoadEdge.start = JSON.parse(
+        JSON.stringify(leftCurveRoadEdge.points[0])
+      );
+
+      rightCurveRoadEdge.points.shift();
+      rightCurveRoadEdge.start = JSON.parse(
+        JSON.stringify(rightCurveRoadEdge.points[0])
+      );
+    } else if (curveRoad.endId == curveRoadPointId) {
+      curveRoad.points.pop();
+      curveRoad.endId = curveRoad.points[curveRoad.points.length - 1].vectorId;
+
+      leftCurveRoadEdge.points.pop();
+      leftCurveRoadEdge.end = JSON.parse(
+        JSON.stringify(
+          leftCurveRoadEdge.points[leftCurveRoadEdge.points.length - 1]
+        )
+      );
+
+      rightCurveRoadEdge.points.pop();
+      rightCurveRoadEdge.end = JSON.parse(
+        JSON.stringify(
+          rightCurveRoadEdge.points[rightCurveRoadEdge.points.length - 1]
+        )
+      );
+    } else {
+      let index = -1;
+      for (let j = 0; j < curveRoad.points.length; ++j) {
+        if (curveRoad.points[j].vectorId == curveRoadPointId) {
+          index = j;
+        }
+        if (index != -1 && j > index) {
+          let _curveRoadPoint = dataService.getCurveRoadPoint(
+            curveRoad.points[j].vectorId
+          );
+          const index = _curveRoadPoint.getIndex();
+          _curveRoadPoint.setIndex(index - 1);
+        }
+      }
+      curveRoad.points.splice(index, 1);
+      leftCurveRoadEdge.points.splice(index, 1);
+      rightCurveRoadEdge.points.splice(index, 1);
+    }
+    dataService.deleteCurveRoadPoint(curveRoadPointId);
+    curveRoadService.setLanes(curveRoadId);
+    curveEdgeService.setCurves(leftCurveRoadEdge);
+    curveEdgeService.setCurves(rightCurveRoadEdge);
+  }
 }
 }
 
 
 const curveRoadPointService = new CurveRoadPointService();
 const curveRoadPointService = new CurveRoadPointService();

+ 263 - 73
src/graphic/Service/CurveRoadService.js

@@ -820,6 +820,110 @@ export default class CurveRoadService extends RoadService {
     this.setLanes(curveRoadId);
     this.setLanes(curveRoadId);
   }
   }
 
 
+  // //变宽或者变窄(车道数据不变)
+  // //单向的情况下,左右两边同时变宽或者变窄,即:dir无效
+  // updateForWidth(curveRoadId, newWidth, dir) {
+  //   let curveRoad = dataService.getCurveRoad(curveRoadId);
+  //   let leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
+  //   let rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
+
+  //   let ratio = null;
+  //   let dx = null;
+  //   let dy = null;
+  //   //需要考虑中间带
+  //   if (dir == "left") {
+  //     ratio =
+  //       (newWidth + curveRoad.midDivide.midDivideWidth / 2) /
+  //       (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
+  //   } else if (dir == "right") {
+  //     ratio =
+  //       (newWidth + curveRoad.midDivide.midDivideWidth / 2) /
+  //       (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
+  //   } else {
+  //     if (curveRoad.way == Constant.oneWay) {
+  //       ratio = newWidth / curveRoad.singleRoadWidth;
+  //     }
+  //   }
+
+  //   for (let i = 0; i < curveRoad.points.length; ++i) {
+  //     if (dir == "left") {
+  //       dx = (leftCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
+  //       leftCurveEdge.points[i].x = curveRoad.points[i].x + dx;
+  //       dy = (leftCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
+  //       leftCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+  //     } else if (dir == "right") {
+  //       dx = (rightCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
+  //       rightCurveEdge.points[i].x = curveRoad.points[i].x + dx;
+  //       dy = (rightCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
+  //       rightCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+  //     } else {
+  //       if (curveRoad.way == Constant.oneWay) {
+  //         dx = (leftCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
+  //         leftCurveEdge.points[i].x = curveRoad.points[i].x + dx;
+  //         dy = (leftCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
+  //         leftCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+  //         dx = (rightCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
+  //         rightCurveEdge.points[i].x = curveRoad.points[i].x + dx;
+  //         dy = (rightCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
+  //         rightCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+  //       } else if (curveRoad.way == Constant.twoWay) {
+  //         ratio = newWidth / (curveRoad.leftWidth + curveRoad.rightWidth);
+  //         ratio =
+  //           (curveRoad.leftWidth * ratio +
+  //             curveRoad.midDivide.midDivideWidth / 2) /
+  //           (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
+  //         dx = (leftCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
+  //         leftCurveEdge.points[i].x = curveRoad.points[i].x + dx;
+  //         dy = (leftCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
+  //         leftCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+  //         ratio = newWidth / (curveRoad.leftWidth + curveRoad.rightWidth);
+  //         ratio =
+  //           (curveRoad.rightWidth * ratio +
+  //             curveRoad.midDivide.midDivideWidth / 2) /
+  //           (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
+  //         dx = (rightCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
+  //         rightCurveEdge.points[i].x = curveRoad.points[i].x + dx;
+  //         dy = (rightCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
+  //         rightCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+  //       }
+  //     }
+  //   }
+  //   leftCurveEdge.start = JSON.parse(JSON.stringify(leftCurveEdge.points[0]));
+  //   leftCurveEdge.end = JSON.parse(
+  //     JSON.stringify(leftCurveEdge.points[leftCurveEdge.points.length - 1])
+  //   );
+  //   rightCurveEdge.start = JSON.parse(JSON.stringify(rightCurveEdge.points[0]));
+  //   rightCurveEdge.end = JSON.parse(
+  //     JSON.stringify(rightCurveEdge.points[rightCurveEdge.points.length - 1])
+  //   );
+
+  //   if (dir == "left") {
+  //     curveEdgeService.setCurves(leftCurveEdge);
+  //     curveRoad.setWidth(newWidth, dir);
+  //   } else if (dir == "right") {
+  //     curveEdgeService.setCurves(rightCurveEdge);
+  //     curveRoad.setWidth(newWidth, dir);
+  //   } else {
+  //     curveEdgeService.setCurves(leftCurveEdge);
+  //     curveEdgeService.setCurves(rightCurveEdge);
+  //     if (curveRoad.way == Constant.oneWay) {
+  //       curveRoad.setWidth(newWidth);
+  //     } else if (curveRoad.way == Constant.twoWay) {
+  //       curveRoad.setWidth(
+  //         (newWidth * curveRoad.leftWidth) /
+  //           (curveRoad.leftWidth + curveRoad.rightWidth),
+  //         "left"
+  //       );
+  //       curveRoad.setWidth(
+  //         (newWidth * curveRoad.rightWidth) /
+  //           (curveRoad.leftWidth + curveRoad.rightWidth),
+  //         "right"
+  //       );
+  //     }
+  //   }
+  //   this.setLanes(curveRoadId, dir);
+  // }
+
   //变宽或者变窄(车道数据不变)
   //变宽或者变窄(车道数据不变)
   //单向的情况下,左右两边同时变宽或者变窄,即:dir无效
   //单向的情况下,左右两边同时变宽或者变窄,即:dir无效
   updateForWidth(curveRoadId, newWidth, dir) {
   updateForWidth(curveRoadId, newWidth, dir) {
@@ -827,75 +931,157 @@ export default class CurveRoadService extends RoadService {
     let leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
     let leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
     let rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
     let rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
 
 
-    let ratio = null;
-    let dx = null;
-    let dy = null;
-    //需要考虑中间带
-    if (dir == "left") {
-      ratio =
-        (newWidth + curveRoad.midDivide.midDivideWidth / 2) /
-        (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
-    } else if (dir == "right") {
-      ratio =
-        (newWidth + curveRoad.midDivide.midDivideWidth / 2) /
-        (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
-    } else {
-      if (curveRoad.way == Constant.oneWay) {
-        ratio = newWidth / curveRoad.singleRoadWidth;
+    let line1 = null;
+    let line2 = null;
+
+    let midDivideWidth = 0;
+    if (curveRoadId.way == Constant.twoWay) {
+      midDivideWidth = curveRoad.midDivide.midDivideWidth;
+    }
+
+    if (dir == "left" || !dir) {
+      for (let i = 0; i < leftCurveEdge.points.length; ++i) {
+        if (i == 0) {
+          let points1 = mathUtil.RectangleVertex(
+            curveRoad.points[i],
+            curveRoad.points[i + 1],
+            newWidth + midDivideWidth / 2
+          );
+          line1 = mathUtil.createLine1(
+            points1.leftEdgeStart,
+            points1.leftEdgeEnd
+          );
+          let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
+          leftCurveEdge.start = JSON.parse(JSON.stringify(leftJoin));
+          leftCurveEdge.points[0] = JSON.parse(JSON.stringify(leftJoin));
+        } else if (i == leftCurveEdge.points.length - 1) {
+          let points1 = mathUtil.RectangleVertex(
+            curveRoad.points[i - 1],
+            curveRoad.points[i],
+            newWidth + midDivideWidth / 2
+          );
+          line1 = mathUtil.createLine1(
+            points1.leftEdgeStart,
+            points1.leftEdgeEnd
+          );
+          let leftJoin = mathUtil.getJoinLinePoint(
+            curveRoad.points[curveRoad.points.length - 1],
+            line1
+          );
+          leftCurveEdge.end = JSON.parse(JSON.stringify(leftJoin));
+          leftCurveEdge.points[leftCurveEdge.points.length - 1] = JSON.parse(
+            JSON.stringify(leftJoin)
+          );
+        } else {
+          if (
+            mathUtil.Angle(
+              curveRoad.points[i],
+              curveRoad.points[i - 1],
+              curveRoad.points[i + 1]
+            ) > Constant.maxAngle
+          ) {
+            let leftJoin = mathUtil.getJoinLinePoint(
+              curveRoad.points[i],
+              line1
+            );
+            leftCurveEdge.points[i] = JSON.parse(JSON.stringify(leftJoin));
+          } else {
+            let points1 = mathUtil.RectangleVertex(
+              curveRoad.points[i - 1],
+              curveRoad.points[i],
+              newWidth + midDivideWidth / 2
+            );
+            line1 = mathUtil.createLine1(
+              points1.leftEdgeStart,
+              points1.leftEdgeEnd
+            );
+            let points2 = mathUtil.RectangleVertex(
+              curveRoad.points[i],
+              curveRoad.points[i + 1],
+              newWidth + midDivideWidth / 2
+            );
+            line2 = mathUtil.createLine1(
+              points2.leftEdgeStart,
+              points2.leftEdgeEnd
+            );
+            let leftJoin = mathUtil.getIntersectionPoint(line1, line2);
+            leftCurveEdge.points[i] = JSON.parse(JSON.stringify(leftJoin));
+          }
+        }
       }
       }
     }
     }
 
 
-    for (let i = 0; i < curveRoad.points.length; ++i) {
-      if (dir == "left") {
-        dx = (leftCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
-        leftCurveEdge.points[i].x = curveRoad.points[i].x + dx;
-        dy = (leftCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
-        leftCurveEdge.points[i].y = curveRoad.points[i].y + dy;
-      } else if (dir == "right") {
-        dx = (rightCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
-        rightCurveEdge.points[i].x = curveRoad.points[i].x + dx;
-        dy = (rightCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
-        rightCurveEdge.points[i].y = curveRoad.points[i].y + dy;
-      } else {
-        if (curveRoad.way == Constant.oneWay) {
-          dx = (leftCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
-          leftCurveEdge.points[i].x = curveRoad.points[i].x + dx;
-          dy = (leftCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
-          leftCurveEdge.points[i].y = curveRoad.points[i].y + dy;
-          dx = (rightCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
-          rightCurveEdge.points[i].x = curveRoad.points[i].x + dx;
-          dy = (rightCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
-          rightCurveEdge.points[i].y = curveRoad.points[i].y + dy;
-        } else if (curveRoad.way == Constant.twoWay) {
-          ratio = newWidth / (curveRoad.leftWidth + curveRoad.rightWidth);
-          ratio =
-            (curveRoad.leftWidth * ratio +
-              curveRoad.midDivide.midDivideWidth / 2) /
-            (curveRoad.leftWidth + curveRoad.midDivide.midDivideWidth / 2);
-          dx = (leftCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
-          leftCurveEdge.points[i].x = curveRoad.points[i].x + dx;
-          dy = (leftCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
-          leftCurveEdge.points[i].y = curveRoad.points[i].y + dy;
-          ratio = newWidth / (curveRoad.leftWidth + curveRoad.rightWidth);
-          ratio =
-            (curveRoad.rightWidth * ratio +
-              curveRoad.midDivide.midDivideWidth / 2) /
-            (curveRoad.rightWidth + curveRoad.midDivide.midDivideWidth / 2);
-          dx = (rightCurveEdge.points[i].x - curveRoad.points[i].x) * ratio;
-          rightCurveEdge.points[i].x = curveRoad.points[i].x + dx;
-          dy = (rightCurveEdge.points[i].y - curveRoad.points[i].y) * ratio;
-          rightCurveEdge.points[i].y = curveRoad.points[i].y + dy;
+    if (dir == "right" || !dir) {
+      for (let i = 0; i < rightCurveEdge.points.length; ++i) {
+        if (i == 0) {
+          let points1 = mathUtil.RectangleVertex(
+            curveRoad.points[i],
+            curveRoad.points[i + 1],
+            newWidth + midDivideWidth / 2
+          );
+          line1 = mathUtil.createLine1(
+            points1.rightEdgeStart,
+            points1.rightEdgeEnd
+          );
+          let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], line1);
+          rightCurveEdge.start = JSON.parse(JSON.stringify(rightJoin));
+          rightCurveEdge.points[0] = JSON.parse(JSON.stringify(rightJoin));
+        } else if (i == rightCurveEdge.points.length - 1) {
+          let points1 = mathUtil.RectangleVertex(
+            curveRoad.points[i - 1],
+            curveRoad.points[i],
+            newWidth + midDivideWidth / 2
+          );
+          line1 = mathUtil.createLine1(
+            points1.leftEdgeStart,
+            points1.leftEdgeEnd
+          );
+          let rightJoin = mathUtil.getJoinLinePoint(
+            curveRoad.points[curveRoad.points.length - 1],
+            line1
+          );
+          rightCurveEdge.end = JSON.parse(JSON.stringify(rightJoin));
+          rightCurveEdge.points[rightCurveEdge.points.length - 1] = JSON.parse(
+            JSON.stringify(rightJoin)
+          );
+        } else {
+          if (
+            mathUtil.Angle(
+              curveRoad.points[i],
+              curveRoad.points[i - 1],
+              curveRoad.points[i + 1]
+            ) > Constant.maxAngle
+          ) {
+            let rightJoin = mathUtil.getJoinLinePoint(
+              curveRoad.points[i],
+              line1
+            );
+            rightCurveEdge.points[i] = JSON.parse(JSON.stringify(rightJoin));
+          } else {
+            let points1 = mathUtil.RectangleVertex(
+              curveRoad.points[i - 1],
+              curveRoad.points[i],
+              newWidth + midDivideWidth / 2
+            );
+            line1 = mathUtil.createLine1(
+              points1.rightEdgeStart,
+              points1.rightEdgeEnd
+            );
+            let points2 = mathUtil.RectangleVertex(
+              curveRoad.points[i],
+              curveRoad.points[i + 1],
+              newWidth + midDivideWidth / 2
+            );
+            line2 = mathUtil.createLine1(
+              points2.rightEdgeStart,
+              points2.rightEdgeEnd
+            );
+            let rightJoin = mathUtil.getIntersectionPoint(line1, line2);
+            rightCurveEdge.points[i] = JSON.parse(JSON.stringify(rightJoin));
+          }
         }
         }
       }
       }
     }
     }
-    leftCurveEdge.start = JSON.parse(JSON.stringify(leftCurveEdge.points[0]));
-    leftCurveEdge.end = JSON.parse(
-      JSON.stringify(leftCurveEdge.points[leftCurveEdge.points.length - 1])
-    );
-    rightCurveEdge.start = JSON.parse(JSON.stringify(rightCurveEdge.points[0]));
-    rightCurveEdge.end = JSON.parse(
-      JSON.stringify(rightCurveEdge.points[rightCurveEdge.points.length - 1])
-    );
 
 
     if (dir == "left") {
     if (dir == "left") {
       curveEdgeService.setCurves(leftCurveEdge);
       curveEdgeService.setCurves(leftCurveEdge);
@@ -909,17 +1095,21 @@ export default class CurveRoadService extends RoadService {
       if (curveRoad.way == Constant.oneWay) {
       if (curveRoad.way == Constant.oneWay) {
         curveRoad.setWidth(newWidth);
         curveRoad.setWidth(newWidth);
       } else if (curveRoad.way == Constant.twoWay) {
       } else if (curveRoad.way == Constant.twoWay) {
-        curveRoad.setWidth(
-          (newWidth * curveRoad.leftWidth) /
-            (curveRoad.leftWidth + curveRoad.rightWidth),
-          "left"
-        );
-        curveRoad.setWidth(
-          (newWidth * curveRoad.rightWidth) /
-            (curveRoad.leftWidth + curveRoad.rightWidth),
-          "right"
-        );
+        curveRoad.setWidth(newWidth, "left");
+        curveRoad.setWidth(newWidth, "right");
       }
       }
+      // else if (curveRoad.way == Constant.twoWay) {
+      //   curveRoad.setWidth(
+      //     (newWidth * curveRoad.leftWidth) /
+      //       (curveRoad.leftWidth + curveRoad.rightWidth),
+      //     "left"
+      //   );
+      //   curveRoad.setWidth(
+      //     (newWidth * curveRoad.rightWidth) /
+      //       (curveRoad.leftWidth + curveRoad.rightWidth),
+      //     "right"
+      //   );
+      // }
     }
     }
     this.setLanes(curveRoadId, dir);
     this.setLanes(curveRoadId, dir);
   }
   }

+ 8 - 0
src/graphic/Service/ImageService.js

@@ -28,9 +28,17 @@ export default class ImageService {
     let bgImg = dataService.getBackgroundImg();
     let bgImg = dataService.getBackgroundImg();
     let vertexs = [];
     let vertexs = [];
     vertexs[0] = coordinate.getScreenXY(bgImg.bounding[0]);
     vertexs[0] = coordinate.getScreenXY(bgImg.bounding[0]);
+    // vertexs[0].x = vertexs[0].x / bgImg.scale;
+    // vertexs[0].y = vertexs[0].y / bgImg.scale;
     vertexs[1] = coordinate.getScreenXY(bgImg.bounding[1]);
     vertexs[1] = coordinate.getScreenXY(bgImg.bounding[1]);
+    // vertexs[1].x = vertexs[0].x / bgImg.scale;
+    // vertexs[1].y = vertexs[0].y / bgImg.scale;
     vertexs[2] = coordinate.getScreenXY(bgImg.bounding[2]);
     vertexs[2] = coordinate.getScreenXY(bgImg.bounding[2]);
+    // vertexs[2].x = vertexs[0].x / bgImg.scale;
+    // vertexs[2].y = vertexs[0].y / bgImg.scale;
     vertexs[3] = coordinate.getScreenXY(bgImg.bounding[3]);
     vertexs[3] = coordinate.getScreenXY(bgImg.bounding[3]);
+    // vertexs[3].x = vertexs[0].x / bgImg.scale;
+    // vertexs[3].y = vertexs[0].y / bgImg.scale;
     let flag =
     let flag =
       isInScreen(vertexs[0]) ||
       isInScreen(vertexs[0]) ||
       isInScreen(vertexs[1]) ||
       isInScreen(vertexs[1]) ||