gisviewer-vue3-arcgis 1.0.117 → 1.0.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import m from "@arcgis/core/Graphic";
|
|
2
2
|
import { Polygon as b } from "@arcgis/core/geometry";
|
|
3
|
-
import * as
|
|
3
|
+
import * as G from "@arcgis/core/geometry/geometryEngineAsync.js";
|
|
4
4
|
import L from "@arcgis/core/layers/FeatureLayer";
|
|
5
5
|
import v from "@arcgis/core/layers/GraphicsLayer";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import O from "axios";
|
|
7
|
+
import j from "pako";
|
|
8
|
+
import N from "./wasm-loader.mjs";
|
|
9
9
|
class I {
|
|
10
10
|
constructor(e) {
|
|
11
|
-
this.wasmLoader =
|
|
11
|
+
this.wasmLoader = N.getInstance(), this.view = e, this.laneLayer = new L({
|
|
12
12
|
id: "OpenDriveLane",
|
|
13
13
|
fields: [
|
|
14
14
|
{
|
|
@@ -295,7 +295,7 @@ class I {
|
|
|
295
295
|
* @param projectName
|
|
296
296
|
*/
|
|
297
297
|
async showOpenDriveFromServer(e, i) {
|
|
298
|
-
const n = `http://${e}/api/openDrive/analyzeXodr`, a = await
|
|
298
|
+
const n = `http://${e}/api/openDrive/analyzeXodr`, a = await O.get(n, {
|
|
299
299
|
headers: {
|
|
300
300
|
projectName: i
|
|
301
301
|
},
|
|
@@ -308,7 +308,7 @@ class I {
|
|
|
308
308
|
throw new Error(`OpenDriveRenderer: ${a.statusText}`);
|
|
309
309
|
let o = a.data.result.json;
|
|
310
310
|
o.startsWith(window.location.protocol) || (o = `${window.location.protocol}//${e}${o}`);
|
|
311
|
-
const s = await (await fetch(o)).arrayBuffer(), r =
|
|
311
|
+
const s = await (await fetch(o)).arrayBuffer(), r = j.inflate(s, { to: "string" }), d = JSON.parse(r);
|
|
312
312
|
return await this.showAllLanes(d, !1, !1), { status: 0, message: "ok" };
|
|
313
313
|
}
|
|
314
314
|
async showAllLanes(e, i, n) {
|
|
@@ -372,6 +372,7 @@ class I {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
+
this.view.type === "2d" ? this.view.goTo(this.allRefLineGraphics) : this.view.goTo(this.allRefLineGraphics);
|
|
375
376
|
const s = setInterval(() => {
|
|
376
377
|
if (this.allLaneGraphics.length > 0 || this.allRefLineGraphics.length > 0) {
|
|
377
378
|
if (this.allLaneGraphics.length > 0) {
|
|
@@ -474,7 +475,7 @@ class I {
|
|
|
474
475
|
}
|
|
475
476
|
const r = s.map(
|
|
476
477
|
(l) => l.geometry
|
|
477
|
-
), d = await
|
|
478
|
+
), d = await G.union(r);
|
|
478
479
|
if (e.flash) {
|
|
479
480
|
this.highlightLayer.removeAll();
|
|
480
481
|
const l = new m({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/Graphic"),v=require("@arcgis/core/geometry"),F=require("@arcgis/core/geometry/geometryEngineAsync.js"),I=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GraphicsLayer"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("@arcgis/core/Graphic"),v=require("@arcgis/core/geometry"),F=require("@arcgis/core/geometry/geometryEngineAsync.js"),I=require("@arcgis/core/layers/FeatureLayer"),O=require("@arcgis/core/layers/GraphicsLayer"),G=require("axios"),N=require("pako"),R=require("./wasm-loader.js");function q(u){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const t in u)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(u,t);Object.defineProperty(e,t,a.get?a:{enumerable:!0,get:()=>u[t]})}}return e.default=u,Object.freeze(e)}const P=q(F);class w{constructor(e){this.wasmLoader=R.default.getInstance(),this.view=e,this.laneLayer=new I({id:"OpenDriveLane",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"id",alias:"编号",type:"string"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"},{name:"sectionId",alias:"路段号",type:"string"},{name:"laneId",alias:"车道号",type:"string"},{name:"type",alias:"类型",type:"string"},{name:"sumoId",alias:"sumo编号",type:"string"}],objectIdField:"ObjectID",geometryType:"polygon",spatialReference:{wkid:4326},source:[],outFields:["*"],renderer:{type:"unique-value",field:"type",defaultSymbol:{type:"simple-fill",color:[100,100,100],style:"solid",outline:{color:"white",width:1}},uniqueValueInfos:[{value:"shoulder",label:"路肩",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"border",label:"路沿",symbol:{type:"simple-fill",color:"#DCDCDC",style:"solid",outline:{color:"white",width:1}}},{value:"driving",label:"机动车道",symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}},{value:"none",label:"无",symbol:{type:"simple-fill",color:[111,120,135],style:"none",outline:{color:"white",width:1}}},{value:"restricted",label:"禁行区",symbol:{type:"simple-fill",color:"yellow",style:"solid",outline:{color:"yellow",width:2}}},{value:"parking",label:"停车区",symbol:{type:"simple-fill",color:[115,115,115],style:"solid",outline:{color:"white",width:1}}},{value:"median",label:"中央隔离带",symbol:{type:"simple-fill",color:"#008000",style:"solid",outline:{color:"white",width:1}}},{value:"biking",label:"非机动车道",symbol:{type:"simple-fill",color:"#D3D3D3",style:"solid",outline:{color:"white",width:1}}},{value:"sidewalk",label:"人行道",symbol:{type:"simple-fill",color:"#C0C0C0",style:"solid",outline:{color:"white",width:1}}},{value:"junction",label:"路口区域",symbol:{type:"simple-fill",color:"#2F4F4F",style:"solid",outline:{color:"white",width:1}}},{value:"selected",label:"选中车道",symbol:{type:"simple-fill",color:[141,168,211],style:"solid",outline:{color:"white",width:1}}}]}}),this.roadNameLayer=new I({id:"OpenDriveRoadName",fields:[{name:"ObjectID",alias:"ObjectID",type:"oid"},{name:"roadId",alias:"道路号",type:"string"},{name:"roadName",alias:"道路名称",type:"string"}],objectIdField:"ObjectID",geometryType:"polyline",spatialReference:{wkid:4326},source:[],renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[0,0,0,0],width:1}},labelingInfo:[{symbol:{type:"text",color:"black",haloColor:"white",haloSize:1,font:{size:12,family:"sans-serif"}},labelPlacement:this.view.type==="2d"?"center-along":void 0,labelExpressionInfo:{expression:"$feature.roadName"}}]}),this.junctionLayer=new O({id:"OpenDriveJunction"}),this.highlightLayer=new O({id:"OpenDriveHighlight"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.highlightLayer,this.roadNameLayer])}static getInstance(e){return this.instance||(this.instance=new w(e)),this.instance}async showOpenDriveFromFile(e){var n,h,s;const t=await this.wasmLoader.load(e.file);if(t.status!==0)return t;console.time("渲染用时");const{roads:a,junctions:o}=t.result;return await this.showAllLanes(a,((n=e.options)==null?void 0:n.showJunctionLane)||!1,((h=e.options)==null?void 0:h.showRoadName)||!0),(s=e.options)!=null&&s.showJunctionPolygon&&this.showJunction(o),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const a=`http://${e}/api/openDrive/analyzeXodr`,o=await G.get(a,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(o.status!==200)throw new Error(`OpenDriveRenderer: ${o.statusText}`);let n=o.data.result.json;n.startsWith(window.location.protocol)||(n=`${window.location.protocol}//${e}${n}`);const s=await(await fetch(n)).arrayBuffer(),r=N.inflate(s,{to:"string"}),d=JSON.parse(r);return await this.showAllLanes(d,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,a){const o=await this.laneLayer.queryFeatures();return o.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:o.features}),this.roadNameLayer.visible=a,new Promise(n=>{let h=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];for(const r of e){if(!t&&r.junction!=="-1")continue;const{id:d,refLine:l}=r;let i=r.name;i.includes("(")&&(i=i.slice(0,i.indexOf("("))),i=i.replace(/(.)/g,"$1 ");const c=new m({geometry:{type:"polyline",paths:[l]},attributes:{ObjectID:h++,roadId:d,roadName:i}});this.allRefLineGraphics.push(c);for(const p of r.laneSections){const b=Number(p.id);for(const y of p.lanePaths){const f=Number(y.id);if(f===0)continue;const D=y.type,g=y.innerPath.concat(y.outerPath.reverse());if(g.length<=3){console.warn(`lane ${f} has less than 3 points`);continue}g.push(y.innerPath[0]);const L=new v.Polygon({rings:[g]});if(L){const j=new m({geometry:L,attributes:{ObjectID:h++,id:`${d}+${b}+${f}`,roadId:d,roadName:r.name,sectionId:b,laneId:f,type:D,sumoId:""}});this.allLaneGraphics.push(j)}}}}this.view.type==="2d"?this.view.goTo(this.allRefLineGraphics):this.view.goTo(this.allRefLineGraphics);const s=setInterval(()=>{if(this.allLaneGraphics.length>0||this.allRefLineGraphics.length>0){if(this.allLaneGraphics.length>0){const r=this.allLaneGraphics.splice(0,100);this.laneLayer.applyEdits({addFeatures:r})}if(this.allRefLineGraphics.length>0){const r=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:r})}}else clearInterval(s),n()},10)})}async showJunction(e){for(const t of e){const a=new v.Polygon({rings:[t.outline]}),o=new m({geometry:a,attributes:{id:t.id,name:t.name},symbol:{type:"simple-fill",color:[47,79,79,.8],style:"solid",outline:{color:"white",width:1}}});this.junctionLayer.add(o)}}async clearOpenDrive(){const e=await this.laneLayer.queryFeatures();e.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:e.features}),this.wasmLoader.clear()}async findSumo(e){const{id:t}=e,a=e.flash===void 0?!0:e.flash,o=t.split("+");if(o.length>2)return{status:-1,message:"id格式错误"};const n=o.length===2?Number(o[1]):void 0,h=o[0].split("#");if(h.length>2)return{status:-1,message:"id格式错误"};let s=h[0];s.startsWith("-")&&(s=s.slice(1));const r=h.length===2?Number(h[1]):void 0;return await this.findLane({roadsectId:s,segmentId:r,laneId:n,flash:a})}async findLane(e){let{segmentId:t,laneId:a}=e;const{roadsectId:o}=e,n=this.laneLayer.createQuery();n.returnGeometry=!0,n.outFields=["*"],n.where=`roadId = '${o}'`;const h=await this.laneLayer.queryFeatures(n);if(h.features.length===0)return{status:-1,message:"未找到。请检查路段编号"};let s=h.features;if(t!==void 0){const l=[];if(s.forEach(i=>{const c=Number(i.attributes.sectionId);l.indexOf(c)===-1&&l.push(c)}),l.sort((i,c)=>i-c),t>l.length-1)return{status:-1,message:"未找到。请检查基本段编号"};t=l[t],s=s.filter(i=>Number(i.attributes.sectionId)===t)}if(a!==void 0){const l=[];if(s.forEach(i=>{const c=Number(i.attributes.laneId);l.indexOf(c)===-1&&l.push(c)}),l.sort((i,c)=>i-c),a>l.length-1)return{status:-1,message:"未找到。请检查车道编号"};a=l[a],s=s.filter(i=>Number(i.attributes.laneId)===a)}const r=s.map(l=>l.geometry),d=await P.union(r);if(e.flash){this.highlightLayer.removeAll();const l=new m({geometry:d,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}}});this.highlightLayer.add(l);let i=0,c=!0;const p=setInterval(()=>{c?(this.highlightLayer.opacity-=.02,this.highlightLayer.opacity<=.1&&(c=!1,i++)):(this.highlightLayer.opacity+=.02,this.highlightLayer.opacity>=1&&(c=!0)),i>5&&(this.highlightLayer.removeAll(),this.highlightLayer.opacity=1,clearInterval(p))},20)}return this.view.type==="2d"?await this.view.goTo(d,{duration:1e3}):await this.view.goTo(d,{duration:1e3}),{status:0,message:"ok"}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=w;
|