浏览代码

修复定位法的bug

xushiting 2 年之前
父节点
当前提交
4b34e437b4
共有 2 个文件被更改,包括 47 次插入10 次删除
  1. 44 10
      src/graphic/Controls/MovePoint.js
  2. 3 0
      src/graphic/ListenLayer.js

+ 44 - 10
src/graphic/Controls/MovePoint.js

@@ -19,7 +19,6 @@ export default class MovePoint {
     } else if (point.getCategory() == VectorCategory.Point.BasePoint) {
       this.updateBasePoint(pointId);
     } else {
-      
       let parent = point.getParent();
       for (let key in parent) {
         let line = dataService.getLine(key);
@@ -39,6 +38,28 @@ export default class MovePoint {
   }
 
   finish(pointId) {
+    // if (
+    //   pointId &&
+    //   listenLayer.modifyPoint &&
+    //   listenLayer.modifyPoint.linkedPointId
+    // ) {
+    //   let linkedPoint = dataService.getPoint(
+    //     listenLayer.modifyPoint.linkedPointId
+    //   );
+    //   const category = linkedPoint.getCategory();
+    //   if (
+    //     category != VectorCategory.Point.BasePoint &&
+    //     category != VectorCategory.Point.TestBasePoint &&
+    //     category != VectorCategory.Point.TestPoint
+    //   ) {
+    //     pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
+    //     Settings.selectBasePointId = null;
+    //   } else if (category == VectorCategory.Point.BasePoint) {
+    //     Settings.selectBasePointId = pointId;
+    //   } else {
+    //     Settings.selectBasePointId = null;
+    //   }
+    // }
     if (
       pointId &&
       listenLayer.modifyPoint &&
@@ -55,10 +76,17 @@ export default class MovePoint {
       ) {
         pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
         Settings.selectBasePointId = null;
-      } else if (category == VectorCategory.Point.BasePoint) {
-        Settings.selectBasePointId = pointId;
       } else {
-        Settings.selectBasePointId = null;
+        let point = dataService.getPoint(pointId);
+        const parent = point.getParent();
+        for (let key in parent) {
+          let line = dataService.getLine(key);
+          let startPoint = dataService.getPoint(line.startId);
+          let endPoint = dataService.getPoint(line.endId);
+          if (mathUtil.getDistance(startPoint, endPoint) == 0) {
+            pointService.deletePoint(pointId);
+          }
+        }
       }
     }
   }
@@ -132,14 +160,20 @@ export default class MovePoint {
         let startPoint = dataService.getPoint(positionLine.startId);
         let endPoint = dataService.getPoint(positionLine.endId);
         let positionLineGeometry = mathUtil.createLine1(startPoint, endPoint);
+        if (!positionLineGeometry) {
+          let lineGeometry = dataService.getLine(Settings.baseLineId);
+          let baseStartPoint = dataService.getPoint(lineGeometry.startId);
+          let baseEndPoint = dataService.getPoint(lineGeometry.endId);
+          let baseLine = mathUtil.createLine1(baseStartPoint, baseEndPoint);
+          positionLineGeometry = mathUtil.createLine3(baseLine, testPoint);
+        }
         let join = mathUtil.getJoinLinePoint(testPoint, positionLineGeometry);
         mathUtil.clonePoint(otherPoint, join);
-
-        if (
-          mathUtil.getDistance(startPoint, endPoint) < Constant.minAdsorbPix
-        ) {
-          pointService.deletePoint(positionLine.startId);
-        }
+        // if (
+        //   mathUtil.getDistance(startPoint, endPoint) < Constant.minAdsorbPix
+        // ) {
+        //   pointService.deletePoint(positionLine.startId);
+        // }
         break;
       }
     }

+ 3 - 0
src/graphic/ListenLayer.js

@@ -307,6 +307,9 @@ export default class ListenLayer {
       let startPoint = dataService.getPoint(line.startId);
       let endPoint = dataService.getPoint(line.endId);
       const comLine = mathUtil.createLine1(startPoint, endPoint);
+      if (!comLine) {
+        continue;
+      }
       const join = mathUtil.getJoinLinePoint(position, comLine);
       const distance = this.getDistance(position, join);
       if (!mathUtil.isContainForSegment(join, startPoint, endPoint)) {