瀏覽代碼

继续搭建绘图:道路模块

xushiting 2 年之前
父節點
當前提交
aea52698cc

+ 1 - 0
src/graphic/Constant.js

@@ -23,6 +23,7 @@ const Constant = {
   // // cadImg_Height: 3000,
   // miniMap_Width: 1200,
   // miniMap_Height: 1200,
+  minLen: 0.2, //挨着,比如:点是否在线段上
   minAdsorbPix: 20, //最小吸附像素
   minRealDis: 20,
   defaultRoad: 100, //默认公路宽度

+ 3 - 0
src/graphic/Controls/AddRoad.js

@@ -7,6 +7,7 @@ import { elementService } from "../Service/ElementService";
 import { stateService } from "../Service/StateService";
 import VectorType from "../enum/VectorType";
 import { roadService } from "../Service/RoadService";
+import { edgeService } from "../Service/EdgeService";
 
 export default class AddRoad {
   constructor() {
@@ -58,6 +59,8 @@ export default class AddRoad {
       let roadId = roadService.getRoadId(pointId1, pointId2);
       if (!roadId) {
         let road = roadService.create(pointId1, pointId2);
+        edgeService.updateEdgeForMulRoad(pointId1);
+        edgeService.updateEdgeForMulRoad(pointId2);
       }
     }
   }

+ 10 - 0
src/graphic/Geometry/Edge.js

@@ -32,6 +32,16 @@ export default class Edge extends Geometry {
     }
   }
 
+  getPosition(dir) {
+    if (dir == "start") {
+      return this.start;
+    } else if (dir == "end") {
+      return this.end;
+    } else {
+      return null;
+    }
+  }
+
   getLine() {
     let line = mathUtil.createLine1(this.start, this.end);
     return line;

+ 47 - 4
src/graphic/Renderer/Draw.js

@@ -206,18 +206,54 @@ export default class Draw {
     this.drawText(vector, vector.vectorId);
   }
 
+  drawControlPoint(vector) {
+    const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y });
+    const color = this.rgb();
+    this.context.strokeStyle = color;
+    this.context.fillStyle = color;
+
+    let radius = Style.Point.radius;
+    this.context.beginPath();
+    this.context.arc(
+      pt.x,
+      pt.y,
+      radius * coordinate.ratio,
+      0,
+      Math.PI * 2,
+      true
+    );
+    this.context.stroke();
+    this.context.fill();
+
+    let start = dataService
+      .getEdge(vector.edgeInfo1.id)
+      .getPosition(vector.edgeInfo1.dir);
+    start = coordinate.getScreenXY(start);
+
+    let end = dataService
+      .getEdge(vector.edgeInfo2.id)
+      .getPosition(vector.edgeInfo2.dir);
+    end = coordinate.getScreenXY(end);
+
+    this.context.beginPath();
+    this.context.moveTo(start.x, start.y);
+    this.context.quadraticCurveTo(pt.x, pt.y, end.x, end.y);
+    this.context.stroke();
+
+    this.context.restore();
+    this.drawText(vector, vector.vectorId);
+  }
+
   // 文字
   drawText(position, txt, angle) {
     this.context.save();
     this.setCanvasStyle(Style.Font);
     if (coordinate.ratio == Constant.ratio) {
-      this.context.font = "36px Microsoft YaHei";
+      this.context.font = "12px Microsoft YaHei";
     } else {
       this.context.font = "12px Microsoft YaHei";
     }
-
     let pt = coordinate.getScreenXY(position);
-
     if (angle) {
       this.context.translate(pt.x, pt.y);
       this.context.rotate(angle);
@@ -227,7 +263,6 @@ export default class Draw {
       //this.context.strokeText(txt, pt.x, pt.y)
       this.context.fillText(txt, pt.x, pt.y);
     }
-
     this.context.restore();
   }
 
@@ -942,6 +977,14 @@ export default class Draw {
     }
   }
 
+  rgb() {
+    //rgb颜色随机
+    const r = Math.floor(Math.random() * 256);
+    const g = Math.floor(Math.random() * 256);
+    const b = Math.floor(Math.random() * 256);
+    return `rgb(${r},${g},${b})`;
+  }
+
   /*************************************************************************************家具**********************************************************************************************/
 
   /***************************************************************************************************************************************************************************************/

+ 9 - 0
src/graphic/Renderer/Render.js

@@ -23,11 +23,15 @@ export default class Render {
       case VectorType.Point:
         draw.drawPoint(vector);
         return;
+      case VectorType.ControlPoint:
+        draw.drawControlPoint(vector);
+        return;
       case VectorType.Tag:
         draw.drawTag(vector, styleType, flag);
         return;
       case VectorType.MeasureLine:
         draw.drawMeasures(vector, styleType);
+        return;
     }
   }
 
@@ -92,6 +96,11 @@ export default class Render {
       this.drawGeometry(points[key]);
     }
 
+    let controlPoints = dataService.getControlPoints();
+    for (let key in controlPoints) {
+      this.drawGeometry(controlPoints[key]);
+    }
+
     let tags = dataService.getTags();
     for (let key in tags) {
       this.drawGeometry(tags[key]);

+ 22 - 7
src/graphic/Service/ControlPointService.js

@@ -6,26 +6,41 @@ import { edgeService } from "./EdgeService.js";
 export default class ControlPointService {
   constructor() {}
 
+  //暂时没有添加到vectorData里
   create(position, vectorId) {
     let controlPoint = new ControlPoint(position, vectorId);
-    dataService.addControlPoint(controlPoint);
     return controlPoint;
   }
 
-  update(point1, point2, edge1, edge2, dir1, dir2) {
+  update(realRosition, point1, point2, edge1, edge2, dir1, dir2) {
     let controlPoint = dataService.getControlPoint(
       edge1.vectorId,
       edge2.vectorId
     );
     const line1 = edgeService.getLine(edge1);
     const line2 = edgeService.getLine(edge2);
-    const position = mathUtil.getPositionForExtendedLine(point1, point2);
+    let position = mathUtil.getPositionForExtendedLine(point1, point2);
     //更新edge的坐标
-    const position1 = mathUtil.getJoinLinePoint(position, line1);
-    const position2 = mathUtil.getJoinLinePoint(position, line2);
+    let position1 = mathUtil.getJoinLinePoint(position, line1);
+    let position2 = mathUtil.getJoinLinePoint(position, line2);
+    //可能position1或者position2不在对应的edge上,这时候需要调换顺序
+    if (
+      !mathUtil.isContainForSegment(position1, edge1.start, edge1.end) ||
+      !mathUtil.isContainForSegment(position2, edge2.start, edge2.end)
+    ) {
+      position = mathUtil.getPositionForExtendedLine(point2, point1);
+      position1 = mathUtil.getJoinLinePoint(position, line1);
+      position2 = mathUtil.getJoinLinePoint(position, line2);
+    }
+
+    // const realRosition = mathUtil.getPositionForExtendedLine(point2, point1);
+    // const realRosition = {
+    //   x: (point1.x + point2.x) / 2,
+    //   y: (point1.y + point2.y) / 2,
+    // };
     if (controlPoint == null) {
       //新建控制点
-      controlPoint = this.create(position);
+      controlPoint = this.create(realRosition);
       //设置控制点的信息
       controlPoint.setEdgeInfo(edge1.vectorId, dir1, edge2.vectorId, dir2);
       //添加到数据集里
@@ -33,7 +48,7 @@ export default class ControlPointService {
     }
     //更新控制点坐标
     else {
-      controlPoint.setPosition(position);
+      controlPoint.setPosition(realRosition);
     }
     edge1.setPosition(position1, dir1);
     edge2.setPosition(position2, dir2);

+ 10 - 2
src/graphic/Service/DataService.js

@@ -129,6 +129,16 @@ export class DataService {
     ] = controlPoint;
   }
 
+  deleteControlPoint(edgeId1, edgeId2) {
+    let key = edgeId1 + "-" + edgeId2;
+    if (!this.vectorData.controlPoints[key]) {
+      key = edgeId2 + "-" + edgeId1;
+    }
+    if (this.vectorData.controlPoints[key]) {
+      delete this.vectorData.controlPoints[key];
+    }
+  }
+
   /**
    * 对公路边缘的操作
    */
@@ -152,8 +162,6 @@ export class DataService {
   }
 
   deleteTag(tagId) {
-    let tag = this.getTag(tagId);
-    tag = null;
     delete this.vectorData.tags[tagId];
   }
 

+ 251 - 29
src/graphic/Service/EdgeService.js

@@ -150,19 +150,26 @@ export default class EdgeService {
       } else {
         newEdgePoint1 = mathUtil.getIntersectionPoint(lineLeft1, lineRight2);
         newEdgePoint2 = mathUtil.getIntersectionPoint(lineLeft2, lineRight1);
+      }
 
-        mathUtil.clonePoint(leftEdge1.start, newEdgePoint1);
-        mathUtil.clonePoint(rightEdge1.start, newEdgePoint2);
+      mathUtil.clonePoint(leftEdge1.start, newEdgePoint1);
+      mathUtil.clonePoint(rightEdge1.start, newEdgePoint2);
 
-        mathUtil.clonePoint(rightEdge2.start, newEdgePoint1);
-        mathUtil.clonePoint(leftEdge2.start, newEdgePoint2);
+      mathUtil.clonePoint(rightEdge2.start, newEdgePoint1);
+      mathUtil.clonePoint(leftEdge2.start, newEdgePoint2);
 
+      if (angle > Constant.maxAngle) {
+        //要删除控制点
+        dataService.deleteControlPoint(leftEdge1.vectorId, rightEdge2.vectorId);
+        dataService.deleteControlPoint(rightEdge1.vectorId, leftEdge2.vectorId);
+      } else {
         points.push(startPoint1);
         points.push(endPoint1);
         points.push(endPoint2);
         if (mathUtil.isClockwise(points)) {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint1,
             startPoint1,
             newEdgePoint1,
             leftEdge1,
@@ -172,6 +179,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint2,
+            newEdgePoint2,
             startPoint1,
             rightEdge1,
             leftEdge2,
@@ -181,6 +189,7 @@ export default class EdgeService {
         } else {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint2,
             startPoint1,
             newEdgePoint2,
             rightEdge1,
@@ -190,6 +199,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint1,
+            newEdgePoint1,
             startPoint1,
             leftEdge1,
             rightEdge2,
@@ -210,19 +220,29 @@ export default class EdgeService {
       } else {
         newEdgePoint1 = mathUtil.getIntersectionPoint(lineLeft1, lineLeft2);
         newEdgePoint2 = mathUtil.getIntersectionPoint(lineRight1, lineRight2);
+      }
 
-        mathUtil.clonePoint(leftEdge1.start, newEdgePoint1);
-        mathUtil.clonePoint(rightEdge1.start, newEdgePoint2);
+      mathUtil.clonePoint(leftEdge1.start, newEdgePoint1);
+      mathUtil.clonePoint(rightEdge1.start, newEdgePoint2);
 
-        mathUtil.clonePoint(leftEdge2.end, newEdgePoint1);
-        mathUtil.clonePoint(rightEdge2.end, newEdgePoint2);
+      mathUtil.clonePoint(leftEdge2.end, newEdgePoint1);
+      mathUtil.clonePoint(rightEdge2.end, newEdgePoint2);
 
+      if (angle > Constant.maxAngle) {
+        //要删除控制点
+        dataService.deleteControlPoint(leftEdge1.vectorId, leftEdge2.vectorId);
+        dataService.deleteControlPoint(
+          rightEdge1.vectorId,
+          rightEdge2.vectorId
+        );
+      } else {
         points.push(startPoint1);
         points.push(endPoint1);
         points.push(startPoint2);
         if (mathUtil.isClockwise(points)) {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint1,
             startPoint1,
             newEdgePoint1,
             leftEdge1,
@@ -232,6 +252,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint2,
+            newEdgePoint2,
             startPoint1,
             rightEdge1,
             rightEdge2,
@@ -241,6 +262,7 @@ export default class EdgeService {
         } else {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint2,
             startPoint1,
             newEdgePoint2,
             rightEdge1,
@@ -250,6 +272,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint1,
+            newEdgePoint1,
             startPoint1,
             leftEdge1,
             leftEdge2,
@@ -269,19 +292,27 @@ export default class EdgeService {
       } else {
         newEdgePoint1 = mathUtil.getIntersectionPoint(lineLeft1, lineLeft2);
         newEdgePoint2 = mathUtil.getIntersectionPoint(lineRight1, lineRight2);
+      }
+      mathUtil.clonePoint(leftEdge1.end, newEdgePoint1);
+      mathUtil.clonePoint(rightEdge1.end, newEdgePoint2);
 
-        mathUtil.clonePoint(leftEdge1.end, newEdgePoint1);
-        mathUtil.clonePoint(rightEdge1.end, newEdgePoint2);
-
-        mathUtil.clonePoint(leftEdge2.start, newEdgePoint1);
-        mathUtil.clonePoint(rightEdge2.start, newEdgePoint2);
-
+      mathUtil.clonePoint(leftEdge2.start, newEdgePoint1);
+      mathUtil.clonePoint(rightEdge2.start, newEdgePoint2);
+      if (angle > Constant.maxAngle) {
+        //要删除控制点
+        dataService.deleteControlPoint(leftEdge1.vectorId, leftEdge2.vectorId);
+        dataService.deleteControlPoint(
+          rightEdge1.vectorId,
+          rightEdge2.vectorId
+        );
+      } else {
         points.push(endPoint1);
         points.push(startPoint1);
         points.push(endPoint2);
         if (!mathUtil.isClockwise(points)) {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint1,
             endPoint1,
             newEdgePoint1,
             leftEdge1,
@@ -291,6 +322,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint2,
+            newEdgePoint2,
             endPoint1,
             rightEdge1,
             rightEdge2,
@@ -300,6 +332,7 @@ export default class EdgeService {
         } else {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint2,
             endPoint1,
             newEdgePoint2,
             rightEdge1,
@@ -309,6 +342,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint1,
+            newEdgePoint1,
             endPoint1,
             leftEdge1,
             leftEdge2,
@@ -328,19 +362,25 @@ export default class EdgeService {
       } else {
         newEdgePoint1 = mathUtil.getIntersectionPoint(lineLeft1, lineRight2);
         newEdgePoint2 = mathUtil.getIntersectionPoint(lineLeft2, lineRight1);
+      }
+      mathUtil.clonePoint(leftEdge1.end, newEdgePoint1);
+      mathUtil.clonePoint(rightEdge1.end, newEdgePoint2);
 
-        mathUtil.clonePoint(leftEdge1.end, newEdgePoint1);
-        mathUtil.clonePoint(rightEdge1.end, newEdgePoint2);
-
-        mathUtil.clonePoint(rightEdge2.end, newEdgePoint1);
-        mathUtil.clonePoint(leftEdge2.end, newEdgePoint2);
+      mathUtil.clonePoint(rightEdge2.end, newEdgePoint1);
+      mathUtil.clonePoint(leftEdge2.end, newEdgePoint2);
 
+      if (angle > Constant.maxAngle) {
+        //要删除控制点
+        dataService.deleteControlPoint(leftEdge1.vectorId, rightEdge2.vectorId);
+        dataService.deleteControlPoint(rightEdge1.vectorId, leftEdge2.vectorId);
+      } else {
         points.push(endPoint1);
         points.push(startPoint1);
         points.push(startPoint2);
         if (!mathUtil.isClockwise(points)) {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint1,
             endPoint1,
             newEdgePoint1,
             leftEdge1,
@@ -350,6 +390,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint2,
+            newEdgePoint2,
             endPoint1,
             leftEdge2,
             rightEdge1,
@@ -359,6 +400,7 @@ export default class EdgeService {
         } else {
           //需要考虑控制点ControlPointService
           controlPointService.update(
+            newEdgePoint2,
             endPoint1,
             newEdgePoint2,
             leftEdge2,
@@ -368,6 +410,7 @@ export default class EdgeService {
           );
           controlPointService.update(
             newEdgePoint1,
+            newEdgePoint1,
             endPoint1,
             leftEdge1,
             rightEdge2,
@@ -394,19 +437,21 @@ export default class EdgeService {
   updateSingleEdgeForTwoRoad(roadId1, roadId2) {
     //console.log('更新'+roadId1+'和'+roadId2+'一侧相交的edge交点');
     console.log("开始执行updateSingleEdgeForTwoRoad");
-    let road1 = dataService.getRoad(roadId1);
-    let startPoint1 = dataService.getPoint(road1.startId);
-    let endPoint1 = dataService.getPoint(road1.endId);
-    this.computerDefaultEdge(roadId1);
+    const road1 = dataService.getRoad(roadId1);
+    const startPoint1 = dataService.getPoint(road1.startId);
+    const endPoint1 = dataService.getPoint(road1.endId);
+    let line1 = mathUtil.createLine1(startPoint1, endPoint1);
+
     let leftEdge1 = dataService.getEdge(road1.leftEdgeId);
     let rightEdge1 = dataService.getEdge(road1.rightEdgeId);
     let lineLeft1 = this.getLine(leftEdge1);
     let lineRight1 = this.getLine(rightEdge1);
 
-    let road2 = dataService.getRoad(roadId2);
-    this.computerDefaultEdge(roadId2);
-    // let startPoint2 = dataService.getPoint(road2.startId);
-    // let endPoint2 = dataService.getPoint(road2.endId);
+    const road2 = dataService.getRoad(roadId2);
+    const startPoint2 = dataService.getPoint(road2.startId);
+    const endPoint2 = dataService.getPoint(road2.endId);
+    let line2 = mathUtil.createLine1(startPoint2, endPoint2);
+
     let leftEdge2 = dataService.getEdge(road2.leftEdgeId);
     let rightEdge2 = dataService.getEdge(road2.rightEdgeId);
     let lineLeft2 = this.getLine(leftEdge2);
@@ -428,7 +473,12 @@ export default class EdgeService {
     if (road1.startId == road2.startId) {
       points.push(startPoint1);
       points.push(endPoint1);
-      //如果墙的角度过大,不能计算edge对应的line的交点
+
+      lineLeft1 = mathUtil.createLine3(line1, leftEdge1.end);
+      lineRight1 = mathUtil.createLine3(line1, rightEdge1.end);
+      lineRight2 = mathUtil.createLine3(line2, rightEdge2.end);
+
+      // 如果墙的角度过大,不能计算edge对应的line的交点
       if (angle > Constant.maxAngle) {
         newEdgePoint1 = mathUtil.getJoinLinePoint(startPoint1, lineLeft1);
         newEdgePoint2 = mathUtil.getJoinLinePoint(startPoint1, lineRight1);
@@ -439,11 +489,49 @@ export default class EdgeService {
 
       points[2] = newEdgePoint1;
       if (mathUtil.isClockwise(points)) {
+        console.log("情况1");
         mathUtil.clonePoint(leftEdge1.start, newEdgePoint1);
         mathUtil.clonePoint(rightEdge2.start, newEdgePoint1);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            leftEdge1.vectorId,
+            rightEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint1,
+            startPoint1,
+            newEdgePoint1,
+            leftEdge1,
+            rightEdge2,
+            "start",
+            "start"
+          );
+        }
       } else {
+        console.log("情况2");
         mathUtil.clonePoint(rightEdge1.start, newEdgePoint2);
         mathUtil.clonePoint(leftEdge2.start, newEdgePoint2);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            leftEdge2.vectorId,
+            rightEdge1.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint2,
+            startPoint1,
+            newEdgePoint2,
+            leftEdge2,
+            rightEdge1,
+            "start",
+            "start"
+          );
+        }
       }
       return true;
     }
@@ -452,6 +540,12 @@ export default class EdgeService {
     else if (road1.startId == road2.endId) {
       points.push(startPoint1);
       points.push(endPoint1);
+
+      lineLeft1 = mathUtil.createLine3(line1, leftEdge1.end);
+      lineRight1 = mathUtil.createLine3(line1, rightEdge1.end);
+      lineLeft2 = mathUtil.createLine3(line2, leftEdge2.start);
+      lineRight2 = mathUtil.createLine3(line2, rightEdge2.start);
+
       if (angle > Constant.maxAngle) {
         newEdgePoint1 = mathUtil.getJoinLinePoint(startPoint1, lineLeft1);
         newEdgePoint2 = mathUtil.getJoinLinePoint(startPoint1, lineRight1);
@@ -461,11 +555,49 @@ export default class EdgeService {
       }
       points[2] = newEdgePoint1;
       if (mathUtil.isClockwise(points)) {
+        console.log("情况3");
         mathUtil.clonePoint(leftEdge1.start, newEdgePoint1);
         mathUtil.clonePoint(leftEdge2.end, newEdgePoint1);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            leftEdge1.vectorId,
+            leftEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint1,
+            startPoint1,
+            newEdgePoint1,
+            leftEdge1,
+            leftEdge2,
+            "start",
+            "end"
+          );
+        }
       } else {
+        console.log("情况4");
         mathUtil.clonePoint(rightEdge1.start, newEdgePoint2);
         mathUtil.clonePoint(rightEdge2.end, newEdgePoint2);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            rightEdge1.vectorId,
+            rightEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint2,
+            startPoint1,
+            newEdgePoint2,
+            rightEdge1,
+            rightEdge2,
+            "start",
+            "end"
+          );
+        }
       }
       return true;
     }
@@ -474,6 +606,12 @@ export default class EdgeService {
     else if (road1.endId == road2.startId) {
       points.push(endPoint1);
       points.push(startPoint1);
+
+      lineLeft1 = mathUtil.createLine3(line1, leftEdge1.start);
+      lineRight1 = mathUtil.createLine3(line1, rightEdge1.start);
+      lineLeft2 = mathUtil.createLine3(line2, leftEdge2.end);
+      lineRight2 = mathUtil.createLine3(line2, rightEdge2.end);
+
       if (angle > Constant.maxAngle) {
         newEdgePoint1 = mathUtil.getJoinLinePoint(endPoint1, lineLeft1);
         newEdgePoint2 = mathUtil.getJoinLinePoint(endPoint1, lineRight1);
@@ -483,19 +621,63 @@ export default class EdgeService {
       }
       points[2] = newEdgePoint1;
       if (mathUtil.isClockwise(points)) {
+        console.log("情况5");
         mathUtil.clonePoint(leftEdge1.end, newEdgePoint1);
         mathUtil.clonePoint(leftEdge2.start, newEdgePoint1);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            leftEdge1.vectorId,
+            leftEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint1,
+            endPoint1,
+            newEdgePoint1,
+            leftEdge1,
+            leftEdge2,
+            "end",
+            "start"
+          );
+        }
       } else {
+        console.log("情况6");
         mathUtil.clonePoint(rightEdge1.end, newEdgePoint2);
         mathUtil.clonePoint(rightEdge2.start, newEdgePoint2);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            rightEdge1.vectorId,
+            rightEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint2,
+            endPoint1,
+            newEdgePoint2,
+            rightEdge1,
+            rightEdge2,
+            "end",
+            "start"
+          );
+        }
       }
       return true;
     }
     //end-end
     //left-right,right-left
-    else if (road1.endID == road2.endId) {
+    else if (road1.endId == road2.endId) {
       points.push(endPoint1);
       points.push(startPoint1);
+
+      lineLeft1 = mathUtil.createLine3(line1, leftEdge1.start);
+      lineRight1 = mathUtil.createLine3(line1, rightEdge1.start);
+      lineLeft2 = mathUtil.createLine3(line2, leftEdge2.start);
+      lineRight2 = mathUtil.createLine3(line2, rightEdge2.start);
+
       if (angle > Constant.maxAngle) {
         newEdgePoint1 = mathUtil.getJoinLinePoint(endPoint1, lineLeft1);
         newEdgePoint2 = mathUtil.getJoinLinePoint(endPoint1, lineRight1);
@@ -505,11 +687,51 @@ export default class EdgeService {
       }
       points[2] = newEdgePoint1;
       if (mathUtil.isClockwise(points)) {
+        console.log("情况7");
         mathUtil.clonePoint(leftEdge1.end, newEdgePoint1);
         mathUtil.clonePoint(rightEdge2.end, newEdgePoint1);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            leftEdge1.vectorId,
+            rightEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint1,
+            endPoint1,
+            newEdgePoint1,
+            leftEdge1,
+            leftEdge2,
+            "end",
+            "end"
+          );
+        }
       } else {
+        console.log("情况8");
         mathUtil.clonePoint(rightEdge1.end, newEdgePoint2);
         mathUtil.clonePoint(leftEdge2.end, newEdgePoint2);
+        //要删除控制点
+        dataService.deleteControlPoint(leftEdge1.vectorId, rightEdge2.vectorId);
+        if (angle > Constant.maxAngle) {
+          //要删除控制点
+          dataService.deleteControlPoint(
+            rightEdge1.vectorId,
+            leftEdge2.vectorId
+          );
+        } else {
+          //需要考虑控制点ControlPointService
+          controlPointService.update(
+            newEdgePoint2,
+            endPoint1,
+            newEdgePoint2,
+            rightEdge1,
+            leftEdge2,
+            "end",
+            "end"
+          );
+        }
       }
       return true;
     } else {

+ 1 - 0
src/graphic/Service/RoadService.js

@@ -80,6 +80,7 @@ export default class RoadService {
       //修改旧公路的start
       point.setPointParent(roadId, "start");
     }
+    edgeService.updateEdgeForTwoRoad(roadId, newRoad.vectorId);
     return newRoad.vectorId;
   }
 

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

@@ -341,10 +341,10 @@ export default class MathUtil {
 
     if ((180 * fi) / Math.PI < 180) {
       //return 180 * fi / Math.PI;
-      return fi;
+      return (fi * 180) / Math.PI;
     } else {
       //return 360 - 180 * fi / Math.PI;
-      return 2 * Math.PI - fi;
+      return ((2 * Math.PI - fi) * 180) / Math.PI;
     }
   }
 
@@ -401,7 +401,7 @@ export default class MathUtil {
   //方法:point到startPoint和endPoint的距离之和与startPoint和endPoint之间的距离对比
   isContainForSegment(point, startPoint, endPoint, minDis) {
     if (!minDis) {
-      minDis = Constant.minAdsorbPix;
+      minDis = Constant.minLen;
     }
     let dis1 =
       this.getDistance(startPoint, point) + this.getDistance(endPoint, point);