Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	server/test/a0k4xu045_202305311600080410/attach/sceneStore
bill 2 years ago
parent
commit
e12bf081af

+ 116 - 12
public/static/lib/potree/potree.js

@@ -54112,6 +54112,7 @@
 	        let done = ()=>{ //一定要旋转和位移都结束了才能执行
 	            
 	            let f = ()=>{
+	                this.position.copy(endPosition);  //因为延时1后control的update会导致位置改变
 	                info.callback && info.callback();     
 	                this.dispatchEvent('flyingDone');  
 	                viewer.dispatchEvent('content_changed');
@@ -81490,6 +81491,8 @@ void main()
 	                || !e.isAtDomElement && this.isNew//如果是刚添加时在其他dom点击, 不要响应
 	                ||  e.hoverViewport != viewer.mainViewport && this.unableDragAtMap //垂直的测量线不允许在地图上放点
 	                || this.isNew && !getDifferentPoint(this.points, this.points.length )   //不允许和之前的点相同, 但这句在点云稀疏时会导致难结束 
+	                || this.isNew && (Date.now() - this.beginAddTime) < Potree.config.clickMaxPressTime && e.pressDistance < Potree.config.clickMaxDragDis/* &&  e.pressTime<Potree.config.clickMaxPressTime */  //有的设备过于灵敏,点击一下就结束测量了,是因为滑动了被判断为拖拽。所以判断下如果滑动距离过近不时间过短就算单击
+	     
 	            ) 
 	        ){
 	            return this.continueDrag(null,e)    
@@ -82013,12 +82016,18 @@ void main()
 	            }
 	            return 
 	        }
+	        
 	         
+	        /* viewer.addEventListener('camera_changed',(e)=>{
+	            if(e.changeInfo.positionChanged){
+	                setLabelPos()
+	            } 
+	        }) */
 	         
 	         
 	        let setEdgeLabel = (label,p1,p2,distance)=>{//设置label位置和字
-	            let center = new Vector3().addVectors(p1,p2).multiplyScalar(0.5);  
-	            label.setPos(center); 
+	            this.setEdgeLabelPos(label,p1,p2);
+	 
 	            distance = distance == void 0 ? p1.distanceTo(p2) : distance; 
 	            var text = this.labelText || viewer.unitConvert.convert(distance, 'distance', Potree.settings.precision, this.unitSystem, 0.1 , true);//distance要传0.1 这个factor
 	            label.setText(text);
@@ -82043,10 +82052,10 @@ void main()
 	                let distance = this.labelText || point.distanceTo(nextPoint);
 	                edgeLabel.shouldVisi = this.labelText || (index < lastIndex || this.isRect || this.closed && !this.isNew ) && distance>0; 
 	                /* this.closed || */edgeLabel.setVisible(edgeLabel.shouldVisi);  
+	                edgeLabel.sprite.lineDir = new Vector3().subVectors(point,nextPoint).normalize(); //[point,nextPoint]
 	                if(edgeLabel.visible){
 	                    setEdgeLabel(edgeLabel,point,nextPoint,distance);
 	                }  
-	                edgeLabel.sprite.lineDir = new Vector3().subVectors(point,nextPoint).normalize(); //[point,nextPoint]
 	            }
 	        } 
 
@@ -82098,7 +82107,28 @@ void main()
 			
 		};
 
-	  
+
+
+	    setEdgeLabelPos(label,p1,p2){ //调整label的位置,使倾斜后看起来在线的中心,而不要挡住端点
+	        let center = new Vector3().addVectors(p1,p2).multiplyScalar(0.5);  
+	         
+	        if(!label.sprite.lineDir || viewer.mainViewport.camera.type == 'OrthographicCamera'){
+	            label.setPos(center);  
+	        }else { 
+	            let eyePos = viewer.mainViewport.camera.position;
+	            let dir = viewer.mainViewport.view.direction; //new THREE.Vector3().subVectors(center,eyePos).normalize()
+	            let vec = label.sprite.lineDir;
+	            let cos = dir.dot(vec);  
+	            
+	            let efficiency = 0.35; // 0-1  数值越高,r越容易接近1或-1,label越容易在倾斜后靠近近端点。 
+	            let r = 0.5*efficiency*cos + 0.5;
+	            //console.log(r,    cos )
+	            center = p1.clone().multiplyScalar(1-r).add(p2.clone().multiplyScalar(r)); //label在线上滑动,使尽量保持在视觉中心
+	            label.setPos(center);  
+	        } 
+	    }
+
+	    
 	      
 		addMarker (o={}) {
 	         
@@ -83295,6 +83325,16 @@ void main()
 	        
 	        viewer.addEventListener('resize',this.setSize.bind(this));
 	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
 		}
 
 		onSceneChange(e){
@@ -83325,7 +83365,41 @@ void main()
 	    }
 	    
 	    
-		update(){
+		update(){ 
+	        //add
+	        viewer.scene.measurements.forEach(measure=>{
+	            
+	            let lastIndex = measure.points.length - 1; 
+	            for (let index = 0; index <= lastIndex; index++) {
+	                
+	                let nextIndex = (index + 1 > lastIndex) ? 0 : index + 1;
+	                let previousIndex = (index === 0) ? lastIndex : index - 1;
+	                
+	                let point = measure.points[index];
+	                let nextPoint = measure.points[nextIndex];
+	                let previousPoint = measure.points[previousIndex];
+	 
+	                if(measure.showDistances || measure.labelText){ // edge labels
+	                    let edgeLabel = measure.edgeLabels[index];
+	                  
+	                    if(edgeLabel.visible){
+	                        measure.setEdgeLabelPos(edgeLabel, point, nextPoint  );
+	                    }  
+	                }
+	            } 
+	            
+	        });
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
+	        
 	        return;
 	        
 	        
@@ -83653,10 +83727,10 @@ void main()
 	        let click = (e)=>{//一旦点击就立刻增加两marker  
 	         
 	            if(ifAtWrongPlace(e))return  
-	            if(e.clickElement)return  //如点击label时focusOnObject
+	            if(e.clickElement || e.drag.object)return  //如点击label时focusOnObject, 或拖拽marker
 	             
 	            
-	            if(e.button === MOUSE.RIGHT)return 
+	            if(e.button === MOUSE.RIGHT )return  
 	            
 	            if(isMobile){
 	                viewer.controls.setEnable(false);
@@ -83706,6 +83780,8 @@ void main()
 	            this.viewer.removeEventListener('global_touchstart', click );//add  importance
 	            measure.dispatchEvent('firstClick');
 	            
+	            
+	            measure.beginAddTime = Date.now();
 	            //console.log('measure clicked')
 	            e.consume && e.consume();
 	            
@@ -89507,6 +89583,7 @@ void main()
 	                    {
 	                        type: 'drop',
 	                        pressDistance, 
+	                        pressTime
 	                    }
 	                ));
 	                
@@ -97307,14 +97384,24 @@ ENDSEC
 	        //Potree.Log('hope flyToPano: '+toPano.pano.id )
 	        
 	        
-	        if(this.latestToPano && this.latestToPano != toPano && this.latestToPano.pano != this.currentPano){//还在飞//如果旧的toPano只是旋转镜头,就直接取消旧的
+	       
+	        //如果旧的toPano只是旋转镜头,就直接取消旧的
+	        
+	        
+	        
+	        if(this.latestToPano && this.latestToPano != toPano && (//还在飞
+	            this.latestToPano.pano != this.currentPano || !this.isAtPano())){//如果旧的toPano只在pano旋转镜头,就直接取消旧的,继续执行 
 	            return done(false) 
 	        }
-	        //Potree.Log('flyToPano: '+toPano.pano.id,  this.latestToPano && this.latestToPano.pano.id )
+	         
 	        if(this.currentPano == toPano.pano && this.isAtPano() && !toPano.target && !toPano.quaternion  ){
+	            //已在该pano
 	            this.dispatchEvent({type:'flyToPano', toPano});
 	            return done(true);
 	        }
+	     
+	        //Potree.Log('flyToPano: '+toPano.pano.id,  this.latestToPano && this.latestToPano.pano.id )
+	        
 	        
 	        let target = toPano.target;   
 	        let config = Potree.config.displayMode[Potree.settings.displayMode];
@@ -139146,9 +139233,18 @@ ENDSEC
 	                this.images360.panos.forEach(pano=>{
 	                    Potree.Utils.updateVisible(pano, 'screenshot', true);
 	                }); 
-	                viewer.scene.measurements.forEach((e)=>{
-	                    Potree.Utils.updateVisible(e, 'screenshot', true);  
-	                });
+	                if(info.hideMeasures){
+	                    viewer.scene.measurements.forEach((e)=>{
+	                        Potree.Utils.updateVisible(e, 'screenshot', true);  
+	                    }); 
+	                }else {
+	                    viewer.scene.measurements.forEach((e)=>{
+	                        e.edgeLabels.forEach(label=>{
+	                            label.backgroundColor.a = label._oldA  ;//透明的抗锯齿渲染会变黑,所以去除透明
+	                            label.updateTexture();  
+	                        });
+	                    });
+	                } 
 	                
 	                Potree.Utils.updateVisible(this.reticule, 'screenshot', true);
 	                 
@@ -139229,6 +139325,14 @@ ENDSEC
 	            viewer.scene.measurements.forEach((e)=>{
 	                Potree.Utils.updateVisible(e, 'screenshot', false);  
 	            });
+	        }else {
+	            viewer.scene.measurements.forEach((e)=>{
+	                e.edgeLabels.forEach(label=>{
+	                    label._oldA = label.backgroundColor.a;
+	                    label.backgroundColor.a = 1 ;//透明的抗锯齿渲染会变黑,所以去除透明
+	                    label.updateTexture();  
+	                });
+	            });
 	        }            
 	        Potree.Utils.updateVisible(this.reticule, 'screenshot', false);//令reticule不可见 
 	                                

File diff suppressed because it is too large
+ 1 - 1
public/static/lib/potree/potree.js.map


+ 5 - 5
src/graphic/Controls/AddCrossRoad.js

@@ -248,7 +248,7 @@ export default class AddCrossRoad {
 
   //六岔口
   buildSix(position) {
-    const len = 300;
+    const len = 500;
     const points = mathUtil.createSixPoint(position, len);
     let end = roadPointService.create(position);
     let start1 = roadPointService.create(points[0]);
@@ -420,7 +420,7 @@ export default class AddCrossRoad {
     rightEdge.points.push(edgePoints.rightEdgeEnd);
 
     let point1 = {
-      x: position.x + 200,
+      x: position.x + 250,
       y: position.y + height / 2,
     };
     let point2 = {
@@ -432,7 +432,7 @@ export default class AddCrossRoad {
       y: position.y - height / 2 + 50,
     };
     let point4 = {
-      x: position.x + 200,
+      x: position.x + 250,
       y: position.y - height / 2,
     };
 
@@ -476,7 +476,7 @@ export default class AddCrossRoad {
   }
 
   buildImportSmashedRoad(position) {
-    const roadLen = 600;
+    const roadLen = 800;
     let startPoint = {
       x: position.x,
       y: position.y - (roadLen * 3) / 5,
@@ -493,7 +493,7 @@ export default class AddCrossRoad {
     roadService.create(startPoint.vectorId, crossPoint.vectorId);
     roadService.create(crossPoint.vectorId, endPoint.vectorId);
     let startPoint2 = {
-      x: startPoint.x + roadLen / 4,
+      x: startPoint.x + roadLen / 3,
       y: startPoint.y,
     };
     startPoint2 = roadPointService.create(startPoint2);

+ 90 - 27
src/graphic/Controls/AddPoint.js

@@ -1,16 +1,16 @@
-import { dataService } from '../Service/DataService';
-import { lineService } from '../Service/LineService';
-import { pointService } from '../Service/PointService';
-import VectorCategory from '../enum/VectorCategory';
-import Point from '../Geometry/Point.js';
-import { mathUtil } from '../Util/MathUtil';
-import addLine from './AddLine';
-import Settings from '../Settings';
-import { stateService } from '../Service/StateService';
-import LayerEvents from '../enum/LayerEvents';
-import VectorType from '../enum/VectorType';
-import Constant from '../Constant';
-import { listenLayer } from '../ListenLayer';
+import { dataService } from "../Service/DataService";
+import { lineService } from "../Service/LineService";
+import { pointService } from "../Service/PointService";
+import VectorCategory from "../enum/VectorCategory";
+import Point from "../Geometry/Point.js";
+import { mathUtil } from "../Util/MathUtil";
+import addLine from "./AddLine";
+import Settings from "../Settings";
+import { stateService } from "../Service/StateService";
+import LayerEvents from "../enum/LayerEvents";
+import VectorType from "../enum/VectorType";
+import Constant from "../Constant";
+import { listenLayer } from "../ListenLayer";
 
 export default class AddPoint {
   constructor() {
@@ -19,7 +19,11 @@ export default class AddPoint {
 
   buildPoint(position) {
     //只有一个基准点的时候,测量的时候自动选择基准点
-    if ((Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode) && Settings.basePointIds.length == 1) {
+    if (
+      (Settings.selectLocationMode == Constant.angleLocationMode ||
+        Settings.selectLocationMode == Constant.allLocationMode) &&
+      Settings.basePointIds.length == 1
+    ) {
       Settings.selectBasePointId = Settings.basePointIds[0];
     }
     let newPoint;
@@ -27,28 +31,43 @@ export default class AddPoint {
       newPoint = pointService.create(position);
       Settings.selectBasePointId = newPoint.vectorId;
     } else {
-      if (Settings.selectBasePointId != null && Settings.selectLocationMode == Constant.angleLocationMode) {
+      if (
+        Settings.selectBasePointId != null &&
+        Settings.selectLocationMode == Constant.angleLocationMode
+      ) {
         newPoint = pointService.create(position);
         this.setLocationByAngle(newPoint.vectorId);
         newPoint.setLocationMode(Constant.angleLocationMode);
         stateService.setEventName(LayerEvents.AddPoint);
-      } else if (Settings.selectBasePointId != null && Settings.selectLocationMode == Constant.allLocationMode) {
+      } else if (
+        Settings.selectBasePointId != null &&
+        Settings.selectLocationMode == Constant.allLocationMode
+      ) {
         newPoint = pointService.create(position);
         this.setLocationByAll(newPoint.vectorId);
         newPoint.setLocationMode(Constant.allLocationMode);
         stateService.setEventName(LayerEvents.AddPoint);
-      } else if (Settings.baseLineId != null && Settings.selectLocationMode == Constant.normalLocationMode) {
+      } else if (
+        Settings.baseLineId != null &&
+        Settings.selectLocationMode == Constant.normalLocationMode
+      ) {
         newPoint = pointService.create(position);
         this.setLocationByNormal(newPoint.vectorId);
         newPoint.setLocationMode(Constant.normalLocationMode);
 
         stateService.setEventName(LayerEvents.AddPoint);
-      } else if (Settings.selectBasePointId == null && (Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode)) {
+      } else if (
+        Settings.selectBasePointId == null &&
+        (Settings.selectLocationMode == Constant.angleLocationMode ||
+          Settings.selectLocationMode == Constant.allLocationMode)
+      ) {
         return null;
       }
       if (
         newPoint &&
-        (newPoint.getLocationMode() == Constant.allLocationMode || newPoint.getLocationMode() == Constant.angleLocationMode || newPoint.getLocationMode() == Constant.normalLocationMode) &&
+        (newPoint.getLocationMode() == Constant.allLocationMode ||
+          newPoint.getLocationMode() == Constant.angleLocationMode ||
+          newPoint.getLocationMode() == Constant.normalLocationMode) &&
         newPoint.getCategory() == VectorCategory.Point.TestPoint
       ) {
         this.testPointIds.push(newPoint.vectorId);
@@ -58,6 +77,24 @@ export default class AddPoint {
     return newPoint;
   }
 
+  //添加固定点/基准点
+  buildPoint2(position) {
+    let newPoint = null;
+    if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedPointId) {
+      return null;
+    }
+    if (Settings.selectPointCategory == VectorCategory.Point.BasePoint) {
+      newPoint = pointService.create(position);
+      Settings.selectBasePointId = newPoint.vectorId;
+      stateService.setEventName(LayerEvents.AddPoint);
+    } else if (Settings.selectPointCategory == VectorCategory.Point.FixPoint) {
+      newPoint = pointService.create(position);
+      stateService.setEventName(LayerEvents.AddPoint);
+    }
+    listenLayer.clear();
+    return newPoint;
+  }
+
   isFocusBasePoint() {
     if (Settings.selectBasePointId) {
       let point = dataService.getPoint(Settings.selectBasePointId);
@@ -90,9 +127,17 @@ export default class AddPoint {
     join.setLocationMode(Constant.angleLocationMode);
     join.setLinkedBasePointId(basePoint.vectorId);
     join.setLinkedTestPointId(testPointId);
-    let guidePositionLine = lineService.createByPointId(testPointId, join.vectorId, VectorCategory.Line.GuidePositionLine);
+    let guidePositionLine = lineService.createByPointId(
+      testPointId,
+      join.vectorId,
+      VectorCategory.Line.GuidePositionLine
+    );
 
-    let positionLine = lineService.createByPointId(basePoint.vectorId, join.vectorId, VectorCategory.Line.PositionLine);
+    let positionLine = lineService.createByPointId(
+      basePoint.vectorId,
+      join.vectorId,
+      VectorCategory.Line.PositionLine
+    );
     guidePositionLine.setLocationMode(Constant.angleLocationMode);
     positionLine.setLocationMode(Constant.angleLocationMode);
     join.setCategory(VectorCategory.Point.TestBasePoint);
@@ -118,15 +163,29 @@ export default class AddPoint {
     join.setLinkedBasePointId(basePoint.vectorId);
     join.setLinkedTestPointId(testPointId);
     //待测点与基准线的垂直线
-    lineService.createByPointId(testPointId, join.vectorId, VectorCategory.Line.PositionLine);
+    lineService.createByPointId(
+      testPointId,
+      join.vectorId,
+      VectorCategory.Line.PositionLine
+    );
     //暂时没有其他待测点
     if (this.testPointIds.length == 0) {
       //待测点与基准线点的连线
-      lineService.createByPointId(basePoint.vectorId, testPointId, VectorCategory.Line.PositionLine);
+      lineService.createByPointId(
+        basePoint.vectorId,
+        testPointId,
+        VectorCategory.Line.PositionLine
+      );
     } else {
       //取上一个待测点
-      lineService.createByPointId(this.testPointIds[this.testPointIds.length - 1], testPointId, VectorCategory.Line.PositionLine);
-      testPoint.setLinkedTestPointId(this.testPointIds[this.testPointIds.length - 1]);
+      lineService.createByPointId(
+        this.testPointIds[this.testPointIds.length - 1],
+        testPointId,
+        VectorCategory.Line.PositionLine
+      );
+      testPoint.setLinkedTestPointId(
+        this.testPointIds[this.testPointIds.length - 1]
+      );
     }
   }
 
@@ -148,7 +207,11 @@ export default class AddPoint {
     join.setCategory(VectorCategory.Point.TestBasePoint);
     join.setLocationMode(Constant.normalLocationMode);
     join.setLinkedTestPointId(testPointId);
-    lineService.createByPointId(testPointId, join.vectorId, VectorCategory.Line.PositionLine);
+    lineService.createByPointId(
+      testPointId,
+      join.vectorId,
+      VectorCategory.Line.PositionLine
+    );
   }
 
   deleteTestPoints() {
@@ -158,7 +221,7 @@ export default class AddPoint {
     this.testPointIds = [];
   }
 
-  resetTestPoints(){
+  resetTestPoints() {
     this.testPointIds = [];
   }
 }

+ 85 - 0
src/graphic/Controls/LocationModeControl.js

@@ -0,0 +1,85 @@
+import { mathUtil } from "../Util/MathUtil";
+import { textService } from "../Service/TextService";
+import { listenLayer } from "../ListenLayer";
+import Settings from "../Settings";
+import { dataService } from "../Service/DataService";
+import { lineService } from "../Service/LineService";
+import { pointService } from "../Service/PointService";
+import VectorCategory from "../enum/VectorCategory";
+
+export default class LocationModeControl {
+  constructor() {}
+
+  //设置直角定位法
+  setAngle() {
+    let selectBasePoint = this.isFocusBasePoint();
+    if (selectBasePoint) {
+      let points = dataService.getPoints();
+      for (let i = 0; i < points.length; ++i) {
+        let point = dataService.getPoint(points[i].vectorId);
+        if (point.getCategory() == VectorCategory.Point.fixPoint) {
+          this.setSingleFixPointByAngle(
+            point.vectorId,
+            selectBasePoint.vectorId
+          );
+        }
+      }
+    }
+  }
+
+  //对一个点进行直角定位法
+  //生成两条定位线和一条辅助线
+  setSingleFixPointByAngle(fixPointId, basePointId) {
+    let fixPoint = dataService.getPoint(fixPointId);
+    let basePoint = dataService.getPoint(basePointId);
+    let baseLine = dataService.getLine(Settings.baseLineId);
+    let startPoint = dataService.getPoint(baseLine.startId);
+    let endPoint = dataService.getPoint(baseLine.endId);
+
+    let baseLineGeometry = mathUtil.createLine1(startPoint, endPoint);
+    let vLine = mathUtil.getVerticalLine(baseLineGeometry, fixPoint);
+    let join = mathUtil.getJoinLinePoint(basePoint, vLine);
+    join = pointService.create(join);
+
+    let locationLineByFixPoint = lineService.createByPointId(
+      fixPointId,
+      join.vectorId,
+      VectorCategory.Line.LocationLineByFixPoint
+    );
+
+    let locationLineByBasePoint = mathUtil.getVerticalLine(vLine, basePoint);
+    join = mathUtil.getIntersectionPoint(locationLineByBasePoint, vLine);
+    join = pointService.create(join);
+    locationLineByBasePoint = lineService.createByPointId(
+      basePointId,
+      join.vectorId,
+      VectorCategory.Line.LocationLineByBasePoint
+    );
+
+    let guideLocationLine = lineService.createByPointId(
+      fixPointId,
+      join.vectorId,
+      VectorCategory.Line.GuideLocationLine
+    );
+  }
+
+  /******************************************************************************************************************************************************/
+
+  //设置综合定位法
+  setAll() {}
+
+  /******************************************************************************************************************************************************/
+
+  isFocusBasePoint() {
+    if (Settings.selectBasePointId) {
+      let point = dataService.getPoint(Settings.selectBasePointId);
+      if (point.getCategory() == VectorCategory.Point.BasePoint) {
+        return point;
+      }
+    }
+    return null;
+  }
+}
+
+const locationModeControl = new LocationModeControl();
+export { locationModeControl };

+ 104 - 22
src/graphic/Controls/MoveLine.js

@@ -1,14 +1,91 @@
-import Constant from '../Constant';
-import { dataService } from '../Service/DataService';
-import { lineService } from '../Service/LineService';
-import { pointService } from '../Service/PointService';
-import { movePoint } from './MovePoint';
-import { mathUtil } from '../Util/MathUtil';
-import VectorCategory from '../enum/VectorCategory';
+import Constant from "../Constant";
+import { dataService } from "../Service/DataService";
+import { lineService } from "../Service/LineService";
+import { pointService } from "../Service/PointService";
+import { movePoint } from "./MovePoint";
+import { mathUtil } from "../Util/MathUtil";
+import VectorCategory from "../enum/VectorCategory";
 
 export default class MoveLine {
   constructor() {}
 
+  // moveLine(lineId, dx, dy) {
+  //   dx = dx;
+  //   dy = -dy;
+  //   let line = dataService.getLine(lineId);
+  //   let startPoint = dataService.getPoint(line.startId);
+  //   let endPoint = dataService.getPoint(line.endId);
+
+  //   //垂直移动
+  //   if (line.getCategory() == VectorCategory.Line.PositionLine && line.getLocationMode() == Constant.angleLocationMode) {
+  //     let point1 = {
+  //       x: startPoint.x + dx,
+  //       y: startPoint.y + dy,
+  //     };
+  //     let point2 = {
+  //       x: endPoint.x + dx,
+  //       y: endPoint.y + dy,
+  //     };
+  //     let lineGeometry = mathUtil.createLine1(point1, point2);
+  //     point1 = mathUtil.getJoinLinePoint(startPoint, lineGeometry);
+  //     //startPoint本来是基准点
+  //     if (startPoint.getCategory() == VectorCategory.Point.BasePoint) {
+  //       //达到一定距离才能移动
+  //       if (mathUtil.getDistance(startPoint, point1) < Constant.minAdsorbPix) {
+  //         return false;
+  //       }
+  //       let newStartPoint = pointService.create(point1);
+  //       let extendedPositionLine = lineService.createByPointId(startPoint.vectorId, newStartPoint.vectorId, VectorCategory.Line.ExtendedPositionLine);
+  //       extendedPositionLine.setLocationMode(Constant.angleLocationMode);
+  //       dataService.deletePointParent(startPoint.vectorId, lineId);
+  //       line.startId = newStartPoint.vectorId;
+  //       newStartPoint.setPointParent(line.vectorId, 'start');
+  //       newStartPoint.setCategory(VectorCategory.Point.TestBasePoint);
+  //     } else {
+  //       startPoint.x = point1.x;
+  //       startPoint.y = point1.y;
+  //       let parents = Object.keys(startPoint.parent);
+  //       let extendedLine = dataService.getLine(parents[0]);
+  //       if (extendedLine.getCategory() != VectorCategory.Line.ExtendedPositionLine) {
+  //         extendedLine = dataService.getLine(parents[1]);
+  //       }
+  //       if (extendedLine.getCategory() == VectorCategory.Line.ExtendedPositionLine) {
+  //         //point1是基准点
+  //         point1 = dataService.getPoint(extendedLine.startId);
+  //         point2 = dataService.getPoint(extendedLine.endId);
+  //         if (mathUtil.getDistance(point1, point2) < Constant.minAdsorbPix) {
+  //           dataService.deleteLine(extendedLine.vectorId);
+  //           dataService.deletePoint(extendedLine.endId);
+
+  //           line.startId = point1.vectorId;
+  //           point1.setPointParent(line.vectorId, 'start');
+
+  //           lineGeometry = mathUtil.createLine3(lineGeometry, point1);
+  //         }
+  //       }
+  //     }
+
+  //     point2 = mathUtil.getJoinLinePoint(endPoint, lineGeometry);
+  //     endPoint.x = point2.x;
+  //     endPoint.y = point2.y;
+  //   } else {
+  //     //综合定位和垂线定位,拖动基准线更新位置
+  //     if (line.getCategory() == VectorCategory.Line.BaseLine) {
+  //       let points = dataService.vectorData.points;
+  //       for (let key in points) {
+  //         if (points[key].category == VectorCategory.Point.TestPoint && (points[key].locationMode == Constant.allLocationMode || points[key].locationMode == Constant.normalLocationMode)) {
+  //           movePoint.updatePositionByTestPoint(points[key].vectorId);
+  //         }
+  //       }
+  //     }
+  //     startPoint.x += dx;
+  //     startPoint.y += dy;
+  //     endPoint.x += dx;
+  //     endPoint.y += dy;
+  //   }
+  //   return true;
+  // }
+
   moveLine(lineId, dx, dy) {
     dx = dx;
     dy = -dy;
@@ -16,8 +93,12 @@ export default class MoveLine {
     let startPoint = dataService.getPoint(line.startId);
     let endPoint = dataService.getPoint(line.endId);
 
-    //垂直移动
-    if (line.getCategory() == VectorCategory.Line.PositionLine && line.getLocationMode() == Constant.angleLocationMode) {
+    //垂直移动,直角定位法只支持定位线的拖拽
+    if (
+      (line.getCategory() == VectorCategory.Line.LocationLineByFixPoint ||
+        line.getCategory() == VectorCategory.Line.LocationLineByBasePoint) &&
+      line.getLocationMode() == Constant.angleLocationMode
+    ) {
       let point1 = {
         x: startPoint.x + dx,
         y: startPoint.y + dy,
@@ -35,21 +116,29 @@ export default class MoveLine {
           return false;
         }
         let newStartPoint = pointService.create(point1);
-        let extendedPositionLine = lineService.createByPointId(startPoint.vectorId, newStartPoint.vectorId, VectorCategory.Line.ExtendedPositionLine);
+        let extendedPositionLine = lineService.createByPointId(
+          startPoint.vectorId,
+          newStartPoint.vectorId,
+          VectorCategory.Line.ExtendedPositionLine
+        );
         extendedPositionLine.setLocationMode(Constant.angleLocationMode);
         dataService.deletePointParent(startPoint.vectorId, lineId);
         line.startId = newStartPoint.vectorId;
-        newStartPoint.setPointParent(line.vectorId, 'start');
+        newStartPoint.setPointParent(line.vectorId, "start");
         newStartPoint.setCategory(VectorCategory.Point.TestBasePoint);
       } else {
         startPoint.x = point1.x;
         startPoint.y = point1.y;
         let parents = Object.keys(startPoint.parent);
         let extendedLine = dataService.getLine(parents[0]);
-        if (extendedLine.getCategory() != VectorCategory.Line.ExtendedPositionLine) {
+        if (
+          extendedLine.getCategory() != VectorCategory.Line.ExtendedPositionLine
+        ) {
           extendedLine = dataService.getLine(parents[1]);
         }
-        if (extendedLine.getCategory() == VectorCategory.Line.ExtendedPositionLine) {
+        if (
+          extendedLine.getCategory() == VectorCategory.Line.ExtendedPositionLine
+        ) {
           //point1是基准点
           point1 = dataService.getPoint(extendedLine.startId);
           point2 = dataService.getPoint(extendedLine.endId);
@@ -58,7 +147,7 @@ export default class MoveLine {
             dataService.deletePoint(extendedLine.endId);
 
             line.startId = point1.vectorId;
-            point1.setPointParent(line.vectorId, 'start');
+            point1.setPointParent(line.vectorId, "start");
 
             lineGeometry = mathUtil.createLine3(lineGeometry, point1);
           }
@@ -70,14 +159,7 @@ export default class MoveLine {
       endPoint.y = point2.y;
     } else {
       //综合定位和垂线定位,拖动基准线更新位置
-      if (line.getCategory() == VectorCategory.Line.BaseLine) {
-        let points = dataService.vectorData.points;
-        for (let key in points) {
-          if (points[key].category == VectorCategory.Point.TestPoint && (points[key].locationMode == Constant.allLocationMode || points[key].locationMode == Constant.normalLocationMode)) {
-            movePoint.updatePositionByTestPoint(points[key].vectorId);
-          }
-        }
-      }
+      //缺
       startPoint.x += dx;
       startPoint.y += dy;
       endPoint.x += dx;

+ 2 - 1
src/graphic/History/Change.js

@@ -94,6 +94,7 @@ export default class Change {
       this.currentData.curveRoadEdges.length == 0 &&
       this.currentData.curveRoads.length == 0 &&
       this.currentData.crossPoints.length == 0 &&
+      this.currentData.svgs.length == 0 &&
       !this.currentData.settings
     ) {
       this.saveCurrentInfo();
@@ -272,7 +273,6 @@ export default class Change {
     for (const key in texts) {
       const text = texts[key];
       const lastText = this.lastData.texts[key];
-
       // 不存在意味着增加
       if (!lastText) {
         const item = {
@@ -414,6 +414,7 @@ export default class Change {
         }
       }
       delete this.lastData.svgs[key];
+  
     }
 
     for (const key in this.lastData.svgs) {

+ 22 - 6
src/graphic/History/HistoryUtil.js

@@ -28,7 +28,9 @@ export default class HistoryUtil {
       line1.startId == line2.startId &&
       line1.endId == line2.endId &&
       line1.category == line2.category &&
-      line1.locationMode == line2.locationMode
+      line1.locationMode == line2.locationMode && 
+      line1.style == line2.style && 
+      line1.weight == line2.weight 
     ) {
       return false;
     } else {
@@ -78,7 +80,9 @@ export default class HistoryUtil {
     if (
       mathUtil.equalPoint(text1.center, text2.center) &&
       text1.value == text2.value &&
-      text1.angle == text2.angle
+      text1.angle == text2.angle && 
+      text1.fontSize == text2.fontSize && 
+      text1.color == text2.color 
     ) {
       return false;
     } else {
@@ -174,19 +178,19 @@ export default class HistoryUtil {
           road1.leftDrivewayCount == road2.leftDrivewayCount &&
           road1.rightDrivewayCount == road2.rightDrivewayCount &&
           road1.midDivide.midDivideWidth == road2.midDivide.midDivideWidth &&
-          mathUtil.clonePoint(
+          mathUtil.equalPoint(
             road1.midDivide.leftMidDivide.start,
             road2.midDivide.leftMidDivide.start
           ) &&
-          mathUtil.clonePoint(
+          mathUtil.equalPoint(
             road1.midDivide.leftMidDivide.end,
             road2.midDivide.leftMidDivide.end
           ) &&
-          mathUtil.clonePoint(
+          mathUtil.equalPoint(
             road1.midDivide.rightMidDivide.start,
             road2.midDivide.rightMidDivide.start
           ) &&
-          mathUtil.clonePoint(
+          mathUtil.equalPoint(
             road1.midDivide.rightMidDivide.end,
             road2.midDivide.rightMidDivide.end
           ) &&
@@ -348,6 +352,8 @@ export default class HistoryUtil {
     lineInfo.category = line2.category;
     lineInfo.locationMode = line2.locationMode;
     lineInfo.value = line2.value;
+    lineInfo.style = line2.style;
+    lineInfo.weight = line2.weight;
     this.setLineInfo(lineInfo);
   }
 
@@ -387,6 +393,8 @@ export default class HistoryUtil {
     textInfo.value = text2.value;
     textInfo.center = JSON.parse(JSON.stringify(text2.center));
     textInfo.angle = text2.angle;
+    textInfo.color = text2.color;
+    textInfo.fontSize = text2.fontSize;
     this.setTextInfo(textInfo);
   }
 
@@ -588,6 +596,8 @@ export default class HistoryUtil {
     data.category = line.category;
     data.locationMode = line.locationMode;
     data.type = line.geoType;
+    data.style = line.style;
+    data.weight = line.weight;
     return data;
   }
 
@@ -633,6 +643,8 @@ export default class HistoryUtil {
     data.center = {};
     mathUtil.clonePoint(data.center, text.center);
     data.value = text.value;
+    data.fontSize = text.fontSize 
+    data.color = text.color 
     return data;
   }
 
@@ -815,6 +827,8 @@ export default class HistoryUtil {
     line.category = lineInfo.category;
     line.locationMode = lineInfo.locationMode;
     line.value = lineInfo.value;
+    line.style = lineInfo.style;
+    line.weight = lineInfo.weight;
     return line;
   }
 
@@ -856,6 +870,8 @@ export default class HistoryUtil {
     text.center = JSON.parse(JSON.stringify(textInfo.center));
     text.value = textInfo.value;
     text.angle = textInfo.angle;
+    text.fontSize = textInfo.fontSize;
+    text.color = textInfo.color;
   }
 
   setMagnifierInfo(magnifierInfo) {

+ 170 - 331
src/graphic/Layer.js

@@ -1,48 +1,48 @@
-import Load from "./Load";
-import { stateService } from "./Service/StateService";
-import { elementService } from "./Service/ElementService";
-import { dataService } from "./Service/DataService";
-import { textService } from "./Service/TextService";
-import { historyService } from "./Service/HistoryService";
-import UIControl from "./Controls/UIControl";
-// import { moveRectangle } from "./Controls/MoveRectangle";
-import { moveText } from "./Controls/MoveText";
-import { moveSVG } from "./Controls/MoveSVG";
-import { moveMagnifier } from "./Controls/MoveMagnifier";
-import { addRoad } from "./Controls/AddRoad";
-import { addCrossRoad } from "./Controls/AddCrossRoad";
-import { addLine } from "./Controls/AddLine";
-import { addPoint } from "./Controls/AddPoint";
-import { addCircle } from "./Controls/AddCircle";
-import { addText } from "./Controls/AddText";
-import { addMagnifier } from "./Controls/AddMagnifier";
-import { addSVG } from "./Controls/AddSVG";
-import { moveRoad } from "./Controls/MoveRoad";
-import { moveLine } from "./Controls/MoveLine";
-import { movePoint } from "./Controls/MovePoint";
-import { moveCircle } from "./Controls/MoveCircle";
-import { coordinate } from "./Coordinate";
-import Render from "./Renderer/Render";
-import { draw } from "./Renderer/Draw";
-import { listenLayer } from "./ListenLayer";
-import LayerEvents from "./enum/LayerEvents.js";
-import UIEvents from "./enum/UIEvents.js";
-import SelectState from "./enum/SelectState.js";
-import VectorType from "./enum/VectorType";
-import { mathUtil } from "./Util/MathUtil";
-import History from "./History/History";
-import mitt from "mitt";
-import { roadService } from "./Service/RoadService";
-import { edgeService } from "./Service/EdgeService";
-import { roadPointService } from "./Service/RoadPointService";
-import { curveRoadService } from "./Service/CurveRoadService";
-import VectorCategory from "./enum/VectorCategory";
-import Settings from "./Settings";
-import Constant from "./Constant";
-import { uiService } from "./Service/UIService";
-import { imageService } from "./Service/ImageService";
-import VectorEvents from "./enum/VectorEvents";
-import { lineService } from "./Service/LineService";
+import Load from './Load';
+import { stateService } from './Service/StateService';
+import { elementService } from './Service/ElementService';
+import { dataService } from './Service/DataService';
+import { textService } from './Service/TextService';
+import { historyService } from './Service/HistoryService';
+import UIControl from './Controls/UIControl';
+import { locationModeControl } from "./Controls/LocationModeControl";
+import { moveText } from './Controls/MoveText';
+import { moveSVG } from './Controls/MoveSVG';
+import { moveMagnifier } from './Controls/MoveMagnifier';
+import { addRoad } from './Controls/AddRoad';
+import { addCrossRoad } from './Controls/AddCrossRoad';
+import { addLine } from './Controls/AddLine';
+import { addPoint } from './Controls/AddPoint';
+import { addCircle } from './Controls/AddCircle';
+import { addText } from './Controls/AddText';
+import { addMagnifier } from './Controls/AddMagnifier';
+import { addSVG } from './Controls/AddSVG';
+import { moveRoad } from './Controls/MoveRoad';
+import { moveLine } from './Controls/MoveLine';
+import { movePoint } from './Controls/MovePoint';
+import { moveCircle } from './Controls/MoveCircle';
+import { coordinate } from './Coordinate';
+import Render from './Renderer/Render';
+import { draw } from './Renderer/Draw';
+import { listenLayer } from './ListenLayer';
+import LayerEvents from './enum/LayerEvents.js';
+import UIEvents from './enum/UIEvents.js';
+import SelectState from './enum/SelectState.js';
+import VectorType from './enum/VectorType';
+import { mathUtil } from './Util/MathUtil';
+import History from './History/History';
+import mitt from 'mitt';
+import { roadService } from './Service/RoadService';
+import { edgeService } from './Service/EdgeService';
+import { roadPointService } from './Service/RoadPointService';
+import { curveRoadService } from './Service/CurveRoadService';
+import VectorCategory from './enum/VectorCategory';
+import Settings from './Settings';
+import Constant from './Constant';
+import { uiService } from './Service/UIService';
+import { imageService } from './Service/ImageService';
+import VectorEvents from './enum/VectorEvents';
+import { lineService } from './Service/LineService';
 
 const minDragDis = 10;
 const minZoom = 20;
@@ -77,24 +77,25 @@ export default class Layer {
   }
 
   bindEvents() {
-    this.canvas.addEventListener("contextmenu", function (e) {
+    this.canvas.addEventListener('contextmenu', function (e) {
       e.preventDefault();
     });
-    this.canvas.addEventListener("mousedown", this.onMouseDown.bind(this));
-    this.canvas.addEventListener("mousemove", this.onMouseMove.bind(this));
-    this.canvas.addEventListener("mouseup", this.onMouseUp.bind(this));
+    this.canvas.addEventListener('mousedown', this.onMouseDown.bind(this));
+    this.canvas.addEventListener('mousemove', this.onMouseMove.bind(this));
+    this.canvas.addEventListener('mouseup', this.onMouseUp.bind(this));
 
-    this.canvas.addEventListener("touchstart", this.onMouseDown.bind(this));
-    this.canvas.addEventListener("touchmove", this.onMouseMove.bind(this));
-    this.canvas.addEventListener("touchend", this.onMouseUp.bind(this));
+    this.canvas.addEventListener('touchstart', this.onMouseDown.bind(this));
+    this.canvas.addEventListener('touchmove', this.onMouseMove.bind(this));
+    this.canvas.addEventListener('touchend', this.onMouseUp.bind(this));
 
-    this.canvas.addEventListener("mousewheel", this.onWheel.bind(this));
-    this.canvas.addEventListener("DOMMouseScroll", this.onWheel.bind(this));
-    this.canvas.addEventListener("resize", this.reSize.bind(this));
+    this.canvas.addEventListener('mousewheel', this.onWheel.bind(this));
+    this.canvas.addEventListener('DOMMouseScroll', this.onWheel.bind(this));
+    this.canvas.addEventListener('resize', this.reSize.bind(this));
+    document.addEventListener("keydown", this.onKeydown.bind(this));
   }
 
   reSize = function () {
-    console.log("resize");
+    console.log('resize');
     coordinate.updateForCanvas();
     this.renderer.autoRedraw();
   };
@@ -130,16 +131,16 @@ export default class Layer {
     let selectItem = stateService.getSelectItem();
     let focusItem = stateService.getFocusItem();
 
-    this.setEventName("mouseDown");
+    this.setEventName('mouseDown');
     const eventName = stateService.getEventName();
     switch (eventName) {
       case LayerEvents.AddRoad:
         stateService.setEventName(LayerEvents.AddingRoad);
-        addRoad.setNewRoadPoint("start", position);
+        addRoad.setNewRoadPoint('start', position);
         break;
       case LayerEvents.AddCurveRoad:
         stateService.setEventName(LayerEvents.AddingCurveRoad);
-        addRoad.setNewRoadPoint("start", position);
+        addRoad.setNewRoadPoint('start', position);
         break;
       case LayerEvents.AddLine:
         stateService.setEventName(LayerEvents.AddingLine);
@@ -151,39 +152,30 @@ export default class Layer {
       //   break;
       case LayerEvents.AddPoint:
         stateService.setEventName(LayerEvents.MovePoint);
-        const newPoint = addPoint.buildPoint(position);
+        const newPoint = addPoint.buildPoint2(position);
         if (newPoint) {
-          stateService.setSelectItem(
-            newPoint.vectorId,
-            VectorType.Point,
-            SelectState.Select
-          );
+          stateService.setSelectItem(newPoint.vectorId, VectorType.Point, SelectState.Select);
           this.history.save();
           this.renderer.autoRedraw();
         } else {
           if (Settings.basePointIds.length > 1) {
-            this.uiControl.prompt({ msg: "请先选择基准点", time: 1000 });
+            this.uiControl.prompt({ msg: '请先选择基准点', time: 1000 });
           } else {
-            this.uiControl.prompt({ msg: "请先添加基准点", time: 1000 });
+            this.uiControl.prompt({ msg: '请先添加基准点', time: 1000 });
           }
 
           // this.uiControl.prompt({ msg: '请先选择基准点', time: 1000 });
         }
         break;
       case LayerEvents.AddCircle:
-       
         stateService.setEventName(LayerEvents.AddingCircle);
         addCircle.setCenter(position);
-        
+
         break;
       case LayerEvents.AddText:
         stateService.setEventName(LayerEvents.MoveText);
         addText.buildText(position);
-        stateService.setSelectItem(
-          addText.newText.vectorId,
-          VectorType.Text,
-          SelectState.Select
-        );
+        stateService.setSelectItem(addText.newText.vectorId, VectorType.Text, SelectState.Select);
         addText.clear();
         break;
       case LayerEvents.AddSVG:
@@ -197,11 +189,7 @@ export default class Layer {
       case LayerEvents.AddMagnifier:
         stateService.setEventName(LayerEvents.MoveMagnifier);
         addMagnifier.buildMagnifier(position);
-        stateService.setSelectItem(
-          addMagnifier.newMagnifier.vectorId,
-          VectorType.Magnifier,
-          SelectState.Select
-        );
+        stateService.setSelectItem(addMagnifier.newMagnifier.vectorId, VectorType.Magnifier, SelectState.Select);
         addMagnifier.clear();
         break;
       case VectorEvents.AddLane:
@@ -209,34 +197,18 @@ export default class Layer {
           let road = dataService.getRoad(selectItem.vectorId);
           if (road) {
             let roadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == "left") {
-              roadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                roadLanCount + 1,
-                selectItem.dir
-              );
+            if (selectItem.dir == 'left') {
+              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount + 1, selectItem.dir);
             } else {
-              roadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                roadLanCount + 1,
-                selectItem.dir
-              );
+              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount + 1, selectItem.dir);
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
             let curveRoadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == "left") {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount + 1,
-                selectItem.dir
-              );
+            if (selectItem.dir == 'left') {
+              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount + 1, selectItem.dir);
             } else {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount + 1,
-                selectItem.dir
-              );
+              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount + 1, selectItem.dir);
             }
           }
           stateService.clearEventName();
@@ -249,34 +221,18 @@ export default class Layer {
           let road = dataService.getRoad(selectItem.vectorId);
           if (road) {
             let roadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == "left") {
-              roadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                roadLanCount - 1,
-                selectItem.dir
-              );
+            if (selectItem.dir == 'left') {
+              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount - 1, selectItem.dir);
             } else {
-              roadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                roadLanCount - 1,
-                selectItem.dir
-              );
+              roadService.updateForAddSubtractLanesCount(road.vectorId, roadLanCount - 1, selectItem.dir);
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
             let curveRoadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == "left") {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount - 1,
-                selectItem.dir
-              );
+            if (selectItem.dir == 'left') {
+              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount - 1, selectItem.dir);
             } else {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount - 1,
-                selectItem.dir
-              );
+              curveRoadService.updateForAddSubtractLanesCount(road.vectorId, curveRoadLanCount - 1, selectItem.dir);
             }
           }
           stateService.clearEventName();
@@ -288,18 +244,12 @@ export default class Layer {
         if (focusItem && focusItem.vectorId) {
           if (focusItem.type == VectorType.CurveRoad) {
             const curveRoad = dataService.getCurveRoad(focusItem.vectorId);
-            let index = mathUtil.getIndexForCurvesPoints(
-              position,
-              curveRoad.points
-            );
+            let index = mathUtil.getIndexForCurvesPoints(position, curveRoad.points);
             if (index != -1) {
               curveRoadService.addCPoint(curveRoad, position, index);
             } else {
               const dis1 = mathUtil.getDistance(curveRoad.points[0], position);
-              const dis2 = mathUtil.getDistance(
-                curveRoad.points[curveRoad.points.length - 1],
-                position
-              );
+              const dis2 = mathUtil.getDistance(curveRoad.points[curveRoad.points.length - 1], position);
               if (dis1 > dis2) {
                 index = curveRoad.points.length - 2;
               } else {
@@ -307,10 +257,11 @@ export default class Layer {
               }
               curveRoadService.addCPoint(curveRoad, position, index);
             }
-            curveRoadService.updateForMovePoint(
-              curveRoad.points[index + 1].vectorId,
-              position
-            );
+            curveRoadService.setLanes(curveRoad.vectorId);
+            // curveRoadService.updateForMovePoint(
+            //   curveRoad.points[index + 1].vectorId,
+            //   position
+            // );
           } else if (focusItem.type == VectorType.Line) {
             let line = dataService.getLine(focusItem.vectorId);
             const weight = line.getWeight();
@@ -323,18 +274,12 @@ export default class Layer {
             curveLine.setWeight(weight);
           } else if (focusItem.type == VectorType.CurveLine) {
             let curveLine = dataService.getCurveLine(focusItem.vectorId);
-            let index = mathUtil.getIndexForCurvesPoints(
-              position,
-              curveLine.points
-            );
+            let index = mathUtil.getIndexForCurvesPoints(position, curveLine.points);
             if (index != -1) {
               lineService.addCPoint(position, index, focusItem.vectorId);
             } else {
               const dis1 = mathUtil.getDistance(curveLine.points[0], position);
-              const dis2 = mathUtil.getDistance(
-                curveLine.points[curveLine.points.length - 1],
-                position
-              );
+              const dis2 = mathUtil.getDistance(curveLine.points[curveLine.points.length - 1], position);
               if (dis1 > dis2) {
                 index = curveLine.points.length - 2;
               } else {
@@ -374,10 +319,10 @@ export default class Layer {
   onMouseMove(e) {
     let X = e.offsetX || e.layerX;
     let Y = e.offsetY || e.layerY;
-
     if (e instanceof TouchEvent) {
       X = e.touches[0].pageX;
       Y = e.touches[0].pageY;
+
       //切换到缩放
       if (e.touches.length > 1) {
         //记录开始的两个触摸点的坐标
@@ -419,29 +364,20 @@ export default class Layer {
       x: X,
       y: Y,
     });
+
     this.mousePosition = {
       x: position.x,
       y: position.y,
     };
     const eventName = stateService.getEventName();
-    if (
-      !this.dragging &&
-      Math.abs(X - this.startX) < minDragDis &&
-      Math.abs(Y - this.startY) < minDragDis
-    ) {
+    if (!this.dragging && Math.abs(X - this.startX) < minDragDis && Math.abs(Y - this.startY) < minDragDis) {
       return;
     }
     this.dragging = true;
-    if (
-      Math.abs(X - this.startX) > minDragDis ||
-      Math.abs(Y - this.startY) > minDragDis
-    ) {
+    if (Math.abs(X - this.startX) > minDragDis || Math.abs(Y - this.startY) > minDragDis) {
       // 是否拖拽了
       if (eventName != null) {
-        if (
-          eventName == LayerEvents.MoveMagnifier &&
-          stateService.getSelectItem().state != 0
-        ) {
+        if (eventName == LayerEvents.MoveMagnifier && stateService.getSelectItem().state != 0) {
         } else {
           stateService.clearFocusItem();
           this.uiControl.focusVector = null;
@@ -462,17 +398,15 @@ export default class Layer {
         needAutoRedraw = listenLayer.start(position);
         let seleteItem = stateService.getSelectItem();
         if (seleteItem != null) {
-          console.log("选中:" + seleteItem.vectorId);
+          console.log('选中:' + seleteItem.vectorId);
         } else {
         }
         break;
       case LayerEvents.PanBackGround:
         stateService.clearItems();
         let center = {};
-        center.x =
-          coordinate.center.x - (dx * coordinate.defaultZoom) / coordinate.zoom;
-        center.y =
-          coordinate.center.y + (dy * coordinate.defaultZoom) / coordinate.zoom;
+        center.x = coordinate.center.x - (dx * coordinate.defaultZoom) / coordinate.zoom;
+        center.y = coordinate.center.y + (dy * coordinate.defaultZoom) / coordinate.zoom;
         let tempCenter = {};
         mathUtil.clonePoint(tempCenter, coordinate.center);
         mathUtil.clonePoint(coordinate.center, center);
@@ -567,12 +501,12 @@ export default class Layer {
         elementService.setNewRoad(addRoad.startInfo.position, position);
         elementService.showNewRoad();
 
-        addRoad.setNewRoadPoint("end", position);
+        addRoad.setNewRoadPoint('end', position);
         addRoad.canAdd = addRoad.canAddRoadForEnd(position);
         if (!addRoad.canAdd) {
-          elementService.setNewRoadState("error");
+          elementService.setNewRoadState('error');
         } else {
-          elementService.setNewRoadState("normal");
+          elementService.setNewRoadState('normal');
         }
         elementService.showPoint();
         this.showElementLine(position, eventName);
@@ -666,16 +600,9 @@ export default class Layer {
         let road = dataService.getRoad(draggingItem.vectorId);
         let start = dataService.getRoadPoint(road.startId);
         let end = dataService.getRoadPoint(road.endId);
-        if (
-          Object.keys(start.getParent()).length == 1 &&
-          Object.keys(end.getParent()).length == 1
-        ) {
+        if (Object.keys(start.getParent()).length == 1 && Object.keys(end.getParent()).length == 1) {
           //拖拽的路只有一条
-          moveRoad.moveRoad(
-            draggingItem.vectorId,
-            (dx * coordinate.defaultZoom) / coordinate.zoom,
-            (dy * coordinate.defaultZoom) / coordinate.zoom
-          );
+          moveRoad.moveRoad(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
         }
         break;
       case LayerEvents.MoveRoadPoint:
@@ -686,10 +613,7 @@ export default class Layer {
         });
         if (
           listenLayer.modifyPoint &&
-          (listenLayer.modifyPoint.linkedRoadPointId ||
-            listenLayer.modifyPoint.linkedRoadId ||
-            listenLayer.modifyPoint.linkedRoadPointIdX ||
-            listenLayer.modifyPoint.linkedRoadPointIdY)
+          (listenLayer.modifyPoint.linkedRoadPointId || listenLayer.modifyPoint.linkedRoadId || listenLayer.modifyPoint.linkedRoadPointIdX || listenLayer.modifyPoint.linkedRoadPointIdY)
         ) {
           position = {
             x: listenLayer.modifyPoint.x,
@@ -699,11 +623,7 @@ export default class Layer {
           listenLayer.modifyPoint = null;
         }
 
-        let flag = moveRoad.moveingRoadPoint(
-          draggingItem.vectorId,
-          position,
-          listenLayer.modifyPoint
-        );
+        let flag = moveRoad.moveingRoadPoint(draggingItem.vectorId, position, listenLayer.modifyPoint);
         if (!flag) {
           elementService.hideAll();
         } else {
@@ -739,23 +659,19 @@ export default class Layer {
         elementService.setNewRoad(addRoad.startInfo.position, position);
         elementService.showNewRoad();
 
-        addRoad.setNewRoadPoint("end", position);
+        addRoad.setNewRoadPoint('end', position);
         addRoad.canAdd = addRoad.canAddRoadForEnd(position);
         if (!addRoad.canAdd) {
-          elementService.setNewRoadState("error");
+          elementService.setNewRoadState('error');
         } else {
-          elementService.setNewRoadState("normal");
+          elementService.setNewRoadState('normal');
         }
         elementService.showPoint();
         this.showElementLine(position, eventName);
         break;
       case LayerEvents.MoveCurveRoad:
         needAutoRedraw = true;
-        moveRoad.moveCurveRoad(
-          draggingItem.vectorId,
-          (dx * coordinate.defaultZoom) / coordinate.zoom,
-          (dy * coordinate.defaultZoom) / coordinate.zoom
-        );
+        moveRoad.moveCurveRoad(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
         break;
       case LayerEvents.MoveCurveRoadPoint:
         if (!draggingItem || !draggingItem.vectorId) {
@@ -798,21 +714,13 @@ export default class Layer {
         break;
       case LayerEvents.MoveCurveEdge:
         if (listenLayer.modifyPoint) {
-          moveRoad.moveCurveEdge(
-            draggingItem.vectorId,
-            listenLayer.modifyPoint.selectIndex,
-            position
-          );
+          moveRoad.moveCurveEdge(draggingItem.vectorId, listenLayer.modifyPoint.selectIndex, position);
         }
         needAutoRedraw = true;
         break;
       case LayerEvents.MoveLine:
         if (draggingItem != null) {
-          let flag = moveLine.moveLine(
-            draggingItem.vectorId,
-            (dx * coordinate.defaultZoom) / coordinate.zoom,
-            (dy * coordinate.defaultZoom) / coordinate.zoom
-          );
+          let flag = moveLine.moveLine(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
           if (!flag) {
             this.lastX = this.lastX - dx / coordinate.ratio;
             this.lastY = this.lastY - dy / coordinate.ratio;
@@ -827,7 +735,10 @@ export default class Layer {
             exceptPointId: draggingItem.vectorId,
             exceptLineId: point.parent,
           });
-          if (listenLayer.modifyPoint) {
+
+
+          // if (listenLayer.modifyPoint) {  //原本是这样的,不知用途,下面修改为了修复拖动点经过放大镜导致NaN或者错位
+          if (listenLayer.modifyPoint && listenLayer.modifyPoint.x && listenLayer.modifyPoint.y) {
             position = {
               x: listenLayer.modifyPoint.x,
               y: listenLayer.modifyPoint.y,
@@ -865,33 +776,16 @@ export default class Layer {
         break;
       case LayerEvents.MoveCurveLine:
         if (draggingItem != null) {
-          moveLine.moveCurveLine(
-            draggingItem.vectorId,
-            (dx * coordinate.defaultZoom) / coordinate.zoom,
-            (dy * coordinate.defaultZoom) / coordinate.zoom
-          );
+          moveLine.moveCurveLine(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
           needAutoRedraw = true;
         }
         break;
       case LayerEvents.MoveCircle:
         if (draggingItem != null) {
           if (draggingItem.state == -1) {
-            moveCircle.moveFull(
-              draggingItem.vectorId,
-              (dx * coordinate.defaultZoom) / coordinate.zoom,
-              (dy * coordinate.defaultZoom) / coordinate.zoom
-            );
-          } else if (
-            draggingItem.state == 0 ||
-            draggingItem.state == 1 ||
-            draggingItem.state == 2 ||
-            draggingItem.state == 3
-          ) {
-            moveCircle.movePoint(
-              position,
-              draggingItem.vectorId,
-              draggingItem.state
-            );
+            moveCircle.moveFull(draggingItem.vectorId, (dx * coordinate.defaultZoom) / coordinate.zoom, (dy * coordinate.defaultZoom) / coordinate.zoom);
+          } else if (draggingItem.state == 0 || draggingItem.state == 1 || draggingItem.state == 2 || draggingItem.state == 3) {
+            moveCircle.movePoint(position, draggingItem.vectorId, draggingItem.state);
           } else {
             debugger;
           }
@@ -910,22 +804,14 @@ export default class Layer {
           if (draggingItem.state == -1) {
             moveSVG.moveFullSVG(position, draggingItem.vectorId);
           } else {
-            moveSVG.movePoint(
-              position,
-              draggingItem.vectorId,
-              draggingItem.state
-            );
+            moveSVG.movePoint(position, draggingItem.vectorId, draggingItem.state);
           }
         }
         break;
       case LayerEvents.MoveMagnifier:
         needAutoRedraw = true;
         if (draggingItem != null) {
-          moveMagnifier.moveFullMagnifier(
-            position,
-            draggingItem.vectorId,
-            draggingItem.state
-          );
+          moveMagnifier.moveFullMagnifier(position, draggingItem.vectorId, draggingItem.state);
         }
         break;
     }
@@ -998,43 +884,23 @@ export default class Layer {
         let point = dataService.getRoadPoint(draggingItem.vectorId);
         if (point) {
           listenLayer.start(point, {
-            exceptPointId: draggingItem.vectorId,
+            exceptRoadPointId: draggingItem.vectorId,
             exceptRoadIds: point.parent,
           });
-          if (
-            listenLayer.modifyPoint &&
-            listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")
-          ) {
-            moveRoad.moveTo(
-              draggingItem.vectorId,
-              listenLayer.modifyPoint.linkedRoadPointId
-            );
-          } else if (
-            listenLayer.modifyPoint &&
-            (listenLayer.modifyPoint.linkedRoadPointIdX ||
-              listenLayer.modifyPoint.linkedRoadPointIdY)
-          ) {
+
+          if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty('linkedRoadPointId')) {
+            moveRoad.moveTo(draggingItem.vectorId, listenLayer.modifyPoint.linkedRoadPointId);
+          } else if (listenLayer.modifyPoint && (listenLayer.modifyPoint.linkedRoadPointIdX || listenLayer.modifyPoint.linkedRoadPointIdY)) {
             mathUtil.clonePoint(point, listenLayer.modifyPoint);
-          } else if (
-            listenLayer.modifyPoint &&
-            listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")
-          ) {
+          } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.hasOwnProperty('linkedRoadId')) {
             point = roadPointService.create({
               x: listenLayer.modifyPoint.x,
               y: listenLayer.modifyPoint.y,
             });
-            roadService.splitRoad(
-              listenLayer.modifyPoint.linkedRoadId,
-              point.vectorId,
-              "start"
-            );
+            roadService.splitRoad(listenLayer.modifyPoint.linkedRoadId, point.vectorId, 'start');
             moveRoad.moveTo(draggingItem.vectorId, point.vectorId);
           } else if (moveRoad.splitRoadId != null) {
-            roadService.splitRoad(
-              moveRoad.splitRoadId,
-              draggingItem.vectorId,
-              "start"
-            );
+            roadService.splitRoad(moveRoad.splitRoadId, draggingItem.vectorId, 'start');
           }
           //draggingItem.vectorId所在的墙面与其他墙角相交
           moveRoad.updateForAbsorbRoadPoints();
@@ -1173,11 +1039,8 @@ export default class Layer {
         break;
       case LayerEvents.AddPoint:
         if (
-          (Settings.selectBasePointId != null &&
-            (Settings.selectLocationMode == Constant.angleLocationMode ||
-              Settings.selectLocationMode == Constant.allLocationMode)) ||
-          (Settings.baseLineId != null &&
-            Settings.selectLocationMode == Constant.normalLocationMode)
+          (Settings.selectBasePointId != null && (Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode)) ||
+          (Settings.baseLineId != null && Settings.selectLocationMode == Constant.normalLocationMode)
         ) {
           this.uiControl.showConfirm();
           needAutoRedraw = true;
@@ -1191,7 +1054,7 @@ export default class Layer {
         break;
     }
 
-    this.setEventName("mouseUp");
+    this.setEventName('mouseUp');
     stateService.clearDraggingItem();
     if (needAutoRedraw) {
       this.renderer.autoRedraw();
@@ -1201,11 +1064,9 @@ export default class Layer {
   onWheel(e) {
     e.preventDefault();
     const type = e.type;
-    if (type == "DOMMouseScroll" || type == "mousewheel") {
+    if (type == 'DOMMouseScroll' || type == 'mousewheel') {
       // 当在canvas用滚轮滚动时
-      const delta = e.wheelDelta
-        ? (e.wheelDelta / 120) * 20
-        : (-(e.detail || 0) / 3) * 20;
+      const delta = e.wheelDelta ? (e.wheelDelta / 120) * 20 : (-(e.detail || 0) / 3) * 20;
       const zoom = coordinate.zoom + delta;
       let X = e.offsetX || e.layerX;
       let Y = e.offsetY || e.layerY;
@@ -1242,7 +1103,7 @@ export default class Layer {
   setEventName(eventType) {
     let eventName = stateService.getEventName();
 
-    if (eventType == "mouseDown") {
+    if (eventType == 'mouseDown') {
       if (eventName == null) {
         const selectItem = stateService.getSelectItem();
         if (selectItem == null) {
@@ -1279,7 +1140,7 @@ export default class Layer {
           stateService.setEventName(LayerEvents.MoveSVG);
         }
       }
-    } else if (eventType == "mouseUp") {
+    } else if (eventType == 'mouseUp') {
       if (eventName == LayerEvents.AddingRoad) {
         if (Settings.isMobile) {
           stateService.clearEventName();
@@ -1311,11 +1172,8 @@ export default class Layer {
       } else if (
         (eventName == LayerEvents.AddPoint &&
           Settings.selectBasePointId != null &&
-          (Settings.selectLocationMode == Constant.angleLocationMode ||
-            Settings.selectLocationMode == Constant.allLocationMode)) ||
-        (eventName == LayerEvents.AddPoint &&
-          Settings.baseLineId != null &&
-          Settings.selectLocationMode == Constant.normalLocationMode)
+          (Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode)) ||
+        (eventName == LayerEvents.AddPoint && Settings.baseLineId != null && Settings.selectLocationMode == Constant.normalLocationMode)
       ) {
       } else {
         stateService.clearEventName();
@@ -1332,10 +1190,7 @@ export default class Layer {
 
   stopAddVector() {
     let eventName = stateService.getEventName();
-    if (
-      eventName != LayerEvents.AddingRoad &&
-      eventName != LayerEvents.AddingLine
-    ) {
+    if (eventName != LayerEvents.AddingRoad && eventName != LayerEvents.AddingLine) {
       stateService.clearEventName();
     } else if (eventName == LayerEvents.AddingRoad) {
       stateService.setEventName(LayerEvents.AddRoad);
@@ -1473,57 +1328,23 @@ export default class Layer {
     let otherPoint1 = null;
     let otherPoint2 = null;
     if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedRoadPointIdX) {
-      otherPoint1 = dataService.getRoadPoint(
-        listenLayer.modifyPoint.linkedRoadPointIdX
-      );
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedCurveRoadPointIdX
-    ) {
-      otherPoint1 = dataService.getCurveRoadPoint(
-        listenLayer.modifyPoint.linkedCurvePointIdX
-      );
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedPointIdX
-    ) {
-      otherPoint1 = dataService.getPoint(
-        listenLayer.modifyPoint.linkedPointIdX
-      );
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedCurvePointIdX
-    ) {
-      otherPoint1 = dataService.getCurvePoint(
-        listenLayer.modifyPoint.linkedCurvePointIdX
-      );
+      otherPoint1 = dataService.getRoadPoint(listenLayer.modifyPoint.linkedRoadPointIdX);
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurveRoadPointIdX) {
+      otherPoint1 = dataService.getCurveRoadPoint(listenLayer.modifyPoint.linkedCurvePointIdX);
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedPointIdX) {
+      otherPoint1 = dataService.getPoint(listenLayer.modifyPoint.linkedPointIdX);
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurvePointIdX) {
+      otherPoint1 = dataService.getCurvePoint(listenLayer.modifyPoint.linkedCurvePointIdX);
     }
 
     if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedRoadPointIdY) {
-      otherPoint2 = dataService.getRoadPoint(
-        listenLayer.modifyPoint.linkedRoadPointIdY
-      );
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedCurvePointIdY
-    ) {
-      otherPoint2 = dataService.getCurveRoadPoint(
-        listenLayer.modifyPoint.linkedCurvePointIdY
-      );
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedPointIdY
-    ) {
-      otherPoint2 = dataService.getPoint(
-        listenLayer.modifyPoint.linkedPointIdY
-      );
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedCurvePointIdY
-    ) {
-      otherPoint2 = dataService.getCurvePoint(
-        listenLayer.modifyPoint.linkedCurvePointIdY
-      );
+      otherPoint2 = dataService.getRoadPoint(listenLayer.modifyPoint.linkedRoadPointIdY);
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurvePointIdY) {
+      otherPoint2 = dataService.getCurveRoadPoint(listenLayer.modifyPoint.linkedCurvePointIdY);
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedPointIdY) {
+      otherPoint2 = dataService.getPoint(listenLayer.modifyPoint.linkedPointIdY);
+    } else if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedCurvePointIdY) {
+      otherPoint2 = dataService.getCurvePoint(listenLayer.modifyPoint.linkedCurvePointIdY);
     }
 
     let otherPoint = {};
@@ -1533,10 +1354,28 @@ export default class Layer {
     }
     if (otherPoint2) {
       otherPoint.y = otherPoint2.y;
-      if (!otherPoint.hasOwnProperty("x")) {
+      if (!otherPoint.hasOwnProperty('x')) {
         otherPoint.x = otherPoint2.x;
       }
     }
     elementService.execute(otherPoint, point);
   }
+
+  //测试用
+  onKeydown(e) {
+    let focusItem = stateService.getFocusItem();
+    if (focusItem) {
+      console.log("键盘(foucus有效):" + e.code);
+      //添加固定点
+      if (e.code == "KeyQ") {
+        stateService.setEventName(LayerEvents.AddPoint);
+      }
+      //一键测量
+      if (e.code == "KeyA") {
+        locationModeControl.setAngle();
+        this.renderer.autoRedraw();
+        this.history.save();
+      }
+    }
+  }
 }

+ 2 - 1
src/graphic/ListenLayer.js

@@ -887,7 +887,8 @@ export default class ListenLayer {
       const svg = dataService.getSVG(svgId);
       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 / 5) { //改大图例四个点的选择范围
+        if (!svgInfo.svgId && distance < Constant.minAdsorbPix / 2) {
           svgInfo = {
             svgId: svgId,
             distance: distance,

+ 84 - 3
src/graphic/Load.js

@@ -15,7 +15,7 @@ import { textService } from "./Service/TextService.js";
 import { svgService } from "./Service/SVGService.js";
 import { mathUtil } from "./Util/MathUtil.js";
 import { historyService } from "./Service/HistoryService.js";
-
+import { uiService } from "./Service/UIService";
 export default class Load {
   constructor(layer) {
     this.layer = layer;
@@ -27,13 +27,19 @@ export default class Load {
   async load(dataLocal, data3d) {
     this.layer.initLocation();
     if (dataLocal) {
+      if(dataLocal.Settings){
+        for(let key in dataLocal.Settings){
+          Settings[key] = dataLocal.Settings[key]
+        }
+      }
       if (dataLocal.backgroundImg) {
         let bgImg = imageService.createBackgroundImg(
           dataLocal.backgroundImg.src,
           dataLocal.backgroundImg.vectorId
         );
         bgImg.setCenter(dataLocal.backgroundImg.center);
-        bgImg.setDisplay(dataLocal.backgroundImg.display);
+        // bgImg.setDisplay(dataLocal.backgroundImg.display);
+        bgImg.setDisplay(true);//背景图始终显示
         bgImg.setAngle(dataLocal.backgroundImg.angle);
         try {
           if (dataLocal.backgroundImg.src) {
@@ -143,6 +149,52 @@ export default class Load {
           }
         }
       }
+      // if (dataLocal.curvelines) {
+      //   for (let key in dataLocal.curvelines) {
+      //     let startPointId = dataLocal.curvelines[key].startId
+      //     let endPointId = dataLocal.curvelines[key].endId
+
+      //     let startPosition = null;
+      //     let endPosition = null ;
+      //     if(dataLocal.curvePoints){
+      //       startPosition ={ 
+      //         x:dataLocal.curvePoints[startPointId].x,
+      //         y:dataLocal.curvePoints[startPointId].y,
+      //       }
+      //       endPosition ={ 
+      //         x:dataLocal.curvePoints[endPointId].x,
+      //         y:dataLocal.curvePoints[endPointId].y,
+      //       }
+
+      //     }
+         
+      //     let curveline = lineService.createCurveLine(
+      //       startPosition,
+      //       endPosition,
+      //       dataLocal.curvelines[key].vectorId,
+      //     );
+
+      //     if (dataLocal.curvelines[key].style) {
+      //       curveline.setStyle(dataLocal.curvelines[key].style);
+      //     }
+      //     if (dataLocal.curvelines[key].weight) {
+      //       curveline.setWeight(dataLocal.curvelines[key].weight);
+      //     }
+      //     if (dataLocal.curvelines[key].color) {
+      //       curveline.setColor(dataLocal.curvelines[key].color);
+      //     }
+      //     if (dataLocal.curvelines[key].value) {
+      //       curveline.setValue(dataLocal.curvelines[key].value);
+      //     }
+      //     if (dataLocal.curvelines[key].locationMode) {
+      //       curveline.setLocationMode(dataLocal.curvelines[key].locationMode);
+      //     }
+      //     curveline.setDisplay(dataLocal.curvelines[key].display);
+      //     if (curveline.getCategory() == VectorCategory.Line.BaseLine) {
+      //       Settings.baseLineId = key;
+      //     }
+      //   }
+      // }
       if(dataLocal.roadPoints){
 
         for (let key in dataLocal.roadPoints) {
@@ -154,11 +206,39 @@ export default class Load {
       }
       if(dataLocal.roads){
         for (let key in dataLocal.roads) {
+          uiService.setWayType(dataLocal.roads[key].way);
+          uiService.setSingleRoadDrivewayCount( dataLocal.roads[key].singleRoadDrivewayCount)
           let road = roadService.create(
             dataLocal.roads[key].startId,
             dataLocal.roads[key].endId,
             dataLocal.roads[key].vectorId,
           );
+          if(dataLocal.roadEdges){ //当roadEdge有样式的时候需要设置
+            for(let edgeKey in dataLocal.roadEdges){
+              let roadId = dataLocal.roadEdges[edgeKey].parent
+              if(roadId== key ){
+                for(let roadKey in dataLocal.roads[key]){
+                  if( roadKey == 'leftEdgeId' && dataLocal.roads[key][roadKey] == dataLocal.roadEdges[edgeKey].vectorId){
+                    let leftEdge = dataService.getRoadEdge(road.leftEdgeId);
+                    if(dataLocal.roadEdges[edgeKey].style){
+                      leftEdge.setStyle(dataLocal.roadEdges[edgeKey].style)
+                    }
+                    if(dataLocal.roadEdges[edgeKey].weight){
+                      leftEdge.setWeight(dataLocal.roadEdges[edgeKey].weight)
+                    }
+                  }else if(roadKey == 'rightEdgeId' && dataLocal.roads[key][roadKey] == dataLocal.roadEdges[edgeKey].vectorId){
+                    let rightEdge = dataService.getRoadEdge(road.rightEdgeId);
+                    if(dataLocal.roadEdges[edgeKey].style){
+                      rightEdge.setStyle(dataLocal.roadEdges[edgeKey].style)
+                    }
+                    if(dataLocal.roadEdges[edgeKey].weight){
+                      rightEdge.setWeight(dataLocal.roadEdges[edgeKey].weight)
+                    }
+                  }
+                }
+              }
+            }
+          }
         }
       }
       if(dataLocal.curveRoadPoints){
@@ -304,7 +384,8 @@ export default class Load {
 
     const scale = res / (coordinate.zoom / coordinate.defaultZoom);
     dataService.setScale(scale);
-    return dataService.vectorData;
+    console.log({...dataService.vectorData,Settings})
+    return {...dataService.vectorData,Settings};
   }
 
   // 退出页面清除缓存及其他操作

+ 90 - 57
src/graphic/Service/CurveRoadService.js

@@ -203,77 +203,110 @@ export default class CurveRoadService extends RoadService {
     let rightJoin = null;
     const leftCurveEdge = dataService.getCurveRoadEdge(curveRoad.leftEdgeId);
     const rightCurveEdge = dataService.getCurveRoadEdge(curveRoad.rightEdgeId);
-    let line1 = mathUtil.createLine1(
-      curveRoad.points[startIndex],
-      curveRoad.points[startIndex + 1]
-    );
-    let line2 = mathUtil.createLine1(
-      curveRoad.points[startIndex + 1],
-      curveRoad.points[startIndex + 2]
-    );
 
-    const leftLine = mathUtil.createLine1(
-      leftCurveEdge.points[startIndex],
-      leftCurveEdge.points[startIndex + 1]
-    );
-    let leftLine1 = mathUtil.createLine3(
-      line1,
-      leftCurveEdge.points[startIndex]
-    );
-    let leftLine2 = mathUtil.createLine3(
-      line2,
-      leftCurveEdge.points[startIndex + 1]
-    );
+    if (curveRoad.points[startIndex + 2]) {
+      let line1 = mathUtil.createLine1(
+        curveRoad.points[startIndex],
+        curveRoad.points[startIndex + 1]
+      );
+      let line2 = mathUtil.createLine1(
+        curveRoad.points[startIndex + 1],
+        curveRoad.points[startIndex + 2]
+      );
 
-    const rightLine = mathUtil.createLine1(
-      rightCurveEdge.points[startIndex],
-      rightCurveEdge.points[startIndex + 1]
-    );
-    let rightLine1 = mathUtil.createLine3(
-      line1,
-      rightCurveEdge.points[startIndex]
-    );
-    let rightLine2 = mathUtil.createLine3(
-      line2,
-      rightCurveEdge.points[startIndex + 1]
-    );
+      const leftLine = mathUtil.createLine1(
+        leftCurveEdge.points[startIndex],
+        leftCurveEdge.points[startIndex + 1]
+      );
+      let leftLine1 = mathUtil.createLine3(
+        line1,
+        leftCurveEdge.points[startIndex]
+      );
+      let leftLine2 = mathUtil.createLine3(
+        line2,
+        leftCurveEdge.points[startIndex + 1]
+      );
 
-    const line = mathUtil.createLine1(
-      curveRoad.points[startIndex],
-      curveRoad.points[startIndex + 2]
-    );
+      const rightLine = mathUtil.createLine1(
+        rightCurveEdge.points[startIndex],
+        rightCurveEdge.points[startIndex + 1]
+      );
+      let rightLine1 = mathUtil.createLine3(
+        line1,
+        rightCurveEdge.points[startIndex]
+      );
+      let rightLine2 = mathUtil.createLine3(
+        line2,
+        rightCurveEdge.points[startIndex + 1]
+      );
 
-    if (
-      mathUtil.Angle(
-        curveRoad.points[startIndex + 1],
+      const line = mathUtil.createLine1(
         curveRoad.points[startIndex],
         curveRoad.points[startIndex + 2]
-      ) > Constant.maxAngle
-    ) {
-      const join = mathUtil.getJoinLinePoint(position, line);
-      let dx = position.x - join.x;
-      let dy = position.y - join.y;
-
-      leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
-      leftJoin.x += dx;
-      leftJoin.y += dy;
-      leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
-      curveEdgeService.setCurves(leftCurveEdge);
+      );
 
-      rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
-      rightJoin.x += dx;
-      rightJoin.y += dy;
-      rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
-      curveEdgeService.setCurves(rightCurveEdge);
+      if (
+        mathUtil.Angle(
+          curveRoad.points[startIndex + 1],
+          curveRoad.points[startIndex],
+          curveRoad.points[startIndex + 2]
+        ) > Constant.maxAngle
+      ) {
+        const join = mathUtil.getJoinLinePoint(position, line);
+        let dx = position.x - join.x;
+        let dy = position.y - join.y;
+
+        leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
+        leftJoin.x += dx;
+        leftJoin.y += dy;
+        leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+        curveEdgeService.setCurves(leftCurveEdge);
+
+        rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
+        rightJoin.x += dx;
+        rightJoin.y += dy;
+        rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+        curveEdgeService.setCurves(rightCurveEdge);
+      } else {
+        leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
+        leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+        curveEdgeService.setCurves(leftCurveEdge);
+
+        rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
+        rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+        curveEdgeService.setCurves(rightCurveEdge);
+      }
     } else {
-      leftJoin = mathUtil.getIntersectionPoint(leftLine1, leftLine2);
+      curveRoad.endId = point.vectorId;
+      let line = mathUtil.createLine1(
+        curveRoad.points[startIndex],
+        curveRoad.points[startIndex + 1]
+      );
+      let leftLine = mathUtil.createLine3(
+        line,
+        leftCurveEdge.points[startIndex]
+      );
+      let leftJoin = mathUtil.getJoinLinePoint(position, leftLine);
       leftCurveEdge.points.splice(startIndex + 1, 0, leftJoin);
+      leftCurveEdge.points[startIndex] = JSON.parse(
+        JSON.stringify(leftCurveEdge.end)
+      );
+      mathUtil.clonePoint(leftCurveEdge.end, leftJoin);
       curveEdgeService.setCurves(leftCurveEdge);
 
-      rightJoin = mathUtil.getIntersectionPoint(rightLine1, rightLine2);
+      let rightLine = mathUtil.createLine3(
+        line,
+        rightCurveEdge.points[startIndex]
+      );
+      let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
       rightCurveEdge.points.splice(startIndex + 1, 0, rightJoin);
+      rightCurveEdge.points[startIndex] = JSON.parse(
+        JSON.stringify(rightCurveEdge.end)
+      );
+      mathUtil.clonePoint(rightCurveEdge.end, rightJoin);
       curveEdgeService.setCurves(rightCurveEdge);
     }
+
     this.setCurves(curveRoad);
   }
 

+ 4 - 4
src/graphic/Service/EdgeService.js

@@ -138,8 +138,8 @@ export default class EdgeService {
 
         newEdgePoint1 = mathUtil.getJoinLinePoint(startPoint1, lineLeft2);
         newEdgePoint2 = mathUtil.getJoinLinePoint(startPoint1, lineRight2);
-        mathUtil.clonePoint(rightEdge2.start, newEdgePoint1);
-        mathUtil.clonePoint(leftEdge2.start, newEdgePoint2);
+        mathUtil.clonePoint(leftEdge2.start, newEdgePoint1);
+        mathUtil.clonePoint(rightEdge2.start, newEdgePoint2);
       } else {
         newEdgePoint1 = mathUtil.getIntersectionPoint(lineLeft1, lineRight2);
         newEdgePoint2 = mathUtil.getIntersectionPoint(lineLeft2, lineRight1);
@@ -373,8 +373,8 @@ export default class EdgeService {
 
         newEdgePoint1 = mathUtil.getJoinLinePoint(endPoint1, lineLeft2);
         newEdgePoint2 = mathUtil.getJoinLinePoint(endPoint1, lineRight2);
-        mathUtil.clonePoint(rightEdge2.end, newEdgePoint1);
-        mathUtil.clonePoint(leftEdge2.end, newEdgePoint2);
+        mathUtil.clonePoint(leftEdge2.end, newEdgePoint1);
+        mathUtil.clonePoint(rightEdge2.end, newEdgePoint2);
       } else {
         newEdgePoint1 = mathUtil.getIntersectionPoint(lineLeft1, lineRight2);
         newEdgePoint2 = mathUtil.getIntersectionPoint(lineLeft2, lineRight1);

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

@@ -616,6 +616,11 @@ export default class RoadService {
     this.subtraRoadFromIntersect(road.startId, roadId);
     this.subtraRoadFromIntersect(road.endId, roadId);
     dataService.deleteRoad(roadId);
+
+    dataService.deleteCrossPointForEdge(road.leftEdgeId, "start");
+    dataService.deleteCrossPointForEdge(road.leftEdgeId, "end");
+    dataService.deleteCrossPointForEdge(road.rightEdgeId, "start");
+    dataService.deleteCrossPointForEdge(road.rightEdgeId, "end");
   }
 
   setRoadPointId(roadId, pointId, dir) {
@@ -1152,12 +1157,20 @@ export default class RoadService {
           road.leftLanes[i].start = {};
           road.leftLanes[i].start.x = startPoint.x + middx1 + leftdx1 * (i + 1);
           road.leftLanes[i].start.y = startPoint.y + middy1 + leftdy1 * (i + 1);
+
+          road.midDivide.leftMidDivide.start = {};
+          road.midDivide.leftMidDivide.start.x = startPoint.x + middx1;
+          road.midDivide.leftMidDivide.start.y = startPoint.y + middy1;
         }
 
         if (dir2 == "end" || !dir2) {
           road.leftLanes[i].end = {};
           road.leftLanes[i].end.x = endPoint.x + middx2 + leftdx2 * (i + 1);
           road.leftLanes[i].end.y = endPoint.y + middy2 + leftdy2 * (i + 1);
+
+          road.midDivide.leftMidDivide.end = {};
+          road.midDivide.leftMidDivide.end.x = endPoint.x + middx1;
+          road.midDivide.leftMidDivide.end.y = endPoint.y + middy2;
         }
       }
       if (dir2 == "start" || !dir2) {

+ 6 - 0
src/graphic/Service/StateService.js

@@ -65,6 +65,9 @@ export default class StateService {
       return;
     } else if (this.draggingItem.type == VectorType.Line) {
       const line = dataService.getLine(this.draggingItem.vectorId);
+      if(!line){
+        return 
+      }
       this.draggingItem.category = line.getCategory();
     } else if (this.draggingItem.type == VectorType.Point) {
       const point = dataService.getPoint(this.draggingItem.vectorId);
@@ -86,6 +89,9 @@ export default class StateService {
       return;
     } else if (this.focusItem.type == VectorType.Line) {
       const line = dataService.getLine(this.focusItem.vectorId);
+      if(!line){
+        return
+      }
       this.focusItem.category = line.getCategory();
     } else if (this.focusItem.type == VectorType.Point) {
       const point = dataService.getPoint(this.focusItem.vectorId);

+ 3 - 0
src/graphic/Util/MathUtil.js

@@ -644,6 +644,9 @@ export default class MathUtil {
   }
 
   equalPoints(points1, points2) {
+    if (points1.length != points2.length) {
+      return false;
+    }
     for (let i = 0; i < points1.length; ++i) {
       let flag = this.equalPoint(points1[i], points2[i]);
       if (!flag) {

+ 8 - 0
src/graphic/enum/VectorCategory.js

@@ -11,6 +11,13 @@ const VectorCategory = {
     PositionLine: "PositionLine", //定位线。基准点与待测点相连的线,或者与待测基准点相连的线
     GuidePositionLine: "GuidePositionLine", //定位辅助线
     ExtendedPositionLine: "ExtendedPositionLine", //定位延长线
+
+    //重做定位
+    GuideLocationLine: "GuideLocationLine", //定位辅助线
+    LocationLineByFixPoint: "LocationLineByFixPoint", //经过固定点的定位线
+    LocationLineByBasePoint: "LocationLineByFixPoint", //经过基础点的定位线
+    LocationLineByFixPointToFixPoint: "LocationLineByFixPointToFixPoint", //经过固定点到固定点的定位线,综合定位法
+    LocationLineByFixPointToBasePoint: "LocationLineByFixPointToBasePoint", //经过固定点到基础点的定位线,综合定位法
   },
   Point: {
     BasePoint: "BasePoint", //基准点
@@ -18,6 +25,7 @@ const VectorCategory = {
     NormalPoint: "NormalPoint", //正常点
     TestBasePoint: "TestBasePoint", //待测基准点,待测点与基准线相交的点
     FixPoint: "FixPoint", //固定点
+    GuidePoint: "GuidePoint", //辅助点,定位法需要
   },
 };
 export default VectorCategory;