Bladeren bron

添加曲路的路缘线。CurveRoadEdge.js里多了一个属性:curveRoadSide。包含:width,points,curves

xushiting 2 jaren geleden
bovenliggende
commit
526ada3e87

+ 41 - 27
src/graphic/Controls/MoveRoad.js

@@ -23,7 +23,6 @@ export default class MoveRoad {
   // 测试要考虑pointId拖拽到包含他的所有墙的另一头
   // 这个函数不会删除/拆分/合并墙或者点
   moveingRoadPoint(pointId, position, modifyPoint) {
-
     let point = dataService.getRoadPoint(pointId);
     let road = dataService.getRoad(Object.keys(point.parent)[0]);
     let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
@@ -135,13 +134,13 @@ export default class MoveRoad {
     //     point.setPosition(position);
     //   }
     // }
-    roadService.initRoadWidthTipsPos(road)
+    roadService.initRoadWidthTipsPos(road);
     edgeService.updateEdgeForMovePoint(pointId);
-    if(leftEdge.roadSide){
-      leftEdge.initRoadSide()
+    if (leftEdge.roadSide) {
+      leftEdge.initRoadSide();
     }
-    if(rightEdge.roadSide){
-      rightEdge.initRoadSide()
+    if (rightEdge.roadSide) {
+      rightEdge.initRoadSide();
     }
     return true;
   }
@@ -1070,7 +1069,6 @@ export default class MoveRoad {
   }
 
   moveRoad(roadId, dx, dy) {
-
     dx = dx;
     dy = -dy;
 
@@ -1100,12 +1098,12 @@ export default class MoveRoad {
       rightEdge.end.y += dy;
 
       roadService.setLanes(roadId);
-      roadService.initRoadWidthTipsPos(road)
-      if(leftEdge.roadSide){
-        leftEdge.initRoadSide()
+      roadService.initRoadWidthTipsPos(road);
+      if (leftEdge.roadSide) {
+        leftEdge.initRoadSide();
       }
-      if(rightEdge.roadSide){
-        rightEdge.initRoadSide()
+      if (rightEdge.roadSide) {
+        rightEdge.initRoadSide();
       }
     }
   }
@@ -1159,6 +1157,12 @@ export default class MoveRoad {
     //   );
     // }
     curveRoadService.setLanes(curveRoadId);
+    if (leftCurveEdge.roadSide) {
+      leftCurveEdge.initCurveRoadSide();
+    }
+    if (rightCurveEdge.roadSide) {
+      rightCurveEdge.initCurveRoadSide();
+    }
   }
 
   // pointId1移动到pointId2
@@ -1237,6 +1241,24 @@ export default class MoveRoad {
     return true;
   }
 
+  moveCurveRoadPoint(pointId, position) {
+    let point = dataService.getCurveRoadPoint(pointId);
+    // point.setPosition(position);
+    const curveRoadId = point.getParent();
+    const curveRoad = dataService.getCurveRoad(curveRoadId);
+    // curveRoadService.updateForMovePoint(curveRoad, point.index);
+    curveRoadService.updateForMovePoint(pointId, position);
+
+    const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
+    const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
+    if (leftCurveEdge.roadSide) {
+      leftCurveEdge.initCurveRoadSide();
+    }
+    if (rightCurveEdge.roadSide) {
+      rightCurveEdge.initCurveRoadSide();
+    }
+  }
+
   // //
   // createRoadForMoveRoad(pointId, roadId, newPosition) {
   //   const road = dataService.getRoad(roadId);
@@ -1254,14 +1276,6 @@ export default class MoveRoad {
   // }
 
   /******************************************************************************************************************************************************************************/
-  moveCurveRoadPoint(pointId, position) {
-    // let point = dataService.getCurvePoint(pointId);
-    // point.setPosition(position);
-    // const curveRoadId = point.getParent();
-    // const curveRoad = dataService.getCurveRoad(curveRoadId);
-    // curveRoadService.updateForMovePoint(curveRoad, point.index);
-    curveRoadService.updateForMovePoint(pointId, position);
-  }
 
   moveCrossPoint(crossPointId, position) {
     crossPointService.updateForMovePoint(crossPointId, position);
@@ -1271,7 +1285,7 @@ export default class MoveRoad {
     const edge = dataService.getRoadEdge(edgeId);
     const parent = edge.getParent();
     const road = dataService.getRoad(parent);
-    
+
     const line = roadService.getMidLine(road);
     let join = mathUtil.getJoinLinePoint(position, line);
 
@@ -1310,12 +1324,9 @@ export default class MoveRoad {
     ) {
       roadService.updateForWidth(parent, newWidth, dir);
     }
-    roadService.initRoadWidthTipsPos(road)
-    if(leftEdge.roadSide){
-      leftEdge.initRoadSide()
-    }
-    if(rightEdge.roadSide){
-      rightEdge.initRoadSide()
+    roadService.initRoadWidthTipsPos(road);
+    if (edge.roadSide) {
+      edge.initRoadSide();
     }
   }
 
@@ -1411,6 +1422,9 @@ export default class MoveRoad {
     ) {
       curveRoadService.updateForWidth(parent, newWidth, dir);
     }
+    if (curveEdge.roadSide) {
+      curveEdge.initCurveRoadSide();
+    }
   }
   /******************************************************************************************************************************************************************************/
 }

+ 110 - 59
src/graphic/Controls/UIControl.js

@@ -1,39 +1,39 @@
-import { coordinate } from '../Coordinate.js';
-import LayerEvents from '../enum/LayerEvents.js';
-import UIEvents from '../enum/UIEvents.js';
-import RoadTemplate from '../enum/RoadTemplate.js';
-import VectorType from '../enum/VectorType.js';
-import VectorStyle from '../enum/VectorStyle.js';
-import VectorWeight from '../enum/VectorWeight.js';
-import GeoActions from '../enum/GeoActions.js';
-import VectorEvents from '../enum/VectorEvents.js';
-import SVGType from '../enum/SVGType.js';
-import { stateService } from '../Service/StateService.js';
-import { uiService } from '../Service/UIService.js';
-import { dataService } from '../Service/DataService.js';
-import { historyService } from '../Service/HistoryService.js';
-import { elementService } from '../Service/ElementService';
-import { lineService } from '../Service/LineService.js';
-import { circleService } from '../Service/CircleService.js';
-import { textService } from '../Service/TextService.js';
-import { svgService } from '../Service/SVGService.js';
-import { magnifierService } from '../Service/MagnifierService.js';
-import { mathUtil } from '../Util/MathUtil';
-import Constant from '../Constant';
+import { coordinate } from "../Coordinate.js";
+import LayerEvents from "../enum/LayerEvents.js";
+import UIEvents from "../enum/UIEvents.js";
+import RoadTemplate from "../enum/RoadTemplate.js";
+import VectorType from "../enum/VectorType.js";
+import VectorStyle from "../enum/VectorStyle.js";
+import VectorWeight from "../enum/VectorWeight.js";
+import GeoActions from "../enum/GeoActions.js";
+import VectorEvents from "../enum/VectorEvents.js";
+import SVGType from "../enum/SVGType.js";
+import { stateService } from "../Service/StateService.js";
+import { uiService } from "../Service/UIService.js";
+import { dataService } from "../Service/DataService.js";
+import { historyService } from "../Service/HistoryService.js";
+import { elementService } from "../Service/ElementService";
+import { lineService } from "../Service/LineService.js";
+import { circleService } from "../Service/CircleService.js";
+import { textService } from "../Service/TextService.js";
+import { svgService } from "../Service/SVGService.js";
+import { magnifierService } from "../Service/MagnifierService.js";
+import { mathUtil } from "../Util/MathUtil";
+import Constant from "../Constant";
 // import { roomsUtil } from "../Room/RoomsUtil.js";
-import { addRoad } from '../Controls/AddRoad';
-import { addLine } from './AddLine.js';
-import VectorCategory from '../enum/VectorCategory.js';
+import { addRoad } from "../Controls/AddRoad";
+import { addLine } from "./AddLine.js";
+import VectorCategory from "../enum/VectorCategory.js";
 // import { floorplanData } from "../VectorData.js";
 
-import { pointService } from '../Service/PointService.js';
-import Settings from '../Settings.js';
-import { addPoint } from './AddPoint.js';
-import { locationModeControl } from './LocationModeControl.js';
-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 { pointService } from "../Service/PointService.js";
+import Settings from "../Settings.js";
+import { addPoint } from "./AddPoint.js";
+import { locationModeControl } from "./LocationModeControl.js";
+import { curveRoadPointService } from "../Service/CurveRoadPointService.js";
+import { roadService } from "../Service/RoadService.js";
+import { curveRoadService } from "../Service/CurveRoadService.js";
+import Msg from "../enum/Msg.js";
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -104,7 +104,7 @@ export default class UIControl {
         uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
         uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
         //执行新的事件
-        if (uiService.isBelongRoad(selectUI) || selectUI == 'road') {
+        if (uiService.isBelongRoad(selectUI) || selectUI == "road") {
           stateService.setEventName(LayerEvents.AddRoad);
         } else if (selectUI == UIEvents.CurveRoad) {
           stateService.setEventName(LayerEvents.AddCurveRoad);
@@ -145,7 +145,7 @@ export default class UIControl {
   }
 
   updateVectorForSelectUI(selectUI) {
-    console.log('selectUI', selectUI);
+    console.log("selectUI", selectUI);
     const focusItem = stateService.getFocusItem();
 
     // if (selectUI == VectorStyle.Bold || selectUI == VectorStyle.Thinning) {
@@ -168,9 +168,9 @@ export default class UIControl {
     if (uiService.isBelongRoadEdgeStyle(selectUI)) {
       let key = null;
       if (VectorStyle[selectUI]) {
-        key = 'setStyle';
+        key = "setStyle";
       } else if (VectorWeight[selectUI]) {
-        key = 'setWeight';
+        key = "setWeight";
       }
       if (focusItem.type == VectorType.Line) {
         let Line = dataService.getLine(focusItem.vectorId);
@@ -201,11 +201,11 @@ export default class UIControl {
           roadEdge = dataService.getCurveRoadEdge(focusItem.vectorId);
           if (selectUI == VectorStyle.RoadSide) {
             //修改路缘线
-            // roadEdge.initRoadSide();
+            roadEdge.initCurveRoadSide();
           } else {
             roadEdge[key](selectUI);
             if (roadEdge.roadSide) {
-              // roadEdge.removeRoadSide();
+              roadEdge.removeCurveRoadSide();
             }
           }
         }
@@ -402,27 +402,52 @@ 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);
               }
             }
@@ -435,7 +460,10 @@ 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);
@@ -542,7 +570,7 @@ export default class UIControl {
   }
 
   getCadBlob(canvas) {
-    var type = 'jpg';
+    var type = "jpg";
     return new Promise((resolve) => canvas.toBlob(resolve, `${type}/image`));
   }
 
@@ -561,19 +589,38 @@ 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);
+    var event = document.createEvent("MouseEvents");
+    event.initMouseEvent(
+      "click",
+      true,
+      false,
+      window,
+      0,
+      0,
+      0,
+      0,
+      0,
+      false,
+      false,
+      false,
+      false,
+      0,
+      null
+    );
     save_link.dispatchEvent(event);
   }
 
   _fixType(type) {
-    type = type.toLowerCase().replace(/jpg/i, 'jpeg');
+    type = type.toLowerCase().replace(/jpg/i, "jpeg");
     var r = type.match(/png|jpeg|bmp|gif/)[0];
-    return 'image/' + r;
+    return "image/" + r;
   }
   /****************************************************************************针对菜单*******************************************************************************/
 
@@ -641,7 +688,7 @@ export default class UIControl {
     this.graphicStateUI.continuedMode = true;
   }
   confirmEntry() {
-    console.log('确认');
+    console.log("确认");
     this.graphicStateUI.continuedMode = false;
     this.layer.exit();
     this.layer.history.save();
@@ -650,7 +697,7 @@ export default class UIControl {
     uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
   }
   confirmCancel() {
-    console.log('取消');
+    console.log("取消");
     this.graphicStateUI.continuedMode = false;
     this.layer.exit();
     this.layer.history.save();
@@ -662,9 +709,13 @@ export default class UIControl {
 
   // 设置默认设置
   setDefaultSetting(setting) {
-    console.log('获得设置', setting);
-    uiService.setRoadMidDivideWidth(setting.roadQuarantineWidth / coordinate.res);
-    uiService.setCurveRoadMidDivideWidth(setting.roadQuarantineWidth / coordinate.res);
+    console.log("获得设置", setting);
+    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;

+ 11 - 4
src/graphic/Geometry/CurveRoad.js

@@ -10,12 +10,17 @@ export default class CurveRoad extends Road {
     this.leftLanesCurves = []; //左车道曲线
     this.rightLanesCurves = []; //左车道曲线
     this.singleLanesCurves = []; //单向车道
+    this.curveRoadWidthTipsPos = []; //车道提示位置
     this.leftDrivewayCount = Settings.curveRoadLeftDrivewayCount; //左边的车道个数
     this.rightDrivewayCount = Settings.curveRoadRightDrivewayCount; //右边的车道个数
     this.leftWidth =
-      (Settings.curveRoadLeftDrivewayCount * Settings.singleLaneWidth)* window.coordinate.ratio;
+      Settings.curveRoadLeftDrivewayCount *
+      Settings.singleLaneWidth *
+      window.coordinate.ratio;
     this.rightWidth =
-      (Settings.curveRoadRightDrivewayCount * Settings.singleLaneWidth)* window.coordinate.ratio;
+      Settings.curveRoadRightDrivewayCount *
+      Settings.singleLaneWidth *
+      window.coordinate.ratio;
     this.midDivide = {
       leftMidDivide: [],
       leftMidDivideCurves: [],
@@ -26,9 +31,11 @@ export default class CurveRoad extends Road {
     this.curves = [];
     this.singleCurveRoadDrivewayCount = Settings.singleCurveRoadDrivewayCount;
     this.singleCurveRoadWidth =
-      Settings.singleCurveRoadDrivewayCount * Settings.singleLaneWidth* window.coordinate.ratio;
+      Settings.singleCurveRoadDrivewayCount *
+      Settings.singleLaneWidth *
+      window.coordinate.ratio;
     this.geoType = VectorType.CurveRoad;
-    this.setWay(Constant.twoWay)
+    this.setWay(Constant.twoWay);
     this.setId(vectorId);
   }
 

+ 35 - 13
src/graphic/Geometry/CurveRoadEdge.js

@@ -1,12 +1,13 @@
 //墙的边缘线
-import Geometry from './Geometry.js';
-import VectorType from '../enum/VectorType.js';
-import { mathUtil } from '../Util/MathUtil.js';
-import VectorWight from '../enum/VectorWeight.js';
-import VectorStyle from '../enum/VectorStyle.js';
-import { dataService } from '../Service/DataService.js';
+import Geometry from "./Geometry.js";
+import VectorType from "../enum/VectorType.js";
+import { mathUtil } from "../Util/MathUtil.js";
+import VectorWight from "../enum/VectorWeight.js";
+import VectorStyle from "../enum/VectorStyle.js";
+import { dataService } from "../Service/DataService.js";
 import { curveEdgeService } from "../Service/CurveEdgeService";
-import Constant from '../Constant';
+import Constant from "../Constant";
+
 export default class CurveRoadEdge extends Geometry {
   constructor(start, end, vectorId, parentId, points) {
     super();
@@ -18,10 +19,10 @@ export default class CurveRoadEdge extends Geometry {
     this.weight = VectorWight.Thinning;
     this.points = points || [];
     this.curves = [];
+    this.curveRoadSide = null;
     this.geoType = VectorType.CurveRoadEdge;
     this.setId(vectorId);
     this.setPositions(start, end);
-
   }
 
   setPositions(point1, point2) {
@@ -33,21 +34,42 @@ export default class CurveRoadEdge 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);
     }
   }
 
   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;
     }
   }
-  
+
+  initCurveRoadSide() {
+    if (this.curveRoadSide.width) {
+      let curveRoad = dataService.getCurveRoad(this.parent);
+      this.curveRoadSide.points = [];
+      this.curveRoadSide.curves = [];
+      for (let i = 0; i < curveRoad.points.length; ++i) {
+        this.curveRoadSide.points[i] = mathUtil.getLinePointPos(
+          curveRoad.points[i],
+          this.points[i],
+          this.curveRoadSide.width
+        );
+      }
+      this.curveRoadSide.curves = mathUtil.getCurvesByPoints(
+        this.curveRoadSide.points
+      );
+    }
+  }
+
+  removeCurveRoadSide() {
+    this.curveRoadSide = null;
+  }
 }

+ 28 - 13
src/graphic/Layer.js

@@ -184,7 +184,7 @@ export default class Layer {
         break;
       case LayerEvents.AddSVG:
         stateService.setEventName(LayerEvents.MoveSVG);
-        addSVG.buildSVG(position,Settings.selectSVGType);
+        addSVG.buildSVG(position, Settings.selectSVGType);
         // addSVG.newSVG.setType(Settings.selectSVGType);
 
         stateService.setSelectItem(addSVG.newSVG.vectorId, VectorType.SVG, -1);
@@ -220,15 +220,15 @@ export default class Layer {
                 selectItem.dir
               );
             }
-            roadService.initRoadWidthTipsPos(road)
+            roadService.initRoadWidthTipsPos(road);
 
             let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
             let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
-            if(leftEdge.roadSide){
-              leftEdge.initRoadSide()
+            if (leftEdge.roadSide) {
+              leftEdge.initRoadSide();
             }
-            if(rightEdge.roadSide){
-              rightEdge.initRoadSide()
+            if (rightEdge.roadSide) {
+              rightEdge.initRoadSide();
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
@@ -248,9 +248,17 @@ export default class Layer {
                   selectItem.dir
                 );
               }
+              let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
+              let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
+              if (leftEdge.roadSide) {
+                leftEdge.initCurveRoadSide();
+              }
+              if (rightEdge.roadSide) {
+                rightEdge.initCurveRoadSide();
+              }
             }
           }
-          
+
           this.history.save();
           this.renderer.autoRedraw();
         }
@@ -280,11 +288,11 @@ export default class Layer {
             }
             let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
             let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
-            if(leftEdge.roadSide){
-              leftEdge.initRoadSide()
+            if (leftEdge.roadSide) {
+              leftEdge.initRoadSide();
             }
-            if(rightEdge.roadSide){
-              rightEdge.initRoadSide()
+            if (rightEdge.roadSide) {
+              rightEdge.initRoadSide();
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
@@ -304,9 +312,17 @@ export default class Layer {
                   selectItem.dir
                 );
               }
+              let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
+              let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
+              if (leftEdge.roadSide) {
+                leftEdge.initCurveRoadSide();
+              }
+              if (rightEdge.roadSide) {
+                rightEdge.initCurveRoadSide();
+              }
             }
           }
-          roadService.initRoadWidthTipsPos(road)
+          roadService.initRoadWidthTipsPos(road);
           this.history.save();
           this.renderer.autoRedraw();
         }
@@ -397,7 +413,6 @@ export default class Layer {
           }
         }
         break;
-      
     }
     selectItem = stateService.getSelectItem();
     stateService.setDraggingItem(selectItem);

+ 39 - 0
src/graphic/Service/CurveRoadService.js

@@ -208,6 +208,14 @@ export default class CurveRoadService extends RoadService {
     newCurveRoad.leftWidth = curveRoad.leftWidth;
     newCurveRoad.rightWidth = curveRoad.rightWidth;
     this.setLanes(newCurveRoad.vectorId);
+
+    if (leftCurveEdge.roadSide) {
+      leftEdge.initCurveRoadSide();
+    }
+    if (rightCurveEdge.roadSide) {
+      rightEdge.initCurveRoadSide();
+    }
+
     return newCurveRoad.vectorId;
   }
 
@@ -1124,6 +1132,37 @@ export default class CurveRoadService extends RoadService {
     curveRoad.curves = mathUtil.getCurvesByPoints(curveRoad.points);
   }
 
+  initRoadWidthTipsPos(curveRoad) {
+    // const startPoint = dataService.getRoadPoint(road.startId);
+    // const endPoint = dataService.getRoadPoint(road.endId);
+    // const leftEdge = dataService.getRoadEdge(road.leftEdgeId);
+    // const rightEdge = dataService.getRoadEdge(road.rightEdgeId);
+    // const line = mathUtil.createLine1(startPoint, endPoint);
+    // const vLine = mathUtil.getLineForPoint(line, startPoint);
+    // const line1 = mathUtil.createLine3(vLine, leftEdge.start);
+    // const line2 = mathUtil.createLine3(vLine, leftEdge.end);
+    // const line3 = mathUtil.createLine3(vLine, rightEdge.start);
+    // const line4 = mathUtil.createLine3(vLine, rightEdge.end);
+    // let start1, end1, start2, end2;
+    // let dis1, dis2;
+    // if (road.way == Constant.oneWay) {
+    //   if (Object.keys(endPoint.getParent()).length == 1) {
+    //     start1 = mathUtil.getJoinForStartToEnd(leftEdge.end, leftEdge.start);
+    //   } else if (Object.keys(startPoint.getParent()).length == 1) {
+    //     start1 = mathUtil.getJoinForStartToEnd(leftEdge.start, leftEdge.end);
+    //   } else {
+    //     //暂时决定采用end方向
+    //     dis1 = mathUtil.getDisForPoinLine(point, line2);
+    //     dis2 = mathUtil.getDisForPoinLine(point, line4);
+    //   }
+    //   // if(Object.keys(startPoint.getParent()).length == 1 &&
+    //   // Object.keys(endPoint.getParent()).length == 1)
+    // } else if (road.way == Constant.twoWay) {
+    // }
+    // // getJoinForStartToEnd1(start, end, distance)
+    // // getJoinForStartToEnd2(start, end, ratio)
+  }
+
   convertToCurveLines(curveRoadId) {
     let curveRoad = dataService.getCurveRoad(curveRoadId);
     let leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);

+ 0 - 11
src/graphic/Service/RoadService.js

@@ -1511,17 +1511,6 @@ export default class RoadService {
     this.setLanes(roadId, dir);
   }
 
-  updateMeasureLineForWidth() {
-    const road = dataService.getRoad(roadId);
-    const startPoint = dataService.getRoadPoint(road.startId);
-    const endPoint = dataService.getRoadPoint(road.endId);
-    const leftEdge = dataService.getRoadEdge(road.leftEdgeId);
-    const rightEdge = dataService.getRoadEdge(road.rightEdgeId);
-    if (road.way == Constant.oneWay) {
-    } else if (road.way == Constant.twoWay) {
-    }
-  }
-
   //将道路转换成线条
   convertToLines(roadId) {
     let road = dataService.getRoad(roadId);

+ 32 - 2
src/graphic/Util/MathUtil.js

@@ -117,10 +117,40 @@ export default class MathUtil {
   }
 
   //start-end这条线段上,距离start是distance的点
-  getJoinForStartToEnd1(start, end, distance) {}
+  getJoinForStartToEnd1(start, end, distance) {
+    const line = this.createLine1(start, end);
+    const lines = this.getParallelLineForDistance(line, distance);
+    const join1 = this.getIntersectionPoint(lines.line1, line);
+    const join2 = this.getIntersectionPoint(lines.line2, line);
+
+    const dis1 = this.getDistance(join1, end);
+    const dis2 = this.getDistance(join2, end);
+    if (dis1 > dis2) {
+      return join2;
+    } else {
+      return join1;
+    }
+  }
 
   //start-end这条线段上,离start的距离是start-end长度的ratio
-  getJoinForStartToEnd2(start, end, ratio) {}
+  getJoinForStartToEnd2(start, end, ratio) {
+    const dx = end.x - start.x;
+    const dy = end.y - start.y;
+    return {
+      x: start.x + dx * ratio,
+      y: start.y + dy * ratio,
+    };
+  }
+
+  getJoinForStartToEnd(start, end) {
+    const distance = Constant.minLen * 4;
+    const ratio = 0.5;
+    if (this.getDistance(start, end) < distance * 2) {
+      return this.getJoinForStartToEnd2(start, end, ratio);
+    } else {
+      return this.getJoinForStartToEnd1(start, end, distance);
+    }
+  }
 
   //获取扇形的两个端点
   getEndpoint(point, angle, sectorAngle) {