UNPKG

gisviewer-vue3-arcgis

Version:

在应用中引入私服的包, 项目根目录下 新建文件 .npmrc 在 .npmrc 中对包源进行配置:

2 lines (1 loc) 4.48 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("@turf/helpers"),M=require("@turf/length");class S{static getFeaturesExtent(t){var o;let s=1/0,n=1/0,r=-1/0,i=-1/0;for(const c of t){const a=(o=c.getGeometry())==null?void 0:o.getExtent();a&&(s=Math.min(s,a[0]),n=Math.min(n,a[1]),r=Math.max(r,a[2]),i=Math.max(i,a[3]))}if(Number.isFinite(s))return[s,n,r,i]}static laneToPolygon(t,s){if(t.length<2)return[];const n=t[0][1],r=111320,i=111320*Math.cos(n*Math.PI/180),o=s/2/r,c=s/2/i,a=[],m=[];for(let f=0;f<t.length;f++){let T=0,d=0;f<t.length-1?(T=t[f+1][0]-t[f][0],d=t[f+1][1]-t[f][1]):(T=t[f][0]-t[f-1][0],d=t[f][1]-t[f-1][1]);const R=Math.sqrt(T*T+d*d)||1,g=-d/R,l=T/R;a.push([t[f][0]+g*c,t[f][1]+l*o]),m.push([t[f][0]-g*c,t[f][1]-l*o])}return[...a,...m.reverse(),a[0]]}static smoothShape(t,s=10){if(t.length<3)return[...t];const n=[t[0],t[0],t[0],...t,t[t.length-1],t[t.length-1],t[t.length-1]],r=[];for(let o=0;o<n.length-3;o++){const c=n[o],a=n[o+1],m=n[o+2],f=n[o+3];for(let T=0;T<=s;T++){const d=T/s,R=d*d,g=R*d,l=1-d,e=l*l*l/6,b=(3*g-6*R+4)/6,u=(-3*g+3*R+3*d+1)/6,h=g/6;r.push([e*c[0]+b*a[0]+u*m[0]+h*f[0],e*c[1]+b*a[1]+u*m[1]+h*f[1]])}}const i=[];for(const o of r){const c=i[i.length-1];(!c||c[0]!==o[0]||c[1]!==o[1])&&i.push(o)}return i}static createTrafficLightImage(){const s=document.createElement("canvas");s.width=64,s.height=64;const n=s.getContext("2d");if(!n)throw new Error("Unable to create traffic light canvas context");const r=64*.45,i=64*.82,o=(64-r)/2,c=(64-i)/2,a=4;n.fillStyle="#2d2d2d",n.beginPath(),n.moveTo(o+a,c),n.lineTo(o+r-a,c),n.quadraticCurveTo(o+r,c,o+r,c+a),n.lineTo(o+r,c+i-a),n.quadraticCurveTo(o+r,c+i,o+r-a,c+i),n.lineTo(o+a,c+i),n.quadraticCurveTo(o,c+i,o,c+i-a),n.lineTo(o,c+a),n.quadraticCurveTo(o,c,o+a,c),n.closePath(),n.fill();const m=r*.2,f=i*.14,T=(i-f*2-m*2*3)/2,d=64/2,R=["#ef4444","#f59e0b","#22c55e"];for(let g=0;g<3;g++){const l=c+f+m+g*(m*2+T);n.beginPath(),n.arc(d,l,m,0,Math.PI*2),n.fillStyle=R[g],n.fill()}return s}static getLaneArrowPosition(t){if(t.length<2)return{point:t[0]||[0,0],angle:0};const s=M(v.lineString(t),{units:"meters"}),r=Math.max(s-5,0);let i=0;const o=[];for(let e=1;e<t.length;e++){const b=t[e][0]-t[e-1][0],u=t[e][1]-t[e-1][1],h=Math.sqrt(b*b+u*u);o.push(h),i+=h}const c=s===0?0:r/s,a=i*c;let m=0,f=t[t.length-1],T=t[t.length-2],d=t[t.length-1];for(let e=0;e<o.length;e++){if(m+o[e]>=a){const b=o[e]||1,u=Math.min(Math.max((a-m)/b,0),1);f=[t[e][0]+u*(t[e+1][0]-t[e][0]),t[e][1]+u*(t[e+1][1]-t[e][1])],T=t[e],d=t[e+1];break}m+=o[e]}const R=d[0]-T[0],g=d[1]-T[1],l=Math.atan2(R,g)*(180/Math.PI);return{point:f,angle:l}}static drawArrowIcon(t,s,n){const r=n/2,i=n*.88,o=n*.12,c=n*.08,a=n*.28,m=n*.22;t.fillStyle="#ffffff",t.strokeStyle="#ffffff";const f=(g,l)=>{const e=r+g,b=c*l,u=a*l,h=m*l,P=o+n*(1-l)*.15,w=i-n*(1-l)*.15,L=P+h;t.fillRect(e-b/2,L,b,w-L),t.beginPath(),t.moveTo(e,P),t.lineTo(e-u/2,P+h),t.lineTo(e+u/2,P+h),t.closePath(),t.fill()},T=(g,l)=>{const e=r+g,b=c*l,u=a*l*.8,h=m*l*.8,P=i-n*(1-l)*.15,w=n*.45,L=e-n*.25*l;t.fillRect(e-b/2,w,b,P-w),t.fillRect(L,w-b/2,e-L,b),t.beginPath(),t.moveTo(L-h*.5,w),t.lineTo(L+h*.5,w-u/2),t.lineTo(L+h*.5,w+u/2),t.closePath(),t.fill()},d=(g,l)=>{const e=r+g,b=c*l,u=a*l*.8,h=m*l*.8,P=i-n*(1-l)*.15,w=n*.45,L=e+n*.25*l;t.fillRect(e-b/2,w,b,P-w),t.fillRect(e,w-b/2,L-e,b),t.beginPath(),t.moveTo(L+h*.5,w),t.lineTo(L-h*.5,w-u/2),t.lineTo(L-h*.5,w+u/2),t.closePath(),t.fill()},R=()=>{const g=c,l=a*.7,e=m*.7,b=i,u=n*.35,h=n*.15;t.fillRect(r+h-g/2,u,g,b-u),t.lineWidth=g,t.beginPath(),t.arc(r,u,h,0,Math.PI,!0),t.stroke();const P=u+e;t.beginPath(),t.moveTo(r-h,P),t.lineTo(r-h-l/2,u),t.lineTo(r-h+l/2,u),t.closePath(),t.fill()};switch(s){case"S":f(0,1);break;case"L":T(0,1);break;case"R":d(0,1);break;case"SL":f(n*.13,.75),T(-n*.08,.75);break;case"SR":f(-n*.13,.75),d(n*.08,.75);break;case"LR":T(-n*.1,.75),d(n*.1,.75);break;case"SLR":T(-n*.16,.65),f(0,.65),d(n*.16,.65);break;case"T":R();break;case"default":default:f(0,1);break}}static createArrowIcon(t,s=64){const n=document.createElement("canvas");n.width=s,n.height=s;const r=n.getContext("2d");if(!r)throw new Error("Unable to create arrow icon canvas context");return S.drawArrowIcon(r,t,s),n}static determineArrowType(t){const s=new Set(t.map(c=>c.toUpperCase())),n=s.has("S"),r=s.has("L"),i=s.has("R");return s.has("T")&&s.size===1?"T":n&&r&&i?"SLR":n&&r?"SL":n&&i?"SR":r&&i?"LR":r?"L":i?"R":n?"S":"default"}}exports.default=S;