소스 검색

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

bill 1 년 전
부모
커밋
35b4bd9cf8
5개의 변경된 파일472개의 추가작업 그리고 746개의 파일을 삭제
  1. 214 110
      public/static/lib/potree/potree.js
  2. 1 1
      public/static/lib/potree/potree.js.map
  3. 168 381
      src/graphic/ListenLayer.js
  4. 9 6
      src/graphic/Service/SVGService.js
  5. 80 248
      src/graphic/Util/MathUtil.js

+ 214 - 110
public/static/lib/potree/potree.js

@@ -53956,9 +53956,14 @@
 	        return rotation
 	    }
 	     
-	    set rotation(rotation){//这个在数字很小(垂直向上看)的时候水平旋转精度可能损失,导致突变到另一个角度去了,用 set quaternion比较好
-	        //因为 rotation的y不一定是0 , 所以不能直接逆着写。
-	        this.direction = new Vector3(0,0,-1).applyEuler(rotation);
+	    set rotation(rotation){ 
+	        if(rotation.y != 0){//因为 rotation的y不一定是0 , 所以不能直接逆着get rotation写。 
+	            //console.error('set rotation y不为0!!!!?', rotation ) //过渡时因为quaternion lerp所以不为0。没办法了orz
+	            this.direction = new Vector3(0,0,-1).applyEuler(rotation);  //转回direction有损耗,在俯视时的(dir.x==dir.y==0), 丢失yaw信息从而 yaw无法获取(希望不要遇到这种情况,如果有的话,考虑先计算yaw,似乎好像可以算)
+	        }else {//尽量不用direction
+	            this.pitch = rotation.x - Math.PI / 2;
+	            this.yaw = rotation.z;
+	        } 
 	    }
 	    
 	   
@@ -53966,8 +53971,8 @@
 	        return new Quaternion().setFromEuler(this.rotation)
 	    }
 	    
-	    set quaternion(q){
-	        this.direction = new Vector3(0,0,-1).applyQuaternion(q); //注意如果得到的dir.x==dir.y==0,  yaw不会变为0, 导致算的quaternion和q不一致
+	    set quaternion(q){ 
+	        this.rotation = new Euler().setFromQuaternion(q);
 	    }
 	    
 	    copy(a){
@@ -54053,7 +54058,7 @@
 	        
 			this.position = this.position.add(t);
 	         
-	        if((!math.closeTo(x, 0, 1e-4) || !math.closeTo(y, 0, 1e-4) || !math.closeTo(z, 0, 1e-4)) && Potree.settings.displayMode != 'showPanos'){
+	        if((!math.closeTo(x, 0, 1e-2) || !math.closeTo(y, 0, 1e-2) || !math.closeTo(z, 0, 1e-2)) && Potree.settings.displayMode != 'showPanos'){
 	            this.cancelFlying('pos');
 	        }
 	        
@@ -54063,7 +54068,7 @@
 		translateWorld (x, y, z) { 
 			super.translateWorld(x, y, z);
 	        
-	        if((!math.closeTo(x, 0, 1e-4) || !math.closeTo(y, 0, 1e-4) || !math.closeTo(z, 0, 1e-4)) && Potree.settings.displayMode != 'showPanos'){
+	        if((!math.closeTo(x, 0, 1e-2) || !math.closeTo(y, 0, 1e-2) || !math.closeTo(z, 0, 1e-2)) && Potree.settings.displayMode != 'showPanos'){
 	            this.cancelFlying('pos');
 	        }
 	           
@@ -54146,21 +54151,36 @@
 	        
 	        this.restrictPos(endPosition);
 	         
-	         
+	        if(info.endYaw == void 0){
+	                                   
+	                                      
+	                                                               
+	                                             
+	            if(info.target ){
+	                endTarget = new Vector3().copy(info.target);  
+	                endQuaternion = math.getQuaFromPosAim(endPosition,endTarget); //若为垂直,会自动偏向x负的方向
+	           
+	                                                 
+	            }else if(info.quaternion){
+	                endQuaternion = info.quaternion.clone();
+	            }   
+	            
+	            if(endQuaternion && math.closeTo(Math.abs(this.direction.z), 1, 1e-4)){ //在垂直的视角下的quaternion刚开始突变的厉害,这时候可能渐变yaw比较好(如俯视时点击测量线)
+	                let a = this.clone();
+	                a.quaternion = endQuaternion;
+	                info.endYaw = a.yaw; info.endPitch = a.pitch;
+	                console.log('turn to yaw');
+	            }
+	        }
+	        
+	 
 	        if(info.endYaw != void 0) { 
 	            startPitch = this.pitch;
 	            endPitch = info.endPitch; 
 	            let a = math.getStandardYaw(this.yaw, info.endYaw );
 	            startYaw = a[0];   endYaw = a[1];
-			}else if(info.target ){
-				endTarget = new Vector3().copy(info.target);  
-	            endQuaternion = math.getQuaFromPosAim(endPosition,endTarget); //若为垂直,会自动偏向x负的方向
-	            dir = new Vector3().subVectors(endTarget, endPosition).normalize();
-	            //console.log(dir, this.direction)   
-			}else if(info.quaternion){
-	            endQuaternion = info.quaternion.clone();
-	        }
-	         
+	            console.log('startYaw', startYaw, 'endYaw', endYaw);
+			}  
 	        if(endQuaternion){ 
 	            startQuaternion = this.quaternion; 
 	        }
@@ -57995,7 +58015,7 @@
 	                this.uniforms.resolution.value.copy(viewport.resolution2);  
 	                this.uniforms.devicePixelRatio.value = window.devicePixelRatio; 
 	                this.lineWidth = this.lineWidth_; //update
-	                if(!this.useDepth /* || !e.viewport.camera.isPerspectiveCamera  */|| !e.viewport)return
+	                if(!this.realUseDepth || !e.viewport)return
 	                let viewportOffset = viewport.offset || new THREE.Vector2(); 
 	                this.uniforms.viewportOffset.value.copy(viewportOffset);
 	                
@@ -58034,7 +58054,7 @@
 	             
 	            if(value){
 	                viewer.addEventListener("render.begin",  this.events.render);  
-	                this.events.setSize( {viewport:viewer.mainViewport} );  
+	                
 	                this.updateDepthParams(); 
 	            }else {
 	                viewer.removeEventListener("render.begin",  this.events.render);  
@@ -58045,7 +58065,7 @@
 	    } 
 	    
 	    
-	    setRealDepth(useDepth){//确实使用到depthTex
+	    setRealDepth(useDepth, viewport){//确实使用到depthTex
 	        if(this.realUseDepth != useDepth){
 	            if(useDepth ){
 	                this.defines.useDepth = '';  
@@ -58055,6 +58075,8 @@
 	            this.realUseDepth = useDepth;
 	            if(this.autoDepthTest)this.depthWrite = this.depthTest = !useDepth;  //如果useDepth = false,使用原始的depthTest
 	            this.needsUpdate = true;
+	            if(!viewport)viewport = viewer.mainViewport; //暂时这么设置
+	            useDepth && this.events.setSize({viewport});
 	        }
 	    }
 	    
@@ -58070,7 +58092,7 @@
 	        let hasDepth = this.useDepth && Potree.settings.displayMode == 'showPointCloud' &&
 	                (Potree.settings.pointEnableRT || viewer.useEDL);
 	         
-	        this.setRealDepth(hasDepth);
+	        this.setRealDepth(hasDepth, viewport);
 	        
 	        if(hasDepth){
 	            this.uniforms.depthTexture.value = viewer.getPRenderer().getRtEDL(viewport).depthTexture;   //其实只赋值一次就行
@@ -70901,7 +70923,7 @@ void main()
 	         
 	        this.events = {
 	            setSize:(e)=>{//如果出现横条状的异常,往往是viewportOffset出错  //地图不需要
-	                if(!this.useDepth /* || !e.viewport.camera.isPerspectiveCamera  */|| !e.viewport)return
+	                if(!this.realUseDepth || !e.viewport)return
 	                let viewport = e.viewport;
 	                let viewportOffset = viewport.offset || new Vector2(); 
 	                
@@ -70911,12 +70933,12 @@ void main()
 	            render:(e)=>{//before render  如果有大于两个viewport的话,不同viewport用不同的depthTex
 	                this.updateDepthParams(e);
 	            },
-	            cameraChange:(e)=>{
+	            /* cameraChange:(e)=>{
 	                if(e.changeInfo.projectionChanged){//resize时也会触发。虽然保守起见的话加上resize比较好//所以当时为何不用resize
 	                    //console.log('projectionChanged')
-	                    this.events.setSize(e);  
-	                }
-	            }
+	                    this.events.setSize(e)  
+	                } 
+	            } */
 	            
 	        };
 	        if(o.mapColorReplace){
@@ -70954,19 +70976,19 @@ void main()
 	             
 	            if(value){
 	                viewer.addEventListener("render.begin",  this.events.render); 
-	                viewer.addEventListener('camera_changed', this.events.cameraChange);  
-	                this.events.setSize( {viewport:viewer.mainViewport} );  
+	                //viewer.addEventListener('camera_changed', this.events.cameraChange) 
+	                viewer.addEventListener('resize', this.events.setSize);  
 	                this.updateDepthParams(); 
 	            }else {
 	                viewer.removeEventListener("render.begin",  this.events.render);  
-	                viewer.removeEventListener('camera_changed', this.events.cameraChange);
+	                viewer.removeEventListener('resize', this.events.setSize);
 	            }
 	        }
 	        
 	    } 
 	    
 	    
-	    setRealDepth(useDepth){//确实使用到depthTex
+	    setRealDepth(useDepth, viewport){//确实使用到depthTex
 	        if(this.realUseDepth != useDepth){
 	            if(useDepth ){
 	                this.defines.useDepth = '';  
@@ -70976,6 +70998,8 @@ void main()
 	            this.realUseDepth = useDepth;
 	            if(this.autoDepthTest)this.depthWrite = this.depthTest = !useDepth;  //如果useDepth = false,使用原始的depthTest
 	            this.needsUpdate = true;
+	            if(!viewport)viewport = viewer.mainViewport; //暂时这么设置
+	            useDepth && this.events.setSize({viewport});
 	        }
 	    }
 	    
@@ -71037,7 +71061,7 @@ void main()
 	                (Potree.settings.pointEnableRT || viewer.useEDL);
 	         
 	         
-	        this.setRealDepth(hasDepth);
+	        this.setRealDepth(hasDepth, viewport);
 	        
 	        if(hasDepth){
 	            this.uniforms.depthTexture.value = viewer.getPRenderer().getRtEDL(viewport).depthTexture;   //其实只赋值一次就行
@@ -71080,27 +71104,23 @@ void main()
 	        this.visible_ = true;
 	        
 	        
-	        let update = (e)=>{
-	            //this.update(e)
-	            this.needsUpdate = true;
+	        let clear = (e)=>{ 
+	            this.matrixMap.clear();//清空后在所有viewport上都必须更新才能渲染    //this.needsUpdate = true
 	        };
-	        viewer.mapViewer && viewer.mapViewer.addEventListener("camera_changed",  update); 
-	        viewer.addEventListener("camera_changed",  update); 
-	        /* if(viewer.viewports.length == 1){//直接更新。如果有多个不在这更新,在"render.begin"
-	            this.update(e)
-	        } */
+	        viewer.mapViewer && viewer.mapViewer.addEventListener("camera_changed",  clear); 
+	        viewer.addEventListener("camera_changed",  clear); 
 	         
 	        
 	        let applyMatrix = (e)=>{
-	            if(this.needsUpdate) this.update(e);
-	            else this.applyMatrix(e);
+	            /* if(this.needsUpdate) this.update(e)
+	            else  */this.applyMatrix(e);
 	        };
 	        viewer.addEventListener("raycaster", applyMatrix);        //before render
 	        viewer.addEventListener("render.begin", applyMatrix); //before render  //magnifier时要禁止吗
 	            
 	        this.addEventListener('dispose', ()=>{
-	            viewer.mapViewer && viewer.mapViewer.removeEventListener("camera_changed",  update); 
-	            viewer.removeEventListener("camera_changed",  update); 
+	            viewer.mapViewer && viewer.mapViewer.removeEventListener("camera_changed",  clear); 
+	            viewer.removeEventListener("camera_changed",  clear); 
 	            viewer.removeEventListener("raycaster", applyMatrix);        //before render
 	            viewer.removeEventListener("render.begin", applyMatrix);
 	             
@@ -71110,9 +71130,10 @@ void main()
 	    }
 	    
 	    set visible(v){
+	        let oldV = this.visible_;
 	        this.visible_ = v;  
-	        if(v){
-	            this.update();
+	        if(v && !oldV){ 
+	            this.matrixMap && this.matrixMap.clear(); //this.update() //update内有unableCompute会无限回调
 	        }
 	    }
 	    get visible(){
@@ -71158,6 +71179,10 @@ void main()
 	    
 	    
 	    
+	    waitUpdate(){
+	        this.matrixMap.clear();//清空后在所有viewport上都必须更新才能渲染 
+	        //viewer.dispatchEvent('content_changed')
+	    }
 	    
 	    
 	    
@@ -71206,7 +71231,7 @@ void main()
 	                    
 	                    let p2State = '', len=1,  p2StateHistory = [];
 	                    while(p2State != 'got' && p2StateHistory.length<10){ 
-	                        point2 = center.clone().add(lineDir.multiplyScalar(len));
+	                        point2 = center.clone().add(lineDir.clone().multiplyScalar(len));
 	                         
 	                        r2 = Potree.Utils.getPos2d(point2, camera, viewer.renderArea, e.viewport);  
 	                        if(!r2.trueSide){ //很少遇到点2在背面的
@@ -71281,7 +71306,8 @@ void main()
 	                        
 	                        if(index == 1){
 	                            orient2dAngle -= Math.PI; 
-	                        }   
+	                        } 
+	                        //console.log('orient2dAngle measure_point',index, orient2dAngle  )
 	                    } 
 	                }else {
 	                    Potree.Utils.updateVisible(this, 'unableCompute', false);
@@ -71298,6 +71324,7 @@ void main()
 	            this.root.quaternion.multiplyQuaternions(parentQua.invert(),camera.quaternion);    //乘上parentQua.invert()是为了中和掉父结点的qua,使只剩下camera.quaternion
 	        
 	            if(orient2dAngle){ 
+	                //console.log('orient2dAngle ',this.root.name,orient2dAngle)
 	                let qua = new Quaternion().setFromAxisAngle(new Vector3(0,0,1),  orient2dAngle); 
 	                this.root.quaternion.multiply(qua); 
 	            }
@@ -71425,6 +71452,7 @@ void main()
 				this.text = text + '';
 
 				this.updateTexture();
+	            this.sprite.waitUpdate(); //重新计算各个viewport的matrix 
 			}
 		}
 
@@ -71447,10 +71475,10 @@ void main()
 		}
 	    setPos(pos){
 	        this.position.copy(pos);
-	        this.sprite.update();
+	        this.sprite.waitUpdate();
 	    }
 	    update(){
-	        this.sprite.update();
+	        this.sprite.waitUpdate();
 	    }
 	    setVisible(v){ 
 	        Potree.Utils.updateVisible(this, 'setVisible', v);
@@ -71461,60 +71489,68 @@ void main()
 		updateTexture(){
 			let canvas = document.createElement('canvas');
 			let context = canvas.getContext('2d');
-			context.font = this.fontWeight + ' ' + this.fontsize + 'px ' + this.fontface; 
+	        const r = window.devicePixelRatio;
+			context.font = this.fontWeight + ' ' + this.fontsize * r + 'px ' + this.fontface; 
 	       
 	        //context["font-weight"] = 100; //语法与 CSS font 属性相同。
-			// get size data (height depends only on font size)
-	        
-	        //this.text = 'f 啊啊啊 jg'
+	                                                     
+			 
+	        //this.text = '啊啊啊啊啊啊fag'
 	        
 			let metrics = context.measureText(this.text );
 			let textWidth = metrics.width;
-			let margin = this.margin || new Vector2(this.fontsize, Math.max(  this.fontsize*0.4, 10)  );
-			let spriteWidth = 2 * margin.x + textWidth + 2 * this.rectBorderThick;
-			let spriteHeight = 2 * margin.y + this.fontsize + 2 * this.rectBorderThick; 
+			let margin = (this.margin ? new Vector2().copy(this.margin) : new Vector2(this.fontsize, Math.max(  this.fontsize*0.4, 10)  )).clone().multiplyScalar(r); 
+			let spriteWidth = 2 * margin.x + textWidth + 2 * this.rectBorderThick * r ;
+			let spriteHeight = 2 * margin.y + this.fontsize * r + 2 * this.rectBorderThick * r; 
 			context.canvas.width = spriteWidth;
 			context.canvas.height = spriteHeight;
-			context.font = this.fontWeight + ' ' + this.fontsize + 'px ' + this.fontface; 
-
+			context.font = this.fontWeight + ' ' + this.fontsize * r + 'px ' + this.fontface; 
 	 
-	        let expand = Math.max(1, Math.pow(this.fontsize / 16, 1.3)); // 针对英文大部分在baseLine之上所以降低一点,或者可以识别当不包含jgqp时才加这个值  
+	        /* let diff = 2//针对英文大部分在baseLine之上所以降低一点(metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2
+
+	        context.textBaseline = "middle"
+	         */
+	        let expand = Math.max(1, Math.pow(this.fontsize / 16, 1.3)) * r;  // 针对英文大部分在baseLine之上所以降低一点,或者可以识别当不包含jgqp时才加这个值  
 	         
 	        //canvas原点在左上角
 	        context.textBaseline = 'alphabetic'; //  "middle"  //设置文字基线。当起点y设置为0时,只有该线以下的部分被绘制出来。middle时文字显示一半(但是对该字体所有字的一半,有的字是不一定显示一半的,尤其汉字),alphabetic时是英文字母的那条基线。
 	        
-	        let actualHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent; // 当前文本字符串在这个字体下用的实际高度
+	        //let actualHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent; // 当前文本字符串在这个字体下用的实际高度
 	        
 	        //文字y向距离从textBaseline向上算
-	        let y = metrics.actualBoundingBoxAscent + margin.y + expand; 
+	        let actualBoundingBoxAscent = metrics.actualBoundingBoxAscent == void 0 ? this.fontsize * r * 0.8 : metrics.actualBoundingBoxAscent; //有的流览器没有。只能大概给一个
+	        let y = actualBoundingBoxAscent + margin.y + expand; 
 	        //console.log(this.text, 'y' , y, 'actualBoundingBoxAscent', metrics.actualBoundingBoxAscent,'expand',expand )
-	        
+	                                  
 	        
 	        // border color
 	        context.strokeStyle = 'rgba(' + this.borderColor.r + ',' + this.borderColor.g + ',' +
 	            this.borderColor.b + ',' + this.borderColor.a + ')';
-	  
-	        context.lineWidth = this.rectBorderThick;
+	            
+	        let rectBorderThick = this.rectBorderThick * r;
+	        
+	        context.lineWidth = rectBorderThick;
 			// background color
 			context.fillStyle = 'rgba(' + this.backgroundColor.r + ',' + this.backgroundColor.g + ',' +
 				this.backgroundColor.b + ',' + this.backgroundColor.a + ')';
-	        this.roundRect(context, this.rectBorderThick / 2, this.rectBorderThick / 2,
-	            spriteWidth - this.rectBorderThick, spriteHeight - this.rectBorderThick, this.borderRadius);
+	        this.roundRect(context, rectBorderThick / 2 , rectBorderThick / 2,
+	            spriteWidth - rectBorderThick, spriteHeight - rectBorderThick, this.borderRadius * r);
 	        
 			// text color
 	        if(this.textBorderThick){
 	            context.strokeStyle = 'rgba(' + this.textBorderColor.r + ',' + this.textBorderColor.g + ',' +
 	                this.textBorderColor.b + ',' + this.textBorderColor.a + ')';
-	            context.lineWidth = this.textBorderThick;
-	            context.strokeText(this.text , this.rectBorderThick + margin.x, y /* spriteHeight/2  + expand */ );
+	            context.lineWidth = this.textBorderThick * r;
+	            context.strokeText(this.text , rectBorderThick + margin.x,  y /* spriteHeight/2  + diff */ );
 	        }
 	        
 			context.fillStyle = 'rgba(' + this.textColor.r + ',' + this.textColor.g + ',' +
 				this.textColor.b + ',' + this.textColor.a + ')';
-			context.fillText(this.text , this.rectBorderThick + margin.x, y  /* spriteHeight/2  + expand  */);//x,y
+			context.fillText(this.text , rectBorderThick + margin.x,  y/* spriteHeight/2  + diff */ );//x,y
+	 
 
 			let texture = new Texture(canvas);
-			texture.minFilter = LinearFilter; //LinearMipMapLinearFilter会缩放到power of 2
+			texture.minFilter = LinearFilter;
 			texture.magFilter = LinearFilter;
 			texture.needsUpdate = true;
 	        
@@ -71522,10 +71558,9 @@ void main()
 	            this.sprite.material.map.dispose();
 	        }
 			this.sprite.material.map = texture;
-			 
-	        
+			  
 	        
-			this.sprite.scale.set(spriteWidth * 0.01, spriteHeight * 0.01, 1.0);
+			this.sprite.scale.set(spriteWidth * 0.01 / r, spriteHeight * 0.01 / r, 1.0);
 		}
 
 		roundRect(ctx, x, y, w, h, r){
@@ -76525,9 +76560,9 @@ void main()
 	                    if(!params.all){
 	                        if(camera.type == 'OrthographicCamera'){
 	                            let vec = new Vector3().subVectors(position, camera.position);
-	                            hit.disSquare = vec.projectOnVector( cameraDir ).lengthSq();  //只考虑到相机的垂直距离 
-	                        }else { 
-	                            hit.disSquare = camera.position.distanceToSquared(position);
+	                            hit.disSquare = vec.projectOnVector( cameraDir ).length();  //只考虑到相机的垂直距离 
+	                        }else {  
+	                            hit.disSquare = camera.position.distanceTo(position);
 	                        }  
 	                    }
 					} else if (attributeName === 'indices') {
@@ -76574,13 +76609,7 @@ void main()
 	                
 	                let nearest = sorted1[0];  //return nearest.point;  //直接用最近点 在点云稀疏时不太跟手,如地面上,最近点往往在鼠标下方
 	                 
-	                let r;  
-	                if(camera.type != 'OrthographicCamera'){ 
-	                    let ratio = 0.1; //系数越大越不跟手,但更容易pick近处的。 (当pick的点较远时,获取框内的点距离可能差别很大,就要所以除以disSquare)
-	                    r = rSquare/Math.max(nearest.disSquare,0.001) * ratio;
-	                }else { 
-	                    r = 10;      //大一点才能pick到表面的点,但太大了有时不跟手,且总容易吸附到近点
-	                }
+	                let r = 10;
 	                
 	                hits.forEach( hit=>{
 	                    let disDiff = hit.disSquare - nearest.disSquare; //和最近点的偏差 
@@ -81685,7 +81714,8 @@ void main()
 	    
 	    updateMarker(marker, pos){
 	        marker.position.copy(pos);
-	        marker.update();
+	        marker.waitUpdate();
+	         
 	    }
 	    
 	    
@@ -81940,6 +81970,7 @@ void main()
 	    maxClipFactor:0.1
 	};  
 	 
+	const textSizeRatio = math.linearClamp(window.innerWidth * window.innerHeight , 360*720,   1920*1080, 0.75, 1);  //pc字显示大一些
 	 
 
 	const markerSizeInfo = {
@@ -81952,7 +81983,7 @@ void main()
 	    textColor: {r: textColor.r*255, g: textColor.g*255, b: textColor.b*255, a: 1.0},
 	    textBorderColor: {r:255, g: 255, b:255, a: 1.0},
 	    textBorderThick:3,
-	    fontsize: 14, 
+	    fontsize: 15 * textSizeRatio,  
 	    borderRadius : 12, margin:{x:20,y:4},
 	    renderOrder : 5, pickOrder:5, 
 	    disToLine:-0.15,
@@ -81971,7 +82002,7 @@ void main()
 	const subLabelProp = { 
 	    backgroundColor: {r: 255, g: 255, b: 255, a:config$1.measure.default.opacity},
 	    textColor: {r: 0.3, g: 0.3, b:0.3, a: 1.0},
-	    fontsize:12, borderRadius : 12,  margin:{x:20,y:4},
+	    fontsize:15 * textSizeRatio,   borderRadius : 12,  margin:{x:20,y:4},
 	    renderOrder : 4, pickOrder:4, 
 	};
 
@@ -82186,7 +82217,7 @@ void main()
 	                /* this.closed || */edgeLabel.setVisible(edgeLabel.shouldVisi);  
 	                if(edgeLabel.shouldVisi){
 	                    this.lineDir = new Vector3().subVectors(point,nextPoint).normalize(); //[point,nextPoint]
-	                   
+	                    
 	                    setEdgeLabel(edgeLabel,point,nextPoint,distance);
 	                    
 	                }
@@ -82243,6 +82274,9 @@ void main()
 
 
 
+
+
+
 	    setEdgeLabelPos(label,p1,p2){ //调整label的位置,使倾斜后看起来在线的中心,而不要挡住端点
 	        let center = new Vector3().addVectors(p1,p2).multiplyScalar(0.5);  
 	        
@@ -82520,13 +82554,13 @@ void main()
 	            let color = new Color(Potree.config.measure.highlight.color); 
 	            //label.sprite.material.opacity = config.measure.highlight.opacity
 	            
-	            //label.backgroundColor = {r:255*color.r, g:255*color.g, b:255*color.b, a:config.measure.highlight.opacity},
-	            //label.backgroundColor.a = config.measure.highlight.opacity
+	            //label.setBackgroundColor({r:255*color.r, g:255*color.g, b:255*color.b, a:config.measure.highlight.opacity})
+	          
 	            label.sprite.material.useDepth = false;
 	            //label.textColor = {r: this.color.r*255, g:  this.color.g*255, b:  this.color.b*255, a: 1} 
 	        }else {
-	            //label.backgroundColor = {r: this.color.r*255, g:  this.color.g*255, b:  this.color.b*255, a:config.measure.default.opacity}
-	            //label.backgroundColor.a = config.measure.default.opacity
+	            //label.setBackgroundColor({r: this.color.r*255, g:  this.color.g*255, b:  this.color.b*255, a:config.measure.default.opacity})
+	            
 	            label.sprite.material.useDepth = true;
 	            //label.sprite.material.opacity = 0.98
 	            //label.textColor = {r: 255, g: 255, b: 255, a: 1} 
@@ -82561,6 +82595,11 @@ void main()
 	    
 	    setPosition(index, position) {
 	        super.setPosition(index, position);
+	        
+	        //相连的点的箭头也要更新方向 
+	        this.markers[(index + this.points.length - 1) % this.points.length].waitUpdate();
+	        this.markers[(index + this.points.length + 1) % this.points.length].waitUpdate();
+	        
 	        let event = {
 				type: 'marker_moved',
 				measure:	this,
@@ -82568,6 +82607,7 @@ void main()
 				position: position.clone()
 			};
 			this.dispatchEvent(event); 
+	         
 	    }
 	    
 	    dispose(){//add
@@ -82763,7 +82803,7 @@ void main()
 	        
 	        
 	        const areaLabel = new TextSprite$2(
-	            $.extend(mainLabelProp,{sizeInfo: labelSizeInfo, name:'areaLabel_'} )
+	            $.extend({}, mainLabelProp,{sizeInfo: labelSizeInfo, name:'areaLabel', fontsize:16*textSizeRatio} )
 	        );
 	        
 	        areaLabel.addEventListener('mouseover',()=>{
@@ -83779,7 +83819,7 @@ void main()
 	                     
 	                    marker.isDragging = true; 
 	                    
-	                    console.log('continueDrag' , marker.uuid);
+	                    //console.log('continueDrag' , marker.uuid)
 	                    measure.continueDrag(marker, e);    
 	                } 
 					 
@@ -89080,7 +89120,7 @@ void main()
 	                //}
 	                viewport.needRender = true;  //直接写这咯  
 	                if(changeInfo.resolutionChanged){
-	                    this.dispatchEvent( {type:'resize', viewport});  
+	                    this.ifEmitResize({viewport}); //for map
 	                } 
 	                  
 	            }                
@@ -91912,8 +91952,8 @@ void main()
 	    
 	    updateCamera(){  
 	        let view = this.listenViewport.view;
-	        this.view.quaternion = view.quaternion;   //this.view.rotation = view.rotation 
-	        this.view.yaw = view.yaw;
+	        this.view.yaw = view.yaw;  
+	        this.view.pitch = view.pitch;   
 	        var dir = view.direction;  //相机朝向
 	        this.view.position.copy(dir.multiplyScalar(this.view.radius).negate());  //相机绕着指南针中心(000)转动
 	          
@@ -91922,7 +91962,7 @@ void main()
 	    
 	    applyToMainView(){
 	        let view = this.listenViewport.view;
-	        view.quaternion = this.view.quaternion; 
+	        view.rotation = this.view.rotation; 
 	    }
 	    
 	    pushHomeBtn(){
@@ -96480,7 +96520,7 @@ ENDSEC
 	        ); 
 	        this.images360.node.add(this.label2);
 	        this.floorPosition && this.label2.position.copy(this.floorPosition);
-	        let s = 0.4;
+	        let s = 0.25;
 	        this.label2.scale.set(s,s,s);
 	        //Potree.Utils.updateVisible(this.label2, 'notDisplay', false)
 	        Potree.Utils.updateVisible(this.label2, 'panoVisi', this.visible);
@@ -97819,7 +97859,30 @@ ENDSEC
 	                pano: panoSet,
 	                callback: deferred.resolve.bind(deferred, !0)
 	            }  );
-	        } else {
+	        } else { //如果离数据集较远,转动也很难找到点云,就飞到就近点:
+	            let po = viewer.scene.pointclouds.find(e=>e.visibleNodes.some(a=>a.getLevel() > Math.ceil(e.maxLevel * 0.15) )); //虽然当点云在前方很远的地方也可能符合
+	             
+	            if(!po){//无可见点云
+	                //console.log('no visi cloud')
+	                
+	                if(!this.panos.length){//如果场景中没有漫游点,如SG-t-XPf1k9pv3Zg 点击后回到可见区域
+	                    let map = new Map(); 
+	                    let clouds = viewer.scene.pointclouds.filter(e=>e.root.geometryNode);
+	                    clouds.forEach(e=>map.set(e, e.bound.distanceToPoint(this.position))); 
+	                    clouds.sort((a,b)=>map.get(a) - map.get(b)); 
+	                    
+	                    viewer.flyToDataset({focusOnPoint:true, pointcloud:clouds[0] });//飞最近的一个点云
+	                    return deferred.promise();
+	                }
+	                 
+	                this.flyToPano({
+	                    pano: this.findNearestPano(),
+	                    callback: deferred.resolve.bind(deferred, !0)
+	                });
+	                return deferred.promise();
+	                 
+	            }
+	             
 	            this.bump(direction);
 	            deferred.resolve(!1);
 	        }
@@ -103753,7 +103816,7 @@ ENDSEC
 
 	const texLoader$7 = new TextureLoader(); 
 	const circleGeo = new CircleGeometry(1.45,100);
-	const sphereGeo = new SphereBufferGeometry(0.018,10,10);
+	const sphereGeo = new SphereBufferGeometry(0.008,8,8);
 	 
 	 
 	const magDisMin = 1;//相机离目标位置的距离的分界线,当离得远时要缩小fov以使看到的视野固定(望远镜效果)
@@ -103761,7 +103824,7 @@ ENDSEC
 	/* const radius_ = 0.2; //当相机离目标位置的距离>magDistance_时,希望看到的视野的半径
 	const maxFov = THREE.Math.radToDeg(Math.atan(radius_ / magDisMin )) * 2//提前计算出当相机离目标位置的距离<magDisMin时的fov,均使用=magDisMin时的fov。只要保证该fov大于主相机的fov就会有放大效果 
 	 */
-	let w = 250/1.43;
+	let w = 230/1.43;
 	let maxPX = 1366*1024; //ipad pro.  大于这个分辨率的就直接用devicePixelRatio, 如macbook也是
 	const width2dPX = Math.round(window.devicePixelRatio >= 2 ? ( window.screen.width * window.screen.height >= maxPX ? window.devicePixelRatio/1.2 : window.devicePixelRatio/1.5)*w : w);  //触屏或高分辨率的可能要放大些。但在手机上不能太大
 	//console.log('width2dPX', width2dPX)
@@ -103878,12 +103941,12 @@ ENDSEC
 	        this.targetPoint.add(new Mesh(sphereGeo, new MeshBasicMaterial({ 
 	            color:"#ff0000",
 	            transparent:true,
-	            opacity:0.5,  
+	            opacity:0.7,  
 	        })));
 	        this.targetPoint.add(new Mesh(sphereGeo, new MeshBasicMaterial({ 
 	            color:"#ff0000",
 	            transparent:true,
-	            opacity:0.2, 
+	            opacity:0.3, 
 	            depthTest:false  //被遮挡层
 	        })));
 	        
@@ -104140,7 +104203,7 @@ ENDSEC
 	}
 
 	let texLoader$8 = new TextureLoader();
-	let defaultOpacity =  0.7;
+	let defaultOpacity =  0.5;
 	let Buttons$1 = Potree.defines.Buttons;
 
 
@@ -104233,7 +104296,7 @@ ENDSEC
 
 
 	    move(e){ 
-	        if(e.type == "global_mousemove" && (e.isTouch || e.buttons != Buttons$1.NONE) && this.state != 'crosshair'){
+	        if(e.type == "global_mousemove" && (e.isTouch || e.buttons != Buttons$1.NONE) && !this.state.cross){
 	            return//按下时不更新,除非拖拽测量
 	        }
 	           
@@ -104303,8 +104366,22 @@ ENDSEC
 	        }else {
 	            
 	            let n = camera.position.distanceTo(this.position);
-	            s = 1 + .1 * n;
-	            n < 1 && (s -= 1 - n);
+	            if( n < 1 ){
+	                if(this.state.cross ){   //测量时更精细些
+	                     s = 0.7 * n;
+	                }else {
+	                     s = 1.1 * n; 
+	                }
+	            }else {
+	                if(this.state.cross ){  
+	                     s = 0.4 + 0.3 * n; //n乘以的系数越高,其越不近大远小(大小越恒定)
+	                }else {
+	                     s = 1 + 0.1 * n; 
+	                }  
+	            }       
+	            if(this.state.cross ){  //测量时更精细些
+	                s /= viewer.images360.zoomLevel;
+	            }                                   
 	        }
 	        this.scale.set(s, s, s);
 	        
@@ -133264,8 +133341,12 @@ ENDSEC
 	                     
 	                    let distance = camera.position.distanceTo(this.rotateStartInfo.rotCenter/* this.intersectStart.location */);                                               //不按下ctrl的话                 
 	                      
-	                    if(this.rotateStartInfo.rotCenter2d.z>1)distance *= -1; //在背面  
-	                      
+
+	                    let posDir = new Vector3().subVectors(this.rotateStartInfo.rotCenter, view.position);
+	                    if(posDir.dot(view.direction) < 0 )distance *= -1; //在背面  
+	                     
+
+	                    
 	                    //按照orbitControl的方式旋转:
 	                    let rotationSpeed = 2;   
 	                    this.yawDelta -= e.drag.pointerDelta.x * rotationSpeed;
@@ -138063,6 +138144,30 @@ ENDSEC
 	        else pointcloud = this.scene.pointclouds.find(p => p.dataset_id == o.id);
 	         
 	        let duration = o.duration == void 0 ? 1000 : o.duration;
+	        
+	        if(o.focusOnPoint){//focus点云上一点,避免center区域刚好没有点
+	            if(pointcloud.root.geometryNode){ 
+	                let posArr = pointcloud.root.geometryNode.geometry.attributes.position.array;
+	                
+	                let count = pointcloud.root.geometryNode.geometry.attributes.position.count;
+	                let index = Math.ceil(count / 2); //随便取一个点 
+	                let point = new Vector3(posArr[index*3+0],posArr[index*3+1],posArr[index*3+2]); 
+	                //point.applyMatrix4(pointcloud.root.pointcloud.matrixWorld)
+	                point.applyMatrix4(pointcloud.root.sceneNode.matrixWorld);
+	                viewer.focusOnObject({position:point},'point',duration,{dontChangeCamDir:true, distance:15});
+
+	                o.dontMoveMap || viewer.mapViewer.fitToPointcloud(pointcloud, duration);           
+	                console.log('flyToDataset focusOnPoint done');
+	                return
+	            }   
+	        }
+	        
+	        
+	        
+	        
+	        
+	        
+	        
 	        var center = pointcloud.bound.getCenter(new Vector3);
 	        let position;
 	        let getPano = ()=>{//获取离中心最近的pano
@@ -138325,7 +138430,6 @@ ENDSEC
 	        
 	        
 	        //-------------
-	        this.images360.update(); 
 	        
 	        this.computeShelter();
 	        //-------------

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
public/static/lib/potree/potree.js.map


+ 168 - 381
src/graphic/ListenLayer.js

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

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

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

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

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