xushiting 2 jaren geleden
bovenliggende
commit
50993f3a90

+ 9 - 0
src/graphic/Coordinate.js

@@ -88,6 +88,15 @@ export default class Coordinate {
       this.height = canvas.height;
     }
     this.setCenter(canvas);
+    console.log(
+      "updateForCanvas" +
+        canvas.offsetWidth +
+        "," +
+        canvas.offsetHeight +
+        "," +
+        this.ratio +
+        JSON.stringify(this.center)
+    );
   }
 
   updateZoom(screenPosition, zoom) {

+ 56 - 14
src/graphic/History/Change.js

@@ -61,9 +61,9 @@ export default class Change {
     this.compareRoadPoints();
     this.compareRoadEdges();
     this.compareRoads();
-    // this.compareCurveRoadPoints();
-    // this.compareCurveRoadEdges();
-    // this.compareCurveRoads();
+    this.compareCurveRoadPoints();
+    this.compareCurveRoadEdges();
+    this.compareCurveRoads();
     this.compareCrossPoints();
     if (
       this.currentData.points.length == 0 &&
@@ -74,9 +74,9 @@ export default class Change {
       this.currentData.roadPoints.length == 0 &&
       this.currentData.roadEdges.length == 0 &&
       this.currentData.roads.length == 0 &&
-      // this.currentData.curveRoadPoints.length == 0 &&
-      // this.currentData.curveRoadEdges.length == 0 &&
-      // this.currentData.curveRoads.length == 0 &&
+      this.currentData.curveRoadPoints.length == 0 &&
+      this.currentData.curveRoadEdges.length == 0 &&
+      this.currentData.curveRoads.length == 0 &&
       this.currentData.crossPoints.length == 0
     ) {
       this.saveCurrentInfo();
@@ -498,12 +498,12 @@ export default class Change {
       if (!lastCurveRoadPoint) {
         const item = {
           handle: HistoryEvents.AddCurveRoadPoint,
-          curveRoadPoint: historyUtil.getDataForRoadPoint(curveRoadPoint),
+          curveRoadPoint: historyUtil.getDataForCurveRoadPoint(curveRoadPoint),
         };
         this.currentData.curveRoadPoints.push(item);
       } else {
         if (
-          !historyUtil.isDifferentForRoadPoints(
+          !historyUtil.isDifferentForCurveRoadPoints(
             curveRoadPoint,
             lastCurveRoadPoint
           )
@@ -512,9 +512,11 @@ export default class Change {
           continue;
         } else {
           const item = {
-            handle: HistoryEvents.ModifyRoadPoint,
-            preRoadPoint: historyUtil.getDataForRoadPoint(lastCurveRoadPoint),
-            curRoadPoint: historyUtil.getDataForRoadPoint(curveRoadPoint),
+            handle: HistoryEvents.ModifyCurveRoadPoint,
+            preCurveRoadPoint:
+              historyUtil.getDataForCurveRoadPoint(lastCurveRoadPoint),
+            curCurveRoadPoint:
+              historyUtil.getDataForCurveRoadPoint(curveRoadPoint),
           };
           this.currentData.curveRoadPoints.push(item);
         }
@@ -524,8 +526,8 @@ export default class Change {
 
     for (const key in this.lastData.curveRoadPoints) {
       const item = {
-        handle: HistoryEvents.DeleteRoadPoint,
-        curveRoadPoint: historyUtil.getDataForRoadPoint(
+        handle: HistoryEvents.DeleteCurveRoadPoint,
+        curveRoadPoint: historyUtil.getDataForCurveRoadPoint(
           this.lastData.curveRoadPoints[key]
         ),
       };
@@ -533,7 +535,47 @@ export default class Change {
     }
   }
 
-  compareCurveRoads() {}
+  compareCurveRoads() {
+    this.currentData.curveRoads = [];
+    const curveRoads = dataService.getCurveRoads();
+
+    for (const key in curveRoads) {
+      const curveRoad = curveRoads[key];
+      const lastCurveRoad = this.lastData.curveRoads[key];
+
+      // 不存在意味着增加
+      if (!lastCurveRoad) {
+        const item = {
+          handle: HistoryEvents.AddCurveRoad,
+          curveRoad: historyUtil.getDataForCurveRoad(curveRoad),
+        };
+        this.currentData.curveRoads.push(item);
+      } else {
+        if (!historyUtil.isDifferentForCurveRoads(curveRoad, lastCurveRoad)) {
+          delete this.lastData.curveRoads[key];
+          continue;
+        } else {
+          const item = {
+            handle: HistoryEvents.ModifyCurveRoad,
+            preCurveRoad: historyUtil.getDataForCurveRoad(lastCurveRoad),
+            curCurveRoad: historyUtil.getDataForCurveRoad(curveRoad),
+          };
+          this.currentData.curveRoads.push(item);
+        }
+      }
+      delete this.lastData.curveRoads[key];
+    }
+
+    for (const key in this.lastData.curveRoads) {
+      const item = {
+        handle: HistoryEvents.DeleteCurveRoad,
+        curveRoad: historyUtil.getDataForCurveRoad(
+          this.lastData.curveRoads[key]
+        ),
+      };
+      this.currentData.curveRoads.push(item);
+    }
+  }
 
   compareCurveRoadEdges() {
     this.currentData.curveRoadEdges = [];

+ 165 - 0
src/graphic/History/History.js

@@ -14,6 +14,9 @@ import { pointService } from "../Service/PointService";
 import { edgeService } from "../Service/EdgeService";
 import { magnifierService } from "../Service/MagnifierService";
 import { crossPointService } from "../Service/CrossPointService";
+import { curveRoadPointService } from "../Service/CurveRoadPointService";
+import { curveEdgeService } from "../Service/CurveEdgeService";
+import { curveRoadService } from "../Service/CurveRoadService";
 
 export default class History {
   constructor(layer) {
@@ -104,6 +107,9 @@ export default class History {
       this.goPreForRoadPoints(item.roadPoints);
       this.goPreForRoadEdges(item.roadEdges);
       this.goPreForRoads(item.roads);
+      this.goPreForCurveRoadPoints(item.curveRoadPoints);
+      this.goPreForCurveRoadEdges(item.curveRoadEdges);
+      this.goPreForCurveRoads(item.curveRoads);
       this.goPreForCrossPoints(item.crossPoints);
       historyService.undoHistoryRecord();
       change.saveCurrentInfo();
@@ -290,6 +296,85 @@ export default class History {
     }
   }
 
+  goPreForCurveRoadPoints(itemForCurveRoadPoints) {
+    for (let i = 0; i < itemForCurveRoadPoints.length; ++i) {
+      const item = itemForCurveRoadPoints[i];
+      if (item.handle == HistoryEvents.AddCurveRoadPoint) {
+        dataService.deleteCurveRoadPoint(item.curveRoadPoint.id);
+      } else if (item.handle == HistoryEvents.DeleteCurveRoadPoint) {
+        let newCurveRoadPoint = curveRoadPointService.create(
+          item.curveRoadPoint.position,
+          item.curveRoadPoint.id
+        );
+        historyUtil.assignCurveRoadPointFromCurveRoadPoint(
+          newCurveRoadPoint,
+          item.curveRoadPoint
+        );
+      } else if (item.handle == HistoryEvents.ModifyCurveRoadPoint) {
+        const preCurveRoadPoint = item.preCurveRoadPoint;
+        let currentCurveRoadPoint = dataService.getCurveRoadPoint(
+          item.curCurveRoadPoint.id
+        );
+        historyUtil.assignCurveRoadPointFromCurveRoadPoint(
+          currentCurveRoadPoint,
+          preCurveRoadPoint
+        );
+      }
+    }
+  }
+
+  goPreForCurveRoadEdges(itemForCurveRoadEdges) {
+    for (let i = 0; i < itemForCurveRoadEdges.length; ++i) {
+      const item = itemForCurveRoadEdges[i];
+      if (item.handle == HistoryEvents.AddCurveRoadEdge) {
+        dataService.deleteCurveRoadEdge(item.curveRoadEdge.id);
+      } else if (item.handle == HistoryEvents.DeleteCurveRoadEdge) {
+        let newCurveRoadEdge = curveEdgeService.create(
+          item.curveRoadEdge.start,
+          item.curveRoadEdge.end,
+          item.curveRoadEdge.id,
+          item.curveRoadEdge.parent
+        );
+        historyUtil.assignCurveRoadEdgeFromCurveRoadEdge(
+          newCurveRoadEdge,
+          item.curveRoadEdge
+        );
+      } else if (item.handle == HistoryEvents.ModifyCurveRoadEdge) {
+        const preCurveRoadEdge = item.preCurveRoadEdge;
+        let currentCurveRoadEdge = dataService.getCurveRoadEdge(
+          item.curCurveRoadEdge.id
+        );
+        historyUtil.assignCurveRoadEdgeFromCurveRoadEdge(
+          currentCurveRoadEdge,
+          preCurveRoadEdge
+        );
+      }
+    }
+  }
+
+  goPreForCurveRoads(itemForCurveRoads) {
+    for (let i = 0; i < itemForCurveRoads.length; ++i) {
+      const item = itemForCurveRoads[i];
+      if (item.handle == HistoryEvents.AddCurveRoad) {
+        dataService.deleteCurveRoad(item.curveRoad.id);
+      } else if (item.handle == HistoryEvents.DeleteCurveRoad) {
+        let newCurveRoad = curveRoadService.createOnlyCurveRoad(
+          item.curveRoad.startId,
+          item.curveRoad.endId,
+          item.curveRoad.id
+        );
+        historyUtil.assignCurveRoadFromCurveRoad(newCurveRoad, item.curveRoad);
+      } else if (item.handle == HistoryEvents.ModifyCurveRoad) {
+        const preCurveRoad = item.preCurveRoad;
+        let currentCurveRoad = dataService.getCurveRoad(item.curCurveRoad.id);
+        historyUtil.assignCurveRoadFromCurveRoad(
+          currentCurveRoad,
+          preCurveRoad
+        );
+      }
+    }
+  }
+
   goPreForCrossPoints(itemForCrossPoints) {
     for (let i = 0; i < itemForCrossPoints.length; ++i) {
       const item = itemForCrossPoints[i];
@@ -494,6 +579,83 @@ export default class History {
     }
   }
 
+  goNextForCurveRoadPoints(itemForCurveRoadPoints) {
+    for (let i = 0; i < itemForCurveRoadPoints.length; ++i) {
+      const item = itemForCurveRoadPoints[i];
+      if (item.handle == HistoryEvents.AddCurveRoadPoint) {
+        let vCurveRoadPoint = curveRoadPointService.create(
+          item.curveRoadPoint.position,
+          item.curveRoadPoint.id
+        );
+        historyUtil.assignCurveRoadPointFromCurveRoadPoint(
+          vCurveRoadPoint,
+          item.curveRoadPoint
+        );
+      } else if (item.handle == HistoryEvents.DeleteCurveRoadPoint) {
+        dataService.deleteCurveRoadPoint(item.curveRoadPoint.id);
+      } else if (item.handle == HistoryEvents.ModifyCurveRoadPoint) {
+        const currentCurveRoadPoint = item.curCurveRoadPoint;
+        let preCurveRoadPoint = dataService.getCurveRoadPoint(
+          item.curCurveRoadPoint.id
+        );
+        historyUtil.assignCurveRoadPointFromCurveRoadPoint(
+          preCurveRoadPoint,
+          currentCurveRoadPoint
+        );
+      }
+    }
+  }
+
+  goNextForCurveRoadEdges(itemForCurveRoadEdges) {
+    for (let i = 0; i < itemForCurveRoadEdges.length; ++i) {
+      const item = itemForCurveRoadEdges[i];
+      if (item.handle == HistoryEvents.AddCurveRoadEdge) {
+        let vCurveRoadEdge = curveEdgeService.create(
+          item.curveRoadEdge.start,
+          item.curveRoadEdge.end,
+          item.curveRoadEdge.id,
+          item.curveRoadEdge.parent
+        );
+        historyUtil.assignCurveRoadEdgeFromCurveRoadEdge(
+          vCurveRoadEdge,
+          item.curveRoadEdge
+        );
+      } else if (item.handle == HistoryEvents.DeleteCurveRoadEdge) {
+        dataService.deleteCurveRoadEdge(item.curveRoadEdge.id);
+      } else if (item.handle == HistoryEvents.ModifyCurveRoadEdge) {
+        const currentRoadEdge = item.curRoadEdge;
+        let preRoadEdge = dataService.getCurveRoadEdge(item.curRoadEdge.id);
+        historyUtil.assignCurveRoadEdgeFromCurveRoadEdge(
+          preRoadEdge,
+          currentRoadEdge
+        );
+      }
+    }
+  }
+
+  goNextForCurveRoads(itemForCurveRoads) {
+    for (let i = 0; i < itemForCurveRoads.length; ++i) {
+      const item = itemForCurveRoads[i];
+      if (item.handle == HistoryEvents.AddCurveRoad) {
+        let vCurveRoad = curveRoadService.createOnlyCurveRoad(
+          item.curveRoad.startId,
+          item.curveRoad.endId,
+          item.curveRoad.id
+        );
+        historyUtil.assignCurveRoadFromCurveRoad(vCurveRoad, item.curveRoad);
+      } else if (item.handle == HistoryEvents.DeleteCurveRoad) {
+        dataService.deleteCurveRoad(item.curveRoad.id);
+      } else if (item.handle == HistoryEvents.ModifyCurveRoad) {
+        const currentCurveRoad = item.curCurveRoad;
+        let preCurveRoad = dataService.getCurveRoad(item.curCurveRoad.id);
+        historyUtil.assignCurveRoadFromCurveRoad(
+          preCurveRoad,
+          currentCurveRoad
+        );
+      }
+    }
+  }
+
   goNextForCrossPoints(itemForCrossPoints) {
     for (let i = 0; i < itemForCrossPoints.length; ++i) {
       const item = itemForCrossPoints[i];
@@ -535,6 +697,9 @@ export default class History {
       this.goNextForRoadPoints(item.roadPoints);
       this.goNextForRoadEdges(item.roadEdges);
       this.goNextForRoads(item.roads);
+      this.goNextForCurveRoadPoints(item.curveRoadPoints);
+      this.goNextForCurveRoadEdges(item.curveRoadEdges);
+      this.goNextForCurveRoads(item.curveRoads);
       this.goNextForCrossPoints(item.crossPoints);
       change.saveCurrentInfo();
       this.setState();

+ 195 - 10
src/graphic/History/HistoryUtil.js

@@ -6,19 +6,11 @@ import Constant from "../Constant";
 export default class HistoryUtil {
   constructor() {}
 
-  isDifferentForRoads(road1, road2) {
-    if (road1.startId == road2.startId && road1.endId == road2.endId) {
-      return false;
-    } else {
-      return true;
-    }
-  }
-
   isDifferentForPoints(point1, point2) {
     if (
       point1.x == point2.x &&
       point1.y == point2.y &&
-      JSON.stringify(point1.parent) == JSON.stringify(point2.parent) &&
+      mathUtil.equalJSON(point1.parent, point1.parent) &&
       point1.category == point2.category &&
       point1.locationMode == point2.locationMode &&
       point1.linkedBasePointId == point2.linkedBasePointId &&
@@ -90,7 +82,7 @@ export default class HistoryUtil {
   isDifferentForRoadPoints(roadPoint1, roadPoint2) {
     if (
       mathUtil.equalPoint(roadPoint1, roadPoint2) &&
-      JSON.stringify(roadPoint1.parent) == JSON.stringify(roadPoint2.parent)
+      mathUtil.equalJSON(roadPoint1.parent, roadPoint2.parent)
     ) {
       return false;
     } else {
@@ -147,6 +139,71 @@ export default class HistoryUtil {
     }
   }
 
+  isDifferentForCurveRoadPoints(curveRoadPoint1, curveRoadPoint2) {
+    if (
+      mathUtil.equalPoint(curveRoadPoint1, curveRoadPoint2) &&
+      mathUtil.equalJSON(curveRoadPoint1.parent, curveRoadPoint2.parent) &&
+      curveRoadPoint1.index == curveRoadPoint2.index
+    ) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  isDifferentForCurveRoadEdges(curveRoadEdge1, curveRoadEdge2) {
+    if (
+      mathUtil.equalPoint(curveRoadEdge1.start, curveRoadEdge2.start) &&
+      mathUtil.equalPoint(curveRoadEdge1.end, curveRoadEdge2.end) &&
+      mathUtil.equalPoints(curveRoadEdge1.points, curveRoadEdge2.points) &&
+      curveRoadEdge1.parent == curveRoadEdge2.parent
+    ) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  isDifferentForCurveRoads(curveRoad1, curveRoad2) {
+    if (
+      curveRoad1.startId == curveRoad2.startId &&
+      curveRoad1.endId == curveRoad2.endId &&
+      mathUtil.equalPoints(curveRoad1.points, curveRoad2.points) &&
+      curveRoad1.leftEdgeId == curveRoad2.leftEdgeId &&
+      curveRoad1.rightEdgeId == curveRoad2.rightEdgeId &&
+      curveRoad1.way == curveRoad2.way
+    ) {
+      if (curveRoad1.way == Constant.oneWay) {
+        if (
+          curveRoad1.singleRoadWidth == curveRoad2.singleRoadWidth &&
+          curveRoad1.singleRoadDrivewayCount ==
+            curveRoad2.singleRoadDrivewayCount
+        ) {
+          return false;
+        } else {
+          return true;
+        }
+      } else if (curveRoad1.way == Constant.twoWay) {
+        if (
+          curveRoad1.leftWidth == curveRoad2.leftWidth &&
+          curveRoad1.rightWidth == curveRoad2.rightWidth &&
+          curveRoad1.leftDrivewayCount == curveRoad2.leftDrivewayCount &&
+          curveRoad1.rightDrivewayCount == curveRoad2.rightDrivewayCount &&
+          curveRoad1.midDivide.midDivideWidth ==
+            curveRoad2.midDivide.midDivideWidth
+        ) {
+          return false;
+        } else {
+          return true;
+        }
+      } else {
+        return true;
+      }
+    } else {
+      return true;
+    }
+  }
+
   isDifferentForCrossPoints(crossPoint1, crossPoint2) {
     if (
       mathUtil.equalPoint(crossPoint1, crossPoint2) &&
@@ -264,6 +321,79 @@ export default class HistoryUtil {
     this.setRoadInfo(roadInfo);
   }
 
+  assignCurveRoadPointFromCurveRoadPoint(curveRoadPoint1, curveRoadPoint2) {
+    const curveRoadPointInfo = {};
+    curveRoadPointInfo.vectorId = curveRoadPoint1.vectorId;
+    curveRoadPointInfo.position = {
+      x: curveRoadPoint2.position.x,
+      y: curveRoadPoint2.position.y,
+    };
+    curveRoadPointInfo.parent = JSON.parse(
+      JSON.stringify(curveRoadPoint2.parent)
+    );
+    curveRoadPointInfo.index = curveRoadPoint1.index;
+    this.setCurveRoadPointInfo(curveRoadPointInfo);
+  }
+
+  assignCurveRoadEdgeFromCurveRoadEdge(curveRoadEdge1, curveRoadEdge2) {
+    const curveRoadEdgeInfo = {};
+    curveRoadEdgeInfo.vectorId = curveRoadEdge1.vectorId;
+    curveRoadEdgeInfo.start = {
+      x: curveRoadEdge2.start.x,
+      y: curveRoadEdge2.start.y,
+    };
+    curveRoadEdgeInfo.end = {
+      x: curveRoadEdge2.end.x,
+      y: curveRoadEdge2.end.y,
+    };
+    curveRoadEdgeInfo.points = JSON.parse(
+      JSON.stringify(curveRoadEdge2.points)
+    );
+    curveRoadEdgeInfo.curves = JSON.parse(
+      JSON.stringify(curveRoadEdge2.curves)
+    );
+    curveRoadEdgeInfo.parent = curveRoadEdge2.parent;
+    this.setCurveRoadEdgeInfo(curveRoadEdgeInfo);
+  }
+
+  assignCurveRoadFromCurveRoad(curveRoad1, curveRoad2) {
+    const curveRoadInfo = {};
+    curveRoadInfo.vectorId = curveRoad1.vectorId;
+    curveRoadInfo.startId = curveRoad2.startId;
+    curveRoadInfo.endId = curveRoad2.endId;
+    curveRoadInfo.leftEdgeId = curveRoad2.leftEdgeId;
+    curveRoadInfo.rightEdgeId = curveRoad2.rightEdgeId;
+    curveRoadInfo.way = curveRoad2.way;
+    if (curveRoad2.way == Constant.oneWay) {
+      curveRoadInfo.singleRoadWidth = curveRoad2.singleRoadWidth;
+      curveRoadInfo.singleRoadDrivewayCount =
+        curveRoad2.singleRoadDrivewayCount;
+      curveRoadInfo.singleLanes = JSON.parse(
+        JSON.stringify(curveRoad2.singleLanes)
+      );
+    } else if (curveRoad2.way == Constant.twoWay) {
+      curveRoadInfo.leftWidth = curveRoad2.leftWidth;
+      curveRoadInfo.rightWidth = curveRoad2.rightWidth;
+      curveRoadInfo.leftDrivewayCount = curveRoad2.leftDrivewayCount;
+      curveRoadInfo.rightDrivewayCount = curveRoad2.rightDrivewayCount;
+      curveRoadInfo.midDivide = JSON.parse(
+        JSON.stringify(curveRoad2.midDivide)
+      );
+      curveRoadInfo.leftLanes = JSON.parse(
+        JSON.stringify(curveRoad2.leftLanes)
+      );
+      curveRoadInfo.rightLanes = JSON.parse(
+        JSON.stringify(curveRoad2.rightLanes)
+      );
+    }
+    curveRoadInfo.points = [];
+    for (let i = 0; i < curveRoad2.points.length; ++i) {
+      curveRoadInfo.points[i] = {};
+      curveRoadInfo.points[i].vectorId = curveRoad2.points[i].vectorId;
+    }
+    this.setCurveRoadInfo(curveRoadInfo);
+  }
+
   assignCrossPointFromCrossPoint(crossPoint1, crossPoint2) {
     const crossPointInfo = {};
     crossPointInfo.vectorId = crossPoint1.vectorId;
@@ -507,6 +637,61 @@ export default class HistoryUtil {
     }
   }
 
+  setCurveRoadPointInfo(curveRoadPointInfo) {
+    let curveRoadPoint = dataService.getCurveRoadPoint(
+      curveRoadPointInfo.vectorId
+    );
+    curveRoadPoint.vectorId = curveRoadPointInfo.vectorId;
+    mathUtil.clonePoint(curveRoadPoint, curveRoadPointInfo.position);
+    curveRoadPoint.parent = JSON.parse(
+      JSON.stringify(curveRoadPointInfo.parent)
+    );
+    curveRoadPoint.index = curveRoadPointInfo.index;
+  }
+
+  setCurveRoadEdgeInfo(curveRoadEdgeInfo) {
+    let curveRoadEdge = dataService.getCurveRoadEdge(
+      curveRoadEdgeInfo.vectorId
+    );
+    curveRoadEdge.vectorId = curveRoadEdgeInfo.vectorId;
+    mathUtil.clonePoint(curveRoadEdge.start, curveRoadEdgeInfo.start);
+    mathUtil.clonePoint(curveRoadEdge.end, curveRoadEdgeInfo.end);
+    mathUtil.clonePoints(curveRoadEdge.points, curveRoadEdgeInfo.points);
+    curveRoadEdge.name = curveRoadEdgeInfo.name;
+  }
+
+  setCurveRoadInfo(curveRoadInfo) {
+    let curveRoad = dataService.getCurveRoad(curveRoadInfo.vectorId);
+    curveRoad.vectorId = curveRoadInfo.vectorId;
+    curveRoad.startId = curveRoadInfo.startId;
+    curveRoad.endId = curveRoadInfo.endId;
+    curveRoad.leftEdgeId = curveRoadInfo.leftEdgeId;
+    curveRoad.rightEdgeId = curveRoadInfo.rightEdgeId;
+    for (let i = 0; i < curveRoadInfo.points.length; ++i) {
+      curveRoad.points[i] = dataService.getCurveRoadPoint(
+        curveRoadInfo.points[i]
+      );
+    }
+    curveRoad.way = curveRoadInfo.way;
+    if (curveRoad.way == Constant.oneWay) {
+      curveRoad.singleRoadWidth = curveRoadInfo.singleRoadWidth;
+      curveRoad.singleRoadDrivewayCount = curveRoadInfo.singleRoadDrivewayCount;
+      curveRoad.singleLanes = JSON.parse(
+        JSON.stringify(curveRoadInfo.singleLanes)
+      );
+    } else if (curveRoad.way == Constant.twoWay) {
+      curveRoad.leftWidth = curveRoadInfo.leftWidth;
+      curveRoad.rightWidth = curveRoadInfo.rightWidth;
+      curveRoad.leftDrivewayCount = curveRoadInfo.leftDrivewayCount;
+      curveRoad.rightDrivewayCount = curveRoadInfo.rightDrivewayCount;
+      curveRoad.midDivide = JSON.parse(JSON.stringify(curveRoadInfo.midDivide));
+      curveRoad.leftLanes = JSON.parse(JSON.stringify(curveRoadInfo.leftLanes));
+      curveRoad.rightLanes = JSON.parse(
+        JSON.stringify(curveRoadInfo.rightLanes)
+      );
+    }
+  }
+
   setCrossPointInfo(crossPointInfo) {
     let crossPoint = dataService.getCrossPoint3(crossPointInfo.vectorId);
     crossPoint.vectorId = crossPointInfo.vectorId;

+ 1 - 0
src/graphic/Layer.js

@@ -1107,6 +1107,7 @@ export default class Layer {
         stateService.setEventName(LayerEvents.AddingLine);
       } else {
         stateService.clearEventName();
+        this.exit();
       }
     }
   }

+ 13 - 0
src/graphic/Service/CurveRoadService.js

@@ -82,6 +82,19 @@ export default class CurveRoadService extends RoadService {
     return curveRoad;
   }
 
+  //撤销恢复用的,edge这些会专门调用
+  createOnlyCurveRoad(startId, endId, vectorId) {
+    let curveRoad = new CurveRoad(startId, endId, vectorId);
+    dataService.addCurveRoad(curveRoad);
+
+    let startPoint = dataService.getCurveRoadPoint(startId);
+    startPoint.setPointParent(curveRoad.vectorId, "start");
+
+    let endPoint = dataService.getCurveRoadPoint(endId);
+    endPoint.setPointParent(curveRoad.vectorId, "end");
+    return curveRoad;
+  }
+
   //不能加首尾,只能加中间
   //完全不处理车道,都放在setLanes上处理
   addCPoint(curveRoad, position, startIndex) {

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

@@ -596,6 +596,12 @@ export default class MathUtil {
     p1.y = p2.y;
   }
 
+  clonePoints(points1, points2) {
+    for (let i = 0; i < points1.length; ++i) {
+      this.clonePoint(points1[i], points2[i]);
+    }
+  }
+
   equalPoint(p1, p2) {
     if (p1.x == p2.x && p1.y == p2.y) {
       return true;
@@ -604,6 +610,34 @@ export default class MathUtil {
     }
   }
 
+  equalPoints(points1, points2) {
+    for (let i = 0; i < points1.length; ++i) {
+      let flag = this.equalPoint(points1[i], points2[i]);
+      if (!flag) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  equalJSON(json1, json2) {
+    for (key in json1) {
+      if (json2.hasOwnProperty(key) && json1[key] == json2[key]) {
+        continue;
+      } else {
+        return false;
+      }
+    }
+    for (key in json2) {
+      if (json1.hasOwnProperty(key) && json1[key] == json2[key]) {
+        continue;
+      } else {
+        return false;
+      }
+    }
+    return true;
+  }
+
   crossTwoLines(point1, point2, point3, point4, dis) {
     if (typeof dis == "undefined") {
       dis = Constant.minAdsorbPix;
@@ -1159,11 +1193,11 @@ export default class MathUtil {
   }
   // 中心点
   lineCenter(v1, v2) {
-    const point = this.pointPlus(v1, v2)
+    const point = this.pointPlus(v1, v2);
     return {
       x: point.x / 2,
-      y: point.y / 2
-    }
+      y: point.y / 2,
+    };
   }
   // 点放大
   pointScale(v, a) {