瀏覽代碼

修复bug

xushiting 2 年之前
父節點
當前提交
57b1943d01

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

@@ -108,7 +108,7 @@ export default class AddCrossRoad {
     startPoint.setIndex(0);
 
     endPoint.setPointParent(curveRoad.vectorId);
-    endPoint.setIndex(2);
+    endPoint.setIndex(1);
 
     let edgePoints = mathUtil.RectangleVertex(
       startPoint,
@@ -158,8 +158,8 @@ export default class AddCrossRoad {
       y: (endPoint.y + midPoint.y) / 2,
     };
 
-    curveRoadService.addCPoint(curveRoad, mid1, 0);
-    curveRoadService.addCPoint(curveRoad, mid2, 1);
+    curveRoadService.addCPoint(curveRoad, mid1, 1);
+    curveRoadService.addCPoint(curveRoad, mid2, 2);
     mid1.x -= offsetDis;
     mid2.x += offsetDis;
     curveRoadService.updateForMovePoint(curveRoad.points[1].vectorId, mid1);
@@ -383,7 +383,7 @@ export default class AddCrossRoad {
     startPoint.setIndex(0);
 
     endPoint.setPointParent(curveRoad.vectorId);
-    endPoint.setIndex(2);
+    endPoint.setIndex(1);
 
     let edgePoints = mathUtil.RectangleVertex(
       startPoint,
@@ -436,11 +436,11 @@ export default class AddCrossRoad {
       y: position.y - height / 2,
     };
 
-    curveRoadService.addCPoint(curveRoad, point1, 0);
-    curveRoadService.addCPoint(curveRoad, point2, 1);
-    curveRoadService.addCPoint(curveRoad, position, 2);
-    curveRoadService.addCPoint(curveRoad, point3, 3);
-    curveRoadService.addCPoint(curveRoad, point4, 4);
+    curveRoadService.addCPoint(curveRoad, point1, 1);
+    curveRoadService.addCPoint(curveRoad, point2, 2);
+    curveRoadService.addCPoint(curveRoad, position, 3);
+    curveRoadService.addCPoint(curveRoad, point3, 4);
+    curveRoadService.addCPoint(curveRoad, point4, 5);
 
     curveRoadService.updateForMovePoint(curveRoad.points[1].vectorId, point1);
     curveRoadService.updateForMovePoint(curveRoad.points[2].vectorId, point2);

+ 9 - 3
src/graphic/Controls/LocationModeControl.js

@@ -6,6 +6,7 @@ import { dataService } from "../Service/DataService";
 import { lineService } from "../Service/LineService";
 import { pointService } from "../Service/PointService";
 import VectorCategory from "../enum/VectorCategory";
+import Constant from "../Constant";
 
 export default class LocationModeControl {
   constructor() {}
@@ -15,9 +16,9 @@ export default class LocationModeControl {
     let selectBasePoint = this.isFocusBasePoint();
     if (selectBasePoint) {
       let points = dataService.getPoints();
-      for (let i = 0; i < points.length; ++i) {
-        let point = dataService.getPoint(points[i].vectorId);
-        if (point.getCategory() == VectorCategory.Point.fixPoint) {
+      for (let key in points) {
+        let point = dataService.getPoint(key);
+        if (point.getCategory() == VectorCategory.Point.FixPoint) {
           this.setSingleFixPointByAngle(
             point.vectorId,
             selectBasePoint.vectorId
@@ -40,27 +41,32 @@ export default class LocationModeControl {
     let vLine = mathUtil.getVerticalLine(baseLineGeometry, fixPoint);
     let join = mathUtil.getJoinLinePoint(basePoint, vLine);
     join = pointService.create(join);
+    join.setLocationMode(Constant.angleLocationMode);
 
     let locationLineByFixPoint = lineService.createByPointId(
       fixPointId,
       join.vectorId,
       VectorCategory.Line.LocationLineByFixPoint
     );
+    locationLineByFixPoint.setLocationMode(Constant.angleLocationMode);
 
     let locationLineByBasePoint = mathUtil.getVerticalLine(vLine, basePoint);
     join = mathUtil.getIntersectionPoint(locationLineByBasePoint, vLine);
     join = pointService.create(join);
+    join.setLocationMode(Constant.angleLocationMode);
     locationLineByBasePoint = lineService.createByPointId(
       basePointId,
       join.vectorId,
       VectorCategory.Line.LocationLineByBasePoint
     );
+    locationLineByBasePoint.setLocationMode(Constant.angleLocationMode);
 
     let guideLocationLine = lineService.createByPointId(
       fixPointId,
       join.vectorId,
       VectorCategory.Line.GuideLocationLine
     );
+    guideLocationLine.setLocationMode(Constant.angleLocationMode);
   }
 
   /******************************************************************************************************************************************************/

+ 326 - 137
src/graphic/Layer.js

@@ -1,48 +1,48 @@
-import Load from './Load';
-import { stateService } from './Service/StateService';
-import { elementService } from './Service/ElementService';
-import { dataService } from './Service/DataService';
-import { textService } from './Service/TextService';
-import { historyService } from './Service/HistoryService';
-import UIControl from './Controls/UIControl';
+import Load from "./Load";
+import { stateService } from "./Service/StateService";
+import { elementService } from "./Service/ElementService";
+import { dataService } from "./Service/DataService";
+import { textService } from "./Service/TextService";
+import { historyService } from "./Service/HistoryService";
+import UIControl from "./Controls/UIControl";
 import { locationModeControl } from "./Controls/LocationModeControl";
-import { moveText } from './Controls/MoveText';
-import { moveSVG } from './Controls/MoveSVG';
-import { moveMagnifier } from './Controls/MoveMagnifier';
-import { addRoad } from './Controls/AddRoad';
-import { addCrossRoad } from './Controls/AddCrossRoad';
-import { addLine } from './Controls/AddLine';
-import { addPoint } from './Controls/AddPoint';
-import { addCircle } from './Controls/AddCircle';
-import { addText } from './Controls/AddText';
-import { addMagnifier } from './Controls/AddMagnifier';
-import { addSVG } from './Controls/AddSVG';
-import { moveRoad } from './Controls/MoveRoad';
-import { moveLine } from './Controls/MoveLine';
-import { movePoint } from './Controls/MovePoint';
-import { moveCircle } from './Controls/MoveCircle';
-import { coordinate } from './Coordinate';
-import Render from './Renderer/Render';
-import { draw } from './Renderer/Draw';
-import { listenLayer } from './ListenLayer';
-import LayerEvents from './enum/LayerEvents.js';
-import UIEvents from './enum/UIEvents.js';
-import SelectState from './enum/SelectState.js';
-import VectorType from './enum/VectorType';
-import { mathUtil } from './Util/MathUtil';
-import History from './History/History';
-import mitt from 'mitt';
-import { roadService } from './Service/RoadService';
-import { edgeService } from './Service/EdgeService';
-import { roadPointService } from './Service/RoadPointService';
-import { curveRoadService } from './Service/CurveRoadService';
-import VectorCategory from './enum/VectorCategory';
-import Settings from './Settings';
-import Constant from './Constant';
-import { uiService } from './Service/UIService';
-import { imageService } from './Service/ImageService';
-import VectorEvents from './enum/VectorEvents';
-import { lineService } from './Service/LineService';
+import { moveText } from "./Controls/MoveText";
+import { moveSVG } from "./Controls/MoveSVG";
+import { moveMagnifier } from "./Controls/MoveMagnifier";
+import { addRoad } from "./Controls/AddRoad";
+import { addCrossRoad } from "./Controls/AddCrossRoad";
+import { addLine } from "./Controls/AddLine";
+import { addPoint } from "./Controls/AddPoint";
+import { addCircle } from "./Controls/AddCircle";
+import { addText } from "./Controls/AddText";
+import { addMagnifier } from "./Controls/AddMagnifier";
+import { addSVG } from "./Controls/AddSVG";
+import { moveRoad } from "./Controls/MoveRoad";
+import { moveLine } from "./Controls/MoveLine";
+import { movePoint } from "./Controls/MovePoint";
+import { moveCircle } from "./Controls/MoveCircle";
+import { coordinate } from "./Coordinate";
+import Render from "./Renderer/Render";
+import { draw } from "./Renderer/Draw";
+import { listenLayer } from "./ListenLayer";
+import LayerEvents from "./enum/LayerEvents.js";
+import UIEvents from "./enum/UIEvents.js";
+import SelectState from "./enum/SelectState.js";
+import VectorType from "./enum/VectorType";
+import { mathUtil } from "./Util/MathUtil";
+import History from "./History/History";
+import mitt from "mitt";
+import { roadService } from "./Service/RoadService";
+import { edgeService } from "./Service/EdgeService";
+import { roadPointService } from "./Service/RoadPointService";
+import { curveRoadService } from "./Service/CurveRoadService";
+import VectorCategory from "./enum/VectorCategory";
+import Settings from "./Settings";
+import Constant from "./Constant";
+import { uiService } from "./Service/UIService";
+import { imageService } from "./Service/ImageService";
+import VectorEvents from "./enum/VectorEvents";
+import { lineService } from "./Service/LineService";
 
 const minDragDis = 10;
 const minZoom = 20;
@@ -77,25 +77,25 @@ export default class Layer {
   }
 
   bindEvents() {
-    this.canvas.addEventListener('contextmenu', function (e) {
+    this.canvas.addEventListener("contextmenu", function (e) {
       e.preventDefault();
     });
-    this.canvas.addEventListener('mousedown', this.onMouseDown.bind(this));
-    this.canvas.addEventListener('mousemove', this.onMouseMove.bind(this));
-    this.canvas.addEventListener('mouseup', this.onMouseUp.bind(this));
+    this.canvas.addEventListener("mousedown", this.onMouseDown.bind(this));
+    this.canvas.addEventListener("mousemove", this.onMouseMove.bind(this));
+    this.canvas.addEventListener("mouseup", this.onMouseUp.bind(this));
 
-    this.canvas.addEventListener('touchstart', this.onMouseDown.bind(this));
-    this.canvas.addEventListener('touchmove', this.onMouseMove.bind(this));
-    this.canvas.addEventListener('touchend', this.onMouseUp.bind(this));
+    this.canvas.addEventListener("touchstart", this.onMouseDown.bind(this));
+    this.canvas.addEventListener("touchmove", this.onMouseMove.bind(this));
+    this.canvas.addEventListener("touchend", this.onMouseUp.bind(this));
 
-    this.canvas.addEventListener('mousewheel', this.onWheel.bind(this));
-    this.canvas.addEventListener('DOMMouseScroll', this.onWheel.bind(this));
-    this.canvas.addEventListener('resize', this.reSize.bind(this));
+    this.canvas.addEventListener("mousewheel", this.onWheel.bind(this));
+    this.canvas.addEventListener("DOMMouseScroll", this.onWheel.bind(this));
+    this.canvas.addEventListener("resize", this.reSize.bind(this));
     document.addEventListener("keydown", this.onKeydown.bind(this));
   }
 
   reSize = function () {
-    console.log('resize');
+    console.log("resize");
     coordinate.updateForCanvas();
     this.renderer.autoRedraw();
   };
@@ -131,16 +131,16 @@ export default class Layer {
     let selectItem = stateService.getSelectItem();
     let focusItem = stateService.getFocusItem();
 
-    this.setEventName('mouseDown');
+    this.setEventName("mouseDown");
     const eventName = stateService.getEventName();
     switch (eventName) {
       case LayerEvents.AddRoad:
         stateService.setEventName(LayerEvents.AddingRoad);
-        addRoad.setNewRoadPoint('start', position);
+        addRoad.setNewRoadPoint("start", position);
         break;
       case LayerEvents.AddCurveRoad:
         stateService.setEventName(LayerEvents.AddingCurveRoad);
-        addRoad.setNewRoadPoint('start', position);
+        addRoad.setNewRoadPoint("start", position);
         break;
       case LayerEvents.AddLine:
         stateService.setEventName(LayerEvents.AddingLine);
@@ -154,14 +154,18 @@ export default class Layer {
         stateService.setEventName(LayerEvents.MovePoint);
         const newPoint = addPoint.buildPoint2(position);
         if (newPoint) {
-          stateService.setSelectItem(newPoint.vectorId, VectorType.Point, SelectState.Select);
+          stateService.setSelectItem(
+            newPoint.vectorId,
+            VectorType.Point,
+            SelectState.Select
+          );
           this.history.save();
           this.renderer.autoRedraw();
         } else {
           if (Settings.basePointIds.length > 1) {
-            this.uiControl.prompt({ msg: '请先选择基准点', time: 1000 });
+            this.uiControl.prompt({ msg: "请先选择基准点", time: 1000 });
           } else {
-            this.uiControl.prompt({ msg: '请先添加基准点', time: 1000 });
+            this.uiControl.prompt({ msg: "请先添加基准点", time: 1000 });
           }
 
           // this.uiControl.prompt({ msg: '请先选择基准点', time: 1000 });
@@ -175,7 +179,11 @@ export default class Layer {
       case LayerEvents.AddText:
         stateService.setEventName(LayerEvents.MoveText);
         addText.buildText(position);
-        stateService.setSelectItem(addText.newText.vectorId, VectorType.Text, SelectState.Select);
+        stateService.setSelectItem(
+          addText.newText.vectorId,
+          VectorType.Text,
+          SelectState.Select
+        );
         addText.clear();
         break;
       case LayerEvents.AddSVG:
@@ -189,7 +197,11 @@ export default class Layer {
       case LayerEvents.AddMagnifier:
         stateService.setEventName(LayerEvents.MoveMagnifier);
         addMagnifier.buildMagnifier(position);
-        stateService.setSelectItem(addMagnifier.newMagnifier.vectorId, VectorType.Magnifier, SelectState.Select);
+        stateService.setSelectItem(
+          addMagnifier.newMagnifier.vectorId,
+          VectorType.Magnifier,
+          SelectState.Select
+        );
         addMagnifier.clear();
         break;
       case VectorEvents.AddLane:
@@ -197,18 +209,34 @@ export default class Layer {
           let road = dataService.getRoad(selectItem.vectorId);
           if (road) {
             let roadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == 'left') {
-              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount + 1, selectItem.dir);
+            if (selectItem.dir == "left") {
+              roadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                roadLanCount + 1,
+                selectItem.dir
+              );
             } else {
-              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount + 1, selectItem.dir);
+              roadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                roadLanCount + 1,
+                selectItem.dir
+              );
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
             let curveRoadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == 'left') {
-              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount + 1, selectItem.dir);
+            if (selectItem.dir == "left") {
+              curveRoadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                curveRoadLanCount + 1,
+                selectItem.dir
+              );
             } else {
-              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount + 1, selectItem.dir);
+              curveRoadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                curveRoadLanCount + 1,
+                selectItem.dir
+              );
             }
           }
           stateService.clearEventName();
@@ -221,18 +249,34 @@ export default class Layer {
           let road = dataService.getRoad(selectItem.vectorId);
           if (road) {
             let roadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == 'left') {
-              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount - 1, selectItem.dir);
+            if (selectItem.dir == "left") {
+              roadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                roadLanCount - 1,
+                selectItem.dir
+              );
             } else {
-              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount - 1, selectItem.dir);
+              roadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                roadLanCount - 1,
+                selectItem.dir
+              );
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
             let curveRoadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == 'left') {
-              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount - 1, selectItem.dir);
+            if (selectItem.dir == "left") {
+              curveRoadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                curveRoadLanCount - 1,
+                selectItem.dir
+              );
             } else {
-              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount - 1, selectItem.dir);
+              curveRoadService.updateForAddSubtractLanesCount(
+                road.vectorId,
+                curveRoadLanCount - 1,
+                selectItem.dir
+              );
             }
           }
           stateService.clearEventName();
@@ -244,12 +288,18 @@ export default class Layer {
         if (focusItem && focusItem.vectorId) {
           if (focusItem.type == VectorType.CurveRoad) {
             const curveRoad = dataService.getCurveRoad(focusItem.vectorId);
-            let index = mathUtil.getIndexForCurvesPoints(position, curveRoad.points);
+            let index = mathUtil.getIndexForCurvesPoints(
+              position,
+              curveRoad.points
+            );
             if (index != -1) {
               curveRoadService.addCPoint(curveRoad, position, index);
             } else {
               const dis1 = mathUtil.getDistance(curveRoad.points[0], position);
-              const dis2 = mathUtil.getDistance(curveRoad.points[curveRoad.points.length - 1], position);
+              const dis2 = mathUtil.getDistance(
+                curveRoad.points[curveRoad.points.length - 1],
+                position
+              );
               if (dis1 > dis2) {
                 index = curveRoad.points.length - 2;
               } else {
@@ -274,12 +324,18 @@ export default class Layer {
             curveLine.setWeight(weight);
           } else if (focusItem.type == VectorType.CurveLine) {
             let curveLine = dataService.getCurveLine(focusItem.vectorId);
-            let index = mathUtil.getIndexForCurvesPoints(position, curveLine.points);
+            let index = mathUtil.getIndexForCurvesPoints(
+              position,
+              curveLine.points
+            );
             if (index != -1) {
               lineService.addCPoint(position, index, focusItem.vectorId);
             } else {
               const dis1 = mathUtil.getDistance(curveLine.points[0], position);
-              const dis2 = mathUtil.getDistance(curveLine.points[curveLine.points.length - 1], position);
+              const dis2 = mathUtil.getDistance(
+                curveLine.points[curveLine.points.length - 1],
+                position
+              );
               if (dis1 > dis2) {
                 index = curveLine.points.length - 2;
               } else {
@@ -370,14 +426,24 @@ export default class Layer {
       y: position.y,
     };
     const eventName = stateService.getEventName();
-    if (!this.dragging && Math.abs(X - this.startX) < minDragDis && Math.abs(Y - this.startY) < minDragDis) {
+    if (
+      !this.dragging &&
+      Math.abs(X - this.startX) < minDragDis &&
+      Math.abs(Y - this.startY) < minDragDis
+    ) {
       return;
     }
     this.dragging = true;
-    if (Math.abs(X - this.startX) > minDragDis || Math.abs(Y - this.startY) > minDragDis) {
+    if (
+      Math.abs(X - this.startX) > minDragDis ||
+      Math.abs(Y - this.startY) > minDragDis
+    ) {
       // 是否拖拽了
       if (eventName != null) {
-        if (eventName == LayerEvents.MoveMagnifier && stateService.getSelectItem().state != 0) {
+        if (
+          eventName == LayerEvents.MoveMagnifier &&
+          stateService.getSelectItem().state != 0
+        ) {
         } else {
           stateService.clearFocusItem();
           this.uiControl.focusVector = null;
@@ -398,15 +464,17 @@ export default class Layer {
         needAutoRedraw = listenLayer.start(position);
         let seleteItem = stateService.getSelectItem();
         if (seleteItem != null) {
-          console.log('选中:' + seleteItem.vectorId);
+          console.log("选中:" + seleteItem.vectorId);
         } else {
         }
         break;
       case LayerEvents.PanBackGround:
         stateService.clearItems();
         let center = {};
-        center.x = coordinate.center.x - (dx * coordinate.defaultZoom) / coordinate.zoom;
-        center.y = coordinate.center.y + (dy * coordinate.defaultZoom) / coordinate.zoom;
+        center.x =
+          coordinate.center.x - (dx * coordinate.defaultZoom) / coordinate.zoom;
+        center.y =
+          coordinate.center.y + (dy * coordinate.defaultZoom) / coordinate.zoom;
         let tempCenter = {};
         mathUtil.clonePoint(tempCenter, coordinate.center);
         mathUtil.clonePoint(coordinate.center, center);
@@ -501,12 +569,12 @@ export default class Layer {
         elementService.setNewRoad(addRoad.startInfo.position, position);
         elementService.showNewRoad();
 
-        addRoad.setNewRoadPoint('end', position);
+        addRoad.setNewRoadPoint("end", position);
         addRoad.canAdd = addRoad.canAddRoadForEnd(position);
         if (!addRoad.canAdd) {
-          elementService.setNewRoadState('error');
+          elementService.setNewRoadState("error");
         } else {
-          elementService.setNewRoadState('normal');
+          elementService.setNewRoadState("normal");
         }
         elementService.showPoint();
         this.showElementLine(position, eventName);
@@ -600,9 +668,16 @@ export default class Layer {
         let road = dataService.getRoad(draggingItem.vectorId);
         let start = dataService.getRoadPoint(road.startId);
         let end = dataService.getRoadPoint(road.endId);
-        if (Object.keys(start.getParent()).length == 1 && Object.keys(end.getParent()).length == 1) {
+        if (
+          Object.keys(start.getParent()).length == 1 &&
+          Object.keys(end.getParent()).length == 1
+        ) {
           //拖拽的路只有一条
-          moveRoad.moveRoad(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
+          moveRoad.moveRoad(
+            draggingItem.vectorId,
+            (dx * coordinate.defaultZoom) / coordinate.zoom,
+            (dy * coordinate.defaultZoom) / coordinate.zoom
+          );
         }
         break;
       case LayerEvents.MoveRoadPoint:
@@ -613,7 +688,10 @@ export default class Layer {
         });
         if (
           listenLayer.modifyPoint &&
-          (listenLayer.modifyPoint.linkedRoadPointId || listenLayer.modifyPoint.linkedRoadId || listenLayer.modifyPoint.linkedRoadPointIdX || listenLayer.modifyPoint.linkedRoadPointIdY)
+          (listenLayer.modifyPoint.linkedRoadPointId ||
+            listenLayer.modifyPoint.linkedRoadId ||
+            listenLayer.modifyPoint.linkedRoadPointIdX ||
+            listenLayer.modifyPoint.linkedRoadPointIdY)
         ) {
           position = {
             x: listenLayer.modifyPoint.x,
@@ -623,7 +701,11 @@ export default class Layer {
           listenLayer.modifyPoint = null;
         }
 
-        let flag = moveRoad.moveingRoadPoint(draggingItem.vectorId, position, listenLayer.modifyPoint);
+        let flag = moveRoad.moveingRoadPoint(
+          draggingItem.vectorId,
+          position,
+          listenLayer.modifyPoint
+        );
         if (!flag) {
           elementService.hideAll();
         } else {
@@ -659,19 +741,23 @@ export default class Layer {
         elementService.setNewRoad(addRoad.startInfo.position, position);
         elementService.showNewRoad();
 
-        addRoad.setNewRoadPoint('end', position);
+        addRoad.setNewRoadPoint("end", position);
         addRoad.canAdd = addRoad.canAddRoadForEnd(position);
         if (!addRoad.canAdd) {
-          elementService.setNewRoadState('error');
+          elementService.setNewRoadState("error");
         } else {
-          elementService.setNewRoadState('normal');
+          elementService.setNewRoadState("normal");
         }
         elementService.showPoint();
         this.showElementLine(position, eventName);
         break;
       case LayerEvents.MoveCurveRoad:
         needAutoRedraw = true;
-        moveRoad.moveCurveRoad(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
+        moveRoad.moveCurveRoad(
+          draggingItem.vectorId,
+          (dx * coordinate.defaultZoom) / coordinate.zoom,
+          (dy * coordinate.defaultZoom) / coordinate.zoom
+        );
         break;
       case LayerEvents.MoveCurveRoadPoint:
         if (!draggingItem || !draggingItem.vectorId) {
@@ -714,13 +800,21 @@ export default class Layer {
         break;
       case LayerEvents.MoveCurveEdge:
         if (listenLayer.modifyPoint) {
-          moveRoad.moveCurveEdge(draggingItem.vectorId, listenLayer.modifyPoint.selectIndex, position);
+          moveRoad.moveCurveEdge(
+            draggingItem.vectorId,
+            listenLayer.modifyPoint.selectIndex,
+            position
+          );
         }
         needAutoRedraw = true;
         break;
       case LayerEvents.MoveLine:
         if (draggingItem != null) {
-          let flag = moveLine.moveLine(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
+          let flag = moveLine.moveLine(
+            draggingItem.vectorId,
+            (dx * coordinate.defaultZoom) / coordinate.zoom,
+            (dy * coordinate.defaultZoom) / coordinate.zoom
+          );
           if (!flag) {
             this.lastX = this.lastX - dx / coordinate.ratio;
             this.lastY = this.lastY - dy / coordinate.ratio;
@@ -736,9 +830,12 @@ export default class Layer {
             exceptLineId: point.parent,
           });
 
-
           // if (listenLayer.modifyPoint) {  //原本是这样的,不知用途,下面修改为了修复拖动点经过放大镜导致NaN或者错位
-          if (listenLayer.modifyPoint && listenLayer.modifyPoint.x && listenLayer.modifyPoint.y) {
+          if (
+            listenLayer.modifyPoint &&
+            listenLayer.modifyPoint.x &&
+            listenLayer.modifyPoint.y
+          ) {
             position = {
               x: listenLayer.modifyPoint.x,
               y: listenLayer.modifyPoint.y,
@@ -776,16 +873,33 @@ export default class Layer {
         break;
       case LayerEvents.MoveCurveLine:
         if (draggingItem != null) {
-          moveLine.moveCurveLine(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
+          moveLine.moveCurveLine(
+            draggingItem.vectorId,
+            (dx * coordinate.defaultZoom) / coordinate.zoom,
+            (dy * coordinate.defaultZoom) / coordinate.zoom
+          );
           needAutoRedraw = true;
         }
         break;
       case LayerEvents.MoveCircle:
         if (draggingItem != null) {
           if (draggingItem.state == -1) {
-            moveCircle.moveFull(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
-          } else if (draggingItem.state == 0 || draggingItem.state == 1 || draggingItem.state == 2 || draggingItem.state == 3) {
-            moveCircle.movePoint(position, draggingItem.vectorId, draggingItem.state);
+            moveCircle.moveFull(
+              draggingItem.vectorId,
+              (dx * coordinate.defaultZoom) / coordinate.zoom,
+              (dy * coordinate.defaultZoom) / coordinate.zoom
+            );
+          } else if (
+            draggingItem.state == 0 ||
+            draggingItem.state == 1 ||
+            draggingItem.state == 2 ||
+            draggingItem.state == 3
+          ) {
+            moveCircle.movePoint(
+              position,
+              draggingItem.vectorId,
+              draggingItem.state
+            );
           } else {
             debugger;
           }
@@ -804,14 +918,22 @@ export default class Layer {
           if (draggingItem.state == -1) {
             moveSVG.moveFullSVG(position, draggingItem.vectorId);
           } else {
-            moveSVG.movePoint(position, draggingItem.vectorId, draggingItem.state);
+            moveSVG.movePoint(
+              position,
+              draggingItem.vectorId,
+              draggingItem.state
+            );
           }
         }
         break;
       case LayerEvents.MoveMagnifier:
         needAutoRedraw = true;
         if (draggingItem != null) {
-          moveMagnifier.moveFullMagnifier(position, draggingItem.vectorId, draggingItem.state);
+          moveMagnifier.moveFullMagnifier(
+            position,
+            draggingItem.vectorId,
+            draggingItem.state
+          );
         }
         break;
     }
@@ -888,19 +1010,40 @@ export default class Layer {
             exceptRoadIds: point.parent,
           });
 
-          if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty('linkedRoadPointId')) {
-            moveRoad.moveTo(draggingItem.vectorId, listenLayer.modifyPoint.linkedRoadPointId);
-          } else if (listenLayer.modifyPoint && (listenLayer.modifyPoint.linkedRoadPointIdX || listenLayer.modifyPoint.linkedRoadPointIdY)) {
+          if (
+            listenLayer.modifyPoint &&
+            listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")
+          ) {
+            moveRoad.moveTo(
+              draggingItem.vectorId,
+              listenLayer.modifyPoint.linkedRoadPointId
+            );
+          } else if (
+            listenLayer.modifyPoint &&
+            (listenLayer.modifyPoint.linkedRoadPointIdX ||
+              listenLayer.modifyPoint.linkedRoadPointIdY)
+          ) {
             mathUtil.clonePoint(point, listenLayer.modifyPoint);
-          } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty('linkedRoadId')) {
+          } else if (
+            listenLayer.modifyPoint &&
+            listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")
+          ) {
             point = roadPointService.create({
               x: listenLayer.modifyPoint.x,
               y: listenLayer.modifyPoint.y,
             });
-            roadService.splitRoad(listenLayer.modifyPoint.linkedRoadId, point.vectorId, 'start');
+            roadService.splitRoad(
+              listenLayer.modifyPoint.linkedRoadId,
+              point.vectorId,
+              "start"
+            );
             moveRoad.moveTo(draggingItem.vectorId, point.vectorId);
           } else if (moveRoad.splitRoadId != null) {
-            roadService.splitRoad(moveRoad.splitRoadId, draggingItem.vectorId, 'start');
+            roadService.splitRoad(
+              moveRoad.splitRoadId,
+              draggingItem.vectorId,
+              "start"
+            );
           }
           //draggingItem.vectorId所在的墙面与其他墙角相交
           moveRoad.updateForAbsorbRoadPoints();
@@ -1039,8 +1182,11 @@ export default class Layer {
         break;
       case LayerEvents.AddPoint:
         if (
-          (Settings.selectBasePointId != null && (Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode)) ||
-          (Settings.baseLineId != null && Settings.selectLocationMode == Constant.normalLocationMode)
+          (Settings.selectBasePointId != null &&
+            (Settings.selectLocationMode == Constant.angleLocationMode ||
+              Settings.selectLocationMode == Constant.allLocationMode)) ||
+          (Settings.baseLineId != null &&
+            Settings.selectLocationMode == Constant.normalLocationMode)
         ) {
           this.uiControl.showConfirm();
           needAutoRedraw = true;
@@ -1054,7 +1200,7 @@ export default class Layer {
         break;
     }
 
-    this.setEventName('mouseUp');
+    this.setEventName("mouseUp");
     stateService.clearDraggingItem();
     if (needAutoRedraw) {
       this.renderer.autoRedraw();
@@ -1064,9 +1210,11 @@ export default class Layer {
   onWheel(e) {
     e.preventDefault();
     const type = e.type;
-    if (type == 'DOMMouseScroll' || type == 'mousewheel') {
+    if (type == "DOMMouseScroll" || type == "mousewheel") {
       // 当在canvas用滚轮滚动时
-      const delta = e.wheelDelta ? (e.wheelDelta / 120) * 20 : (-(e.detail || 0) / 3) * 20;
+      const delta = e.wheelDelta
+        ? (e.wheelDelta / 120) * 20
+        : (-(e.detail || 0) / 3) * 20;
       const zoom = coordinate.zoom + delta;
       let X = e.offsetX || e.layerX;
       let Y = e.offsetY || e.layerY;
@@ -1103,7 +1251,7 @@ export default class Layer {
   setEventName(eventType) {
     let eventName = stateService.getEventName();
 
-    if (eventType == 'mouseDown') {
+    if (eventType == "mouseDown") {
       if (eventName == null) {
         const selectItem = stateService.getSelectItem();
         if (selectItem == null) {
@@ -1140,7 +1288,7 @@ export default class Layer {
           stateService.setEventName(LayerEvents.MoveSVG);
         }
       }
-    } else if (eventType == 'mouseUp') {
+    } else if (eventType == "mouseUp") {
       if (eventName == LayerEvents.AddingRoad) {
         if (Settings.isMobile) {
           stateService.clearEventName();
@@ -1172,8 +1320,11 @@ export default class Layer {
       } else if (
         (eventName == LayerEvents.AddPoint &&
           Settings.selectBasePointId != null &&
-          (Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode)) ||
-        (eventName == LayerEvents.AddPoint && Settings.baseLineId != null && Settings.selectLocationMode == Constant.normalLocationMode)
+          (Settings.selectLocationMode == Constant.angleLocationMode ||
+            Settings.selectLocationMode == Constant.allLocationMode)) ||
+        (eventName == LayerEvents.AddPoint &&
+          Settings.baseLineId != null &&
+          Settings.selectLocationMode == Constant.normalLocationMode)
       ) {
       } else {
         stateService.clearEventName();
@@ -1190,7 +1341,10 @@ export default class Layer {
 
   stopAddVector() {
     let eventName = stateService.getEventName();
-    if (eventName != LayerEvents.AddingRoad && eventName != LayerEvents.AddingLine) {
+    if (
+      eventName != LayerEvents.AddingRoad &&
+      eventName != LayerEvents.AddingLine
+    ) {
       stateService.clearEventName();
     } else if (eventName == LayerEvents.AddingRoad) {
       stateService.setEventName(LayerEvents.AddRoad);
@@ -1328,23 +1482,57 @@ export default class Layer {
     let otherPoint1 = null;
     let otherPoint2 = null;
     if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedRoadPointIdX) {
-      otherPoint1 = dataService.getRoadPoint(listenLayer.modifyPoint.linkedRoadPointIdX);
-    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurveRoadPointIdX) {
-      otherPoint1 = dataService.getCurveRoadPoint(listenLayer.modifyPoint.linkedCurvePointIdX);
-    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedPointIdX) {
-      otherPoint1 = dataService.getPoint(listenLayer.modifyPoint.linkedPointIdX);
-    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurvePointIdX) {
-      otherPoint1 = dataService.getCurvePoint(listenLayer.modifyPoint.linkedCurvePointIdX);
+      otherPoint1 = dataService.getRoadPoint(
+        listenLayer.modifyPoint.linkedRoadPointIdX
+      );
+    } else if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.linkedCurveRoadPointIdX
+    ) {
+      otherPoint1 = dataService.getCurveRoadPoint(
+        listenLayer.modifyPoint.linkedCurvePointIdX
+      );
+    } else if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.linkedPointIdX
+    ) {
+      otherPoint1 = dataService.getPoint(
+        listenLayer.modifyPoint.linkedPointIdX
+      );
+    } else if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.linkedCurvePointIdX
+    ) {
+      otherPoint1 = dataService.getCurvePoint(
+        listenLayer.modifyPoint.linkedCurvePointIdX
+      );
     }
 
     if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedRoadPointIdY) {
-      otherPoint2 = dataService.getRoadPoint(listenLayer.modifyPoint.linkedRoadPointIdY);
-    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurvePointIdY) {
-      otherPoint2 = dataService.getCurveRoadPoint(listenLayer.modifyPoint.linkedCurvePointIdY);
-    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedPointIdY) {
-      otherPoint2 = dataService.getPoint(listenLayer.modifyPoint.linkedPointIdY);
-    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurvePointIdY) {
-      otherPoint2 = dataService.getCurvePoint(listenLayer.modifyPoint.linkedCurvePointIdY);
+      otherPoint2 = dataService.getRoadPoint(
+        listenLayer.modifyPoint.linkedRoadPointIdY
+      );
+    } else if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.linkedCurvePointIdY
+    ) {
+      otherPoint2 = dataService.getCurveRoadPoint(
+        listenLayer.modifyPoint.linkedCurvePointIdY
+      );
+    } else if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.linkedPointIdY
+    ) {
+      otherPoint2 = dataService.getPoint(
+        listenLayer.modifyPoint.linkedPointIdY
+      );
+    } else if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.linkedCurvePointIdY
+    ) {
+      otherPoint2 = dataService.getCurvePoint(
+        listenLayer.modifyPoint.linkedCurvePointIdY
+      );
     }
 
     let otherPoint = {};
@@ -1354,7 +1542,7 @@ export default class Layer {
     }
     if (otherPoint2) {
       otherPoint.y = otherPoint2.y;
-      if (!otherPoint.hasOwnProperty('x')) {
+      if (!otherPoint.hasOwnProperty("x")) {
         otherPoint.x = otherPoint2.x;
       }
     }
@@ -1368,6 +1556,7 @@ export default class Layer {
       console.log("键盘(foucus有效):" + e.code);
       //添加固定点
       if (e.code == "KeyQ") {
+        uiService.setSelectPointCategory(VectorCategory.Point.FixPoint);
         stateService.setEventName(LayerEvents.AddPoint);
       }
       //一键测量

+ 39 - 8
src/graphic/ListenLayer.js

@@ -134,11 +134,19 @@ export default class ListenLayer {
           }
         }
       } else {
-        if (Math.abs(position.x - curvePoint.x) < Constant.minAdsorbPix) {
+        if (
+          (Math.abs(position.x - curvePoint.x) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedCurvePointIdX = curvePointId;
           seqInfo.x = curvePoint.x;
         }
-        if (Math.abs(position.y - curvePoint.y) < Constant.minAdsorbPix) {
+        if (
+          (Math.abs(position.y - curvePoint.y) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedPointIdY = curvePointId;
           seqInfo.y = curvePoint.y;
         }
@@ -250,11 +258,19 @@ export default class ListenLayer {
           }
         }
       } else {
-        if (Math.abs(position.x - point.x) < Constant.minAdsorbPix) {
+        if (
+          (Math.abs(position.x - point.x) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedPointIdX = pointId;
           seqInfo.x = point.x;
         }
-        if (Math.abs(position.y - point.y) < Constant.minAdsorbPix) {
+        if (
+          (Math.abs(position.y - point.y) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedPointIdY = pointId;
           seqInfo.y = point.y;
         }
@@ -439,10 +455,18 @@ export default class ListenLayer {
           }
         }
       } else {
-        if (Math.abs(position.x - roadPoint.x) < Constant.minAdsorbPix) {
+        if (
+          (Math.abs(position.x - roadPoint.x) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedRoadPointIdX = roadPointId;
           seqInfo.x = roadPoint.x;
-        } else if (Math.abs(position.y - roadPoint.y) < Constant.minAdsorbPix) {
+        } else if (
+          (Math.abs(position.y - roadPoint.y) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedRoadPointIdY = roadPointId;
           seqInfo.y = roadPoint.y;
         }
@@ -514,11 +538,17 @@ export default class ListenLayer {
           }
         }
       } else {
-        if (Math.abs(position.x - curveRoadPoint.x) < Constant.minAdsorbPix) {
+        if (
+          (Math.abs(position.x - curveRoadPoint.x) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
+        ) {
           seqInfo.linkedCurveRoadPointIdX = curveRoadPointId;
           seqInfo.x = curveRoadPoint.x;
         } else if (
-          Math.abs(position.y - curveRoadPoint.y) < Constant.minAdsorbPix
+          (Math.abs(position.y - curveRoadPoint.y) * coordinate.zoom) /
+            coordinate.defaultZoom <
+          Constant.minAdsorbPix
         ) {
           seqInfo.linkedCurveRoadPointIdY = curveRoadPointId;
           seqInfo.y = curveRoadPoint.y;
@@ -1337,6 +1367,7 @@ export default class ListenLayer {
     return flag;
   }
 
+  //调整到与像素的长度一致
   getDistance(start, end) {
     return (
       (mathUtil.getDistance(start, end) * coordinate.zoom) /

+ 228 - 76
src/graphic/Service/CurveRoadService.js

@@ -25,7 +25,7 @@ export default class CurveRoadService extends RoadService {
     startPoint.setIndex(0);
     let endPoint = dataService.getCurveRoadPoint(endId);
     endPoint.setPointParent(curveRoad.vectorId);
-    endPoint.setIndex(2);
+    endPoint.setIndex(1);
 
     let edgePoints;
     if (curveRoad.way == Constant.oneWay) {
@@ -83,7 +83,7 @@ export default class CurveRoadService extends RoadService {
     let parallelLines = mathUtil.getParallelLineForDistance(line, offsetDis);
     const join = mathUtil.getJoinLinePoint(midPoint, parallelLines.line1);
 
-    this.addCPoint(curveRoad, join, 0);
+    this.addCPoint(curveRoad, join, 1);
     this.setLanes(curveRoad.vectorId);
     return curveRoad;
   }
@@ -121,7 +121,7 @@ export default class CurveRoadService extends RoadService {
     newStartPoint.setIndex(0);
 
     newEndPoint.setPointParent(newCurveRoad.vectorId);
-    newEndPoint.setIndex(endPoint.getIndex());
+    newEndPoint.setIndex(1); //addCPoint执行后会自动增加
 
     newCurveRoad.setWay(curveRoad.way);
     newCurveRoad.singleRoadWidth = curveRoad.singleRoadWidth;
@@ -175,13 +175,35 @@ export default class CurveRoadService extends RoadService {
       this.addCPoint(
         newCurveRoad,
         uiService.getNewPositionForPop(curveRoad.points[i]),
-        curveRoad.points[i].getIndex() - 1
+        curveRoad.points[i].getIndex()
       );
     }
 
+    const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
+    for (let i = 0; i < leftEdge.points.length; ++i) {
+      leftEdge.points[i] = uiService.getNewPositionForPop(
+        leftCurveEdge.points[i]
+      );
+    }
+    leftEdge.start = uiService.getNewPositionForPop(leftCurveEdge.start);
+    leftEdge.end = uiService.getNewPositionForPop(leftCurveEdge.end);
+
+    const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
+    for (let i = 0; i < rightEdge.points.length; ++i) {
+      rightEdge.points[i] = uiService.getNewPositionForPop(
+        rightCurveEdge.points[i]
+      );
+    }
+    rightEdge.start = uiService.getNewPositionForPop(rightCurveEdge.start);
+    rightEdge.end = uiService.getNewPositionForPop(rightCurveEdge.end);
+
+    curveEdgeService.setCurves(leftEdge);
+    curveEdgeService.setCurves(rightEdge);
     newCurveRoad.singleRoadDrivewayCount = curveRoad.singleRoadDrivewayCount;
     newCurveRoad.leftDrivewayCount = curveRoad.leftDrivewayCount;
     newCurveRoad.rightDrivewayCount = curveRoad.rightDrivewayCount;
+    newCurveRoad.leftWidth = curveRoad.leftWidth;
+    newCurveRoad.rightWidth = curveRoad.rightWidth;
     this.setLanes(newCurveRoad.vectorId);
     return newCurveRoad.vectorId;
   }
@@ -190,123 +212,245 @@ export default class CurveRoadService extends RoadService {
   //完全不处理车道,都放在setLanes上处理
   addCPoint(curveRoad, position, startIndex) {
     let point = curveRoadPointService.create(position);
-    curveRoad.points.splice(startIndex + 1, 0, point);
+    curveRoad.points.splice(startIndex, 0, point);
     point.setPointParent(curveRoad.vectorId, startIndex);
-    point.setIndex(startIndex + 1);
-    for (let i = startIndex + 2; i < curveRoad.points.length; ++i) {
-      curveRoad.points[i].setIndex(i);
+    point.setIndex(startIndex);
+    for (let i = startIndex + 1; i < curveRoad.points.length; ++i) {
+      let index = curveRoad.points[i].getIndex();
+      curveRoad.points[i].setIndex(index + 1);
     }
 
     let leftCount = curveRoad.leftDrivewayCount;
     let rightCount = curveRoad.rightDrivewayCount;
+    let leftWidth = curveRoad.leftWidth;
+    let rightWidth = curveRoad.rightWidth;
     let leftJoin = null;
     let rightJoin = null;
     const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
     const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
 
-    if (curveRoad.points[startIndex + 2]) {
-      let line1 = mathUtil.createLine1(
-        curveRoad.points[startIndex],
-        curveRoad.points[startIndex + 1]
-      );
-      let line2 = mathUtil.createLine1(
-        curveRoad.points[startIndex + 1],
-        curveRoad.points[startIndex + 2]
-      );
+    if (startIndex == 0) {
+      let line = mathUtil.createLine1(curveRoad.points[0], curveRoad.points[1]);
+      let leftLine = mathUtil.createLine3(line, leftCurveEdge.points[0]);
+      let rightLine = mathUtil.createLine3(line, rightCurveEdge.points[0]);
+      let leftJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], leftLine);
+      let rightJoin = mathUtil.getJoinLinePoint(curveRoad.points[0], rightLine);
 
-      const leftLine = mathUtil.createLine1(
-        leftCurveEdge.points[startIndex],
-        leftCurveEdge.points[startIndex + 1]
-      );
-      let leftLine1 = mathUtil.createLine3(
-        line1,
-        leftCurveEdge.points[startIndex]
-      );
-      let leftLine2 = mathUtil.createLine3(
-        line2,
-        leftCurveEdge.points[startIndex + 1]
-      );
+      leftCurveEdge.start = JSON.parse(JSON.stringify(leftJoin));
+      //mathUtil.clonePoint(leftCurveEdge.start, leftJoin);
+      leftCurveEdge.points.splice(startIndex, 0, leftJoin);
+      curveEdgeService.setCurves(leftCurveEdge);
 
-      const rightLine = mathUtil.createLine1(
-        rightCurveEdge.points[startIndex],
-        rightCurveEdge.points[startIndex + 1]
+      rightCurveEdge.start = JSON.parse(JSON.stringify(rightJoin));
+      //mathUtil.clonePoint(rightCurveEdge.start, rightJoin);
+      rightCurveEdge.points.splice(startIndex, 0, rightJoin);
+      curveEdgeService.setCurves(rightCurveEdge);
+      curveRoad.startId = point.vectorId;
+    } else if (startIndex == curveRoad.points.length - 1) {
+      let line = mathUtil.createLine1(
+        curveRoad.points[startIndex],
+        curveRoad.points[startIndex - 1]
+      );
+      let leftLine = mathUtil.createLine3(
+        line,
+        leftCurveEdge.points[startIndex - 1]
       );
-      let rightLine1 = mathUtil.createLine3(
-        line1,
-        rightCurveEdge.points[startIndex]
+      let rightLine = mathUtil.createLine3(
+        line,
+        rightCurveEdge.points[startIndex - 1]
       );
-      let rightLine2 = mathUtil.createLine3(
-        line2,
-        rightCurveEdge.points[startIndex + 1]
+      let leftJoin = mathUtil.getJoinLinePoint(
+        curveRoad.points[startIndex],
+        leftLine
       );
-
-      const line = mathUtil.createLine1(
+      let rightJoin = mathUtil.getJoinLinePoint(
         curveRoad.points[startIndex],
-        curveRoad.points[startIndex + 2]
+        rightLine
       );
 
+      leftCurveEdge.end = JSON.parse(JSON.stringify(leftJoin));
+      //mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
+      leftCurveEdge.points.splice(startIndex, 0, leftJoin);
+      curveEdgeService.setCurves(leftCurveEdge);
+
+      rightCurveEdge.end = JSON.parse(JSON.stringify(rightJoin));
+      //mathUtil.clonePoint(rightCurveEdge.end, rightJoin);
+      rightCurveEdge.points.splice(startIndex, 0, rightJoin);
+      curveEdgeService.setCurves(rightCurveEdge);
+      curveRoad.endId = point.vectorId;
+    } else {
       if (
         mathUtil.Angle(
-          curveRoad.points[startIndex + 1],
           curveRoad.points[startIndex],
-          curveRoad.points[startIndex + 2]
+          curveRoad.points[startIndex - 1],
+          curveRoad.points[startIndex + 1]
         ) > Constant.maxAngle
       ) {
+        let line = mathUtil.createLine1(
+          curveRoad.points[startIndex - 1],
+          curveRoad.points[startIndex + 1]
+        );
         const join = mathUtil.getJoinLinePoint(position, line);
         let dx = position.x - join.x;
         let dy = position.y - join.y;
 
+        let leftLine = mathUtil.createLine1(
+          leftCurveEdge.points[startIndex - 1],
+          leftCurveEdge.points[startIndex]
+        );
         leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
         leftJoin.x += dx;
         leftJoin.y += dy;
-        leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+        leftCurveEdge.points.splice(startIndex, 0, leftJoin);
         curveEdgeService.setCurves(leftCurveEdge);
 
+        let rightLine = mathUtil.createLine1(
+          rightCurveEdge.points[startIndex - 1],
+          rightCurveEdge.points[startIndex]
+        );
         rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
         rightJoin.x += dx;
         rightJoin.y += dy;
-        rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+        rightCurveEdge.points.splice(startIndex, 0, rightJoin);
         curveEdgeService.setCurves(rightCurveEdge);
       } else {
+        let line1 = mathUtil.createLine1(
+          curveRoad.points[startIndex - 1],
+          curveRoad.points[startIndex]
+        );
+        let line2 = mathUtil.createLine1(
+          curveRoad.points[startIndex],
+          curveRoad.points[startIndex + 1]
+        );
+        let leftLine1 = mathUtil.createLine3(
+          line1,
+          leftCurveEdge.points[startIndex - 1]
+        );
+        let leftLine2 = mathUtil.createLine3(
+          line2,
+          leftCurveEdge.points[startIndex]
+        );
         leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
-        leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+        leftCurveEdge.points.splice(startIndex, 0, leftJoin);
         curveEdgeService.setCurves(leftCurveEdge);
 
+        let rightLine1 = mathUtil.createLine3(
+          line1,
+          rightCurveEdge.points[startIndex - 1]
+        );
+        let rightLine2 = mathUtil.createLine3(
+          line2,
+          rightCurveEdge.points[startIndex]
+        );
         rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
-        rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+        rightCurveEdge.points.splice(startIndex, 0, rightJoin);
         curveEdgeService.setCurves(rightCurveEdge);
       }
-    } else {
-      curveRoad.endId = point.vectorId;
-      let line = mathUtil.createLine1(
-        curveRoad.points[startIndex],
-        curveRoad.points[startIndex + 1]
-      );
-      let leftLine = mathUtil.createLine3(
-        line,
-        leftCurveEdge.points[startIndex]
-      );
-      let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
-      leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
-      leftCurveEdge.points[startIndex] = JSON.parse(
-        JSON.stringify(leftCurveEdge.end)
-      );
-      mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
-      curveEdgeService.setCurves(leftCurveEdge);
-
-      let rightLine = mathUtil.createLine3(
-        line,
-        rightCurveEdge.points[startIndex]
-      );
-      let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
-      rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
-      rightCurveEdge.points[startIndex] = JSON.parse(
-        JSON.stringify(rightCurveEdge.end)
-      );
-      mathUtil.clonePoint(rightCurveEdge.end, rightJoin);
-      curveEdgeService.setCurves(rightCurveEdge);
     }
 
+    // if (curveRoad.points[startIndex + 2]) {
+    //   let line1 = mathUtil.createLine1(
+    //     curveRoad.points[startIndex],
+    //     curveRoad.points[startIndex + 1]
+    //   );
+    //   let line2 = mathUtil.createLine1(
+    //     curveRoad.points[startIndex + 1],
+    //     curveRoad.points[startIndex + 2]
+    //   );
+
+    //   const leftLine = mathUtil.createLine1(
+    //     leftCurveEdge.points[startIndex],
+    //     leftCurveEdge.points[startIndex + 1]
+    //   );
+    //   let leftLine1 = mathUtil.createLine3(
+    //     line1,
+    //     leftCurveEdge.points[startIndex]
+    //   );
+    //   let leftLine2 = mathUtil.createLine3(
+    //     line2,
+    //     leftCurveEdge.points[startIndex + 1]
+    //   );
+
+    //   const rightLine = mathUtil.createLine1(
+    //     rightCurveEdge.points[startIndex],
+    //     rightCurveEdge.points[startIndex + 1]
+    //   );
+    //   let rightLine1 = mathUtil.createLine3(
+    //     line1,
+    //     rightCurveEdge.points[startIndex]
+    //   );
+    //   let rightLine2 = mathUtil.createLine3(
+    //     line2,
+    //     rightCurveEdge.points[startIndex + 1]
+    //   );
+
+    //   const line = mathUtil.createLine1(
+    //     curveRoad.points[startIndex],
+    //     curveRoad.points[startIndex + 2]
+    //   );
+
+    //   if (
+    //     mathUtil.Angle(
+    //       curveRoad.points[startIndex + 1],
+    //       curveRoad.points[startIndex],
+    //       curveRoad.points[startIndex + 2]
+    //     ) > Constant.maxAngle
+    //   ) {
+    //     const join = mathUtil.getJoinLinePoint(position, line);
+    //     let dx = position.x - join.x;
+    //     let dy = position.y - join.y;
+
+    //     leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
+    //     leftJoin.x += dx;
+    //     leftJoin.y += dy;
+    //     leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+    //     curveEdgeService.setCurves(leftCurveEdge);
+
+    //     rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
+    //     rightJoin.x += dx;
+    //     rightJoin.y += dy;
+    //     rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+    //     curveEdgeService.setCurves(rightCurveEdge);
+    //   } else {
+    //     leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
+    //     leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+    //     curveEdgeService.setCurves(leftCurveEdge);
+
+    //     rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
+    //     rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+    //     curveEdgeService.setCurves(rightCurveEdge);
+    //   }
+    // } else {
+    //   curveRoad.endId = point.vectorId;
+    //   let line = mathUtil.createLine1(
+    //     curveRoad.points[startIndex],
+    //     curveRoad.points[startIndex + 1]
+    //   );
+    //   let leftLine = mathUtil.createLine3(
+    //     line,
+    //     leftCurveEdge.points[startIndex]
+    //   );
+    //   let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
+    //   leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+    //   leftCurveEdge.points[startIndex] = JSON.parse(
+    //     JSON.stringify(leftCurveEdge.end)
+    //   );
+    //   mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
+    //   curveEdgeService.setCurves(leftCurveEdge);
+
+    //   let rightLine = mathUtil.createLine3(
+    //     line,
+    //     rightCurveEdge.points[startIndex]
+    //   );
+    //   let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
+    //   rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+    //   rightCurveEdge.points[startIndex] = JSON.parse(
+    //     JSON.stringify(rightCurveEdge.end)
+    //   );
+    //   mathUtil.clonePoint(rightCurveEdge.end, rightJoin);
+    //   curveEdgeService.setCurves(rightCurveEdge);
+    // }
+
     this.setCurves(curveRoad);
   }
 
@@ -744,6 +888,14 @@ export default class CurveRoadService extends RoadService {
         }
       }
     }
+    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);

+ 17 - 3
src/graphic/Service/LineService.js

@@ -176,6 +176,11 @@ export default class LineService {
     newPoint.setIndex(index);
     newPoint.setPointParent(vectorId);
     curveLine.points.splice(index + 1, 0, newPoint);
+    for (let i = index + 1; i < curveLine.points.length; ++i) {
+      curveLine.points[i].setIndex(i);
+    }
+    curveLine.startId = curveLine.points[0].vectorId;
+    curveLine.endId = curveLine.points[curveLine.points.length - 1].vectorId;
     curveLine.curves = mathUtil.getCurvesByPoints(curveLine.points);
   }
 
@@ -194,14 +199,23 @@ export default class LineService {
     if (curveLine.style) {
       newCurveLine.setStyle(curveLine.style);
     }
-    mathUtil.clonePoint(newCurveLine.points[1], curveLine.points[1]);
+
+    mathUtil.clonePoint(
+      newCurveLine.points[1],
+      uiService.getNewPositionForPop(curveLine.points[1])
+    );
+    newCurveLine.points[1].setIndex(curveLine.points[1].getIndex());
+
     for (let i = 2; i < curveLine.points.length - 1; ++i) {
       let newPoint = uiService.getNewPositionForPop(curveLine.points[i]);
       newPoint = curvePointService.create(newPoint);
       newPoint.setPointParent(vectorId);
-      newPoint.setIndex(i);
-      newCurveLine.points.splice(i + 1, 0, newPoint);
+      newPoint.setIndex(curveLine.points[i].getIndex());
+      newCurveLine.points.splice(i, 0, newPoint);
     }
+    newCurveLine.points[newCurveLine.points.length - 1].setIndex(
+      curveLine.points[curveLine.points.length - 1].getIndex()
+    );
     newCurveLine.curves = mathUtil.getCurvesByPoints(newCurveLine.points);
     return newCurveLine;
   }

+ 16 - 3
src/graphic/Service/RoadService.js

@@ -9,6 +9,7 @@ import Constant from "../Constant";
 import { crossPointService } from "./CrossPointService.js";
 import { lineService } from "./LineService.js";
 import { uiService } from "./UIService.js";
+import VectorStyle from "../enum/VectorStyle.js";
 
 export default class RoadService {
   constructor() {}
@@ -1494,14 +1495,26 @@ export default class RoadService {
     lineService.create(rightEdge.start, rightEdge.end);
     if (road.way == Constant.oneWay) {
       for (let i = 0; i < road.singleLanes.length; ++i) {
-        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) {
-        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) {
-        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,

+ 1 - 1
src/graphic/Util/MathUtil.js

@@ -1589,7 +1589,7 @@ export default class MathUtil {
         minDisToPoint >
         mathUtil.getDistance(position, points[points.length - 1])
       ) {
-        return points.length - 1;
+        return points.length;
       } else {
         return minPointIndex;
       }

+ 1 - 0
src/graphic/enum/VectorCategory.js

@@ -7,6 +7,7 @@ const VectorCategory = {
 
     MeasureLine: "MeasureLine",
     FreeMeasureLine: "FreeMeasureLine",
+
     GuideLine: "GuideLine",
     PositionLine: "PositionLine", //定位线。基准点与待测点相连的线,或者与待测基准点相连的线
     GuidePositionLine: "GuidePositionLine", //定位辅助线