UNPKG

gisviewer-vue3-arcgis

Version:

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

2 lines (1 loc) 4.44 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("@arcgis/core/geometry"),L=require("@arcgis/core/geometry/geometryEngineAsync"),w=require("@arcgis/core/geometry/support/webMercatorUtils"),h=require("@turf/bearing"),y=require("@turf/destination"),b=require("@turf/helpers"),S=require("@turf/length"),x=require("@turf/line-slice-along"),A=require("pako"),P=require("proj4");function d(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const g=d(L),O=d(w),f=d(b);class o{static destinationWithPoint(e,t,n){const r=f.point([e.x,e.y]),i=y(r,n,t,{units:"meters"});return new p.Point({x:i.geometry.coordinates[0],y:i.geometry.coordinates[1]})}static angleOfLine(e){const t=e.paths[0],n=f.point(t[0]),r=f.point(t[t.length-1]);return h(n,r)}static extendLineInTowDir(e,t){const n=e.paths[0],r=f.point(n[0]),i=f.point(n[1]),a=h(i,r),c=y(r,t,a,{units:"meters"}),u=a>0?a-180:a+180,s=y(i,t,u,{units:"meters"});return new p.Polyline({paths:[[c.geometry.coordinates,s.geometry.coordinates]]})}static async getIntersectPointOfTwoLines(e,t){const n=await g.intersectLinesToPoints(e,t);if(n.length)return n[0]}static async getIntersectPointsOfStopLineAndLane(e,t,n){let r=await o.getIntersectPointOfLineAndPolygon(e,t);if(await o.pointDistance(r)<3&&n){for(const i of n)if(r=await o.getIntersectPointOfLineAndPolygon(e,t,i),await o.pointDistance(r)>2.5){const a=new p.Polyline({paths:[r]});return(await o.getOffsetLine(a,-i)).paths[0]}}else return r;return[]}static async pointDistance(e){if(e.length<2)return 0;const t=new p.Polyline({paths:[e]});return await g.geodesicLength(t,"meters")}static async getIntersectPointOfLineAndPolygon(e,t,n=0){n!==0&&(e=await o.getOffsetLine(e,n));const r=await g.intersect(e,t);if(r instanceof p.Polyline){const i=r.paths[0],a=i[0],c=i[i.length-1];return[a,c]}return[]}static async getOffsetLine(e,t){const n=O.geographicToWebMercator(e),r=await g.offset(n,t,"meters");return O.webMercatorToGeographic(r,!1)}static unzip(e){try{const t=[],n=e.split("");for(let i=0;i<n.length;i++){const a=n[i];t.push(a.charCodeAt(0))}const r=new Uint8Array(t);return A.inflate(r,{to:"string"})}catch{console.log(`非压缩内容: ${e}`)}}static getStdVecEntries(e,t=!1){const n=new Array(e.size());for(let r=0;r<e.size();r++)n[r]=e.get(r);return t&&e.delete(),n}static getStdMapEntries(e){const t=[];for(const n of o.getStdMapKeys(e))t.push([n,e.get(n)]);return t}static getStdMapKeys(e,t=!1){const n=[],r=e.keys();for(let i=0;i<r.size();i++)n.push(r.get(i));return r.delete(),t&&e.delete(),n}static setGeoData(e,t,n){o.geoReference=e,o.xOffset=t,o.yOffset=n}static transformLineProjection(e){try{return e.map(t=>P(o.geoReference).inverse([t[0]-o.xOffset,t[1]-o.yOffset]))}catch{return console.error("OpenDrive坐标转换为WGS84坐标失败",o.geoReference),e}}static transformPointProjection(e){try{return P(o.geoReference).inverse([e[0]-o.xOffset,e[1]-o.yOffset])}catch{return console.error("OpenDrive坐标转换为WGS84坐标失败",o.geoReference),e}}static pointsEqual(e,t){return Math.abs(e[0]-t[0])<Number.EPSILON&&Math.abs(e[1]-t[1])<Number.EPSILON}static getExtensionLine(e,t,n){const r=f.point(e),i=f.point(t),a=h(r,i);return y(i,n,a,{units:"meters"}).geometry.coordinates}static isCoordinateValid(e){return typeof e.latitude=="string"&&(e.latitude=Number(e.latitude)),typeof e.longitude=="string"&&(e.longitude=Number(e.longitude)),e.latitude!==null&&e.longitude!==null&&!isNaN(e.latitude)&&!isNaN(e.longitude)&&e.latitude!==0&&e.longitude!==0}static getCenterPointInLine(e){const t=f.lineString(e),n=S(t,{units:"meters"})/2,r=x(t,0,n,{units:"meters"});return r.geometry.coordinates[r.geometry.coordinates.length-1]}static async viewGoto(e,t,n=!0){var a,c;const i=localStorage.getItem("gpu")!=="Unknown";if(!n){if(t.length>0){const u=t.map(s=>s.geometry).filter(s=>s);if(u.length>0){let s=(a=await g.union(u))==null?void 0:a.extent;s&&(s=s.expand(1.3),i?await e.goTo(s.center,{duration:1e3}):e.center=s.center)}}return}if(i)await e.goTo(t,{duration:1e3});else if(t.length>0){const u=t.map(s=>s.geometry).filter(s=>s);if(u.length>0){let s=(c=await g.union(u))==null?void 0:c.extent;s&&(s=s.expand(1.3),e.extent=s)}}}}exports.default=o;