소스 검색

修复bug

xushiting 2 년 전
부모
커밋
ee514026ad
3개의 변경된 파일135개의 추가작업 그리고 62개의 파일을 삭제
  1. 99 13
      src/graphic/Controls/MoveRoad.js
  2. 13 13
      src/graphic/Controls/UIControl.js
  3. 23 36
      src/graphic/ListenLayer.js

+ 99 - 13
src/graphic/Controls/MoveRoad.js

@@ -1169,12 +1169,36 @@ export default class MoveRoad {
     const parent = edge.getParent();
     const road = dataService.getRoad(parent);
     const line = roadService.getMidLine(road);
+    let join = mathUtil.getJoinLinePoint(position, line);
 
     let dir = "left";
     if (road.rightEdgeId == edgeId) {
       dir = "right";
     }
 
+    let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
+    const line1 = mathUtil.createLine1(leftEdge.start, leftEdge.end);
+    let leftJoin = mathUtil.getJoinLinePoint(position, line1);
+    let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
+    const line2 = mathUtil.createLine1(rightEdge.start, rightEdge.end);
+    let rightJoin = mathUtil.getJoinLinePoint(position, line2);
+
+    if (
+      dir == "left" &&
+      (mathUtil.isContainForSegment(position, join, rightJoin) ||
+        mathUtil.isContainForSegment(rightJoin, join, position))
+    ) {
+      return;
+    }
+
+    if (
+      dir == "right" &&
+      (mathUtil.isContainForSegment(position, join, leftJoin) ||
+        mathUtil.isContainForSegment(leftJoin, join, position))
+    ) {
+      return;
+    }
+
     const newWidth = mathUtil.getDisForPoinLine(position, line);
     if (
       newWidth > Constant.minRoadSideWidth &&
@@ -1188,25 +1212,87 @@ export default class MoveRoad {
     const curveEdge = dataService.getCurveRoadEdge(curveEdgeId);
     const parent = curveEdge.getParent();
     const curveRoad = dataService.getCurveRoad(parent);
-    let joinInfo = null;
+    //let joinInfo = null;
     let dir = "left";
     if (curveRoad.rightEdgeId == curveEdgeId) {
       dir = "right";
     }
 
-    if (dir == "left") {
-      joinInfo = mathUtil.getHitInfoForCurve(
-        position,
-        curveRoad.curves[index],
-        curveRoad.leftWidth
-      );
-    } else if (dir == "right") {
-      joinInfo = mathUtil.getHitInfoForCurve(
-        position,
-        curveRoad.curves[index],
-        curveRoad.rightWidth
-      );
+    // if (dir == "left") {
+    //   joinInfo = mathUtil.getHitInfoForCurve(
+    //     position,
+    //     curveRoad.curves[index],
+    //     curveRoad.leftWidth
+    //   );
+    // } else if (dir == "right") {
+    //   joinInfo = mathUtil.getHitInfoForCurve(
+    //     position,
+    //     curveRoad.curves[index],
+    //     curveRoad.rightWidth
+    //   );
+    // }
+
+    const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
+    const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
+    let joinInfo = mathUtil.getHitInfoForCurve(
+      position,
+      curveRoad.curves[index],
+      Math.max(curveRoad.leftWidth, curveRoad.rightWidth)
+    );
+
+    let leftJoinInfo = mathUtil.getHitInfoForCurve(
+      position,
+      leftCurveEdge.curves[index],
+      curveRoad.leftWidth
+    );
+    let leftLine = mathUtil.createLine1(
+      leftJoinInfo.position,
+      joinInfo.position
+    );
+    let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
+
+    let rightJoinInfo = mathUtil.getHitInfoForCurve(
+      position,
+      rightCurveEdge.curves[index],
+      curveRoad.rightWidth
+    );
+    let rightLine = mathUtil.createLine1(
+      rightJoinInfo.position,
+      joinInfo.position
+    );
+    let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
+    if (
+      dir == "left" &&
+      (mathUtil.isContainForSegment(
+        rightJoin,
+        rightJoinInfo.position,
+        joinInfo.position
+      ) ||
+        mathUtil.isContainForSegment(
+          rightJoinInfo.position,
+          rightJoin,
+          joinInfo.position
+        ))
+    ) {
+      return;
+    }
+
+    if (
+      dir == "right" &&
+      (mathUtil.isContainForSegment(
+        leftJoin,
+        leftJoinInfo.position,
+        joinInfo.position
+      ) ||
+        mathUtil.isContainForSegment(
+          leftJoinInfo.position,
+          leftJoin,
+          joinInfo.position
+        ))
+    ) {
+      return;
     }
+
     const newWidth = mathUtil.getDistance(joinInfo.position, position);
     if (
       newWidth > Constant.minRoadSideWidth &&

+ 13 - 13
src/graphic/Controls/UIControl.js

@@ -460,19 +460,19 @@ export default class UIControl {
     return new Promise((resolve) => canvas.toBlob(resolve, `${type}/image`));
   }
 
-  downloadCadImg(canvas, filename) {
-    // 图片导出为 jpg 格式
-    var type = "jpg";
-    var imgData = canvas.toDataURL(type, 3);
-    canvas.toBlob(`${type}/image`);
-
-    // 加工image data,替换mime type
-    imgData = imgData.replace(this._fixType(type), "image/octet-stream");
-    // 下载后的图片名
-    //var filename = 'cad_' + new Date().getTime() + '.' + type
-    // download
-    this.saveFile(imgData, filename);
-  }
+  // downloadCadImg(canvas, filename) {
+  //   // 图片导出为 jpg 格式
+  //   var type = "jpg";
+  //   var imgData = canvas.toDataURL(type, 3);
+  //   canvas.toBlob(`${type}/image`);
+
+  //   // 加工image data,替换mime type
+  //   imgData = imgData.replace(this._fixType(type), "image/octet-stream");
+  //   // 下载后的图片名
+  //   //var filename = 'cad_' + new Date().getTime() + '.' + type
+  //   // download
+  //   this.saveFile(imgData, filename);
+  // }
 
   saveFile(data, filename) {
     var save_link = document.createElementNS(

+ 23 - 36
src/graphic/ListenLayer.js

@@ -807,45 +807,32 @@ export default class ListenLayer {
         }
         curveRoadInfo.dir = "left";
       } else {
-        if (joinInfo.distance < curveRoad.rightWidth) {
-          curveRoadInfo = {
-            curveRoadId: curveRoadId,
-            type: VectorType.CurveRoad,
-            distance: joinInfo.distance,
-            x: joinInfo.position.x,
-            y: joinInfo.position.y,
-          };
+        let line2 = mathUtil.createLine1(
+          joinInfo.position,
+          rightJoinInfo.position
+        );
+
+        let position2 = mathUtil.getJoinLinePoint(position, line2);
+        if (
+          mathUtil.isContainForSegment(
+            position2,
+            joinInfo.position,
+            rightJoinInfo.position
+          )
+        ) {
+          if (joinInfo.distance < curveRoad.rightWidth) {
+            curveRoadInfo = {
+              curveRoadId: curveRoadId,
+              type: VectorType.CurveRoad,
+              distance: joinInfo.distance,
+              x: joinInfo.position.x,
+              y: joinInfo.position.y,
+            };
+          }
+          curveRoadInfo.dir = "right";
         }
-        curveRoadInfo.dir = "right";
       }
 
-      // if (
-      //   mathUtil.getDistance(position, leftJoinInfo.position) >
-      //   mathUtil.getDistance(position, rightJoinInfo.position)
-      // ) {
-      //   if (joinInfo.distance < curveRoad.rightWidth) {
-      //     curveRoadInfo = {
-      //       curveRoadId: curveRoadId,
-      //       type: VectorType.CurveRoad,
-      //       distance: joinInfo.distance,
-      //       x: joinInfo.position.x,
-      //       y: joinInfo.position.y,
-      //     };
-      //   }
-      //   curveRoadInfo.dir = "right";
-      // } else {
-      //   if (joinInfo.distance < curveRoad.leftWidth) {
-      //     curveRoadInfo = {
-      //       curveRoadId: curveRoadId,
-      //       type: VectorType.CurveRoad,
-      //       distance: joinInfo.distance,
-      //       x: joinInfo.position.x,
-      //       y: joinInfo.position.y,
-      //     };
-      //   }
-      //   curveRoadInfo.dir = "left";
-      // }
-
       if (leftJoinInfo.distance < Constant.minAdsorbPix) {
         const index = mathUtil.getCurvesIndexForCurvesPoints(
           leftJoinInfo.position,