Browse Source

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

bill 2 years ago
parent
commit
4f1121281e

File diff suppressed because it is too large
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 17 - 9
src/graphic/Controls/AddLine.js

@@ -26,7 +26,10 @@ export default class AddLine {
   }
   }
 
 
   setNewLinePoint(position) {
   setNewLinePoint(position) {
-    if (listenLayer.modifyPoint) {
+    if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.hasOwnProperty("x")
+    ) {
       this.setPointInfo(listenLayer.modifyPoint);
       this.setPointInfo(listenLayer.modifyPoint);
     } else {
     } else {
       this.setPointInfo(position);
       this.setPointInfo(position);
@@ -35,7 +38,6 @@ export default class AddLine {
   }
   }
 
 
   buildLine(position) {
   buildLine(position) {
-    // if (Settings.selectLineCategory == VectorCategory.Line.NormalLine) {
     if (
     if (
       this.newLine == null &&
       this.newLine == null &&
       !mathUtil.equalPoint(this.startInfo.position, position)
       !mathUtil.equalPoint(this.startInfo.position, position)
@@ -46,13 +48,6 @@ export default class AddLine {
         this.newLine.setLocationMode(Constant.freeLocationMode);
         this.newLine.setLocationMode(Constant.freeLocationMode);
       }
       }
     }
     }
-    // } else {
-    //   console.error(this.startInfo.position, position);
-    //   if (Settings.selectLineCategory == Constant.freeLocationMode) {
-    //     this.newLine = lineService.create(this.startInfo.position, position);
-    //     this.newLine.setLocationMode(Constant.freeLocationMode);
-    //   }
-    // }
   }
   }
 
 
   updateLine(position) {
   updateLine(position) {
@@ -80,6 +75,19 @@ export default class AddLine {
           this.newLine.endId,
           this.newLine.endId,
           listenLayer.modifyPoint.linkedPointId
           listenLayer.modifyPoint.linkedPointId
         );
         );
+        //可能要合并起点
+        let points = dataService.getPoints();
+        let startPoint = dataService.getPoint(this.newLine.startId);
+        for (let key in points) {
+          if (key == this.newLine.endId || key == this.newLine.startId) {
+            continue;
+          }
+          let point = points[key];
+          if (mathUtil.equalPoint(startPoint, point)) {
+            pointService.mergePoint(this.newLine.startId, key);
+            break;
+          }
+        }
       }
       }
       if (this.newLine.getCategory() == VectorCategory.Line.BaseLine) {
       if (this.newLine.getCategory() == VectorCategory.Line.BaseLine) {
         Settings.baseLineId = this.newLine.vectorId;
         Settings.baseLineId = this.newLine.vectorId;

+ 4 - 1
src/graphic/Controls/AddRoad.js

@@ -83,7 +83,10 @@ export default class AddRoad {
   }
   }
 
 
   canAddRoadForEnd(endPt) {
   canAddRoadForEnd(endPt) {
-    if (listenLayer.modifyPoint) {
+    if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.hasOwnProperty("x")
+    ) {
       if (
       if (
         mathUtil.getDistance(this.startInfo.position, listenLayer.modifyPoint) <
         mathUtil.getDistance(this.startInfo.position, listenLayer.modifyPoint) <
         Constant.minAdsorbPix
         Constant.minAdsorbPix

+ 1 - 1
src/graphic/Controls/MovePoint.js

@@ -234,7 +234,6 @@ export default class MovePoint {
         let otherPointId = line.getOtherPointId(fixPointId);
         let otherPointId = line.getOtherPointId(fixPointId);
         let otherPoint = dataService.getPoint(otherPointId);
         let otherPoint = dataService.getPoint(otherPointId);
         mathUtil.clonePoint(otherPoint, join);
         mathUtil.clonePoint(otherPoint, join);
-        moveText.moveFullText(position, fixPoint.linkedTextId);
       } else if (line.getCategory() == VectorCategory.Line.GuideLocationLine) {
       } else if (line.getCategory() == VectorCategory.Line.GuideLocationLine) {
         let otherPointId = line.getOtherPointId(fixPointId);
         let otherPointId = line.getOtherPointId(fixPointId);
         let otherPoint = dataService.getPoint(otherPointId);
         let otherPoint = dataService.getPoint(otherPointId);
@@ -252,6 +251,7 @@ export default class MovePoint {
       }
       }
     }
     }
     mathUtil.clonePoint(fixPoint, position);
     mathUtil.clonePoint(fixPoint, position);
+    moveText.moveFullText(position, fixPoint.linkedTextId);
   }
   }
 
 
   /*****************************************************************************曲线上的点********************************************************************************/
   /*****************************************************************************曲线上的点********************************************************************************/

+ 44 - 12
src/graphic/Layer.js

@@ -512,7 +512,10 @@ export default class Layer {
       case LayerEvents.AddRoad:
       case LayerEvents.AddRoad:
         needAutoRedraw = true;
         needAutoRedraw = true;
         listenLayer.start(position);
         listenLayer.start(position);
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -527,7 +530,10 @@ export default class Layer {
       case LayerEvents.AddLine:
       case LayerEvents.AddLine:
         needAutoRedraw = true;
         needAutoRedraw = true;
         listenLayer.start(position);
         listenLayer.start(position);
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -541,7 +547,10 @@ export default class Layer {
       case LayerEvents.AddCurveLine:
       case LayerEvents.AddCurveLine:
         needAutoRedraw = true;
         needAutoRedraw = true;
         listenLayer.start(position);
         listenLayer.start(position);
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -555,7 +564,10 @@ export default class Layer {
       case LayerEvents.AddCircle:
       case LayerEvents.AddCircle:
         needAutoRedraw = true;
         needAutoRedraw = true;
         listenLayer.start(position);
         listenLayer.start(position);
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -577,7 +589,10 @@ export default class Layer {
         //   addRoad.startInfo.linkedRoadPointId
         //   addRoad.startInfo.linkedRoadPointId
         // });
         // });
 
 
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -619,7 +634,10 @@ export default class Layer {
           exceptLineIds: exceptLineId,
           exceptLineIds: exceptLineId,
           exceptPointId: exceptPointId,
           exceptPointId: exceptPointId,
         });
         });
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -649,7 +667,10 @@ export default class Layer {
           exceptCurveLineId: exceptCurveLineId,
           exceptCurveLineId: exceptCurveLineId,
           exceptCurvePointId: exceptCurvePointId,
           exceptCurvePointId: exceptCurvePointId,
         });
         });
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -674,7 +695,10 @@ export default class Layer {
           exceptCircleId = addCircle.newCircle.vectorId;
           exceptCircleId = addCircle.newCircle.vectorId;
         }
         }
         listenLayer.start(position, { exceptCircleId: exceptCircleId });
         listenLayer.start(position, { exceptCircleId: exceptCircleId });
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -744,7 +768,10 @@ export default class Layer {
       case LayerEvents.AddCurveRoad:
       case LayerEvents.AddCurveRoad:
         needAutoRedraw = true;
         needAutoRedraw = true;
         listenLayer.start(position);
         listenLayer.start(position);
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -758,7 +785,10 @@ export default class Layer {
       case LayerEvents.AddingCurveRoad:
       case LayerEvents.AddingCurveRoad:
         needAutoRedraw = true;
         needAutoRedraw = true;
         listenLayer.start(position);
         listenLayer.start(position);
-        if (listenLayer.modifyPoint) {
+        if (
+          listenLayer.modifyPoint &&
+          listenLayer.modifyPoint.hasOwnProperty("x")
+        ) {
           position = {
           position = {
             x: listenLayer.modifyPoint.x,
             x: listenLayer.modifyPoint.x,
             y: listenLayer.modifyPoint.y,
             y: listenLayer.modifyPoint.y,
@@ -859,7 +889,6 @@ export default class Layer {
             exceptLineIds: point.parent,
             exceptLineIds: point.parent,
           });
           });
 
 
-          // if (listenLayer.modifyPoint) {  //原本是这样的,不知用途,下面修改为了修复拖动点经过放大镜导致NaN或者错位
           if (
           if (
             listenLayer.modifyPoint &&
             listenLayer.modifyPoint &&
             listenLayer.modifyPoint.x &&
             listenLayer.modifyPoint.x &&
@@ -886,7 +915,10 @@ export default class Layer {
             exceptCurvePointId: draggingItem.vectorId,
             exceptCurvePointId: draggingItem.vectorId,
             exceptCurveLineId: curvePoint.parent,
             exceptCurveLineId: curvePoint.parent,
           });
           });
-          if (listenLayer.modifyPoint) {
+          if (
+            listenLayer.modifyPoint &&
+            listenLayer.modifyPoint.hasOwnProperty("x")
+          ) {
             position = {
             position = {
               x: listenLayer.modifyPoint.x,
               x: listenLayer.modifyPoint.x,
               y: listenLayer.modifyPoint.y,
               y: listenLayer.modifyPoint.y,

+ 8 - 14
src/graphic/Load.js

@@ -442,25 +442,19 @@ export default class Load {
         }
         }
         if (data3d.fixPoints) {
         if (data3d.fixPoints) {
           for (let i = 0; i < data3d.fixPoints.length; ++i) {
           for (let i = 0; i < data3d.fixPoints.length; ++i) {
-            // let point = pointService.create(
-            //   this.getXY(width, height, data3d.fixPoints[i].pos)
-            // );
-            // point.setCategory(VectorCategory.Point.FixPoint);
-            console.log(
-              "001-fixPoints-" +
-                i +
-                ":" +
-                JSON.stringify(data3d.fixPoints[i].pos)
+            let point = pointService.create(
+              this.getXY(width, height, data3d.fixPoints[i].pos)
             );
             );
+            point.setCategory(VectorCategory.Point.FixPoint);
             let text = textService.create(
             let text = textService.create(
               this.getXY(width, height, data3d.fixPoints[i].pos)
               this.getXY(width, height, data3d.fixPoints[i].pos)
             );
             );
-            console.log(
-              "002-fixPoints-" + i + ":" + JSON.stringify(text.center)
-            );
             text.setValue(data3d.fixPoints[i].text);
             text.setValue(data3d.fixPoints[i].text);
-            text.setAngle(angle);
-            text.setDisplayPoint(true);
+            // text.setAngle(angle);
+            // text.setDisplayPoint(true);
+
+            point.linkedTextId = text.vectorId;
+            text.linkedPointId = point.vectorId;
           }
           }
         }
         }
       }
       }

+ 10 - 4
src/graphic/Service/ElementService.js

@@ -178,15 +178,18 @@ export class ElementService {
     if (!mathUtil.equalPoint(point1, point2)) {
     if (!mathUtil.equalPoint(point1, point2)) {
       let edgePoints = null;
       let edgePoints = null;
       if (this.newRoad.way == Constant.oneWay) {
       if (this.newRoad.way == Constant.oneWay) {
-        this.newRoad.singleRoadWidth = Settings.singleRoadWidth* window.coordinate.ratio;
+        this.newRoad.singleRoadWidth =
+          Settings.singleRoadWidth * window.coordinate.ratio;
         edgePoints = mathUtil.RectangleVertex(
         edgePoints = mathUtil.RectangleVertex(
           point1,
           point1,
           point2,
           point2,
           this.newRoad.singleRoadWidth
           this.newRoad.singleRoadWidth
         );
         );
       } else if (this.newRoad.way == Constant.twoWay) {
       } else if (this.newRoad.way == Constant.twoWay) {
-        this.newRoad.leftWidth = Settings.leftRoadWidth* window.coordinate.ratio;
-        this.newRoad.rightWidth = Settings.rightRoadWidth* window.coordinate.ratio;
+        this.newRoad.leftWidth =
+          Settings.leftRoadWidth * window.coordinate.ratio;
+        this.newRoad.rightWidth =
+          Settings.rightRoadWidth * window.coordinate.ratio;
         edgePoints = mathUtil.RectangleVertex(
         edgePoints = mathUtil.RectangleVertex(
           point1,
           point1,
           point2,
           point2,
@@ -314,7 +317,10 @@ export class ElementService {
     }
     }
 
 
     if (!this.vCheckLines.Y.display && !this.vCheckLines.Y.display) {
     if (!this.vCheckLines.Y.display && !this.vCheckLines.Y.display) {
-      if (listenLayer.modifyPoint) {
+      if (
+        listenLayer.modifyPoint &&
+        listenLayer.modifyPoint.hasOwnProperty("x")
+      ) {
         if (listenLayer.modifyPoint.linkedRoadPointIdX) {
         if (listenLayer.modifyPoint.linkedRoadPointIdX) {
           let linkedPointX = dataService.getRoadPoint(
           let linkedPointX = dataService.getRoadPoint(
             listenLayer.modifyPoint.linkedRoadPointIdX
             listenLayer.modifyPoint.linkedRoadPointIdX

+ 17 - 0
src/graphic/Service/PointService.js

@@ -41,6 +41,23 @@ export default class PointService {
         point2.setPointParent(key, dir);
         point2.setPointParent(key, dir);
       }
       }
       dataService.deletePoint(pointId1);
       dataService.deletePoint(pointId1);
+
+      //可能会有重复的线段
+      let parent2 = point2.getParent();
+      let keys = Object.keys(parent2);
+      for (let i = 0; i < keys.length - 1; ++i) {
+        for (let j = i + 1; j < keys.length; ++j) {
+          let line1 = dataService.getLine(keys[i]);
+          let line2 = dataService.getLine(keys[j]);
+          if (
+            (line1.startId == line2.startId && line1.endId == line2.endId) ||
+            (line1.endId == line2.startId && line1.startId == line2.endId)
+          ) {
+            dataService.deleteLine(line1.vectorId);
+            return;
+          }
+        }
+      }
     }
     }
   }
   }