UNPKG

gisviewer-vue3-arcgis

Version:

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

2 lines (1 loc) 6.93 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const j=require("echarts/core"),L=require("../../../../node_modules/.pnpm/ol-echarts@4.0.1_echarts@6.0.0_ol@10.7.0/node_modules/ol-echarts/dist/ol-echarts.esm.js"),F=require("ol/extent"),Z=require("ol/Observable");function B(w){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(w){for(const l in w)if(l!=="default"){const r=Object.getOwnPropertyDescriptor(w,l);Object.defineProperty(e,l,r.get?r:{enumerable:!0,get:()=>w[l]})}}return e.default=w,Object.freeze(e)}const H=B(j);class U{constructor(e){this.hasGpu=!1,this.odChart=null,this.odSelectionListener=null,this.odPairs=new Map,this.map=e;const l=localStorage.getItem("gpu");this.hasGpu=l!=="Unknown"}showODLines(e){var T,A,k,R,z;const l=e.odPairs.filter(o=>o.fromId===o.toId).length;l>0&&(e.odPairs=e.odPairs.filter(o=>o.fromId!==o.toId),console.warn(`已删除 ${l} 条起终点相同的无效 OD 数据`));const r=o=>{if(o){if(Array.isArray(o)){if(o.length>=4)return`rgba(${o[0]}, ${o[1]}, ${o[2]}, ${o[3]})`;if(o.length>=3)return`rgb(${o[0]}, ${o[1]}, ${o[2]})`}return o}},M=(o,s,a,n)=>{const d=r(o),c=r(s);if(!d&&!c)return;const i=d??c,I=c??d;if(!i||!I)return;const[h,u]=a?this.map.getPixelFromCoordinate(a):[0,0],[_,q]=n?this.map.getPixelFromCoordinate(n):[1,1];return new H.graphic.LinearGradient(h<=_?0:1,u<=q?0:1,h<=_?1:0,u<=q?1:0,[{offset:0,color:i},{offset:1,color:I}],!1)};e.odPairs.forEach(o=>{o.fromId!==o.toId&&this.odPairs.set(`${o.fromId}-${o.toId}`,o)});const p=r((T=e.options)==null?void 0:T.fromColor),C=r((A=e.options)==null?void 0:A.toColor),v=Array.from(this.odPairs.values()).sort((o,s)=>{const a=r(o.fromColor)!==p||r(o.toColor)!==C,n=r(s.fromColor)!==p||r(s.toColor)!==C;return Number(n)-Number(a)}),S=v.some(o=>o.fromColor!==void 0||o.toColor!==void 0)||p!==void 0||C!==void 0,g=new Map,N=new Map,D=new Map,x=new Map,t=(o,s,a,n)=>{g.set(o,(g.get(o)||0)+1),N.has(o)||N.set(o,s),D.has(o)||D.set(o,a),!x.has(o)&&n&&x.set(o,n)};v.forEach(o=>{var n,d;const s=r(o.fromColor??((n=e.options)==null?void 0:n.fromColor)),a=r(o.toColor??((d=e.options)==null?void 0:d.toColor));t(o.fromId,o.fromCoord,o.fromName,s??a),t(o.toId,o.toCoord,o.toName,a??s)});const f=Array.from(N.values());if(f.length>0){const o=F.boundingExtent(f);this.map.getView().fit(o,{padding:[10,10,10,10]})}const m=Array.from(g.entries()).map(([o,s])=>{const a=N.get(o),n=D.get(o)||o,d=x.get(o);return{id:o,name:n,value:[a[0],a[1],s],...S&&d?{itemStyle:{color:d}}:{}}}),O=Math.min(...m.map(o=>o.value[2]),1),y=Math.max(...m.map(o=>o.value[2]),1),E={backgroundColor:"transparent",...S?{}:{visualMap:{show:!1,min:1,max:y,dimension:2,seriesIndex:1,inRange:{color:["#ff9999","#ff4d4d","#e60000","#cc0000","#800000"]}}},series:[{name:"od线",type:"lines",effect:{show:this.hasGpu,constantSpeed:30,symbol:"pin",symbolSize:6,trailLength:0},lineStyle:{...S?{}:{color:"#808080"},opacity:.8,width:1.2,curveness:.2},data:v.map(o=>{var c,i;const s=r(o.fromColor??((c=e.options)==null?void 0:c.fromColor)),a=r(o.toColor??((i=e.options)==null?void 0:i.toColor)),n=g.get(o.fromId)||1,d=g.get(o.toId)||1;return{fromName:o.fromName,toName:o.toName,coords:[o.fromCoord,o.toCoord],value:[o.fromCoord[0],o.fromCoord[1],Math.max(n,d)],...S?{lineStyle:{color:M(s,a,o.fromCoord,o.toCoord),opacity:.8,width:1.2,curveness:.2}}:{}}})},{name:"路口",type:this.hasGpu?"effectScatter":"scatter",zlevel:3,cursor:"pointer",symbolSize:o=>{const s=o[2]||O;return y===O?4:4+(s-O)/(y-O)*8},label:{show:((k=e.options)==null?void 0:k.showNodeName)!==!1,position:"right",formatter:o=>o.name||""},data:m}]};this.removeODChart();const b=new L.default(E,{stopEvent:!1,hideOnMoving:!1,hideOnZooming:!1,forcedPrecomposeRerender:!0});b.appendTo(this.map);let P=null;const G=()=>{var o;P=null,(o=b.$chart)==null||o.setOption(E,{notMerge:!0})},$=o=>{var c;const s=new Set,a=new Set,n=E.series[0].data.map((i,I)=>{const h=v[I],u=h.fromId===o||h.toId===o;return u&&(s.add(h.fromId),a.add(h.toId)),{...i,lineStyle:{...i.lineStyle,color:u?M("#ff0000","#00a000",h.fromCoord,h.toCoord):"#808080",opacity:u?1:.5,width:u?3:1.2}}}),d=m.map(i=>{const I=s.has(i.id),h=a.has(i.id),u=i.id===o;return{...i,itemStyle:{...i.itemStyle,...u?{}:{color:I?"#ff0000":h?"#00a000":"#808080"},opacity:1,borderColor:u?"#ffd700":void 0,borderWidth:u?3:0}}});(c=b.$chart)==null||c.setOption({series:[{data:n},{data:d}]})};this.odSelectionListener=this.map.on("moveend",()=>{const o=P;o&&requestAnimationFrame(()=>{P===o&&$(o)})}),(R=b.$chart)==null||R.on("click",o=>{var c,i;if(o.seriesName!=="路口"||!o.data)return;const s=o.data.id;P=s,$(s);const[a,n,d]=o.value;(i=(c=e.options)==null?void 0:c.onNodeClick)==null||i.call(c,{id:o.data.id,name:o.name,coord:[a,n],count:d})}),(z=b.$chart)==null||z.getZr().on("click",o=>{o.target||G()}),this.odChart=b}clearODLines(){this.odPairs.clear(),this.removeODChart()}removeODChart(){this.odSelectionListener&&(Z.unByKey(this.odSelectionListener),this.odSelectionListener=null),this.odChart&&(this.odChart.remove(),this.odChart=null)}showRandomODLines(e){const r=e.data.sort(()=>.5-Math.random()).slice(0,50),M=[];r.forEach(t=>{const f=Math.floor(Math.random()*10)+1;for(let m=0;m<f;m++){const O=Math.floor(Math.random()*r.length),y=r[O];M.push({fromId:t.NODE_ID,fromName:t.NAME,toId:y.NODE_ID,toName:y.NAME,fromCoord:[t.LON,t.LAT],toCoord:[y.LON,y.LAT]})}});const p=new Map,C=new Map,v=new Map,S=(t,f,m)=>{p.set(t,(p.get(t)||0)+1),C.has(t)||C.set(t,m),v.has(t)||v.set(t,f)};M.forEach(t=>{S(t.fromId,t.fromName,t.fromCoord),S(t.toId,t.toName,t.toCoord)});const g=Array.from(p.entries()).map(([t,f])=>{const m=C.get(t);return{name:v.get(t)||t,value:[m[0],m[1],f]}});new Set([...g].sort((t,f)=>f.value[2]-t.value[2]).slice(0,15).map(t=>t.name));const D={backgroundColor:"transparent",visualMap:{show:!1,min:1,max:Math.max(...g.map(t=>t.value[2]),1),dimension:2,seriesIndex:1,inRange:{color:["#ff9999","#ff4d4d","#e60000","#cc0000","#800000"]}},series:[{name:"线路",type:"lines",zlevel:1,large:!1,largeThreshold:100,blendMode:"multiply",lineStyle:{color:"#1f6bff",opacity:.22,width:1.2,curveness:.2},data:M.map(t=>({coords:[t.fromCoord,t.toCoord]}))},{name:"关键路口",type:"effectScatter",zlevel:3,showEffectOn:"render",rippleEffect:{brushType:"stroke",scale:2.6},itemStyle:{shadowBlur:8,shadowColor:"rgba(77,163,255,0.45)"},symbolSize:t=>{const f=t[2]||1;return Math.min(24,Math.max(5,Math.sqrt(f)*2))},data:g}]};new L.default(D,{stopEvent:!1,hideOnMoving:!1,hideOnZooming:!1,forcedPrecomposeRerender:!0}).appendTo(this.map)}showTrace(e){const l=e.map((p,C)=>({name:`轨迹${C}`,coords:p})),r={backgroundColor:"transparent",series:[{type:"lines",polyline:!0,lineStyle:{color:"#1f6bff"},data:l,zlevel:1}]};new L.default(r,{stopEvent:!1,hideOnMoving:!1,hideOnZooming:!1,forcedPrecomposeRerender:!0,forcedRerender:!0}).appendTo(this.map)}destroy(){this.clearODLines()}}exports.default=U;