浏览代码

Merge branch 'dev' of http://192.168.0.115:3000/bill/traffic-laser into dev

xzw 1 年之前
父节点
当前提交
ac63730650
共有 3 个文件被更改,包括 257 次插入635 次删除
  1. 168 381
      src/graphic/ListenLayer.js
  2. 9 6
      src/graphic/Service/SVGService.js
  3. 80 248
      src/graphic/Util/MathUtil.js

+ 168 - 381
src/graphic/ListenLayer.js

@@ -1,4 +1,4 @@
-import { mathUtil } from "./Util/MathUtil";
+import MathUtil, { mathUtil } from "./Util/MathUtil";
 import { dataService } from "./Service/DataService.js";
 import { dataService } from "./Service/DataService.js";
 import { stateService } from "./Service/StateService.js";
 import { stateService } from "./Service/StateService.js";
 import { roadService } from "./Service/RoadService.js";
 import { roadService } from "./Service/RoadService.js";
@@ -64,37 +64,18 @@ export default class ListenLayer {
     }
     }
     this.clear();
     this.clear();
     if (!vType || vType == VectorType.CurveRoad) {
     if (!vType || vType == VectorType.CurveRoad) {
-      selectInfo.curveRoadEdgeInfo = this.isSelectCurveRoad(
-        position,
-        exceptVectorIds.exceptCurveRoadId
-      ); //包括edge
-      selectInfo.curveRoadPointInfo = this.isSelectCurveRoadPoint(
-        position,
-        exceptVectorIds.exceptCurveRoadPointId
-      );
+      selectInfo.curveRoadEdgeInfo = this.isSelectCurveRoad(position, exceptVectorIds.exceptCurveRoadId); //包括edge
+      selectInfo.curveRoadPointInfo = this.isSelectCurveRoadPoint(position, exceptVectorIds.exceptCurveRoadPointId);
     }
     }
 
 
     if (!vType || vType == VectorType.Road) {
     if (!vType || vType == VectorType.Road) {
-      selectInfo.roadEdgeInfo = this.isSelectRoad(
-        position,
-        exceptVectorIds.exceptRoadIds
-      ); //包括edge
-      selectInfo.roadPointInfo = this.isSelectRoadPoint(
-        position,
-        exceptVectorIds.exceptRoadPointId
-      );
+      selectInfo.roadEdgeInfo = this.isSelectRoad(position, exceptVectorIds.exceptRoadIds); //包括edge
+      selectInfo.roadPointInfo = this.isSelectRoadPoint(position, exceptVectorIds.exceptRoadPointId);
     }
     }
 
 
     if (!vType || vType == VectorType.Line) {
     if (!vType || vType == VectorType.Line) {
-      selectInfo.lineInfo = this.isSelectLine(
-        position,
-        exceptVectorIds.exceptLineIds
-      );
-      selectInfo.pointInfo = this.isSelectPoint(
-        position,
-        exceptVectorIds.exceptPointId,
-        exceptVectorIds.exceptLineIds
-      );
+      selectInfo.lineInfo = this.isSelectLine(position, exceptVectorIds.exceptLineIds);
+      selectInfo.pointInfo = this.isSelectPoint(position, exceptVectorIds.exceptPointId, exceptVectorIds.exceptLineIds);
     }
     }
     // selectInfo.pointInfo = this.isSelectPoint(
     // selectInfo.pointInfo = this.isSelectPoint(
     //   position,
     //   position,
@@ -102,44 +83,23 @@ export default class ListenLayer {
     // );
     // );
 
 
     if (!vType || vType == VectorType.CurveLine) {
     if (!vType || vType == VectorType.CurveLine) {
-      selectInfo.curvePointInfo = this.isSelectCurvePoint(
-        position,
-        exceptVectorIds.exceptCurvePointId
-      );
-      selectInfo.curveLineInfo = this.isSelectCurveLine(
-        position,
-        exceptVectorIds.exceptCurveLineId
-      );
+      selectInfo.curvePointInfo = this.isSelectCurvePoint(position, exceptVectorIds.exceptCurvePointId);
+      selectInfo.curveLineInfo = this.isSelectCurveLine(position, exceptVectorIds.exceptCurveLineId);
     }
     }
 
 
     //if (!vType || vType == VectorType.Circle) {
     //if (!vType || vType == VectorType.Circle) {
-    selectInfo.circleInfo = this.isSelectCircle(
-      position,
-      exceptVectorIds.exceptCircleId
-    );
+    selectInfo.circleInfo = this.isSelectCircle(position, exceptVectorIds.exceptCircleId);
     //}
     //}
 
 
     //if (!vType) {
     //if (!vType) {
     //交叉口拐弯处的控制点
     //交叉口拐弯处的控制点
-    selectInfo.crossPointInfo = this.isSelectCrossCrossPoint(
-      position,
-      exceptVectorIds.exceptCrossCrossPointId
-    );
-    selectInfo.textInfo = this.isSelectText(
-      position,
-      exceptVectorIds.exceptTextId
-    );
-    selectInfo.magnifierInfo = this.isSelectMagnifier(
-      position,
-      exceptVectorIds.exceptMagnifierId
-    );
+    selectInfo.crossPointInfo = this.isSelectCrossCrossPoint(position, exceptVectorIds.exceptCrossCrossPointId);
+    selectInfo.textInfo = this.isSelectText(position, exceptVectorIds.exceptTextId);
+    selectInfo.magnifierInfo = this.isSelectMagnifier(position, exceptVectorIds.exceptMagnifierId);
     //
     //
 
 
     if (!vType || vType == VectorType.SVG) {
     if (!vType || vType == VectorType.SVG) {
-      selectInfo.svgInfo = this.isSelectSVG(
-        position,
-        exceptVectorIds.exceptSVGId
-      );
+      selectInfo.svgInfo = this.isSelectSVG(position, exceptVectorIds.exceptSVGId);
     }
     }
 
 
     this.setModifyPoint(position, selectInfo);
     this.setModifyPoint(position, selectInfo);
@@ -179,19 +139,11 @@ export default class ListenLayer {
           }
           }
         }
         }
       } else {
       } else {
-        if (
-          (Math.abs(position.x - curvePoint.x) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        if ((Math.abs(position.x - curvePoint.x) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedCurvePointIdX = curvePointId;
           seqInfo.linkedCurvePointIdX = curvePointId;
           seqInfo.x = curvePoint.x;
           seqInfo.x = curvePoint.x;
         }
         }
-        if (
-          (Math.abs(position.y - curvePoint.y) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        if ((Math.abs(position.y - curvePoint.y) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedPointIdY = curvePointId;
           seqInfo.linkedPointIdY = curvePointId;
           seqInfo.y = curvePoint.y;
           seqInfo.y = curvePoint.y;
         }
         }
@@ -200,9 +152,7 @@ export default class ListenLayer {
 
 
     if (curvePointInfo.curvePointId) {
     if (curvePointInfo.curvePointId) {
       curvePointInfo.linkedCurvePointId = curvePointInfo.curvePointId;
       curvePointInfo.linkedCurvePointId = curvePointInfo.curvePointId;
-      const linkedCurvePoint = dataService.getCurvePoint(
-        curvePointInfo.curvePointId
-      );
+      const linkedCurvePoint = dataService.getCurvePoint(curvePointInfo.curvePointId);
       curvePointInfo.x = linkedCurvePoint.x;
       curvePointInfo.x = linkedCurvePoint.x;
       curvePointInfo.y = linkedCurvePoint.y;
       curvePointInfo.y = linkedCurvePoint.y;
     } else {
     } else {
@@ -214,16 +164,10 @@ export default class ListenLayer {
         curvePointInfo.linkedCurvePointIdY = seqInfo.linkedCurvePointIdY;
         curvePointInfo.linkedCurvePointIdY = seqInfo.linkedCurvePointIdY;
         curvePointInfo.y = seqInfo.y;
         curvePointInfo.y = seqInfo.y;
       }
       }
-      if (
-        curvePointInfo.hasOwnProperty("y") &&
-        !curvePointInfo.hasOwnProperty("x")
-      ) {
+      if (curvePointInfo.hasOwnProperty("y") && !curvePointInfo.hasOwnProperty("x")) {
         curvePointInfo.x = position.x;
         curvePointInfo.x = position.x;
       }
       }
-      if (
-        curvePointInfo.hasOwnProperty("x") &&
-        !curvePointInfo.hasOwnProperty("y")
-      ) {
+      if (curvePointInfo.hasOwnProperty("x") && !curvePointInfo.hasOwnProperty("y")) {
         curvePointInfo.y = position.y;
         curvePointInfo.y = position.y;
       }
       }
     }
     }
@@ -238,20 +182,12 @@ export default class ListenLayer {
     };
     };
     const curveLines = dataService.getCurveLines();
     const curveLines = dataService.getCurveLines();
     for (const curveLineId in curveLines) {
     for (const curveLineId in curveLines) {
-      if (
-        exceptCurveLineIds &&
-        (exceptCurveLineIds.hasOwnProperty(curveLineId) ||
-          exceptCurveLineIds == curveLineId)
-      ) {
+      if (exceptCurveLineIds && (exceptCurveLineIds.hasOwnProperty(curveLineId) || exceptCurveLineIds == curveLineId)) {
         continue;
         continue;
       }
       }
       const curveLine = dataService.getCurveLine(curveLineId);
       const curveLine = dataService.getCurveLine(curveLineId);
 
 
-      let joinInfo = this.distanceForBezier(
-        position,
-        curveLine.curves,
-        Constant.minAdsorbPix
-      );
+      let joinInfo = this.distanceForBezier(position, curveLine.curves, Constant.minAdsorbPix);
       //选中了路
       //选中了路
       if (joinInfo.distance < Constant.minAdsorbPix) {
       if (joinInfo.distance < Constant.minAdsorbPix) {
         curveLineInfo = {
         curveLineInfo = {
@@ -315,19 +251,11 @@ export default class ListenLayer {
           }
           }
         }
         }
       } else {
       } else {
-        if (
-          (Math.abs(position.x - point.x) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        if ((Math.abs(position.x - point.x) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedPointIdX = pointId;
           seqInfo.linkedPointIdX = pointId;
           seqInfo.x = point.x;
           seqInfo.x = point.x;
         }
         }
-        if (
-          (Math.abs(position.y - point.y) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        if ((Math.abs(position.y - point.y) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedPointIdY = pointId;
           seqInfo.linkedPointIdY = pointId;
           seqInfo.y = point.y;
           seqInfo.y = point.y;
         }
         }
@@ -380,8 +308,7 @@ export default class ListenLayer {
         line.getCategory() == VectorCategory.Line.ExtendedPositionLine ||
         line.getCategory() == VectorCategory.Line.ExtendedPositionLine ||
         line.getCategory() == VectorCategory.Line.GuideLocationLine ||
         line.getCategory() == VectorCategory.Line.GuideLocationLine ||
         line.getCategory() == VectorCategory.Line.GuidePositionLine ||
         line.getCategory() == VectorCategory.Line.GuidePositionLine ||
-        (line.getCategory() == VectorCategory.Line.PositionLine &&
-          line.getLocationMode() != Constant.angleLocationMode)
+        (line.getCategory() == VectorCategory.Line.PositionLine && line.getLocationMode() != Constant.angleLocationMode)
       ) {
       ) {
         continue;
         continue;
       }
       }
@@ -459,12 +386,7 @@ export default class ListenLayer {
       //     };
       //     };
       //   }
       //   }
       // }
       // }
-      const flag = mathUtil.isPointInElliptic(
-        position,
-        circle.center,
-        circle.radiusX,
-        circle.radiusY
-      );
+      const flag = mathUtil.isPointInElliptic(position, circle.center, circle.radiusX, circle.radiusY);
       if (flag) {
       if (flag) {
         circleInfo = {
         circleInfo = {
           circleId: circleId,
           circleId: circleId,
@@ -511,18 +433,10 @@ export default class ListenLayer {
           }
           }
         }
         }
       } else {
       } else {
-        if (
-          (Math.abs(position.x - roadPoint.x) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        if ((Math.abs(position.x - roadPoint.x) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedRoadPointIdX = roadPointId;
           seqInfo.linkedRoadPointIdX = roadPointId;
           seqInfo.x = roadPoint.x;
           seqInfo.x = roadPoint.x;
-        } else if (
-          (Math.abs(position.y - roadPoint.y) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        } else if ((Math.abs(position.y - roadPoint.y) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedRoadPointIdY = roadPointId;
           seqInfo.linkedRoadPointIdY = roadPointId;
           seqInfo.y = roadPoint.y;
           seqInfo.y = roadPoint.y;
         }
         }
@@ -545,16 +459,10 @@ export default class ListenLayer {
         roadPointInfo.y = seqInfo.y;
         roadPointInfo.y = seqInfo.y;
       }
       }
 
 
-      if (
-        roadPointInfo.hasOwnProperty("y") &&
-        !roadPointInfo.hasOwnProperty("x")
-      ) {
+      if (roadPointInfo.hasOwnProperty("y") && !roadPointInfo.hasOwnProperty("x")) {
         roadPointInfo.x = position.x;
         roadPointInfo.x = position.x;
       }
       }
-      if (
-        roadPointInfo.hasOwnProperty("x") &&
-        !roadPointInfo.hasOwnProperty("y")
-      ) {
+      if (roadPointInfo.hasOwnProperty("x") && !roadPointInfo.hasOwnProperty("y")) {
         roadPointInfo.y = position.y;
         roadPointInfo.y = position.y;
       }
       }
     }
     }
@@ -594,18 +502,10 @@ export default class ListenLayer {
           }
           }
         }
         }
       } else {
       } else {
-        if (
-          (Math.abs(position.x - curveRoadPoint.x) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        if ((Math.abs(position.x - curveRoadPoint.x) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedCurveRoadPointIdX = curveRoadPointId;
           seqInfo.linkedCurveRoadPointIdX = curveRoadPointId;
           seqInfo.x = curveRoadPoint.x;
           seqInfo.x = curveRoadPoint.x;
-        } else if (
-          (Math.abs(position.y - curveRoadPoint.y) * coordinate.zoom) /
-            coordinate.defaultZoom <
-          Constant.minAdsorbPix
-        ) {
+        } else if ((Math.abs(position.y - curveRoadPoint.y) * coordinate.zoom) / coordinate.defaultZoom < Constant.minAdsorbPix) {
           seqInfo.linkedCurveRoadPointIdY = curveRoadPointId;
           seqInfo.linkedCurveRoadPointIdY = curveRoadPointId;
           seqInfo.y = curveRoadPoint.y;
           seqInfo.y = curveRoadPoint.y;
         }
         }
@@ -613,33 +513,22 @@ export default class ListenLayer {
     }
     }
 
 
     if (curveRoadPointInfo.curveRoadPointId) {
     if (curveRoadPointInfo.curveRoadPointId) {
-      curveRoadPointInfo.linkedCurveRoadPointId =
-        curveRoadPointInfo.curveRoadPointId;
-      const linkedCurvePoint = dataService.getCurveRoadPoint(
-        curveRoadPointInfo.curveRoadPointId
-      );
+      curveRoadPointInfo.linkedCurveRoadPointId = curveRoadPointInfo.curveRoadPointId;
+      const linkedCurvePoint = dataService.getCurveRoadPoint(curveRoadPointInfo.curveRoadPointId);
       curveRoadPointInfo.x = linkedCurvePoint.x;
       curveRoadPointInfo.x = linkedCurvePoint.x;
       curveRoadPointInfo.y = linkedCurvePoint.y;
       curveRoadPointInfo.y = linkedCurvePoint.y;
     } else {
     } else {
       if (seqInfo.hasOwnProperty("linkedCurveRoadPointIdX")) {
       if (seqInfo.hasOwnProperty("linkedCurveRoadPointIdX")) {
-        curveRoadPointInfo.linkedCurveRoadPointIdX =
-          seqInfo.linkedCurveRoadPointIdX;
+        curveRoadPointInfo.linkedCurveRoadPointIdX = seqInfo.linkedCurveRoadPointIdX;
         curveRoadPointInfo.x = seqInfo.x;
         curveRoadPointInfo.x = seqInfo.x;
       } else if (seqInfo.hasOwnProperty("linkedCurveRoadPointIdY")) {
       } else if (seqInfo.hasOwnProperty("linkedCurveRoadPointIdY")) {
-        curveRoadPointInfo.linkedCurveRoadPointIdY =
-          seqInfo.linkedCurveRoadPointIdY;
+        curveRoadPointInfo.linkedCurveRoadPointIdY = seqInfo.linkedCurveRoadPointIdY;
         curveRoadPointInfo.y = seqInfo.y;
         curveRoadPointInfo.y = seqInfo.y;
       }
       }
-      if (
-        curveRoadPointInfo.hasOwnProperty("y") &&
-        !curveRoadPointInfo.hasOwnProperty("x")
-      ) {
+      if (curveRoadPointInfo.hasOwnProperty("y") && !curveRoadPointInfo.hasOwnProperty("x")) {
         curveRoadPointInfo.x = position.x;
         curveRoadPointInfo.x = position.x;
       }
       }
-      if (
-        curveRoadPointInfo.hasOwnProperty("x") &&
-        !curveRoadPointInfo.hasOwnProperty("y")
-      ) {
+      if (curveRoadPointInfo.hasOwnProperty("x") && !curveRoadPointInfo.hasOwnProperty("y")) {
         curveRoadPointInfo.y = position.y;
         curveRoadPointInfo.y = position.y;
       }
       }
     }
     }
@@ -676,25 +565,13 @@ export default class ListenLayer {
       let rightLine = mathUtil.createLine1(rightEdge.start, rightEdge.end);
       let rightLine = mathUtil.createLine1(rightEdge.start, rightEdge.end);
       let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
       let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
 
 
-      let leftSideLine = leftEdge.roadSide
-        ? mathUtil.createLine1(leftEdge.roadSide.start, leftEdge.roadSide.end)
-        : null;
-      let leftSideJoin = leftSideLine
-        ? mathUtil.getJoinLinePoint(position, leftSideLine)
-        : null;
-
-      let rightSideLine = rightEdge.roadSide
-        ? mathUtil.createLine1(rightEdge.roadSide.start, rightEdge.roadSide.end)
-        : null;
-      let rightSideJoin = rightSideLine
-        ? mathUtil.getJoinLinePoint(position, rightSideLine)
-        : null;
+      let leftSideLine = leftEdge.roadSide ? mathUtil.createLine1(leftEdge.roadSide.start, leftEdge.roadSide.end) : null;
+      let leftSideJoin = leftSideLine ? mathUtil.getJoinLinePoint(position, leftSideLine) : null;
+
+      let rightSideLine = rightEdge.roadSide ? mathUtil.createLine1(rightEdge.roadSide.start, rightEdge.roadSide.end) : null;
+      let rightSideJoin = rightSideLine ? mathUtil.getJoinLinePoint(position, rightSideLine) : null;
       let distance = this.getDistance(position, join);
       let distance = this.getDistance(position, join);
-      if (
-        mathUtil.isContainForSegment(join, startPoint, endPoint) &&
-        (mathUtil.isContainForSegment(position, join, leftJoin) ||
-          mathUtil.isContainForSegment(position, join, rightJoin))
-      ) {
+      if (mathUtil.isContainForSegment(join, startPoint, endPoint) && (mathUtil.isContainForSegment(position, join, leftJoin) || mathUtil.isContainForSegment(position, join, rightJoin))) {
         if (!roadInfo.roadId || distance < roadInfo.distance) {
         if (!roadInfo.roadId || distance < roadInfo.distance) {
           roadInfo = {
           roadInfo = {
             roadId: roadId,
             roadId: roadId,
@@ -726,11 +603,8 @@ export default class ListenLayer {
 
 
       distance = this.getDistance(position, leftJoin);
       distance = this.getDistance(position, leftJoin);
       if (
       if (
-        (mathUtil.isContainForSegment(leftJoin, leftEdge.start, leftEdge.end) &&
-          distance < Constant.minAdsorbPix / 2) ||
-        (mathUtil.isContainForSegment(join, startPoint, endPoint) &&
-          leftSideJoin &&
-          mathUtil.isContainForSegment(position, leftSideJoin, leftJoin))
+        (mathUtil.isContainForSegment(leftJoin, leftEdge.start, leftEdge.end) && distance < Constant.minAdsorbPix / 2) ||
+        (mathUtil.isContainForSegment(join, startPoint, endPoint) && leftSideJoin && mathUtil.isContainForSegment(position, leftSideJoin, leftJoin))
       ) {
       ) {
         if (!edgeInfo.edgeId || distance < edgeInfo.distance) {
         if (!edgeInfo.edgeId || distance < edgeInfo.distance) {
           edgeInfo = {
           edgeInfo = {
@@ -745,15 +619,8 @@ export default class ListenLayer {
       distance = this.getDistance(position, rightJoin);
       distance = this.getDistance(position, rightJoin);
 
 
       if (
       if (
-        (mathUtil.isContainForSegment(
-          rightJoin,
-          rightEdge.start,
-          rightEdge.end
-        ) &&
-          distance < Constant.minAdsorbPix / 2) ||
-        (mathUtil.isContainForSegment(join, startPoint, endPoint) &&
-          rightSideJoin &&
-          mathUtil.isContainForSegment(position, rightSideJoin, rightJoin))
+        (mathUtil.isContainForSegment(rightJoin, rightEdge.start, rightEdge.end) && distance < Constant.minAdsorbPix / 2) ||
+        (mathUtil.isContainForSegment(join, startPoint, endPoint) && rightSideJoin && mathUtil.isContainForSegment(position, rightSideJoin, rightJoin))
       ) {
       ) {
         if (!edgeInfo.edgeId || distance < edgeInfo.distance) {
         if (!edgeInfo.edgeId || distance < edgeInfo.distance) {
           edgeInfo = {
           edgeInfo = {
@@ -766,16 +633,10 @@ export default class ListenLayer {
       }
       }
     }
     }
 
 
-    if (
-      roadInfo.roadId &&
-      (!edgeInfo.edgeId || roadInfo.distance < edgeInfo.distance)
-    ) {
+    if (roadInfo.roadId && (!edgeInfo.edgeId || roadInfo.distance < edgeInfo.distance)) {
       const linkedRoad = dataService.getRoad(roadInfo.roadId);
       const linkedRoad = dataService.getRoad(roadInfo.roadId);
       const linkedRoadLine = roadService.getMidLine(linkedRoad);
       const linkedRoadLine = roadService.getMidLine(linkedRoad);
-      const linkedPosition = mathUtil.getJoinLinePoint(
-        position,
-        linkedRoadLine
-      );
+      const linkedPosition = mathUtil.getJoinLinePoint(position, linkedRoadLine);
 
 
       roadInfo.x = linkedPosition.x;
       roadInfo.x = linkedPosition.x;
       roadInfo.y = linkedPosition.y;
       roadInfo.y = linkedPosition.y;
@@ -839,33 +700,14 @@ export default class ListenLayer {
       console.log("isSelectCurveRoad:" + JSON.stringify(joinInfo));
       console.log("isSelectCurveRoad:" + JSON.stringify(joinInfo));
       //检查edge
       //检查edge
       const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
       const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
-      const leftJoinInfo = this.distanceForBezier(
-        position,
-        leftCurveEdge.curves,
-        Constant.minAdsorbPix
-      );
+      const leftJoinInfo = this.distanceForBezier(position, leftCurveEdge.curves, Constant.minAdsorbPix);
 
 
-      const rightCurveEdge = dataService.getCurveRoadEdge(
-        curveRoad.rightEdgeId
-      );
-      const rightJoinInfo = this.distanceForBezier(
-        position,
-        rightCurveEdge.curves,
-        Constant.minAdsorbPix
-      );
+      const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
+      const rightJoinInfo = this.distanceForBezier(position, rightCurveEdge.curves, Constant.minAdsorbPix);
 
 
-      let line1 = mathUtil.createLine1(
-        joinInfo.position,
-        leftJoinInfo.position
-      );
+      let line1 = mathUtil.createLine1(joinInfo.position, leftJoinInfo.position);
       let position1 = mathUtil.getJoinLinePoint(position, line1);
       let position1 = mathUtil.getJoinLinePoint(position, line1);
-      if (
-        mathUtil.isContainForSegment(
-          position1,
-          joinInfo.position,
-          leftJoinInfo.position
-        )
-      ) {
+      if (mathUtil.isContainForSegment(position1, joinInfo.position, leftJoinInfo.position)) {
         if (joinInfo.distance < curveRoad.leftWidth) {
         if (joinInfo.distance < curveRoad.leftWidth) {
           curveRoadInfo = {
           curveRoadInfo = {
             curveRoadId: curveRoadId,
             curveRoadId: curveRoadId,
@@ -877,19 +719,10 @@ export default class ListenLayer {
         }
         }
         curveRoadInfo.dir = "left";
         curveRoadInfo.dir = "left";
       } else {
       } else {
-        let line2 = mathUtil.createLine1(
-          joinInfo.position,
-          rightJoinInfo.position
-        );
+        let line2 = mathUtil.createLine1(joinInfo.position, rightJoinInfo.position);
 
 
         let position2 = mathUtil.getJoinLinePoint(position, line2);
         let position2 = mathUtil.getJoinLinePoint(position, line2);
-        if (
-          mathUtil.isContainForSegment(
-            position2,
-            joinInfo.position,
-            rightJoinInfo.position
-          )
-        ) {
+        if (mathUtil.isContainForSegment(position2, joinInfo.position, rightJoinInfo.position)) {
           if (joinInfo.distance < curveRoad.rightWidth) {
           if (joinInfo.distance < curveRoad.rightWidth) {
             curveRoadInfo = {
             curveRoadInfo = {
               curveRoadId: curveRoadId,
               curveRoadId: curveRoadId,
@@ -904,10 +737,7 @@ export default class ListenLayer {
       }
       }
 
 
       if (leftJoinInfo.distance < Constant.minAdsorbPix) {
       if (leftJoinInfo.distance < Constant.minAdsorbPix) {
-        const index = mathUtil.getCurvesIndexForCurvesPoints(
-          leftJoinInfo.position,
-          curveRoad.points
-        );
+        const index = mathUtil.getCurvesIndexForCurvesPoints(leftJoinInfo.position, curveRoad.points);
         curveEdgeInfo = {
         curveEdgeInfo = {
           curveEdgeId: curveRoad.leftEdgeId,
           curveEdgeId: curveRoad.leftEdgeId,
           type: VectorType.CurveRoadEdge,
           type: VectorType.CurveRoadEdge,
@@ -917,10 +747,7 @@ export default class ListenLayer {
           y: leftJoinInfo.position.y,
           y: leftJoinInfo.position.y,
         };
         };
       } else if (rightJoinInfo.distance < Constant.minAdsorbPix) {
       } else if (rightJoinInfo.distance < Constant.minAdsorbPix) {
-        const index = mathUtil.getCurvesIndexForCurvesPoints(
-          rightJoinInfo.position,
-          curveRoad.points
-        );
+        const index = mathUtil.getCurvesIndexForCurvesPoints(rightJoinInfo.position, curveRoad.points);
         curveEdgeInfo = {
         curveEdgeInfo = {
           curveEdgeId: curveRoad.rightEdgeId,
           curveEdgeId: curveRoad.rightEdgeId,
           type: VectorType.CurveRoadEdge,
           type: VectorType.CurveRoadEdge,
@@ -931,11 +758,7 @@ export default class ListenLayer {
         };
         };
       }
       }
     }
     }
-    if (
-      curveRoadInfo.curveRoadId &&
-      (!curveEdgeInfo.curveEdgeId ||
-        curveRoadInfo.distance < curveEdgeInfo.distance)
-    ) {
+    if (curveRoadInfo.curveRoadId && (!curveEdgeInfo.curveEdgeId || curveRoadInfo.distance < curveEdgeInfo.distance)) {
       // console.log("选中的CurveRoad:" + curveRoadInfo.curveRoadId);
       // console.log("选中的CurveRoad:" + curveRoadInfo.curveRoadId);
       return curveRoadInfo;
       return curveRoadInfo;
     } else if (curveEdgeInfo.curveEdgeId) {
     } else if (curveEdgeInfo.curveEdgeId) {
@@ -1020,6 +843,7 @@ export default class ListenLayer {
     };
     };
     const svgs = dataService.getSVGs();
     const svgs = dataService.getSVGs();
 
 
+    /**-----暴力做法 */
     for (const svgId in svgs) {
     for (const svgId in svgs) {
       if (svgId == exceptSVGId) {
       if (svgId == exceptSVGId) {
         continue;
         continue;
@@ -1048,22 +872,91 @@ export default class ListenLayer {
           };
           };
         }
         }
       }
       }
-      if (svgInfo.svgId) {
-        return svgInfo;
+    }
+    /**----- */
+
+    for (const svgId in svgs) {
+      if (svgId == exceptSVGId) {
+        continue;
+      }
+      const svg = dataService.getSVG(svgId);
+      let centerPoint = mathUtil.calculateCenterPoint(svg.points);
+
+      let newDistance = this.getDistance(position, centerPoint);
+      for (let i = 0; i < svg.points.length; ++i) {
+        let distance = this.getDistance(position, svg.points[i]);
+
+        // if (!svgInfo.svgId && distance < Constant.minAdsorbPix / 5) { //改大图例四个点的选择范围
+        if (!svgInfo.svgId && distance < Constant.minAdsorbPix / 2) {
+          svgInfo = {
+            svgId: svgId,
+            distance: distance,
+            newDistance: newDistance,
+            type: VectorType.SVG,
+            index: i,
+            x: position.x,
+            y: position.y,
+          };
+        } else if (svgInfo.svgId && distance < svgInfo.distance) {
+          svgInfo = {
+            svgId: svgId,
+            distance: distance,
+            newDistance: newDistance,
+            type: VectorType.SVG,
+            index: i,
+            x: position.x,
+            y: position.y,
+          };
+        }
       }
       }
+      // if (svgInfo.svgId) {
+      //   return svgInfo;
+      // }
+
       let flag = mathUtil.isPointInPoly(position, svg.points);
       let flag = mathUtil.isPointInPoly(position, svg.points);
-      if (flag) {
+      if (flag && !svgInfo.svgId) {
         svgInfo = {
         svgInfo = {
           svgId: svgId,
           svgId: svgId,
           type: VectorType.SVG,
           type: VectorType.SVG,
           x: position.x,
           x: position.x,
           y: position.y,
           y: position.y,
           index: -1,
           index: -1,
+          newDistance: newDistance,
+        };
+      } else if (flag && newDistance < svgInfo.newDistance) {
+        svgInfo = {
+          svgId: svgId,
+          type: VectorType.SVG,
+          x: position.x,
+          y: position.y,
+          index: -1,
+          newDistance: newDistance,
         };
         };
-        break;
       }
       }
+
+      // if (!svgInfo.svgId && newDistance < Constant.minAdsorbPix / 2) {
+      //   svgInfo = {
+      //     svgId: svgId,
+      //     type: VectorType.SVG,
+      //     x: position.x,
+      //     y: position.y,
+      //     index: -1,
+      //     newDistance: newDistance,
+      //   };
+      //   break;
+      // } else if (svgInfo.svgId && newDistance < svgInfo.newDistance) {
+      //   svgInfo = {
+      //     svgId: svgId,
+      //     type: VectorType.SVG,
+      //     x: position.x,
+      //     y: position.y,
+      //     index: -1,
+      //     newDistance: newDistance,
+      //   };
+      //   break;
+      // }
     }
     }
-    // console.error(svgInfo);
+
     return svgInfo;
     return svgInfo;
   }
   }
 
 
@@ -1145,10 +1038,7 @@ export default class ListenLayer {
       this.modifyPoint.index = info.circleInfo.index;
       this.modifyPoint.index = info.circleInfo.index;
       this.modifyPoint.x = info.circleInfo.x;
       this.modifyPoint.x = info.circleInfo.x;
       this.modifyPoint.y = info.circleInfo.y;
       this.modifyPoint.y = info.circleInfo.y;
-    } else if (
-      info &&
-      (info.pointInfo.pointId || info.curvePointInfo.curvePointId)
-    ) {
+    } else if (info && (info.pointInfo.pointId || info.curvePointInfo.curvePointId)) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       if (info.pointInfo.pointId && info.curvePointInfo.curvePointId) {
       if (info.pointInfo.pointId && info.curvePointInfo.curvePointId) {
         if (info.pointInfo.distance < info.curvePointInfo.distance) {
         if (info.pointInfo.distance < info.curvePointInfo.distance) {
@@ -1156,8 +1046,7 @@ export default class ListenLayer {
           this.modifyPoint.x = info.pointInfo.x;
           this.modifyPoint.x = info.pointInfo.x;
           this.modifyPoint.y = info.pointInfo.y;
           this.modifyPoint.y = info.pointInfo.y;
         } else {
         } else {
-          this.modifyPoint.linkedCurvePointId =
-            info.curvePointInfo.curvePointId;
+          this.modifyPoint.linkedCurvePointId = info.curvePointInfo.curvePointId;
           this.modifyPoint.x = info.curvePointInfo.x;
           this.modifyPoint.x = info.curvePointInfo.x;
           this.modifyPoint.y = info.curvePointInfo.y;
           this.modifyPoint.y = info.curvePointInfo.y;
         }
         }
@@ -1170,10 +1059,7 @@ export default class ListenLayer {
         this.modifyPoint.x = info.curvePointInfo.x;
         this.modifyPoint.x = info.curvePointInfo.x;
         this.modifyPoint.y = info.curvePointInfo.y;
         this.modifyPoint.y = info.curvePointInfo.y;
       }
       }
-    } else if (
-      info &&
-      (info.lineInfo.lineId || info.curveLineInfo.curveLineId)
-    ) {
+    } else if (info && (info.lineInfo.lineId || info.curveLineInfo.curveLineId)) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       if (info.lineInfo.lineId && info.curveLineInfo.curveLineId) {
       if (info.lineInfo.lineId && info.curveLineInfo.curveLineId) {
         if (info.lineInfo.distance < info.curveLineInfo.distance) {
         if (info.lineInfo.distance < info.curveLineInfo.distance) {
@@ -1200,22 +1086,14 @@ export default class ListenLayer {
       this.modifyPoint.index = info.svgInfo.index;
       this.modifyPoint.index = info.svgInfo.index;
       this.modifyPoint.x = info.svgInfo.x;
       this.modifyPoint.x = info.svgInfo.x;
       this.modifyPoint.y = info.svgInfo.y;
       this.modifyPoint.y = info.svgInfo.y;
-    } else if (
-      info &&
-      (info.roadPointInfo.roadPointId ||
-        info.curveRoadPointInfo.curveRoadPointId)
-    ) {
-      if (
-        info.roadPointInfo.roadPointId &&
-        info.curveRoadPointInfo.curveRoadPointId
-      ) {
+    } else if (info && (info.roadPointInfo.roadPointId || info.curveRoadPointInfo.curveRoadPointId)) {
+      if (info.roadPointInfo.roadPointId && info.curveRoadPointInfo.curveRoadPointId) {
         if (info.roadPointInfo.distance < info.curveRoadPointInfo.distance) {
         if (info.roadPointInfo.distance < info.curveRoadPointInfo.distance) {
           this.modifyPoint.linkedRoadPointId = info.roadPointInfo.roadPointId;
           this.modifyPoint.linkedRoadPointId = info.roadPointInfo.roadPointId;
           this.modifyPoint.x = info.roadPointInfo.x;
           this.modifyPoint.x = info.roadPointInfo.x;
           this.modifyPoint.y = info.roadPointInfo.y;
           this.modifyPoint.y = info.roadPointInfo.y;
         } else {
         } else {
-          this.modifyPoint.linkedCurveRoadPointId =
-            info.curveRoadPointInfo.curveRoadPointId;
+          this.modifyPoint.linkedCurveRoadPointId = info.curveRoadPointInfo.curveRoadPointId;
           this.modifyPoint.x = info.curveRoadPointInfo.x;
           this.modifyPoint.x = info.curveRoadPointInfo.x;
           this.modifyPoint.y = info.curveRoadPointInfo.y;
           this.modifyPoint.y = info.curveRoadPointInfo.y;
         }
         }
@@ -1224,15 +1102,11 @@ export default class ListenLayer {
         this.modifyPoint.x = info.roadPointInfo.x;
         this.modifyPoint.x = info.roadPointInfo.x;
         this.modifyPoint.y = info.roadPointInfo.y;
         this.modifyPoint.y = info.roadPointInfo.y;
       } else if (info.curveRoadPointInfo.curveRoadPointId) {
       } else if (info.curveRoadPointInfo.curveRoadPointId) {
-        this.modifyPoint.linkedCurveRoadPointId =
-          info.curveRoadPointInfo.curveRoadPointId;
+        this.modifyPoint.linkedCurveRoadPointId = info.curveRoadPointInfo.curveRoadPointId;
         this.modifyPoint.x = info.curveRoadPointInfo.x;
         this.modifyPoint.x = info.curveRoadPointInfo.x;
         this.modifyPoint.y = info.curveRoadPointInfo.y;
         this.modifyPoint.y = info.curveRoadPointInfo.y;
       }
       }
-    } else if (
-      info &&
-      (info.roadEdgeInfo.roadId || info.curveRoadEdgeInfo.curveRoadId)
-    ) {
+    } else if (info && (info.roadEdgeInfo.roadId || info.curveRoadEdgeInfo.curveRoadId)) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       if (info.roadEdgeInfo.roadId && info.curveRoadEdgeInfo.curveRoadId) {
       if (info.roadEdgeInfo.roadId && info.curveRoadEdgeInfo.curveRoadId) {
         if (roadEdgeInfo.distance < info.curveRoadEdgeInfo.distance) {
         if (roadEdgeInfo.distance < info.curveRoadEdgeInfo.distance) {
@@ -1257,10 +1131,7 @@ export default class ListenLayer {
         this.modifyPoint.y = info.curveRoadEdgeInfo.y;
         this.modifyPoint.y = info.curveRoadEdgeInfo.y;
         this.modifyPoint.dir = info.curveRoadEdgeInfo.dir;
         this.modifyPoint.dir = info.curveRoadEdgeInfo.dir;
       }
       }
-    } else if (
-      info &&
-      (info.roadEdgeInfo.edgeId || info.curveRoadEdgeInfo.curveEdgeId)
-    ) {
+    } else if (info && (info.roadEdgeInfo.edgeId || info.curveRoadEdgeInfo.curveEdgeId)) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       if (info.roadEdgeInfo.edgeId && info.curveRoadEdgeInfo.curveEdgeId) {
       if (info.roadEdgeInfo.edgeId && info.curveRoadEdgeInfo.curveEdgeId) {
         if (info.roadEdgeInfo.distance < info.curveRoadEdgeInfo.distance) {
         if (info.roadEdgeInfo.distance < info.curveRoadEdgeInfo.distance) {
@@ -1268,8 +1139,7 @@ export default class ListenLayer {
           this.modifyPoint.x = info.roadEdgeInfo.x;
           this.modifyPoint.x = info.roadEdgeInfo.x;
           this.modifyPoint.y = info.roadEdgeInfo.y;
           this.modifyPoint.y = info.roadEdgeInfo.y;
         } else {
         } else {
-          this.modifyPoint.linkedCurveEdgeId =
-            info.curveRoadEdgeInfo.curveEdgeId;
+          this.modifyPoint.linkedCurveEdgeId = info.curveRoadEdgeInfo.curveEdgeId;
           this.modifyPoint.selectIndex = info.curveRoadEdgeInfo.selectIndex;
           this.modifyPoint.selectIndex = info.curveRoadEdgeInfo.selectIndex;
           this.modifyPoint.x = info.curveRoadEdgeInfo.x;
           this.modifyPoint.x = info.curveRoadEdgeInfo.x;
           this.modifyPoint.y = info.curveRoadEdgeInfo.y;
           this.modifyPoint.y = info.curveRoadEdgeInfo.y;
@@ -1286,57 +1156,40 @@ export default class ListenLayer {
       }
       }
     } else if (info && info.crossPointInfo.crossCrossPointId) {
     } else if (info && info.crossPointInfo.crossCrossPointId) {
       this.modifyPoint = {};
       this.modifyPoint = {};
-      this.modifyPoint.linkedCrossCrossPointId =
-        info.crossPointInfo.crossCrossPointId;
+      this.modifyPoint.linkedCrossCrossPointId = info.crossPointInfo.crossCrossPointId;
       this.modifyPoint.x = info.crossPointInfo.x;
       this.modifyPoint.x = info.crossPointInfo.x;
       this.modifyPoint.y = info.crossPointInfo.y;
       this.modifyPoint.y = info.crossPointInfo.y;
     } else if (info && info.roadPointInfo.linkedRoadPointIdX) {
     } else if (info && info.roadPointInfo.linkedRoadPointIdX) {
       this.modifyPoint = {};
       this.modifyPoint = {};
-      this.modifyPoint.linkedRoadPointIdX =
-        info.roadPointInfo.linkedRoadPointIdX;
+      this.modifyPoint.linkedRoadPointIdX = info.roadPointInfo.linkedRoadPointIdX;
       this.modifyPoint.x = info.roadPointInfo.x;
       this.modifyPoint.x = info.roadPointInfo.x;
       this.modifyPoint.y = info.roadPointInfo.y;
       this.modifyPoint.y = info.roadPointInfo.y;
     } else if (info && info.roadPointInfo.linkedRoadPointIdY) {
     } else if (info && info.roadPointInfo.linkedRoadPointIdY) {
       this.modifyPoint = {};
       this.modifyPoint = {};
-      this.modifyPoint.linkedRoadPointIdY =
-        info.roadPointInfo.linkedRoadPointIdY;
+      this.modifyPoint.linkedRoadPointIdY = info.roadPointInfo.linkedRoadPointIdY;
       this.modifyPoint.y = info.roadPointInfo.y;
       this.modifyPoint.y = info.roadPointInfo.y;
       this.modifyPoint.x = info.roadPointInfo.x;
       this.modifyPoint.x = info.roadPointInfo.x;
     } else if (info && info.curvePointInfo.linkedRoadPointIdX) {
     } else if (info && info.curvePointInfo.linkedRoadPointIdX) {
       this.modifyPoint = {};
       this.modifyPoint = {};
-      this.modifyPoint.linkedRoadPointIdX =
-        info.curvePointInfo.linkedRoadPointIdX;
+      this.modifyPoint.linkedRoadPointIdX = info.curvePointInfo.linkedRoadPointIdX;
       this.modifyPoint.x = info.curvePointInfo.x;
       this.modifyPoint.x = info.curvePointInfo.x;
       this.modifyPoint.y = position.y;
       this.modifyPoint.y = position.y;
     } else if (info && info.curvePointInfo.linkedRoadPointIdY) {
     } else if (info && info.curvePointInfo.linkedRoadPointIdY) {
       this.modifyPoint = {};
       this.modifyPoint = {};
-      this.modifyPoint.linkedRoadPointIdY =
-        info.curvePointInfo.linkedRoadPointIdY;
+      this.modifyPoint.linkedRoadPointIdY = info.curvePointInfo.linkedRoadPointIdY;
       this.modifyPoint.y = info.curvePointInfo.y;
       this.modifyPoint.y = info.curvePointInfo.y;
       this.modifyPoint.x = position.x;
       this.modifyPoint.x = position.x;
-    } else if (
-      info &&
-      info.pointInfo.linkedPointIdX &&
-      !info.pointInfo.linkedPointIdY
-    ) {
+    } else if (info && info.pointInfo.linkedPointIdX && !info.pointInfo.linkedPointIdY) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       this.modifyPoint.linkedPointIdX = info.pointInfo.linkedPointIdX;
       this.modifyPoint.linkedPointIdX = info.pointInfo.linkedPointIdX;
       this.modifyPoint.x = info.pointInfo.x;
       this.modifyPoint.x = info.pointInfo.x;
       this.modifyPoint.y = info.pointInfo.y;
       this.modifyPoint.y = info.pointInfo.y;
-    } else if (
-      info &&
-      info.pointInfo.linkedPointIdY &&
-      !info.pointInfo.linkedPointIdX
-    ) {
+    } else if (info && info.pointInfo.linkedPointIdY && !info.pointInfo.linkedPointIdX) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       this.modifyPoint.linkedPointIdY = info.pointInfo.linkedPointIdY;
       this.modifyPoint.linkedPointIdY = info.pointInfo.linkedPointIdY;
       this.modifyPoint.y = info.pointInfo.y;
       this.modifyPoint.y = info.pointInfo.y;
       this.modifyPoint.x = info.pointInfo.x;
       this.modifyPoint.x = info.pointInfo.x;
-    } else if (
-      info &&
-      info.pointInfo.linkedPointIdY &&
-      info.pointInfo.linkedPointIdX
-    ) {
+    } else if (info && info.pointInfo.linkedPointIdY && info.pointInfo.linkedPointIdX) {
       this.modifyPoint = {};
       this.modifyPoint = {};
       this.modifyPoint.linkedPointIdX = info.pointInfo.linkedPointIdX;
       this.modifyPoint.linkedPointIdX = info.pointInfo.linkedPointIdX;
       this.modifyPoint.linkedPointIdY = info.pointInfo.linkedPointIdY;
       this.modifyPoint.linkedPointIdY = info.pointInfo.linkedPointIdY;
@@ -1357,103 +1210,40 @@ export default class ListenLayer {
         return false;
         return false;
       }
       }
     } else if (this.modifyPoint.linkedRoadPointId) {
     } else if (this.modifyPoint.linkedRoadPointId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedRoadPointId,
-        VectorType.RoadPoint,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedRoadPointId, VectorType.RoadPoint, SelectState.Select);
     } else if (this.modifyPoint.linkedCurveRoadPointId) {
     } else if (this.modifyPoint.linkedCurveRoadPointId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCurveRoadPointId,
-        VectorType.CurveRoadPoint,
-        SelectState.Select,
-        this.modifyPoint.dir
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCurveRoadPointId, VectorType.CurveRoadPoint, SelectState.Select, this.modifyPoint.dir);
     } else if (this.modifyPoint.linkedRoadId) {
     } else if (this.modifyPoint.linkedRoadId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedRoadId,
-        VectorType.Road,
-        SelectState.Select,
-        this.modifyPoint.dir
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedRoadId, VectorType.Road, SelectState.Select, this.modifyPoint.dir);
     } else if (this.modifyPoint.linkedCurveRoadId) {
     } else if (this.modifyPoint.linkedCurveRoadId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCurveRoadId,
-        VectorType.CurveRoad,
-        SelectState.Select,
-        this.modifyPoint.dir
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCurveRoadId, VectorType.CurveRoad, SelectState.Select, this.modifyPoint.dir);
     } else if (this.modifyPoint.linkedCrossCrossPointId) {
     } else if (this.modifyPoint.linkedCrossCrossPointId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCrossCrossPointId,
-        VectorType.CrossPoint,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCrossCrossPointId, VectorType.CrossPoint, SelectState.Select);
     } else if (this.modifyPoint.textId) {
     } else if (this.modifyPoint.textId) {
-      stateService.setSelectItem(
-        this.modifyPoint.textId,
-        VectorType.Text,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.textId, VectorType.Text, SelectState.Select);
     } else if (this.modifyPoint.magnifierId) {
     } else if (this.modifyPoint.magnifierId) {
       // if (this.modifyPoint.index == 0) {
       // if (this.modifyPoint.index == 0) {
       //点击隐藏的放大镜不显示
       //点击隐藏的放大镜不显示
-      stateService.setSelectItem(
-        this.modifyPoint.magnifierId,
-        VectorType.Magnifier,
-        this.modifyPoint.index
-      );
+      stateService.setSelectItem(this.modifyPoint.magnifierId, VectorType.Magnifier, this.modifyPoint.index);
       // } else {
       // } else {
       stateService.setSelectState(this.modifyPoint.index);
       stateService.setSelectState(this.modifyPoint.index);
       // }
       // }
     } else if (this.modifyPoint.svgId) {
     } else if (this.modifyPoint.svgId) {
-      stateService.setSelectItem(
-        this.modifyPoint.svgId,
-        VectorType.SVG,
-        this.modifyPoint.index
-      );
+      stateService.setSelectItem(this.modifyPoint.svgId, VectorType.SVG, this.modifyPoint.index);
     } else if (this.modifyPoint.linkedEdgeId) {
     } else if (this.modifyPoint.linkedEdgeId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedEdgeId,
-        VectorType.RoadEdge,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedEdgeId, VectorType.RoadEdge, SelectState.Select);
     } else if (this.modifyPoint.linkedCurveEdgeId) {
     } else if (this.modifyPoint.linkedCurveEdgeId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCurveEdgeId,
-        VectorType.CurveRoadEdge,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCurveEdgeId, VectorType.CurveRoadEdge, SelectState.Select);
     } else if (this.modifyPoint.linkedPointId) {
     } else if (this.modifyPoint.linkedPointId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedPointId,
-        VectorType.Point,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedPointId, VectorType.Point, SelectState.Select);
     } else if (this.modifyPoint.linkedCurvePointId) {
     } else if (this.modifyPoint.linkedCurvePointId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCurvePointId,
-        VectorType.CurvePoint,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCurvePointId, VectorType.CurvePoint, SelectState.Select);
     } else if (this.modifyPoint.linkedLineId) {
     } else if (this.modifyPoint.linkedLineId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedLineId,
-        VectorType.Line,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedLineId, VectorType.Line, SelectState.Select);
     } else if (this.modifyPoint.linkedCurveLineId) {
     } else if (this.modifyPoint.linkedCurveLineId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCurveLineId,
-        VectorType.CurveLine,
-        SelectState.Select
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCurveLineId, VectorType.CurveLine, SelectState.Select);
     } else if (this.modifyPoint.linkedCircleId) {
     } else if (this.modifyPoint.linkedCircleId) {
-      stateService.setSelectItem(
-        this.modifyPoint.linkedCircleId,
-        VectorType.Circle,
-        this.modifyPoint.index
-      );
+      stateService.setSelectItem(this.modifyPoint.linkedCircleId, VectorType.Circle, this.modifyPoint.index);
     } else {
     } else {
       stateService.clearSelectItem();
       stateService.clearSelectItem();
     }
     }
@@ -1491,10 +1281,7 @@ export default class ListenLayer {
 
 
   //调整到与像素的长度一致
   //调整到与像素的长度一致
   getDistance(start, end) {
   getDistance(start, end) {
-    return (
-      (mathUtil.getDistance(start, end) * coordinate.zoom) /
-      coordinate.defaultZoom
-    );
+    return (mathUtil.getDistance(start, end) * coordinate.zoom) / coordinate.defaultZoom;
   }
   }
 
 
   clear() {
   clear() {

+ 9 - 6
src/graphic/Service/SVGService.js

@@ -1,7 +1,7 @@
-import SVG from '../Geometry/SVG.js';
-import { dataService } from './DataService.js';
-import { mathUtil } from '../Util/MathUtil.js';
-import { uiService } from './UIService.js';
+import SVG from "../Geometry/SVG.js";
+import { dataService } from "./DataService.js";
+import { mathUtil } from "../Util/MathUtil.js";
+import { uiService } from "./UIService.js";
 import LayerEvents from "../enum/LayerEvents.js";
 import LayerEvents from "../enum/LayerEvents.js";
 import { addLine } from "../Controls/AddLine";
 import { addLine } from "../Controls/AddLine";
 export default class SVGService {
 export default class SVGService {
@@ -14,8 +14,11 @@ export default class SVGService {
   }
   }
   copy(vectorId) {
   copy(vectorId) {
     let SVG = dataService.getSVG(vectorId);
     let SVG = dataService.getSVG(vectorId);
-    let newCenter = uiService.getNewPositionForPop(SVG.center);
-    let newSVG = this.create(newCenter, SVG.type);
+    // let newCenter = uiService.getNewPositionForPop(SVG.center);
+    //为了罗敏的需求改动,要求复制出来的svg不重叠
+    let center = { x: SVG.center.x + 100 * SVG.scale, y: SVG.center.y - 100 * SVG.scale };
+    // let newSVG = this.create(newCenter, SVG.type);
+    let newSVG = this.create(center, SVG.type);
     newSVG.setScale(SVG.scale);
     newSVG.setScale(SVG.scale);
     for (let i = 0; i < SVG.points.length; ++i) {
     for (let i = 0; i < SVG.points.length; ++i) {
       let dx = SVG.points[i].x - SVG.center.x;
       let dx = SVG.points[i].x - SVG.center.x;

+ 80 - 248
src/graphic/Util/MathUtil.js

@@ -32,8 +32,7 @@ export default class MathUtil {
     }
     }
 
 
     const parametera = (point1.y - point2.y) / (point1.x - point2.x);
     const parametera = (point1.y - point2.y) / (point1.x - point2.x);
-    const parameterb =
-      (point1.x * point2.y - point2.x * point1.y) / (point1.x - point2.x);
+    const parameterb = (point1.x * point2.y - point2.x * point1.y) / (point1.x - point2.x);
     if (this.getFixed(parametera) == 0) {
     if (this.getFixed(parametera) == 0) {
       return { y: this.getFixed(parameterb) };
       return { y: this.getFixed(parameterb) };
     }
     }
@@ -82,10 +81,7 @@ export default class MathUtil {
     var perpendicularVector = { x: -slope, y: 1 };
     var perpendicularVector = { x: -slope, y: 1 };
 
 
     // 将垂直向量归一化为单位向量
     // 将垂直向量归一化为单位向量
-    var length = Math.sqrt(
-      perpendicularVector.x * perpendicularVector.x +
-        perpendicularVector.y * perpendicularVector.y
-    );
+    var length = Math.sqrt(perpendicularVector.x * perpendicularVector.x + perpendicularVector.y * perpendicularVector.y);
     perpendicularVector.x /= length;
     perpendicularVector.x /= length;
     perpendicularVector.y /= length;
     perpendicularVector.y /= length;
 
 
@@ -113,9 +109,7 @@ export default class MathUtil {
   }
   }
 
 
   distanceForPoints(point1, point2) {
   distanceForPoints(point1, point2) {
-    return Math.sqrt(
-      Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2)
-    );
+    return Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2));
   }
   }
 
 
   //与line平行且两条线直接的距离是distance的两条线
   //与line平行且两条线直接的距离是distance的两条线
@@ -206,10 +200,7 @@ export default class MathUtil {
     if (angle > 180) {
     if (angle > 180) {
       angle = 360 - angle;
       angle = 360 - angle;
     }
     }
-    if (
-      Math.abs((angle1 + angle3) / 2 - angle) <
-      Math.abs((angle2 + angle4) / 2 - angle)
-    ) {
+    if (Math.abs((angle1 + angle3) / 2 - angle) < Math.abs((angle2 + angle4) / 2 - angle)) {
       return { p1: point1, p2: point3 };
       return { p1: point1, p2: point3 };
     } else {
     } else {
       return { p1: point2, p2: point4 };
       return { p1: point2, p2: point4 };
@@ -247,10 +238,7 @@ export default class MathUtil {
     if (this.isParallel(parameter1, parameter2)) {
     if (this.isParallel(parameter1, parameter2)) {
       return null;
       return null;
     }
     }
-    if (
-      typeof parameter1.a == "undefined" &&
-      typeof parameter2.a != "undefined"
-    ) {
+    if (typeof parameter1.a == "undefined" && typeof parameter2.a != "undefined") {
       if (parameter1.x) {
       if (parameter1.x) {
         return {
         return {
           x: parameter1.x,
           x: parameter1.x,
@@ -262,10 +250,7 @@ export default class MathUtil {
           y: parameter1.y,
           y: parameter1.y,
         };
         };
       }
       }
-    } else if (
-      typeof parameter2.a == "undefined" &&
-      typeof parameter1.a != "undefined"
-    ) {
+    } else if (typeof parameter2.a == "undefined" && typeof parameter1.a != "undefined") {
       if (parameter2.x) {
       if (parameter2.x) {
         return {
         return {
           x: parameter2.x,
           x: parameter2.x,
@@ -277,16 +262,10 @@ export default class MathUtil {
           y: parameter2.y,
           y: parameter2.y,
         };
         };
       }
       }
-    } else if (
-      typeof parameter2.a == "undefined" &&
-      typeof parameter1.a == "undefined"
-    ) {
+    } else if (typeof parameter2.a == "undefined" && typeof parameter1.a == "undefined") {
       if (parameter1.hasOwnProperty("x") && parameter2.hasOwnProperty("y")) {
       if (parameter1.hasOwnProperty("x") && parameter2.hasOwnProperty("y")) {
         return { x: parameter1.x, y: parameter2.y };
         return { x: parameter1.x, y: parameter2.y };
-      } else if (
-        parameter1.hasOwnProperty("y") &&
-        parameter2.hasOwnProperty("x")
-      ) {
+      } else if (parameter1.hasOwnProperty("y") && parameter2.hasOwnProperty("x")) {
         return { x: parameter2.x, y: parameter1.y };
         return { x: parameter2.x, y: parameter1.y };
       } else {
       } else {
         return null;
         return null;
@@ -297,11 +276,8 @@ export default class MathUtil {
       return null;
       return null;
     }
     }
 
 
-    let joinpointx =
-      (parameter2.b - parameter1.b) / (parameter1.a - parameter2.a);
-    let joinpointy =
-      (parameter1.a * parameter2.b - parameter2.a * parameter1.b) /
-      (parameter1.a - parameter2.a);
+    let joinpointx = (parameter2.b - parameter1.b) / (parameter1.a - parameter2.a);
+    let joinpointy = (parameter1.a * parameter2.b - parameter2.a * parameter1.b) / (parameter1.a - parameter2.a);
 
 
     let point = { x: joinpointx, y: joinpointy };
     let point = { x: joinpointx, y: joinpointy };
     return point;
     return point;
@@ -318,17 +294,8 @@ export default class MathUtil {
     }
     }
 
 
     // 线段所在直线的交点坐标 (x , y)
     // 线段所在直线的交点坐标 (x , y)
-    const x =
-      ((b.x - a.x) * (d.x - c.x) * (c.y - a.y) +
-        (b.y - a.y) * (d.x - c.x) * a.x -
-        (d.y - c.y) * (b.x - a.x) * c.x) /
-      denominator;
-    const y =
-      -(
-        (b.y - a.y) * (d.y - c.y) * (c.x - a.x) +
-        (b.x - a.x) * (d.y - c.y) * a.y -
-        (d.x - c.x) * (b.y - a.y) * c.y
-      ) / denominator;
+    const x = ((b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x) / denominator;
+    const y = -((b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y) / denominator;
 
 
     return { x: x, y: y };
     return { x: x, y: y };
   }
   }
@@ -340,12 +307,7 @@ export default class MathUtil {
       const x = join.x;
       const x = join.x;
       const y = join.y; // 交点在线段1上 且交点也在线段2上
       const y = join.y; // 交点在线段1上 且交点也在线段2上
       /** 2 判断交点是否在两条线段上 **/
       /** 2 判断交点是否在两条线段上 **/
-      if (
-        (x - a.x) * (x - b.x) <= 0.001 &&
-        (y - a.y) * (y - b.y) <= 0.001 &&
-        (x - c.x) * (x - d.x) <= 0.001 &&
-        (y - c.y) * (y - d.y) <= 0.001
-      ) {
+      if ((x - a.x) * (x - b.x) <= 0.001 && (y - a.y) * (y - b.y) <= 0.001 && (x - c.x) * (x - d.x) <= 0.001 && (y - c.y) * (y - d.y) <= 0.001) {
         // 返回交点p
         // 返回交点p
         return {
         return {
           x: x,
           x: x,
@@ -515,8 +477,7 @@ export default class MathUtil {
     if (!minDis) {
     if (!minDis) {
       minDis = Constant.minLen;
       minDis = Constant.minLen;
     }
     }
-    let dis1 =
-      this.getDistance(startPoint, point) + this.getDistance(endPoint, point);
+    let dis1 = this.getDistance(startPoint, point) + this.getDistance(endPoint, point);
     let dis2 = this.getDistance(startPoint, endPoint);
     let dis2 = this.getDistance(startPoint, endPoint);
     if (Math.abs(dis1 - dis2) < minDis) {
     if (Math.abs(dis1 - dis2) < minDis) {
       return true;
       return true;
@@ -584,8 +545,7 @@ export default class MathUtil {
       const xj = pt2.x;
       const xj = pt2.x;
       const yj = pt2.y;
       const yj = pt2.y;
 
 
-      const intersect =
-        yi > y != yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
+      const intersect = yi > y != yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi;
       if (intersect) inside = !inside;
       if (intersect) inside = !inside;
     }
     }
 
 
@@ -594,9 +554,7 @@ export default class MathUtil {
 
 
   //a表示横轴,b表示竖轴
   //a表示横轴,b表示竖轴
   isPointInElliptic(point, center, a, b) {
   isPointInElliptic(point, center, a, b) {
-    let r =
-      Math.pow((point.x - center.x) / a, 2) +
-      Math.pow((point.y - center.y) / b, 2);
+    let r = Math.pow((point.x - center.x) / a, 2) + Math.pow((point.y - center.y) / b, 2);
 
 
     if (r <= 1) {
     if (r <= 1) {
       return true;
       return true;
@@ -614,10 +572,7 @@ export default class MathUtil {
     const dis = this.getDistance(point1, point2);
     const dis = this.getDistance(point1, point2);
     const dis1 = this.getDistance(join, point1);
     const dis1 = this.getDistance(join, point1);
     const dis2 = this.getDistance(join, point2);
     const dis2 = this.getDistance(join, point2);
-    if (
-      this.getDistance(join, point1) > dis ||
-      this.getDistance(join, point2) > dis
-    ) {
+    if (this.getDistance(join, point1) > dis || this.getDistance(join, point2) > dis) {
       // 在线段外
       // 在线段外
       if (dis1 < dis2 && dis1 < minDistance) {
       if (dis1 < dis2 && dis1 < minDistance) {
         return { type: 1, join: point1 };
         return { type: 1, join: point1 };
@@ -638,10 +593,7 @@ export default class MathUtil {
   }
   }
 
 
   PointInSegment(Q, pi, pj, minDis) {
   PointInSegment(Q, pi, pj, minDis) {
-    if (
-      this.getDistance(Q, pi) < Constant.minAdsorbPix ||
-      this.getDistance(Q, pj) < Constant.minAdsorbPix
-    ) {
+    if (this.getDistance(Q, pi) < Constant.minAdsorbPix || this.getDistance(Q, pj) < Constant.minAdsorbPix) {
       return true;
       return true;
     }
     }
 
 
@@ -696,11 +648,7 @@ export default class MathUtil {
     const dot_product_AP = AP.x * AB_direction.x + AP.y * AB_direction.y;
     const dot_product_AP = AP.x * AB_direction.x + AP.y * AB_direction.y;
     const dot_product_BP = BP.x * AB_direction.x + BP.y * AB_direction.y;
     const dot_product_BP = BP.x * AB_direction.x + BP.y * AB_direction.y;
     //return dot_product_AP >= 0 && dot_product_BP <= 0 && Math.abs(AP.x * BP.y - AP.y * BP.x) <= AB_length * Number.EPSILON;
     //return dot_product_AP >= 0 && dot_product_BP <= 0 && Math.abs(AP.x * BP.y - AP.y * BP.x) <= AB_length * Number.EPSILON;
-    return (
-      dot_product_AP >= 0 &&
-      dot_product_BP <= 0 &&
-      Math.abs(AP.x * BP.y - AP.y * BP.x) <= 0.01
-    );
+    return dot_product_AP >= 0 && dot_product_BP <= 0 && Math.abs(AP.x * BP.y - AP.y * BP.x) <= 0.01;
   }
   }
 
 
   clonePoint(p1, p2) {
   clonePoint(p1, p2) {
@@ -759,12 +707,7 @@ export default class MathUtil {
     }
     }
     const join = this.getIntersectionPoint2(point1, point2, point3, point4);
     const join = this.getIntersectionPoint2(point1, point2, point3, point4);
     if (join != null) {
     if (join != null) {
-      if (
-        this.getDistance(point1, join) > dis &&
-        this.getDistance(point2, join) > dis &&
-        this.getDistance(point3, join) > dis &&
-        this.getDistance(point4, join) > dis
-      ) {
+      if (this.getDistance(point1, join) > dis && this.getDistance(point2, join) > dis && this.getDistance(point3, join) > dis && this.getDistance(point4, join) > dis) {
         if (
         if (
           this.getDistance(point1, join) < this.getDistance(point1, point2) &&
           this.getDistance(point1, join) < this.getDistance(point1, point2) &&
           this.getDistance(point2, join) < this.getDistance(point1, point2) &&
           this.getDistance(point2, join) < this.getDistance(point1, point2) &&
@@ -777,10 +720,7 @@ export default class MathUtil {
         }
         }
       }
       }
     } else {
     } else {
-      if (
-        this.PointInSegment(point1, point3, point4) ||
-        this.PointInSegment(point2, point3, point4)
-      ) {
+      if (this.PointInSegment(point1, point3, point4) || this.PointInSegment(point2, point3, point4)) {
         return true;
         return true;
       }
       }
     }
     }
@@ -886,8 +826,7 @@ export default class MathUtil {
       return 0;
       return 0;
     }
     }
     let s = points[0].y * (points[point_num - 1].x - points[1].x);
     let s = points[0].y * (points[point_num - 1].x - points[1].x);
-    for (let i = 1; i < point_num; ++i)
-      s += points[i].y * (points[i - 1].x - points[(i + 1) % point_num].x);
+    for (let i = 1; i < point_num; ++i) s += points[i].y * (points[i - 1].x - points[(i + 1) % point_num].x);
     return Math.abs(s / 2.0);
     return Math.abs(s / 2.0);
   }
   }
 
 
@@ -895,13 +834,7 @@ export default class MathUtil {
   getPolygonCore(points) {
   getPolygonCore(points) {
     function Area(p0, p1, p2) {
     function Area(p0, p1, p2) {
       let area = 0.0;
       let area = 0.0;
-      area =
-        p0.x * p1.y +
-        p1.x * p2.y +
-        p2.x * p0.y -
-        p1.x * p0.y -
-        p2.x * p1.y -
-        p0.x * p2.y;
+      area = p0.x * p1.y + p1.x * p2.y + p2.x * p0.y - p1.x * p0.y - p2.x * p1.y - p0.x * p2.y;
       return area / 2;
       return area / 2;
     }
     }
 
 
@@ -1369,15 +1302,9 @@ export default class MathUtil {
 
 
     let delta;
     let delta;
     if (v > 1) {
     if (v > 1) {
-      delta = this.pointMinus(
-        p1,
-        this.pointPlus(pt, this.pointScale(this.pointMinus(p2, pt), 1 / v))
-      );
+      delta = this.pointMinus(p1, this.pointPlus(pt, this.pointScale(this.pointMinus(p2, pt), 1 / v)));
     } else {
     } else {
-      delta = this.pointMinus(
-        this.pointPlus(pt, this.pointScale(this.pointMinus(p1, pt), v)),
-        p2
-      );
+      delta = this.pointMinus(this.pointPlus(pt, this.pointScale(this.pointMinus(p1, pt), v)), p2);
     }
     }
     delta = this.pointScale(delta, scale);
     delta = this.pointScale(delta, scale);
 
 
@@ -1396,12 +1323,7 @@ export default class MathUtil {
     const curves = [];
     const curves = [];
     let preControl1, preControl2;
     let preControl1, preControl2;
     for (let i = 0; i < points.length - 2; i++) {
     for (let i = 0; i < points.length - 2; i++) {
-      const { control1, control2 } = this.getCurvesControls(
-        points[i],
-        points[i + 1],
-        points[i + 2],
-        scale
-      );
+      const { control1, control2 } = this.getCurvesControls(points[i], points[i + 1], points[i + 2], scale);
 
 
       curves.push({
       curves.push({
         start: points[i],
         start: points[i],
@@ -1464,9 +1386,7 @@ export default class MathUtil {
       const xs1 = m1 < 0 ? -1 : 1;
       const xs1 = m1 < 0 ? -1 : 1;
       const xs2 = m2 < 0 ? -1 : 1;
       const xs2 = m2 < 0 ? -1 : 1;
 
 
-      t1 =
-        (-b - (m1 * xs1) ** (1 / 3) * xs1 - (m2 * xs2) ** (1 / 3) * xs2) /
-        (3 * a);
+      t1 = (-b - (m1 * xs1) ** (1 / 3) * xs1 - (m2 * xs2) ** (1 / 3) * xs2) / (3 * a);
       // 涉及虚数,可不考虑。i ** 2 = -1
       // 涉及虚数,可不考虑。i ** 2 = -1
     }
     }
 
 
@@ -1485,16 +1405,8 @@ export default class MathUtil {
 
 
       if (A > 0 && T < 1 && T > -1) {
       if (A > 0 && T < 1 && T > -1) {
         t1 = (-b - 2 * A ** (1 / 2) * Math.cos(theta / 3)) / (3 * a);
         t1 = (-b - 2 * A ** (1 / 2) * Math.cos(theta / 3)) / (3 * a);
-        t2 =
-          (-b +
-            A ** (1 / 2) *
-              (Math.cos(theta / 3) + 3 ** (1 / 2) * Math.sin(theta / 3))) /
-          (3 * a);
-        t3 =
-          (-b +
-            A ** (1 / 2) *
-              (Math.cos(theta / 3) - 3 ** (1 / 2) * Math.sin(theta / 3))) /
-          (3 * a);
+        t2 = (-b + A ** (1 / 2) * (Math.cos(theta / 3) + 3 ** (1 / 2) * Math.sin(theta / 3))) / (3 * a);
+        t3 = (-b + A ** (1 / 2) * (Math.cos(theta / 3) - 3 ** (1 / 2) * Math.sin(theta / 3))) / (3 * a);
       }
       }
     }
     }
     return [t1, t2, t3];
     return [t1, t2, t3];
@@ -1515,16 +1427,8 @@ export default class MathUtil {
     const { x: cx1, y: cy1 } = cp1;
     const { x: cx1, y: cy1 } = cp1;
     const { x: cx2, y: cy2 } = cp2;
     const { x: cx2, y: cy2 } = cp2;
 
 
-    const x =
-      x1 * (1 - t) * (1 - t) * (1 - t) +
-      3 * cx1 * t * (1 - t) * (1 - t) +
-      3 * cx2 * t * t * (1 - t) +
-      x2 * t * t * t;
-    const y =
-      y1 * (1 - t) * (1 - t) * (1 - t) +
-      3 * cy1 * t * (1 - t) * (1 - t) +
-      3 * cy2 * t * t * (1 - t) +
-      y2 * t * t * t;
+    const x = x1 * (1 - t) * (1 - t) * (1 - t) + 3 * cx1 * t * (1 - t) * (1 - t) + 3 * cx2 * t * t * (1 - t) + x2 * t * t * t;
+    const y = y1 * (1 - t) * (1 - t) * (1 - t) + 3 * cy1 * t * (1 - t) * (1 - t) + 3 * cy2 * t * t * (1 - t) + y2 * t * t * t;
     return { x, y };
     return { x, y };
   }
   }
 
 
@@ -1539,16 +1443,8 @@ export default class MathUtil {
     // 参数化方式在曲线上取一系列的点
     // 参数化方式在曲线上取一系列的点
     var pointsOnCurve = [];
     var pointsOnCurve = [];
     for (var t = 0; t <= 1; t += 0.01) {
     for (var t = 0; t <= 1; t += 0.01) {
-      var x =
-        Math.pow(1 - t, 3) * p0.x +
-        3 * Math.pow(1 - t, 2) * t * p1.x +
-        3 * (1 - t) * Math.pow(t, 2) * p2.x +
-        Math.pow(t, 3) * p3.x;
-      var y =
-        Math.pow(1 - t, 3) * p0.y +
-        3 * Math.pow(1 - t, 2) * t * p1.y +
-        3 * (1 - t) * Math.pow(t, 2) * p2.y +
-        Math.pow(t, 3) * p3.y;
+      var x = Math.pow(1 - t, 3) * p0.x + 3 * Math.pow(1 - t, 2) * t * p1.x + 3 * (1 - t) * Math.pow(t, 2) * p2.x + Math.pow(t, 3) * p3.x;
+      var y = Math.pow(1 - t, 3) * p0.y + 3 * Math.pow(1 - t, 2) * t * p1.y + 3 * (1 - t) * Math.pow(t, 2) * p2.y + Math.pow(t, 3) * p3.y;
       pointsOnCurve.push({ x: x, y: y });
       pointsOnCurve.push({ x: x, y: y });
     }
     }
 
 
@@ -1556,10 +1452,7 @@ export default class MathUtil {
     var shortestDistance = Number.MAX_VALUE;
     var shortestDistance = Number.MAX_VALUE;
     var closestPoint;
     var closestPoint;
     for (var i = 0; i < pointsOnCurve.length; i++) {
     for (var i = 0; i < pointsOnCurve.length; i++) {
-      var distance = Math.sqrt(
-        Math.pow(pointsOnCurve[i].x - target.x, 2) +
-          Math.pow(pointsOnCurve[i].y - target.y, 2)
-      );
+      var distance = Math.sqrt(Math.pow(pointsOnCurve[i].x - target.x, 2) + Math.pow(pointsOnCurve[i].y - target.y, 2));
       if (distance < shortestDistance) {
       if (distance < shortestDistance) {
         shortestDistance = distance;
         shortestDistance = distance;
         closestPoint = pointsOnCurve[i];
         closestPoint = pointsOnCurve[i];
@@ -1576,23 +1469,11 @@ export default class MathUtil {
     const { x: offsetX, y: offsetY } = position;
     const { x: offsetX, y: offsetY } = position;
     let results = [];
     let results = [];
     // 用 x 求出对应的 t,用 t 求相应位置的 y,再比较得出的 y 与 offsetY 之间的差值
     // 用 x 求出对应的 t,用 t 求相应位置的 y,再比较得出的 y 与 offsetY 之间的差值
-    const tsx = this.getThreeBezierT(
-      curve.start.x,
-      curve.controls[0].x,
-      curve.controls[1].x,
-      curve.end.x,
-      offsetX
-    );
+    const tsx = this.getThreeBezierT(curve.start.x, curve.controls[0].x, curve.controls[1].x, curve.end.x, offsetX);
     console.log(tsx);
     console.log(tsx);
     for (let x = 0; x < 3; x++) {
     for (let x = 0; x < 3; x++) {
       if (tsx[x] <= 1 && tsx[x] >= 0) {
       if (tsx[x] <= 1 && tsx[x] >= 0) {
-        const point = this.getThreeBezierPoint(
-          tsx[x],
-          curve.start,
-          curve.controls[0],
-          curve.controls[1],
-          curve.end
-        );
+        const point = this.getThreeBezierPoint(tsx[x], curve.start, curve.controls[0], curve.controls[1], curve.end);
         // if (Math.abs(point.y - offsetY) < rang) {
         // if (Math.abs(point.y - offsetY) < rang) {
         results.push({
         results.push({
           position: point,
           position: point,
@@ -1602,22 +1483,10 @@ export default class MathUtil {
       }
       }
     }
     }
     // 如果上述没有结果,则用 y 求出对应的 t,再用 t 求出对应的 x,与 offsetX 进行匹配
     // 如果上述没有结果,则用 y 求出对应的 t,再用 t 求出对应的 x,与 offsetX 进行匹配
-    const tsy = this.getThreeBezierT(
-      curve.start.y,
-      curve.controls[0].y,
-      curve.controls[1].y,
-      curve.end.y,
-      offsetY
-    );
+    const tsy = this.getThreeBezierT(curve.start.y, curve.controls[0].y, curve.controls[1].y, curve.end.y, offsetY);
     for (let y = 0; y < 3; y++) {
     for (let y = 0; y < 3; y++) {
       if (tsy[y] <= 1 && tsy[y] >= 0) {
       if (tsy[y] <= 1 && tsy[y] >= 0) {
-        const point = this.getThreeBezierPoint(
-          tsy[y],
-          curve.start,
-          curve.controls[0],
-          curve.controls[1],
-          curve.end
-        );
+        const point = this.getThreeBezierPoint(tsy[y], curve.start, curve.controls[0], curve.controls[1], curve.end);
         // if (Math.abs(point.x - offsetX) < rang) {
         // if (Math.abs(point.x - offsetX) < rang) {
         results.push({
         results.push({
           position: point,
           position: point,
@@ -1658,15 +1527,9 @@ export default class MathUtil {
   getHitInfoForCurves(pos, curves, roadWidth) {
   getHitInfoForCurves(pos, curves, roadWidth) {
     let joinInfo;
     let joinInfo;
     for (const curve of curves) {
     for (const curve of curves) {
-      const tempJoinInfo =
-        curve.controls.length === 2
-          ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2)
-          : this.getHitInfoForTwoBezier(pos, curve);
-
-      if (
-        !joinInfo ||
-        (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)
-      ) {
+      const tempJoinInfo = curve.controls.length === 2 ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2) : this.getHitInfoForTwoBezier(pos, curve);
+
+      if (!joinInfo || (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)) {
         joinInfo = tempJoinInfo;
         joinInfo = tempJoinInfo;
       }
       }
     }
     }
@@ -1675,15 +1538,9 @@ export default class MathUtil {
 
 
   getHitInfoForCurve(pos, curve, roadWidth) {
   getHitInfoForCurve(pos, curve, roadWidth) {
     let joinInfo;
     let joinInfo;
-    const tempJoinInfo =
-      curve.controls.length === 2
-        ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2)
-        : this.getHitInfoForTwoBezier(pos, curve);
+    const tempJoinInfo = curve.controls.length === 2 ? this.getHitInfoForThreeBezier(pos, curve, roadWidth / 2) : this.getHitInfoForTwoBezier(pos, curve);
 
 
-    if (
-      !joinInfo ||
-      (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)
-    ) {
+    if (!joinInfo || (tempJoinInfo && tempJoinInfo.distance < joinInfo.distance)) {
       joinInfo = tempJoinInfo;
       joinInfo = tempJoinInfo;
     }
     }
     return joinInfo;
     return joinInfo;
@@ -1713,10 +1570,7 @@ export default class MathUtil {
       }
       }
     }
     }
     if (index == -1) {
     if (index == -1) {
-      if (
-        minDisToPoint >
-        mathUtil.getDistance(position, points[points.length - 1])
-      ) {
+      if (minDisToPoint > mathUtil.getDistance(position, points[points.length - 1])) {
         return points.length;
         return points.length;
       } else {
       } else {
         return minPointIndex;
         return minPointIndex;
@@ -1750,10 +1604,7 @@ export default class MathUtil {
       }
       }
     }
     }
     if ((index = -1)) {
     if ((index = -1)) {
-      if (
-        minDisToPoint >
-        mathUtil.getDistance(position, points[points.length - 1])
-      ) {
+      if (minDisToPoint > mathUtil.getDistance(position, points[points.length - 1])) {
         return points.length - 2;
         return points.length - 2;
       } else {
       } else {
         return minPointIndex;
         return minPointIndex;
@@ -1806,43 +1657,23 @@ export default class MathUtil {
         if (mathUtil.equalPoint(points[i], points[i + 1])) {
         if (mathUtil.equalPoint(points[i], points[i + 1])) {
           return null;
           return null;
         }
         }
-        let leftEdgePoins1 = this.RectangleVertex(
-          points[i],
-          points[i + 1],
-          leftWidth * 2
-        );
-        let leftLine1 = mathUtil.createLine1(
-          leftEdgePoins1.leftEdgeStart,
-          leftEdgePoins1.leftEdgeEnd
-        );
+        let leftEdgePoins1 = this.RectangleVertex(points[i], points[i + 1], leftWidth * 2);
+        let leftLine1 = mathUtil.createLine1(leftEdgePoins1.leftEdgeStart, leftEdgePoins1.leftEdgeEnd);
         if (i != points.length - 2) {
         if (i != points.length - 2) {
           if (mathUtil.equalPoint(points[i + 2], points[i + 1])) {
           if (mathUtil.equalPoint(points[i + 2], points[i + 1])) {
             return null;
             return null;
           }
           }
-          let leftEdgePoins2 = this.RectangleVertex(
-            points[i + 1],
-            points[i + 2],
-            leftWidth * 2
-          );
-
-          let leftLine2 = mathUtil.createLine1(
-            leftEdgePoins2.leftEdgeStart,
-            leftEdgePoins2.leftEdgeEnd
-          );
+          let leftEdgePoins2 = this.RectangleVertex(points[i + 1], points[i + 2], leftWidth * 2);
+
+          let leftLine2 = mathUtil.createLine1(leftEdgePoins2.leftEdgeStart, leftEdgePoins2.leftEdgeEnd);
           let join = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
           let join = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
           if (join != null) {
           if (join != null) {
             leftEdgePoints[i + 1] = join;
             leftEdgePoints[i + 1] = join;
           } else {
           } else {
-            leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
-              points[i + 1],
-              leftLine1
-            );
+            leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], leftLine1);
           }
           }
         } else {
         } else {
-          leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
-            points[i + 1],
-            leftLine1
-          );
+          leftEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], leftLine1);
         }
         }
         if (!leftEdgePoints[0]) {
         if (!leftEdgePoints[0]) {
           leftEdgePoints[0] = mathUtil.getJoinLinePoint(points[0], leftLine1);
           leftEdgePoints[0] = mathUtil.getJoinLinePoint(points[0], leftLine1);
@@ -1853,43 +1684,23 @@ export default class MathUtil {
         if (mathUtil.equalPoint(points[i], points[i + 1])) {
         if (mathUtil.equalPoint(points[i], points[i + 1])) {
           return null;
           return null;
         }
         }
-        let rightEdgePoins1 = this.RectangleVertex(
-          points[i],
-          points[i + 1],
-          rightWidth * 2
-        );
-        let rightLine1 = mathUtil.createLine1(
-          rightEdgePoins1.rightEdgeStart,
-          rightEdgePoins1.rightEdgeEnd
-        );
+        let rightEdgePoins1 = this.RectangleVertex(points[i], points[i + 1], rightWidth * 2);
+        let rightLine1 = mathUtil.createLine1(rightEdgePoins1.rightEdgeStart, rightEdgePoins1.rightEdgeEnd);
         if (i != points.length - 2) {
         if (i != points.length - 2) {
           if (mathUtil.equalPoint(points[i + 2], points[i + 1])) {
           if (mathUtil.equalPoint(points[i + 2], points[i + 1])) {
             return null;
             return null;
           }
           }
-          let rightEdgePoins2 = this.RectangleVertex(
-            points[i + 1],
-            points[i + 2],
-            rightWidth * 2
-          );
-
-          let rightLine2 = mathUtil.createLine1(
-            rightEdgePoins2.rightEdgeStart,
-            rightEdgePoins2.rightEdgeEnd
-          );
+          let rightEdgePoins2 = this.RectangleVertex(points[i + 1], points[i + 2], rightWidth * 2);
+
+          let rightLine2 = mathUtil.createLine1(rightEdgePoins2.rightEdgeStart, rightEdgePoins2.rightEdgeEnd);
           let join = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
           let join = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
           if (join != null) {
           if (join != null) {
             rightEdgePoints[i + 1] = join;
             rightEdgePoints[i + 1] = join;
           } else {
           } else {
-            rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
-              points[i + 1],
-              rightLine1
-            );
+            rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], rightLine1);
           }
           }
         } else {
         } else {
-          rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(
-            points[i + 1],
-            rightLine1
-          );
+          rightEdgePoints[i + 1] = mathUtil.getJoinLinePoint(points[i + 1], rightLine1);
         }
         }
 
 
         if (!rightEdgePoints[0]) {
         if (!rightEdgePoints[0]) {
@@ -1975,6 +1786,27 @@ export default class MathUtil {
     };
     };
     return targetPoint;
     return targetPoint;
   }
   }
+  //获取四个顶点内的中心坐标
+  /**
+   *
+   * @param {*} points  //四个顶点
+   * @returns
+   */
+  calculateCenterPoint(points) {
+    // 计算x坐标和y坐标的总和
+    let sumX = 0;
+    let sumY = 0;
+    for (let i = 0; i < points.length; i++) {
+      sumX += points[i].x; // x坐标
+      sumY += points[i].y; // y坐标
+    }
+
+    // 计算平均值
+    const centerX = sumX / points.length;
+    const centerY = sumY / points.length;
+    // 返回中心点坐标
+    return { x: centerX, y: centerY };
+  }
 }
 }
 
 
 const mathUtil = new MathUtil();
 const mathUtil = new MathUtil();