Forráskód Böngészése

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

bill 1 éve
szülő
commit
f799e78fea

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 529 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 1 - 1
src/graphic/Constant.js

@@ -27,7 +27,7 @@ const Constant = {
   minAdsorbPix: 25, //最小吸附像素
   minRealDis: 20,
   defaultRoadWidth: 100, //默认公路宽度
-  roadSideWidth: 100, //默认路缘宽度
+  roadSideWidth: 20, //默认路缘宽度
   roadWidthTipsDistance: 100, //路宽提示距离
   ratio: 1,
   minAngle: 10,

+ 20 - 66
src/graphic/Controls/UIControl.js

@@ -34,7 +34,7 @@ import { curveRoadPointService } from "../Service/CurveRoadPointService.js";
 import { roadService } from "../Service/RoadService.js";
 import { curveRoadService } from "../Service/CurveRoadService.js";
 import Msg from "../enum/Msg.js";
-
+import RoadStructure from "../enum/RoadStructure";
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
     this._prompts = [];
@@ -124,7 +124,11 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddMagnifier);
         } else if (SVGType[selectUI]) {
           uiService.setSelectSVGType(selectUI);
-          stateService.setEventName(LayerEvents.AddSVG);
+          if (selectUI == RoadStructure.ZebraCrossing) {
+            stateService.setEventName(LayerEvents.AddLine);
+          } else {
+            stateService.setEventName(LayerEvents.AddSVG);
+          }
         } else if (selectUI == UIEvents.Img) {
           stateService.setEventName(LayerEvents.Img);
         } else if (uiService.isBelongRoadTemplate(selectUI)) {
@@ -187,6 +191,7 @@ export default class UIControl {
           if (selectUI == VectorStyle.RoadSide) {
             //修改路缘线
             roadEdge.initRoadSide();
+            roadEdge[key](selectUI);
           } else {
             roadEdge[key](selectUI);
             let crossPoint = dataService.getCrossPoint4(focusItem.vectorId);
@@ -402,52 +407,27 @@ export default class UIControl {
           if (endPoint.getCategory() != VectorCategory.Point.BasePoint) {
             pointService.deletePoint(line.endId);
           }
-        } else if (
-          line.getCategory() == VectorCategory.Line.LocationLineByFixPoint
-        ) {
+        } else if (line.getCategory() == VectorCategory.Line.LocationLineByFixPoint) {
           let lines = dataService.getLines();
           for (let key in lines) {
             let _line = dataService.getLine(key);
-            if (
-              _line.getCategory() == VectorCategory.Line.ExtendedPositionLine
-            ) {
-              if (
-                line.startId == _line.startId ||
-                line.startId == _line.endId ||
-                line.endId == _line.startId ||
-                line.endId == _line.endId
-              ) {
+            if (_line.getCategory() == VectorCategory.Line.ExtendedPositionLine) {
+              if (line.startId == _line.startId || line.startId == _line.endId || line.endId == _line.startId || line.endId == _line.endId) {
                 dataService.deleteLine(key);
                 break;
               }
             }
           }
-        } else if (
-          line.getCategory() == VectorCategory.Line.LocationLineByBasePoint
-        ) {
+        } else if (line.getCategory() == VectorCategory.Line.LocationLineByBasePoint) {
           let lines = dataService.getLines();
           for (let key in lines) {
             let _line = dataService.getLine(key);
-            if (
-              _line.getCategory() == VectorCategory.Line.ExtendedPositionLine
-            ) {
-              if (
-                line.startId == _line.startId ||
-                line.startId == _line.endId ||
-                line.endId == _line.startId ||
-                line.endId == _line.endId
-              ) {
+            if (_line.getCategory() == VectorCategory.Line.ExtendedPositionLine) {
+              if (line.startId == _line.startId || line.startId == _line.endId || line.endId == _line.startId || line.endId == _line.endId) {
                 dataService.deleteLine(key);
               }
-            } else if (
-              _line.getCategory() == VectorCategory.Line.GuideLocationLine
-            ) {
-              if (
-                line.startId == _line.startId ||
-                line.startId == _line.endId ||
-                line.endId == _line.startId ||
-                line.endId == _line.endId
-              ) {
+            } else if (_line.getCategory() == VectorCategory.Line.GuideLocationLine) {
+              if (line.startId == _line.startId || line.startId == _line.endId || line.endId == _line.startId || line.endId == _line.endId) {
                 dataService.deleteLine(key);
               }
             }
@@ -460,10 +440,7 @@ export default class UIControl {
         break;
       case VectorType.CurvePoint:
         const curvePoint = dataService.getCurvePoint(vectorId);
-        lineService.deleteCrossPointForCurveLine(
-          vectorId,
-          curvePoint.getParent()
-        );
+        lineService.deleteCrossPointForCurveLine(vectorId, curvePoint.getParent());
         break;
       case VectorType.Circle:
         dataService.deleteCircle(vectorId);
@@ -589,31 +566,12 @@ export default class UIControl {
   // }
 
   saveFile(data, filename) {
-    var save_link = document.createElementNS(
-      "http://www.w3.org/1999/xhtml",
-      "a"
-    );
+    var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
     save_link.href = data;
     save_link.download = filename;
 
     var event = document.createEvent("MouseEvents");
-    event.initMouseEvent(
-      "click",
-      true,
-      false,
-      window,
-      0,
-      0,
-      0,
-      0,
-      0,
-      false,
-      false,
-      false,
-      false,
-      0,
-      null
-    );
+    event.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
     save_link.dispatchEvent(event);
   }
 
@@ -710,12 +668,8 @@ export default class UIControl {
   // 设置默认设置
   setDefaultSetting(setting) {
     console.log("获得设置", setting);
-    uiService.setRoadMidDivideWidth(
-      setting.roadQuarantineWidth / coordinate.res
-    );
-    uiService.setCurveRoadMidDivideWidth(
-      setting.roadQuarantineWidth / coordinate.res
-    );
+    uiService.setRoadMidDivideWidth(setting.roadQuarantineWidth / coordinate.res);
+    uiService.setCurveRoadMidDivideWidth(setting.roadQuarantineWidth / coordinate.res);
     Constant.defaultMidDivideWidth = setting.roadQuarantineWidth;
     uiService.setSingleLaneWidth(setting.singleRoadWidth / coordinate.res);
     Constant.defaultSingleLaneWidth = setting.singleRoadWidth;

+ 12 - 1
src/graphic/Geometry/Line.js

@@ -15,6 +15,7 @@ export default class Line extends Geometry {
     this.endId = endId;
     this.category = Settings.selectLineCategory;
     this.locationMode = null;
+    this.zebraCrossStyle = null;
     this.linkedFixPointId = null;
     this.linkedBasePointId = null;
     this.style = VectorStyle.SingleSolidLine;
@@ -33,7 +34,17 @@ export default class Line extends Geometry {
     }
     this.category = value;
   }
-
+  setZebraCrossStyle(data) {
+    this.zebraCrossStyle = data || { lineWeight: Settings.zebraCrossLineWeight, lineSpace: Settings.zebraCrosslineSpace };
+  }
+  //设置斑马线属性
+  setZebraCrossLineWeight(value) {
+    this.zebraCrossStyle.lineWeight = value;
+  }
+  //设置斑马线属性
+  setZebraCrossLineSpace(value) {
+    this.zebraCrossStyle.lineSpace = value;
+  }
   getDir(pointId) {
     if (this.startId == pointId) {
       return "start";

+ 18 - 19
src/graphic/Geometry/RoadEdge.js

@@ -1,11 +1,11 @@
 //墙的边缘线
-import Geometry from './Geometry.js';
-import VectorType from '../enum/VectorType.js';
-import VectorWight from '../enum/VectorWeight.js';
-import VectorStyle from '../enum/VectorStyle.js';
-import { mathUtil } from '../Util/MathUtil.js';
-import { dataService } from '../Service/DataService.js';
-import Constant from '../Constant';
+import Geometry from "./Geometry.js";
+import VectorType from "../enum/VectorType.js";
+import VectorWight from "../enum/VectorWeight.js";
+import VectorStyle from "../enum/VectorStyle.js";
+import { mathUtil } from "../Util/MathUtil.js";
+import { dataService } from "../Service/DataService.js";
+import Constant from "../Constant";
 export default class RoadEdge extends Geometry {
   constructor(start, end, vectorId, parentId) {
     super();
@@ -31,9 +31,9 @@ export default class RoadEdge extends Geometry {
   }
 
   setPosition(position, dir) {
-    if (dir == 'start') {
+    if (dir == "start") {
       mathUtil.clonePoint(this.start, position);
-    } else if (dir == 'end') {
+    } else if (dir == "end") {
       mathUtil.clonePoint(this.end, position);
     }
   }
@@ -43,9 +43,9 @@ export default class RoadEdge extends Geometry {
   }
 
   getPosition(dir) {
-    if (dir == 'start') {
+    if (dir == "start") {
       return this.start;
-    } else if (dir == 'end') {
+    } else if (dir == "end") {
       return this.end;
     } else {
       return null;
@@ -67,7 +67,6 @@ export default class RoadEdge extends Geometry {
 
     let roadSidePoints = mathUtil.RectangleVertex(startPoint, endPoint, Constant.roadSideWidth * 2);
 
-
     // for (let key in road) {
     //   if (this.vectorId == road[key]) {
     //     if (key == 'rightEdgeId') {
@@ -84,16 +83,16 @@ export default class RoadEdge extends Geometry {
 
     if (!this.roadSide) {
       this.roadSide = {};
-      this.roadSide['width'] = Constant.roadSideWidth;
+      this.roadSide["width"] = Constant.roadSideWidth;
     }
     for (let key in road) {
       if (this.vectorId == road[key]) {
-        if (key == 'rightEdgeId') {
-          this.roadSide['start'] = roadSidePoints.rightEdgeStart;
-          this.roadSide['end'] = roadSidePoints.rightEdgeEnd;
-        } else if (key == 'leftEdgeId') {
-          this.roadSide['start'] = roadSidePoints.leftEdgeStart;
-          this.roadSide['end'] = roadSidePoints.leftEdgeEnd;
+        if (key == "rightEdgeId") {
+          this.roadSide["start"] = roadSidePoints.rightEdgeStart;
+          this.roadSide["end"] = roadSidePoints.rightEdgeEnd;
+        } else if (key == "leftEdgeId") {
+          this.roadSide["start"] = roadSidePoints.leftEdgeStart;
+          this.roadSide["end"] = roadSidePoints.leftEdgeEnd;
         }
       }
     }

+ 5 - 1
src/graphic/History/HistoryUtil.js

@@ -32,7 +32,8 @@ export default class HistoryUtil {
       line1.linkedFixPointId == line2.linkedFixPointId &&
       line1.linkedBasePointId == line2.linkedBasePointId &&
       line1.style == line2.style &&
-      line1.weight == line2.weight
+      line1.weight == line2.weight && 
+      line1.zebraCrossStyle == line2.zebraCrossStyle
     ) {
       return false;
     } else {
@@ -363,6 +364,7 @@ export default class HistoryUtil {
     lineInfo.value = line2.value;
     lineInfo.style = line2.style;
     lineInfo.weight = line2.weight;
+    lineInfo.zebraCrossStyle = line2.zebraCrossStyle
     this.setLineInfo(lineInfo);
   }
 
@@ -624,6 +626,7 @@ export default class HistoryUtil {
     data.type = line.geoType;
     data.style = line.style;
     data.weight = line.weight;
+    data.zebraCrossStyle = line.zebraCrossStyle
     return data;
   }
 
@@ -869,6 +872,7 @@ export default class HistoryUtil {
     line.value = lineInfo.value;
     line.style = lineInfo.style;
     line.weight = lineInfo.weight;
+    line.zebraCrossStyle = lineInfo.zebraCrossStyle
     return line;
   }
 

+ 3 - 0
src/graphic/Load.js

@@ -162,6 +162,9 @@ export default class Load {
           if (dataLocal.lines[key].linkedBasePointId) {
             line.setLinkedBasePointId(dataLocal.lines[key].linkedBasePointId);
           }
+          if (dataLocal.lines[key].zebraCrossStyle) {
+            line.setZebraCrossStyle(dataLocal.lines[key].zebraCrossStyle);
+          }
 
           line.setDisplay(dataLocal.lines[key].display);
           if (line.getCategory() == VectorCategory.Line.BaseLine) {

+ 19 - 43
src/graphic/Service/LineService.js

@@ -9,6 +9,8 @@ import { mathUtil } from "../Util/MathUtil.js";
 import { uiService } from "./UIService.js";
 import { addLine } from "../Controls/AddLine.js";
 import Constant from "../Constant.js";
+import RoadStructure from "../enum/RoadStructure.js";
+import Settings from "../Settings";
 
 export default class LineService {
   constructor() {}
@@ -23,6 +25,12 @@ export default class LineService {
     if (category) {
       line.setCategory(category);
     }
+    if (Settings.selectSVGType == RoadStructure.ZebraCrossing) {
+      line.setCategory(Settings.selectSVGType);
+      line.setZebraCrossStyle()
+      line.setZebraCrossLineWeight(Settings.zebraCrossLineWeight)
+      line.setZebraCrossLineSpace(Settings.zebraCrosslineSpace)
+    }
     start.setPointParent(line.vectorId, "start");
     end.setPointParent(line.vectorId, "end");
     dataService.addPoint(start);
@@ -52,10 +60,7 @@ export default class LineService {
       for (let key in points) {
         let point = dataService.getPoint(key);
         let category = point.getCategory();
-        if (
-          category == VectorCategory.Point.BasePoint ||
-          category == VectorCategory.Point.TestBasePoint
-        ) {
+        if (category == VectorCategory.Point.BasePoint || category == VectorCategory.Point.TestBasePoint) {
           dataService.deletePoint(key);
         }
       }
@@ -85,10 +90,7 @@ export default class LineService {
     let lines = dataService.getLines();
     for (let key in lines) {
       const line = dataService.getLine(key);
-      if (
-        (line.startId == pointId1 && line.endId == pointId2) ||
-        (line.endId == pointId1 && line.startId == pointId2)
-      ) {
+      if ((line.startId == pointId1 && line.endId == pointId2) || (line.endId == pointId1 && line.startId == pointId2)) {
         return key;
       }
     }
@@ -109,20 +111,12 @@ export default class LineService {
 
   /******************************************************************************曲线**************************************************************************************/
   createCurveLine(startPosition, endPosition, vectorId) {
-    if (
-      !startPosition ||
-      !endPosition ||
-      mathUtil.equalPoint(startPosition, endPosition)
-    ) {
+    if (!startPosition || !endPosition || mathUtil.equalPoint(startPosition, endPosition)) {
       return null;
     }
     let startPoint = curvePointService.create(startPosition);
     let endPoint = curvePointService.create(endPosition);
-    let curveLine = new CurveLine(
-      startPoint.vectorId,
-      endPoint.vectorId,
-      vectorId
-    );
+    let curveLine = new CurveLine(startPoint.vectorId, endPoint.vectorId, vectorId);
 
     startPoint.setPointParent(curveLine.vectorId);
     startPoint.setIndex(0);
@@ -144,11 +138,7 @@ export default class LineService {
   }
 
   createCurveLineByPointIds(curvePoints, vectorId) {
-    let curveLine = new CurveLine(
-      curvePoints[0].vectorId,
-      curvePoints[curvePoints.length - 1].vectorId,
-      vectorId
-    );
+    let curveLine = new CurveLine(curvePoints[0].vectorId, curvePoints[curvePoints.length - 1].vectorId, vectorId);
     curveLine.points = [];
     for (let i = 0; i < curvePoints.length; ++i) {
       curveLine.points[i] = dataService.getCurvePoint(curvePoints[i].vectorId);
@@ -167,11 +157,7 @@ export default class LineService {
       curvePoint.setIndex(i);
       curvePoints.push(curvePoint);
     }
-    let curveLine = new CurveLine(
-      curvePoints[0].vectorId,
-      curvePoints[curvePoints.length - 1].vectorId,
-      vectorId
-    );
+    let curveLine = new CurveLine(curvePoints[0].vectorId, curvePoints[curvePoints.length - 1].vectorId, vectorId);
     curveLine.points = curvePoints;
     for (let i = 0; i < curvePoints.length; ++i) {
       curvePoints[i].setIndex(i);
@@ -212,10 +198,7 @@ export default class LineService {
       newCurveLine.setStyle(curveLine.style);
     }
 
-    mathUtil.clonePoint(
-      newCurveLine.points[1],
-      uiService.getNewPositionForPop(curveLine.points[1])
-    );
+    mathUtil.clonePoint(newCurveLine.points[1], uiService.getNewPositionForPop(curveLine.points[1]));
     newCurveLine.points[1].setIndex(curveLine.points[1].getIndex());
 
     for (let i = 2; i < curveLine.points.length - 1; ++i) {
@@ -225,9 +208,7 @@ export default class LineService {
       newPoint.setIndex(curveLine.points[i].getIndex());
       newCurveLine.points.splice(i, 0, newPoint);
     }
-    newCurveLine.points[newCurveLine.points.length - 1].setIndex(
-      curveLine.points[curveLine.points.length - 1].getIndex()
-    );
+    newCurveLine.points[newCurveLine.points.length - 1].setIndex(curveLine.points[curveLine.points.length - 1].getIndex());
     newCurveLine.curves = mathUtil.getCurvesByPoints(newCurveLine.points);
     return newCurveLine.vectorId;
   }
@@ -240,22 +221,17 @@ export default class LineService {
           curveLine.points.shift();
           curveLine.startId = curveLine.points[0].vectorId;
           for (let j = 0; j < curveLine.points.length; ++j) {
-            let _curvePoint = dataService.getCurvePoint(
-              curveLine.points[j].vectorId
-            );
+            let _curvePoint = dataService.getCurvePoint(curveLine.points[j].vectorId);
             const index = _curvePoint.getIndex();
             _curvePoint.setIndex(index - 1);
           }
         } else if (i == curveLine.points.length - 1) {
           curveLine.points.pop();
-          curveLine.endId =
-            curveLine.points[curveLine.points.length - 1].vectorId;
+          curveLine.endId = curveLine.points[curveLine.points.length - 1].vectorId;
         } else {
           curveLine.points.splice(i, 1);
           for (let j = i; j < curveLine.points.length; ++j) {
-            let _curvePoint = dataService.getCurvePoint(
-              curveLine.points[j].vectorId
-            );
+            let _curvePoint = dataService.getCurvePoint(curveLine.points[j].vectorId);
             const index = _curvePoint.getIndex();
             _curvePoint.setIndex(index - 1);
           }

+ 2 - 7
src/graphic/Service/SVGService.js

@@ -2,21 +2,16 @@ 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 { addLine } from "../Controls/AddLine";
 export default class SVGService {
   constructor() {}
 
   create(position, type, svgId) {
     let svg = new SVG(position, type, svgId);
-    if (type == 'ZebraCrossing') {
-      this.setZebraCross(svg);
-    }
     dataService.addSVG(svg);
     return svg;
   }
-  //设置斑马线属性
-  setZebraCross(svg) {
-    svg.style = { lineWidth: 2, lineSpace: 5 };
-  }
   copy(vectorId) {
     let SVG = dataService.getSVG(vectorId);
     let newCenter = uiService.getNewPositionForPop(SVG.center);

+ 3 - 1
src/graphic/Settings.js

@@ -13,6 +13,8 @@ const Settings = {
   singleCurveRoadWidth: 50,
   singleRoadDrivewayCount: 2,
   singleCurveRoadDrivewayCount: 2,
+  zebraCrossLineWeight: 2, //斑马线线宽,真实像素
+  zebraCrosslineSpace: 5, //斑马线线间距,真实像素
   leftRoadWidth: 50,
   rightRoadWidth: 50,
   leftCurveRoadWidth: 50,
@@ -30,7 +32,7 @@ const Settings = {
   selectSVGType: null, //图例
   selectRoadTemplate: null, //道路模板
   selectRoadStructure: null, //道路结构
-  basePointIds:[],//基准点
+  basePointIds: [], //基准点
 };
 console.error(os.isPc);
 export default Settings;