UNPKG

gisviewer-vue3-arcgis

Version:

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

2 lines (1 loc) 2.37 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("../stores/index.js"),q=require("@arcgis/core/layers/GraphicsLayer"),b=require("@turf/helpers"),P=require("@turf/destination"),C=require("@arcgis/core/Graphic"),S=require("@turf/intersect"),w=require("@turf/buffer"),f=require("@turf/area");function O(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const p=O(b);class v{constructor(e){this.initialized=!1,this.lanePolygonMap=new Map,this.view=e;const t=m.default.useAppDataStore;this.mapConfig=JSON.parse(JSON.stringify(t.mapConfig)),this.queueLengthLayer=new q,this.view.map.add(this.queueLengthLayer)}async initializeLaneGraphic(){if(!this.mapConfig.lanePolygonLayer)return;const e=`${this.mapConfig.assetsRoot}/${this.mapConfig.lanePolygonLayer}`,n=await(await fetch(e)).json(),{features:i}=n;i.forEach(s=>{const{properties:o,geometry:a}=s,l=p.polygon(a.coordinates,{code:o.code,laneDirection:o.laneDirection,stopLineCenter:o.stopLineCenter});this.lanePolygonMap.set(o.code,l)}),this.initialized=!0}async updateQueueLength(e){if(this.initialized||await this.initializeLaneGraphic(),this.lanePolygonMap.size!==0)for(const t of e){const n=String(t.laneId),i=`${t.crossNo}+${n[0]}+${n[1]}`,s=this.lanePolygonMap.get(i);if(!s)continue;const o=this.queueLengthLayer.graphics.find(a=>a.getAttribute("code")===i);o&&this.queueLengthLayer.remove(o),t.queueLength!==0&&this.generateQueuePolygon(s,t.queueLength)}}removeQueueLength(){this.queueLengthLayer.removeAll()}generateQueuePolygon(e,t){const n=e.properties.laneDirection,i=JSON.parse(e.properties.stopLineCenter),s=p.point(i),o=n>0?n-180:n+180,a=P(s,t,o,{units:"meters"}),l=p.lineString([i,a.geometry.coordinates]),h=w(l,10,{units:"meters"}),c=S(e,h);if(!c)return;const d=f(c.geometry),y=f(e),g=d/y,u=g>.8?[139,0,0,.6]:g>.6?[255,165,0,.5]:[46,139,87,.5],L=new C({geometry:{type:"polygon",rings:c==null?void 0:c.geometry.coordinates},symbol:{type:"polygon-3d",symbolLayers:[{type:"fill",material:{color:u},outline:{color:[u[0],u[1],u[2]],size:3}}]},attributes:{code:e.properties.code}});this.queueLengthLayer.add(L)}}exports.default=v;