gisviewer-vue3-arcgis 1.0.121 → 1.0.123

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,4 +1,4 @@
1
- @import url('@arcgis/core/assets/esri/themes/dark/main.css');
1
+ @import url('@arcgis/core/assets/esri/themes/light/main.css');
2
2
  .gis-viewer {
3
3
  position: relative;
4
4
  width: 100%;
@@ -0,0 +1,6 @@
1
+ import BaseTileLayer from '@arcgis/core/layers/BaseTileLayer.js';
2
+ export default class CustomWMTS extends BaseTileLayer {
3
+ private urlTemplate;
4
+ constructor(params: any);
5
+ getTileUrl(level: number, row: number, col: number): string;
6
+ }
@@ -0,0 +1,21 @@
1
+ import { subclass as a } from "@arcgis/core/core/accessorSupport/decorators";
2
+ import c from "@arcgis/core/layers/BaseTileLayer.js";
3
+ var i = Object.defineProperty, m = Object.getOwnPropertyDescriptor, f = (e, l, t, s) => {
4
+ for (var r = s > 1 ? void 0 : s ? m(l, t) : l, p = e.length - 1, o; p >= 0; p--)
5
+ (o = e[p]) && (r = (s ? o(l, t, r) : o(r)) || r);
6
+ return s && r && i(l, t, r), r;
7
+ };
8
+ let u = class extends c {
9
+ constructor(e) {
10
+ super(e), this.urlTemplate = "", this.urlTemplate = e.urlTemplate;
11
+ }
12
+ getTileUrl(e, l, t) {
13
+ return this.urlTemplate.replace("{level}", String(e)).replace("{col}", String(t)).replace("{row}", String(l));
14
+ }
15
+ };
16
+ u = f([
17
+ a("CustomWMTS")
18
+ ], u);
19
+ export {
20
+ u as default
21
+ };
@@ -1,21 +1,22 @@
1
1
  import b from "@arcgis/core/Basemap";
2
- import u from "@arcgis/core/config";
2
+ import g from "@arcgis/core/config";
3
3
  import * as M from "@arcgis/core/core/reactiveUtils";
4
- import { Polygon as T, Polyline as z, Point as P } from "@arcgis/core/geometry";
4
+ import { Polygon as P, Polyline as W, Point as T } from "@arcgis/core/geometry";
5
5
  import * as f from "@arcgis/core/geometry/support/webMercatorUtils";
6
- import W from "@arcgis/core/layers/GeoJSONLayer";
6
+ import z from "@arcgis/core/layers/GeoJSONLayer";
7
7
  import x from "@arcgis/core/layers/TileLayer";
8
8
  import L from "@arcgis/core/layers/WebTileLayer";
9
9
  import S from "@arcgis/core/Map";
10
10
  import R from "@arcgis/core/views/MapView";
11
- import H from "@arcgis/core/views/SceneView";
12
- import I from "@turf/destination";
13
- import * as O from "@turf/helpers";
14
- import C from "../stores/index.mjs";
15
- function k(h, e) {
16
- return h && (h.startsWith("http://") || h.startsWith("https://") ? h : e + h);
11
+ import C from "@arcgis/core/views/SceneView";
12
+ import H from "@turf/destination";
13
+ import * as I from "@turf/helpers";
14
+ import O from "../stores/index.mjs";
15
+ import G from "./custom-layer/custom-wmts-layer.mjs";
16
+ function k(l, e) {
17
+ return l && (l.startsWith("http://") || l.startsWith("https://") ? l : e + l);
17
18
  }
18
- class Q {
19
+ class F {
19
20
  constructor() {
20
21
  this.mapConfig = {}, this.watchHandleMap = /* @__PURE__ */ new Map(), this.handleIndex = 0, this.zoomWatchHandle = null;
21
22
  }
@@ -25,16 +26,16 @@ class Q {
25
26
  * @returns view
26
27
  */
27
28
  async initialize(e) {
28
- const i = C.useAppDataStore, t = JSON.parse(JSON.stringify(i.mapConfig));
29
+ const i = O.useAppDataStore, t = JSON.parse(JSON.stringify(i.mapConfig));
29
30
  this.mapConfig = t;
30
31
  const { container: a, markerClickCallback: r, mapClickCallback: d } = e;
31
- u.assetsPath = `${t.assetsRoot}/ArcgisAssets`, u.fontsUrl = `${t.assetsRoot}/fonts`, u.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
32
+ g.assetsPath = `${t.assetsRoot}/ArcgisAssets`, g.fontsUrl = `${t.assetsRoot}/fonts`, g.apiKey = "AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";
32
33
  const n = new S();
33
34
  if ((t == null ? void 0 : t.mapOptions.mode.toLowerCase()) === "2d" ? this.view = new R({
34
35
  map: n,
35
36
  container: a,
36
37
  ...t.mapOptions
37
- }) : this.view = new H({
38
+ }) : this.view = new C({
38
39
  map: n,
39
40
  container: a,
40
41
  environment: {
@@ -93,11 +94,11 @@ class Q {
93
94
  );
94
95
  });
95
96
  }), t != null && t.baseLayers ? t.baseLayers.forEach((s) => {
96
- const l = k(s.url, t.assetsRoot);
97
+ const h = k(s.url, t.assetsRoot);
97
98
  switch (s.type.toLowerCase()) {
98
99
  case "webTile".toLowerCase(): {
99
100
  const c = new L({
100
- urlTemplate: l,
101
+ urlTemplate: h,
101
102
  ...s.options
102
103
  });
103
104
  n.add(c);
@@ -105,7 +106,15 @@ class Q {
105
106
  }
106
107
  case "tile": {
107
108
  const c = new x({
108
- url: l,
109
+ url: h,
110
+ ...s.options
111
+ });
112
+ n.add(c);
113
+ break;
114
+ }
115
+ case "customWMTS".toLowerCase(): {
116
+ const c = new G({
117
+ urlTemplate: h,
109
118
  ...s.options
110
119
  });
111
120
  n.add(c);
@@ -124,12 +133,12 @@ class Q {
124
133
  }
125
134
  }), t != null && t.hdLayers) {
126
135
  const s = t.hdLayers.map(
127
- (l) => (
136
+ (h) => (
128
137
  // 图层文件为GeoJson格式, renderer和symbol使用autocast配置
129
- new W({
130
- url: k(l.url, t.assetsRoot),
131
- ...l.options,
132
- title: l.options.id
138
+ new z({
139
+ url: k(h.url, t.assetsRoot),
140
+ ...h.options,
141
+ title: h.options.id
133
142
  })
134
143
  )
135
144
  );
@@ -137,23 +146,23 @@ class Q {
137
146
  }
138
147
  this.view.ui.remove("attribution"), this.view.ui.add("compass", "top-left"), await this.view.when();
139
148
  const p = this.mapConfig.camera;
140
- let g;
149
+ let u;
141
150
  if (this.view.type === "2d") {
142
151
  let s = this.view.center;
143
152
  this.view.spatialReference.isWebMercator && (s = f.webMercatorToGeographic(
144
153
  s
145
- )), g = { center: [s.x, s.y], zoom: this.view.zoom };
154
+ )), u = { center: [s.x, s.y], zoom: this.view.zoom };
146
155
  } else {
147
156
  let s = this.view.camera.position;
148
157
  this.view.spatialReference.isWebMercator && (s = f.webMercatorToGeographic(
149
158
  s
150
- )), g = {
159
+ )), u = {
151
160
  position: s,
152
161
  heading: this.view.camera.heading,
153
162
  tilt: this.view.camera.tilt
154
163
  };
155
164
  }
156
- return p ? p.home = g : this.mapConfig.camera = { home: g }, this.view;
165
+ return p ? p.home = u : this.mapConfig.camera = { home: u }, this.view;
157
166
  }
158
167
  setLayerVisibility(e) {
159
168
  const { id: i, visible: t } = e, a = this.view.map.findLayerById(i);
@@ -171,13 +180,13 @@ class Q {
171
180
  if (e.center || e.target) {
172
181
  switch ((i = e.target) == null ? void 0 : i.type) {
173
182
  case "point":
174
- e.target = new P(e.target);
183
+ e.target = new T(e.target);
175
184
  break;
176
185
  case "polyline":
177
- e.target = new z(e.target);
186
+ e.target = new W(e.target);
178
187
  break;
179
188
  case "polygon":
180
- e.target = new T(e.target);
189
+ e.target = new P(e.target);
181
190
  break;
182
191
  }
183
192
  await this.view.goTo(e, { duration: (e.duration || 0) * 1e3 });
@@ -205,8 +214,8 @@ class Q {
205
214
  { duration: (e.duration || 2) * 1e3 }
206
215
  );
207
216
  else {
208
- const a = Math.tan(i * Math.PI / 180) * e.height, r = I(
209
- O.point(e.center),
217
+ const a = Math.tan(i * Math.PI / 180) * e.height, r = H(
218
+ I.point(e.center),
210
219
  a,
211
220
  t + 180,
212
221
  {
@@ -252,7 +261,7 @@ class Q {
252
261
  }
253
262
  transformPoints(e) {
254
263
  return e.map((i) => {
255
- const t = new P({
264
+ const t = new T({
256
265
  x: i[0],
257
266
  y: i[1]
258
267
  }), a = this.view.toScreen(t);
@@ -280,5 +289,5 @@ class Q {
280
289
  }
281
290
  }
282
291
  export {
283
- Q as default
292
+ F as default
284
293
  };
@@ -6,7 +6,9 @@ export default class OpenDriveRenderer {
6
6
  private laneLayer;
7
7
  private roadNameLayer;
8
8
  private junctionLayer;
9
+ private sectionLayer;
9
10
  private highlightLayer;
11
+ private flashLayer;
10
12
  private allLaneGraphics;
11
13
  private allRefLineGraphics;
12
14
  private mouseMoveHandler;
@@ -15,6 +17,8 @@ export default class OpenDriveRenderer {
15
17
  constructor(view: __esri.MapView | __esri.SceneView);
16
18
  private projectName;
17
19
  private openDriveServer;
20
+ private openDriveClickCallback;
21
+ private makeMd5FromFile;
18
22
  showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
19
23
  /**
20
24
  * 从服务器载入OpenDrive文件解析结果并显示
@@ -48,11 +52,13 @@ export default class OpenDriveRenderer {
48
52
  * @returns
49
53
  */
50
54
  findSumo(params: IFindSumoParams): Promise<IResult>;
55
+ private findJunction;
51
56
  /**
52
57
  * 用sumo的id定位车道、基本段、路段
53
58
  * @param params
54
59
  * @returns
55
60
  */
56
61
  private findLane;
62
+ private flashGraphic;
57
63
  splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
58
64
  }
@@ -1,16 +1,21 @@
1
- import d from "@arcgis/core/Graphic";
2
- import * as O from "@arcgis/core/core/promiseUtils";
3
- import { Polygon as C } from "@arcgis/core/geometry";
4
- import * as L from "@arcgis/core/geometry/geometryEngineAsync";
5
- import G from "@arcgis/core/layers/FeatureLayer";
6
- import D from "@arcgis/core/layers/GraphicsLayer";
7
- import f from "axios";
8
- import j from "pako";
9
- import S from "../common-utils.mjs";
10
- import F from "./wasm-loader.mjs";
11
- class N {
12
- constructor(e) {
13
- this.wasmLoader = F.getInstance(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = e, this.laneLayer = new G({
1
+ import p from "@arcgis/core/Graphic";
2
+ import * as D from "@arcgis/core/core/promiseUtils";
3
+ import { Polygon as N } from "@arcgis/core/geometry";
4
+ import * as k from "@arcgis/core/geometry/geometryEngineAsync";
5
+ import C from "@arcgis/core/layers/FeatureLayer";
6
+ import f from "@arcgis/core/layers/GraphicsLayer";
7
+ import g from "axios";
8
+ import F from "md5";
9
+ import G from "pako";
10
+ import j from "../common-utils.mjs";
11
+ import A from "./wasm-loader.mjs";
12
+ class S {
13
+ constructor(t) {
14
+ this.wasmLoader = A.getInstance(), this.projectName = "", this.openDriveServer = "", this.currentSectionCode = "", this.currentJunctionId = "", this.view = t, this.view.popup.visibleElements = {
15
+ closeButton: !1,
16
+ collapseButton: !1,
17
+ actionBar: !1
18
+ }, this.laneLayer = new C({
14
19
  id: "OpenDriveLane",
15
20
  fields: [
16
21
  {
@@ -218,7 +223,7 @@ class N {
218
223
  }
219
224
  ]
220
225
  }
221
- }), this.roadNameLayer = new G({
226
+ }), this.roadNameLayer = new C({
222
227
  id: "OpenDriveRoadName",
223
228
  fields: [
224
229
  {
@@ -268,50 +273,62 @@ class N {
268
273
  }
269
274
  }
270
275
  ]
271
- }), this.junctionLayer = new D({ id: "OpenDriveJunction" }), this.highlightLayer = new D({ id: "OpenDriveHighlight" }), this.view.map.addMany([
276
+ }), this.junctionLayer = new f({ id: "OpenDriveJunction" }), this.sectionLayer = new f({ id: "OpenDriveSection" }), this.highlightLayer = new f({ id: "OpenDriveHighlight" }), this.flashLayer = new f({ id: "OpenDriveFlash" }), this.view.map.addMany([
272
277
  this.laneLayer,
273
278
  this.junctionLayer,
279
+ this.sectionLayer,
274
280
  this.roadNameLayer,
275
- this.highlightLayer
281
+ this.highlightLayer,
282
+ this.flashLayer
276
283
  ]);
277
284
  }
278
- static getInstance(e) {
279
- return this.instance || (this.instance = new N(e)), this.instance;
285
+ static getInstance(t) {
286
+ return this.instance || (this.instance = new S(t)), this.instance;
280
287
  }
281
- async showOpenDriveFromFile(e) {
282
- var u, c;
283
- this.projectName = Date.now().toString(), this.openDriveServer = e.server;
284
- const o = `http://${this.openDriveServer}/api/openDrive/uploadXodr`, i = await f.post(
285
- o,
286
- {},
287
- {
288
- params: {
289
- url: e.file,
290
- projectName: this.projectName
288
+ async makeMd5FromFile(t) {
289
+ const i = await (await fetch(t)).text();
290
+ return F(i);
291
+ }
292
+ async showOpenDriveFromFile(t) {
293
+ var h, d;
294
+ this.openDriveClickCallback = t.selectedCallback, this.projectName = await this.makeMd5FromFile(t.file), this.openDriveServer = t.server, await this.makeMd5FromFile(t.file);
295
+ const a = `http://${this.openDriveServer}/api/openDrive/uploadXodr`;
296
+ let i;
297
+ try {
298
+ i = await g.post(
299
+ a,
300
+ {},
301
+ {
302
+ params: {
303
+ url: t.file,
304
+ projectName: this.projectName
305
+ }
291
306
  }
292
- }
293
- );
307
+ );
308
+ } catch (u) {
309
+ return { status: -1, message: u.message };
310
+ }
294
311
  if (i.status !== 200)
295
- throw new Error(`OpenDriveRenderer: ${i.statusText}`);
312
+ return { status: -1, message: i.statusText };
296
313
  console.time("渲染用时");
297
314
  const s = i.data.result.geoSetting;
298
- S.setGeoData(
315
+ j.setGeoData(
299
316
  s.geoReference,
300
317
  s.offsetX,
301
318
  s.offsetY
302
319
  );
303
- let t = i.data.result.json;
304
- t.startsWith(window.location.protocol) || (t = `${window.location.protocol}//${e.server}${t}`);
305
- const l = await (await fetch(t)).arrayBuffer(), a = j.inflate(l, { to: "string" }), r = JSON.parse(a);
320
+ let e = i.data.result.json;
321
+ e.startsWith(window.location.protocol) || (e = `${window.location.protocol}//${t.server}${e}`);
322
+ const r = await (await fetch(e)).arrayBuffer(), n = G.inflate(r, { to: "string" }), o = JSON.parse(n);
306
323
  await this.showAllLanes(
307
- r,
308
- ((u = e.options) == null ? void 0 : u.showJunctionLane) || !1,
309
- ((c = e.options) == null ? void 0 : c.showRoadName) || !0
324
+ o,
325
+ ((h = t.options) == null ? void 0 : h.showJunctionLane) || !1,
326
+ ((d = t.options) == null ? void 0 : d.showRoadName) || !0
310
327
  );
311
- const n = i.data.result.junctions;
312
- if (this.showJunction(n), e.options && e.options.centerMap !== !1) {
313
- const m = S.transformPointProjection([0, 0]);
314
- await this.view.goTo(m);
328
+ const l = i.data.result.junctions;
329
+ if (this.showJunction(l), t.options && t.options.centerMap !== !1) {
330
+ const u = j.transformPointProjection([0, 0]);
331
+ await this.view.goTo(u);
315
332
  }
316
333
  return this.mouseMoveHandler || this.monitorMouseMove(), this.mouseClickHandler || this.monitorMouseClick(), console.timeEnd("渲染用时"), { status: 0, message: "ok" };
317
334
  }
@@ -320,10 +337,10 @@ class N {
320
337
  * @param server
321
338
  * @param projectName
322
339
  */
323
- async showOpenDriveFromServer(e, o) {
324
- const i = `http://${e}/api/openDrive/analyzeXodr`, s = await f.get(i, {
340
+ async showOpenDriveFromServer(t, a) {
341
+ const i = `http://${t}/api/openDrive/analyzeXodr`, s = await g.get(i, {
325
342
  headers: {
326
- projectName: o
343
+ projectName: a
327
344
  },
328
345
  params: {
329
346
  analyze: !1,
@@ -332,141 +349,148 @@ class N {
332
349
  });
333
350
  if (s.status !== 200)
334
351
  throw new Error(`OpenDriveRenderer: ${s.statusText}`);
335
- let t = s.data.result.json;
336
- t.startsWith(window.location.protocol) || (t = `${window.location.protocol}//${e}${t}`);
337
- const l = await (await fetch(t)).arrayBuffer(), a = j.inflate(l, { to: "string" }), r = JSON.parse(a);
338
- return await this.showAllLanes(r, !1, !1), { status: 0, message: "ok" };
352
+ let e = s.data.result.json;
353
+ e.startsWith(window.location.protocol) || (e = `${window.location.protocol}//${t}${e}`);
354
+ const r = await (await fetch(e)).arrayBuffer(), n = G.inflate(r, { to: "string" }), o = JSON.parse(n);
355
+ return await this.showAllLanes(o, !1, !1), { status: 0, message: "ok" };
339
356
  }
340
- async showAllLanes(e, o, i) {
357
+ async showAllLanes(t, a, i) {
341
358
  const s = await this.laneLayer.queryFeatures();
342
359
  return s.features.length > 0 && this.laneLayer.applyEdits({
343
360
  deleteFeatures: s.features
344
- }), this.roadNameLayer.visible = i, new Promise((t) => {
345
- let h = 0;
361
+ }), this.roadNameLayer.visible = i, new Promise((e) => {
362
+ let c = 0;
346
363
  this.allLaneGraphics = [], this.allRefLineGraphics = [];
347
- const l = [];
348
- for (const r of e) {
349
- if (!o && r.junction !== "-1")
364
+ const r = [];
365
+ for (const o of t) {
366
+ if (!a && o.junction !== "-1")
350
367
  continue;
351
- const { id: n, refLine: u } = r;
352
- let c = r.name;
353
- c.includes("(") && (c = c.slice(0, c.indexOf("("))), c = c.replace(/(.)/g, "$1 ");
354
- const m = new d({
368
+ const { id: l, refLine: h } = o;
369
+ let d = o.name;
370
+ d.includes("(") && (d = d.slice(0, d.indexOf("("))), d = d.replace(/(.)/g, "$1 ");
371
+ const u = new p({
355
372
  geometry: {
356
373
  type: "polyline",
357
- paths: [u]
374
+ paths: [h]
358
375
  },
359
376
  attributes: {
360
- ObjectID: h++,
361
- roadId: n,
362
- roadName: c
377
+ ObjectID: c++,
378
+ roadId: l,
379
+ roadName: d
363
380
  }
364
381
  });
365
- this.allRefLineGraphics.push(m);
366
- for (const w of r.laneSections) {
367
- const b = Number(w.id);
368
- for (const p of w.lanePaths) {
369
- const y = Number(p.id);
370
- if (y === 0)
382
+ this.allRefLineGraphics.push(u);
383
+ for (const v of o.laneSections) {
384
+ const b = Number(v.id);
385
+ for (const y of v.lanePaths) {
386
+ const m = Number(y.id);
387
+ if (m === 0)
371
388
  continue;
372
- const k = p.type, g = p.innerPath.concat(
373
- p.outerPath.reverse()
389
+ const O = y.type, w = y.innerPath.concat(
390
+ y.outerPath.reverse()
374
391
  );
375
- if (g.length <= 3) {
376
- console.warn(`lane ${y} has less than 3 points`);
392
+ if (w.length <= 3) {
393
+ console.warn(`lane ${m} has less than 3 points`);
377
394
  continue;
378
395
  }
379
- g.push(p.innerPath[0]);
380
- const v = new C({
381
- rings: [g]
396
+ w.push(y.innerPath[0]);
397
+ const I = new N({
398
+ rings: [w]
382
399
  });
383
- if (v) {
384
- const I = new d({
385
- geometry: v,
400
+ if (I) {
401
+ const L = new p({
402
+ geometry: I,
386
403
  attributes: {
387
- ObjectID: h++,
388
- id: `${n}+${b}+${y}`,
389
- roadId: n,
390
- roadName: r.name,
404
+ ObjectID: c++,
405
+ id: `${l}+${b}+${m}`,
406
+ roadId: l,
407
+ roadName: o.name,
391
408
  sectionId: b,
392
- laneId: y,
393
- type: k,
409
+ laneId: m,
410
+ type: O,
394
411
  sumoId: ""
395
412
  }
396
413
  });
397
- this.allLaneGraphics.push(I), l.push(I);
414
+ this.allLaneGraphics.push(L), r.push(L);
398
415
  }
399
416
  }
400
417
  }
401
418
  }
402
- const a = setInterval(() => {
403
- if (l.length > 0 || this.allRefLineGraphics.length > 0) {
404
- if (l.length > 0) {
405
- const r = l.splice(0, 100);
419
+ const n = setInterval(() => {
420
+ if (r.length > 0 || this.allRefLineGraphics.length > 0) {
421
+ if (r.length > 0) {
422
+ const o = r.splice(0, 100);
406
423
  this.laneLayer.applyEdits({
407
- addFeatures: r
424
+ addFeatures: o
408
425
  });
409
426
  }
410
427
  if (this.allRefLineGraphics.length > 0) {
411
- const r = this.allRefLineGraphics.splice(0, 10);
428
+ const o = this.allRefLineGraphics.splice(0, 10);
412
429
  this.roadNameLayer.applyEdits({
413
- addFeatures: r
430
+ addFeatures: o
414
431
  });
415
432
  }
416
433
  } else
417
- clearInterval(a), t();
434
+ clearInterval(n), e();
418
435
  }, 10);
419
436
  });
420
437
  }
421
- showJunction(e) {
422
- const o = [];
423
- for (const i of e) {
424
- const s = new d({
438
+ showJunction(t) {
439
+ const a = [];
440
+ for (const i of t) {
441
+ i.nodeType = i.type;
442
+ const s = new p({
425
443
  geometry: {
426
444
  type: "point",
427
445
  x: i.coordinates[0],
428
446
  y: i.coordinates[1]
429
447
  },
430
- attributes: { ...i, selected: !1 },
448
+ attributes: {
449
+ ...i,
450
+ selected: !1,
451
+ type: "OpenDriveJunction"
452
+ },
431
453
  symbol: {
432
454
  type: "picture-marker",
433
- url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/normal-cross.png",
455
+ url: i.crossId ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png",
434
456
  width: 30,
435
457
  height: 30
436
458
  }
437
459
  });
438
- o.push(s);
460
+ a.push(s);
439
461
  }
440
- this.junctionLayer.addMany(o);
462
+ this.junctionLayer.addMany(a);
441
463
  }
442
464
  /**
443
465
  * 监听鼠标移动事件,高亮显示鼠标所在路段和路口
444
466
  */
445
467
  monitorMouseMove() {
446
- const e = O.debounce(async (o) => {
447
- var h;
448
- const s = (h = (await this.view.hitTest(o, {
468
+ const t = D.debounce(async (a) => {
469
+ var c;
470
+ const s = (c = (await this.view.hitTest(a, {
449
471
  include: [this.laneLayer, this.junctionLayer]
450
- })).results) == null ? void 0 : h.filter(
451
- (l) => l.type === "graphic"
472
+ })).results) == null ? void 0 : c.filter(
473
+ (r) => r.type === "graphic"
452
474
  );
453
475
  if (s.length === 0) {
454
- this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll());
476
+ this.currentSectionCode !== "" && (this.currentSectionCode = "", this.highlightGraphic = void 0, this.highlightLayer.removeAll()), this.currentJunctionId !== "" && (this.currentJunctionId = "", this.view.popup.close());
455
477
  return;
456
478
  }
457
- const t = s[0];
458
- if (this.hitGraphic = t.graphic, t.layer.id === "OpenDriveLane") {
459
- const l = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
460
- if (l === this.currentSectionCode)
479
+ const e = s[0];
480
+ if (this.hitGraphic = e.graphic, e.layer.id === "OpenDriveLane") {
481
+ const r = `${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;
482
+ if (r === this.currentSectionCode || this.sectionLayer.graphics.findIndex(
483
+ (h) => h.getAttribute("id") === r
484
+ ) >= 0)
461
485
  return;
462
- this.currentSectionCode = l;
463
- const a = this.allLaneGraphics.filter(
464
- (n) => `${n.attributes.roadId}+${n.attributes.sectionId}` === l
465
- ), r = await L.union(
466
- a.map((n) => n.geometry)
486
+ this.currentSectionCode = r;
487
+ const o = this.allLaneGraphics.filter(
488
+ (h) => `${h.attributes.roadId}+${h.attributes.sectionId}` === r
489
+ ), l = await k.union(
490
+ o.map((h) => h.geometry)
467
491
  );
468
- this.highlightGraphic = new d({
469
- geometry: r,
492
+ this.highlightGraphic = new p({
493
+ geometry: l,
470
494
  symbol: {
471
495
  type: "simple-fill",
472
496
  color: [255, 0, 0, 0.5],
@@ -478,49 +502,28 @@ class N {
478
502
  },
479
503
  attributes: {
480
504
  type: "OpenDriveSection",
481
- id: l,
482
- detail: ""
505
+ id: r,
506
+ selected: !1
483
507
  }
484
508
  }), this.highlightLayer.removeAll(), this.highlightLayer.add(this.highlightGraphic);
485
- } else if (t.layer.id === "OpenDriveJunction") {
486
- const l = this.hitGraphic.attributes.id;
487
- if (l === this.currentJunctionId)
509
+ } else if (e.layer.id === "OpenDriveJunction") {
510
+ const r = this.hitGraphic.getAttribute("id");
511
+ if (r === this.currentJunctionId)
488
512
  return;
489
- this.currentJunctionId = l, this.highlightGraphic = new d({
490
- geometry: this.hitGraphic.geometry,
491
- symbol: {
492
- type: "simple-marker",
493
- style: "circle",
494
- size: 40,
495
- color: [0, 0, 0, 0],
496
- outline: {
497
- color: [0, 0, 0, 0]
498
- }
499
- },
500
- attributes: {
501
- type: "OpenDriveJunction",
502
- id: l
503
- }
513
+ this.currentJunctionId = r;
514
+ const n = this.hitGraphic.getAttribute("name"), o = this.hitGraphic.getAttribute("crossId");
515
+ this.view.popup.open({
516
+ title: n,
517
+ content: `<table>
518
+ <tr><td>路口编号</td><td>${r}</td></tr>
519
+ <tr><td>信号机编号</td><td>${o || "无信控"}</td></tr>
520
+ </table>`,
521
+ location: this.hitGraphic.geometry
504
522
  });
505
- const a = new d({
506
- geometry: this.hitGraphic.geometry,
507
- symbol: {
508
- type: "text",
509
- color: "black",
510
- backgroundColor: "gray",
511
- text: `${this.hitGraphic.attributes.name}
512
- ${this.hitGraphic.attributes.id}`,
513
- font: {
514
- size: 10
515
- },
516
- yoffset: 40
517
- }
518
- });
519
- this.highlightLayer.removeAll(), this.highlightLayer.addMany([this.highlightGraphic, a]);
520
523
  }
521
524
  });
522
- this.mouseMoveHandler = this.view.on("pointer-move", async (o) => {
523
- e(o).catch(() => {
525
+ this.mouseMoveHandler = this.view.on("pointer-move", async (a) => {
526
+ t(a).catch(() => {
524
527
  });
525
528
  });
526
529
  }
@@ -528,42 +531,84 @@ ${this.hitGraphic.attributes.id}`,
528
531
  * 监听鼠标点击事件,获取高亮要素的拓扑信息
529
532
  */
530
533
  monitorMouseClick() {
531
- this.mouseClickHandler = this.view.on("immediate-click", async () => {
532
- var e, o;
533
- if (this.hitGraphic && !this.currentSectionCode) {
534
- if (this.currentJunctionId)
535
- if (this.hitGraphic.getAttribute("selected") === !1) {
536
- const i = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, s = await f.get(i, {
537
- params: {
538
- id: this.currentJunctionId,
539
- projectName: this.projectName
540
- }
541
- });
542
- s.status === 200 && s.data.status === 0 && ((e = this.highlightGraphic) == null || e.setAttribute("detail", s.data.result), this.hitGraphic.setAttribute("selected", !0), this.hitGraphic.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(this.hitGraphic, 50));
543
- } else
544
- (o = this.highlightGraphic) == null || o.setAttribute("detail", void 0), this.hitGraphic.setAttribute("selected", !1), this.hitGraphic.symbol.url = "/GisViewerAssets/Images/point_green.png", this.decreasePictureMarkerSize(this.hitGraphic, 30);
545
- }
534
+ const t = D.debounce(async (a) => {
535
+ var n;
536
+ const s = (n = (await this.view.hitTest(a, {
537
+ include: [this.highlightLayer, this.junctionLayer, this.sectionLayer]
538
+ })).results) == null ? void 0 : n.filter(
539
+ (o) => o.type === "graphic"
540
+ );
541
+ if (s.length === 0)
542
+ return;
543
+ const e = s[0].graphic, c = e.getAttribute("type"), r = e.getAttribute("id");
544
+ if (c === "OpenDriveJunction")
545
+ if (e.getAttribute("selected") === !1) {
546
+ const o = `http://${this.openDriveServer}/api/sumo/getSumoJunction`, l = await g.get(o, {
547
+ params: {
548
+ id: r,
549
+ projectName: this.projectName
550
+ }
551
+ });
552
+ l.status === 200 && l.data.status === 0 && (this.openDriveClickCallback && this.openDriveClickCallback({
553
+ type: "OpenDriveJunction",
554
+ id: r,
555
+ details: l.data.result
556
+ }), e.setAttribute("selected", !0), e.symbol.url = "/GisViewerAssets/Images/point_red.png", this.increasePictureMarkerSize(e, 50));
557
+ } else {
558
+ this.openDriveClickCallback && this.openDriveClickCallback({
559
+ type: "OpenDriveJunction",
560
+ id: r,
561
+ details: void 0
562
+ }), e.setAttribute("selected", !1);
563
+ const o = e.getAttribute("crossId");
564
+ e.symbol.url = o ? "/GisViewerAssets/Images/point_green.png" : "/GisViewerAssets/Images/point_yellow.png", this.decreasePictureMarkerSize(e, 30);
565
+ }
566
+ else if (c === "OpenDriveSection")
567
+ if (e.getAttribute("selected"))
568
+ this.sectionLayer.remove(e), this.openDriveClickCallback && this.openDriveClickCallback({
569
+ type: "OpenDriveSection",
570
+ id: r,
571
+ details: void 0
572
+ });
573
+ else {
574
+ this.highlightLayer.remove(e), this.sectionLayer.add(e), e.setAttribute("selected", !0);
575
+ const o = `http://${this.openDriveServer}/api/sumo/getSumoEdge`, l = await g.get(o, {
576
+ params: {
577
+ id: r,
578
+ projectName: this.projectName
579
+ }
580
+ });
581
+ l.status === 200 && l.data.status === 0 && this.openDriveClickCallback && this.openDriveClickCallback({
582
+ type: "OpenDriveSection",
583
+ id: r,
584
+ details: l.data.result
585
+ });
586
+ }
587
+ });
588
+ this.mouseClickHandler = this.view.on("immediate-click", async (a) => {
589
+ t(a).catch(() => {
590
+ });
546
591
  });
547
592
  }
548
- increasePictureMarkerSize(e, o) {
593
+ increasePictureMarkerSize(t, a) {
549
594
  const i = setInterval(() => {
550
- const s = e.symbol, t = s.width;
551
- t < o ? e.symbol = {
595
+ const s = t.symbol, e = s.width;
596
+ e < a ? t.symbol = {
552
597
  type: "picture-marker",
553
598
  url: s.url,
554
- width: t + 1,
555
- height: t + 1
599
+ width: e + 1,
600
+ height: e + 1
556
601
  } : clearInterval(i);
557
602
  }, 20);
558
603
  }
559
- decreasePictureMarkerSize(e, o) {
604
+ decreasePictureMarkerSize(t, a) {
560
605
  const i = setInterval(() => {
561
- const s = e.symbol, t = s.width;
562
- t > o ? e.symbol = {
606
+ const s = t.symbol, e = s.width;
607
+ e > a ? t.symbol = {
563
608
  type: "picture-marker",
564
609
  url: s.url,
565
- width: t - 1,
566
- height: t - 1
610
+ width: e - 1,
611
+ height: e - 1
567
612
  } : clearInterval(i);
568
613
  }, 20);
569
614
  }
@@ -571,95 +616,125 @@ ${this.hitGraphic.attributes.id}`,
571
616
  * 清除OpenDrive内容
572
617
  */
573
618
  async clearOpenDrive() {
574
- var o, i;
575
- let e = await this.laneLayer.queryFeatures();
576
- e.features.length > 0 && await this.laneLayer.applyEdits({
577
- deleteFeatures: e.features
578
- }), e = await this.roadNameLayer.queryFeatures(), e.features.length > 0 && await this.roadNameLayer.applyEdits({
579
- deleteFeatures: e.features
580
- }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.wasmLoader.clear(), (o = this.mouseMoveHandler) == null || o.remove(), (i = this.mouseClickHandler) == null || i.remove();
619
+ var a, i;
620
+ let t = await this.laneLayer.queryFeatures();
621
+ t.features.length > 0 && await this.laneLayer.applyEdits({
622
+ deleteFeatures: t.features
623
+ }), t = await this.roadNameLayer.queryFeatures(), t.features.length > 0 && await this.roadNameLayer.applyEdits({
624
+ deleteFeatures: t.features
625
+ }), this.highlightLayer.removeAll(), this.junctionLayer.removeAll(), this.wasmLoader.clear(), (a = this.mouseMoveHandler) == null || a.remove(), (i = this.mouseClickHandler) == null || i.remove();
581
626
  }
582
627
  /**
583
628
  * 用sumo的id定位车道、基本段、路段
584
629
  * @param params
585
630
  * @returns
586
631
  */
587
- async findSumo(e) {
588
- const { id: o } = e, i = e.flash === void 0 ? !0 : e.flash, s = o.split("+");
589
- if (s.length > 2)
590
- return { status: -1, message: "id格式错误" };
591
- const t = s.length === 2 ? Number(s[1]) : void 0, h = s[0].split("#");
592
- if (h.length > 2)
593
- return { status: -1, message: "id格式错误" };
594
- let l = h[0];
595
- l.startsWith("-") && (l = l.slice(1));
596
- const a = h.length === 2 ? Number(h[1]) : void 0;
597
- return await this.findLane({ roadsectId: l, segmentId: a, laneId: t, flash: i });
632
+ async findSumo(t) {
633
+ const { type: a, id: i } = t, s = t.flash === void 0 ? !0 : t.flash;
634
+ if (a === "junction")
635
+ return await this.findJunction(i, s);
636
+ if (a === "edge") {
637
+ const e = i.split("+");
638
+ if (e.length > 2)
639
+ return { status: -1, message: "id格式错误" };
640
+ const c = e.length === 2 ? Number(e[1]) : void 0, r = e[0].split("#");
641
+ if (r.length > 2)
642
+ return { status: -1, message: "id格式错误" };
643
+ const n = r[0], o = r.length === 2 ? Number(r[1]) : void 0;
644
+ return await this.findLane({ roadsectId: n, segmentId: o, laneId: c, flash: s });
645
+ } else
646
+ return { status: -1, message: "未知类型" };
647
+ }
648
+ async findJunction(t, a) {
649
+ const i = this.junctionLayer.graphics.find(
650
+ (s) => s.attributes.id === t
651
+ );
652
+ if (!i)
653
+ return { status: -1, message: "未找到。请检查路口编号" };
654
+ if (a) {
655
+ const s = new p({
656
+ geometry: i.geometry,
657
+ symbol: {
658
+ type: "simple-marker",
659
+ style: "circle",
660
+ size: 30,
661
+ color: [255, 0, 0, 0.6],
662
+ outline: {
663
+ color: "red",
664
+ width: 1
665
+ }
666
+ }
667
+ });
668
+ this.flashGraphic(s);
669
+ }
670
+ return await this.view.goTo(i.geometry, { duration: 1e3 }), { status: 0, message: "ok" };
598
671
  }
599
672
  /**
600
673
  * 用sumo的id定位车道、基本段、路段
601
674
  * @param params
602
675
  * @returns
603
676
  */
604
- async findLane(e) {
605
- let { segmentId: o, laneId: i } = e;
606
- const { roadsectId: s } = e;
607
- let t = this.allLaneGraphics.filter(
608
- (a) => a.attributes.roadId === s
677
+ async findLane(t) {
678
+ let { roadsectId: a, segmentId: i, laneId: s } = t;
679
+ a.startsWith("-") && (a = a.slice(1));
680
+ let e = this.allLaneGraphics.filter(
681
+ (n) => n.attributes.roadId === a
609
682
  );
610
- if (t.length === 0)
683
+ if (e.length === 0)
611
684
  return { status: -1, message: "未找到。请检查路段编号" };
612
- if (o !== void 0) {
613
- const a = [];
614
- if (t.forEach((r) => {
615
- const n = Number(r.attributes.sectionId);
616
- a.indexOf(n) === -1 && a.push(n);
617
- }), a.sort((r, n) => r - n), o > a.length - 1)
685
+ if (i !== void 0) {
686
+ const n = [];
687
+ if (e.forEach((o) => {
688
+ const l = Number(o.attributes.sectionId);
689
+ n.indexOf(l) === -1 && n.push(l);
690
+ }), n.sort((o, l) => o - l), i > n.length - 1)
618
691
  return { status: -1, message: "未找到。请检查基本段编号" };
619
- o = a[o], t = t.filter(
620
- (r) => Number(r.attributes.sectionId) === o
692
+ i = n[i], e = e.filter(
693
+ (o) => Number(o.attributes.sectionId) === i
621
694
  );
622
695
  }
623
- if (i !== void 0) {
624
- const a = [];
625
- if (t.forEach((r) => {
626
- const n = Number(r.attributes.laneId);
627
- a.indexOf(n) === -1 && a.push(n);
628
- }), a.sort((r, n) => r - n), i > a.length - 1)
696
+ if (s !== void 0) {
697
+ const n = [];
698
+ if (e.forEach((o) => {
699
+ const l = Number(o.attributes.laneId);
700
+ n.indexOf(l) === -1 && n.push(l);
701
+ }), n.sort((o, l) => o - l), s > n.length - 1)
629
702
  return { status: -1, message: "未找到。请检查车道编号" };
630
- i = a[i], t = t.filter(
631
- (r) => Number(r.attributes.laneId) === i
703
+ s = n[s], e = e.filter(
704
+ (o) => Number(o.attributes.laneId) === s
632
705
  );
633
706
  }
634
- const h = t.map(
635
- (a) => a.geometry
636
- ), l = await L.union(h);
637
- if (e.flash) {
638
- this.highlightLayer.removeAll();
639
- const a = new d({
640
- geometry: l,
707
+ const c = e.map(
708
+ (n) => n.geometry
709
+ ), r = await k.union(c);
710
+ if (t.flash) {
711
+ const n = new p({
712
+ geometry: r,
641
713
  symbol: {
642
714
  type: "simple-fill",
643
715
  color: [255, 0, 0, 0.5],
644
716
  style: "solid",
645
717
  outline: {
646
718
  color: "red",
647
- width: 2
719
+ width: 0
648
720
  }
649
721
  }
650
722
  });
651
- this.highlightLayer.add(a);
652
- let r = 0, n = !0;
653
- const u = setInterval(() => {
654
- n ? (this.highlightLayer.opacity -= 0.02, this.highlightLayer.opacity <= 0.1 && (n = !1, r++)) : (this.highlightLayer.opacity += 0.02, this.highlightLayer.opacity >= 1 && (n = !0)), r > 5 && (this.highlightLayer.removeAll(), this.highlightLayer.opacity = 1, clearInterval(u));
655
- }, 20);
723
+ this.flashGraphic(n);
656
724
  }
657
- return await this.view.goTo(l, { duration: 1e3 }), { status: 0, message: "ok" };
725
+ return await this.view.goTo(r, { duration: 1e3 }), { status: 0, message: "ok" };
726
+ }
727
+ flashGraphic(t) {
728
+ this.flashLayer.removeAll(), this.flashLayer.add(t);
729
+ let a = 0, i = !0;
730
+ const s = setInterval(() => {
731
+ i ? (this.flashLayer.opacity -= 0.02, this.flashLayer.opacity <= 0.1 && (i = !1, a++)) : (this.flashLayer.opacity += 0.02, this.flashLayer.opacity >= 1 && (i = !0)), a >= 5 && (this.flashLayer.removeAll(), this.flashLayer.opacity = 1, clearInterval(s));
732
+ }, 10);
658
733
  }
659
- async splitLane(e) {
660
- return { status: 0, message: "ok", result: e };
734
+ async splitLane(t) {
735
+ return { status: 0, message: "ok", result: t };
661
736
  }
662
737
  }
663
738
  export {
664
- N as default
739
+ S as default
665
740
  };
@@ -216,8 +216,10 @@ export interface IShowOpenDriveFromFileParams {
216
216
  showRoadName: boolean;
217
217
  centerMap?: boolean;
218
218
  };
219
+ selectedCallback?: (info: any) => void;
219
220
  }
220
221
  export interface IFindSumoParams {
222
+ type: string;
221
223
  id: string;
222
224
  flash?: boolean;
223
225
  }
@@ -229,6 +231,7 @@ export interface ISplitOpenDriveLaneParams {
229
231
  export interface IJunctionTableData {
230
232
  id: string;
231
233
  name: string;
234
+ nodeType: string;
232
235
  type: string;
233
236
  coordinates: number[];
234
237
  district: string;
@@ -1,4 +1,4 @@
1
- @import url('@arcgis/core/assets/esri/themes/dark/main.css');
1
+ @import url('@arcgis/core/assets/esri/themes/light/main.css');
2
2
  .gis-viewer {
3
3
  position: relative;
4
4
  width: 100%;
@@ -0,0 +1,6 @@
1
+ import BaseTileLayer from '@arcgis/core/layers/BaseTileLayer.js';
2
+ export default class CustomWMTS extends BaseTileLayer {
3
+ private urlTemplate;
4
+ constructor(params: any);
5
+ getTileUrl(level: number, row: number, col: number): string;
6
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("@arcgis/core/core/accessorSupport/decorators"),c=require("@arcgis/core/layers/BaseTileLayer.js");var i=Object.defineProperty,p=Object.getOwnPropertyDescriptor,n=(s,e,l,t)=>{for(var r=t>1?void 0:t?p(e,l):e,u=s.length-1,a;u>=0;u--)(a=s[u])&&(r=(t?a(e,l,r):a(r))||r);return t&&r&&i(e,l,r),r};exports.default=class extends c{constructor(e){super(e),this.urlTemplate="",this.urlTemplate=e.urlTemplate}getTileUrl(e,l,t){return this.urlTemplate.replace("{level}",String(e)).replace("{col}",String(t)).replace("{row}",String(l))}};exports.default=n([o.subclass("CustomWMTS")],exports.default);
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),y=require("@arcgis/core/config"),z=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),q=require("@arcgis/core/geometry/support/webMercatorUtils"),O=require("@arcgis/core/layers/GeoJSONLayer"),S=require("@arcgis/core/layers/TileLayer"),W=require("@arcgis/core/layers/WebTileLayer"),x=require("@arcgis/core/Map"),L=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const k=b(z),p=b(q),C=b(I);function T(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class G{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;y.assetsPath=`${t.assetsRoot}/ArcgisAssets`,y.fontsUrl=`${t.assetsRoot}/fonts`,y.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new x;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new L({map:c,container:o,...t.mapOptions}):this.view=new R({map:c,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var v,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(v=navigator.clipboard)==null||v.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{const h=T(s.url,t.assetsRoot);switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const l=new W({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new S({url:h,...s.options});c.add(l);break}case"arcgis":{const l=new P(s.options);c.basemap=l;break}}}):c.basemap=new P({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(h=>new O({url:T(h.url,t.assetsRoot),...h.options,title:h.options.id}));c.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(C.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=k.watch(()=>this.view.center,()=>{const c=this.transformPoints(e),w=Date.now();w-t>n&&(i(c),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=k.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=G;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const P=require("@arcgis/core/Basemap"),y=require("@arcgis/core/config"),q=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),z=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/TileLayer"),S=require("@arcgis/core/layers/WebTileLayer"),L=require("@arcgis/core/Map"),x=require("@arcgis/core/views/MapView"),R=require("@arcgis/core/views/SceneView"),H=require("@turf/destination"),I=require("@turf/helpers"),_=require("../stores/index.js"),C=require("./custom-layer/custom-wmts-layer.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const i in r)if(i!=="default"){const t=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,t.get?t:{enumerable:!0,get:()=>r[i]})}}return e.default=r,Object.freeze(e)}const T=b(q),p=b(z),G=b(I);function k(r,e){return r&&(r.startsWith("http://")||r.startsWith("https://")?r:e+r)}class N{constructor(){this.mapConfig={},this.watchHandleMap=new Map,this.handleIndex=0,this.zoomWatchHandle=null}async initialize(e){const i=_.default.useAppDataStore,t=JSON.parse(JSON.stringify(i.mapConfig));this.mapConfig=t;const{container:o,markerClickCallback:n,mapClickCallback:f}=e;y.assetsPath=`${t.assetsRoot}/ArcgisAssets`,y.fontsUrl=`${t.assetsRoot}/fonts`,y.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const c=new L;if((t==null?void 0:t.mapOptions.mode.toLowerCase())==="2d"?this.view=new x({map:c,container:o,...t.mapOptions}):this.view=new R({map:c,container:o,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...t==null?void 0:t.mapOptions}),this.view.on("click",async s=>{var v,M;if(f){let a=s.mapPoint;a.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),f([a.x,a.y],[s.screenPoint.x,s.screenPoint.y],s)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const u=p.webMercatorToGeographic(a.position),d={heading:a.heading,tilt:a.tilt,position:u.toJSON()};console.log(d),(v=navigator.clipboard)==null||v.writeText(JSON.stringify(d))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=p.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom})}const l=(M=(await this.view.hitTest(s)).results)==null?void 0:M.filter(a=>a.type==="graphic");l.length>0&&l.forEach(a=>{var d;const u=a.graphic;(d=u.attributes)!=null&&d.type&&n&&n(u.attributes.type,u.attributes.id,u.attributes,s)})}),t!=null&&t.baseLayers?t.baseLayers.forEach(s=>{const h=k(s.url,t.assetsRoot);switch(s.type.toLowerCase()){case"webTile".toLowerCase():{const l=new S({urlTemplate:h,...s.options});c.add(l);break}case"tile":{const l=new O({url:h,...s.options});c.add(l);break}case"customWMTS".toLowerCase():{const l=new C.default({urlTemplate:h,...s.options});c.add(l);break}case"arcgis":{const l=new P(s.options);c.basemap=l;break}}}):c.basemap=new P({style:{id:"arcgis/dark-gray",language:"zh-CN"}}),t!=null&&t.hdLayers){const s=t.hdLayers.map(h=>new W({url:k(h.url,t.assetsRoot),...h.options,title:h.options.id}));c.addMany(s)}this.view.ui.remove("attribution"),this.view.ui.add("compass","top-left"),await this.view.when();const w=this.mapConfig.camera;let m;if(this.view.type==="2d"){let s=this.view.center;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={center:[s.x,s.y],zoom:this.view.zoom}}else{let s=this.view.camera.position;this.view.spatialReference.isWebMercator&&(s=p.webMercatorToGeographic(s)),m={position:s,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return w?w.home=m:this.mapConfig.camera={home:m},this.view}setLayerVisibility(e){const{id:i,visible:t}=e,o=this.view.map.findLayerById(i);return o?(o.visible=t,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var i;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((i=e.target)==null?void 0:i.type){case"point":e.target=new g.Point(e.target);break;case"polyline":e.target=new g.Polyline(e.target);break;case"polygon":e.target=new g.Polygon(e.target);break}await this.view.goTo(e,{duration:(e.duration||0)*1e3})}return{status:0,message:"成功"}}async lookAt(e){if(this.view.type==="2d")return;const i=e.tilt||0,t=e.heading||0;if(i===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:t,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(i*Math.PI/180)*e.height,n=H(G.point(e.center),o,t+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:t,tilt:i},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:i,duration:t=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[i];return n?(await this.view.goTo(n,{duration:t*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,i){let t=0;const n=1e3/30,f=T.watch(()=>this.view.center,()=>{const c=this.transformPoints(e),w=Date.now();w-t>n&&(i(c),t=w)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(i=>{const t=new g.Point({x:i[0],y:i[1]}),o=this.view.toScreen(t);return[o.x,o.y]})}cancelCoordinateTransform(e){const i=this.watchHandleMap.get(e);i&&(i.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:i,max:t}=e;!i&&!t||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,o=>{i&&o<=i&&(this.view.zoom=i),t&&o>=t&&(this.view.zoom=t)}))}}exports.default=N;
@@ -6,7 +6,9 @@ export default class OpenDriveRenderer {
6
6
  private laneLayer;
7
7
  private roadNameLayer;
8
8
  private junctionLayer;
9
+ private sectionLayer;
9
10
  private highlightLayer;
11
+ private flashLayer;
10
12
  private allLaneGraphics;
11
13
  private allRefLineGraphics;
12
14
  private mouseMoveHandler;
@@ -15,6 +17,8 @@ export default class OpenDriveRenderer {
15
17
  constructor(view: __esri.MapView | __esri.SceneView);
16
18
  private projectName;
17
19
  private openDriveServer;
20
+ private openDriveClickCallback;
21
+ private makeMd5FromFile;
18
22
  showOpenDriveFromFile(params: IShowOpenDriveFromFileParams): Promise<IResult>;
19
23
  /**
20
24
  * 从服务器载入OpenDrive文件解析结果并显示
@@ -48,11 +52,13 @@ export default class OpenDriveRenderer {
48
52
  * @returns
49
53
  */
50
54
  findSumo(params: IFindSumoParams): Promise<IResult>;
55
+ private findJunction;
51
56
  /**
52
57
  * 用sumo的id定位车道、基本段、路段
53
58
  * @param params
54
59
  * @returns
55
60
  */
56
61
  private findLane;
62
+ private flashGraphic;
57
63
  splitLane(params: ISplitOpenDriveLaneParams): Promise<IResult>;
58
64
  }
@@ -1,2 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const u=require("@arcgis/core/Graphic"),C=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),A=require("@arcgis/core/geometry/geometryEngineAsync"),D=require("@arcgis/core/layers/FeatureLayer"),j=require("@arcgis/core/layers/GraphicsLayer"),w=require("axios"),S=require("pako"),O=require("../common-utils.js"),M=require("./wasm-loader.js");function k(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const t in p)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(p,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>p[t]})}}return e.default=p,Object.freeze(e)}const P=k(C),N=k(A);class b{constructor(e){this.wasmLoader=M.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.laneLayer=new D({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 D({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 j({id:"OpenDriveJunction"}),this.highlightLayer=new j({id:"OpenDriveHighlight"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.roadNameLayer,this.highlightLayer])}static getInstance(e){return this.instance||(this.instance=new b(e)),this.instance}async showOpenDriveFromFile(e){var d,c;this.projectName=Date.now().toString(),this.openDriveServer=e.server;const t=`http://${this.openDriveServer}/api/openDrive/uploadXodr`,i=await w.post(t,{},{params:{url:e.file,projectName:this.projectName}});if(i.status!==200)throw new Error(`OpenDriveRenderer: ${i.statusText}`);console.time("渲染用时");const r=i.data.result.geoSetting;O.default.setGeoData(r.geoReference,r.offsetX,r.offsetY);let s=i.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e.server}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=S.inflate(n,{to:"string"}),o=JSON.parse(a);await this.showAllLanes(o,((d=e.options)==null?void 0:d.showJunctionLane)||!1,((c=e.options)==null?void 0:c.showRoadName)||!0);const l=i.data.result.junctions;if(this.showJunction(l),e.options&&e.options.centerMap!==!1){const g=O.default.transformPointProjection([0,0]);await this.view.goTo(g)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,t){const i=`http://${e}/api/openDrive/analyzeXodr`,r=await w.get(i,{headers:{projectName:t},params:{analyze:!1,compressed:!0}});if(r.status!==200)throw new Error(`OpenDriveRenderer: ${r.statusText}`);let s=r.data.result.json;s.startsWith(window.location.protocol)||(s=`${window.location.protocol}//${e}${s}`);const n=await(await fetch(s)).arrayBuffer(),a=S.inflate(n,{to:"string"}),o=JSON.parse(a);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,t,i){const r=await this.laneLayer.queryFeatures();return r.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:r.features}),this.roadNameLayer.visible=i,new Promise(s=>{let h=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const n=[];for(const o of e){if(!t&&o.junction!=="-1")continue;const{id:l,refLine:d}=o;let c=o.name;c.includes("(")&&(c=c.slice(0,c.indexOf("("))),c=c.replace(/(.)/g,"$1 ");const g=new u({geometry:{type:"polyline",paths:[d]},attributes:{ObjectID:h++,roadId:l,roadName:c}});this.allRefLineGraphics.push(g);for(const v of o.laneSections){const I=Number(v.id);for(const y of v.lanePaths){const m=Number(y.id);if(m===0)continue;const F=y.type,f=y.innerPath.concat(y.outerPath.reverse());if(f.length<=3){console.warn(`lane ${m} has less than 3 points`);continue}f.push(y.innerPath[0]);const L=new $.Polygon({rings:[f]});if(L){const G=new u({geometry:L,attributes:{ObjectID:h++,id:`${l}+${I}+${m}`,roadId:l,roadName:o.name,sectionId:I,laneId:m,type:F,sumoId:""}});this.allLaneGraphics.push(G),n.push(G)}}}}const a=setInterval(()=>{if(n.length>0||this.allRefLineGraphics.length>0){if(n.length>0){const o=n.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(a),s()},10)})}showJunction(e){const t=[];for(const i of e){const r=new u({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/normal-cross.png",width:30,height:30}});t.push(r)}this.junctionLayer.addMany(t)}monitorMouseMove(){const e=P.debounce(async t=>{var h;const r=(h=(await this.view.hitTest(t,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:h.filter(n=>n.type==="graphic");if(r.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.highlightGraphic=void 0,this.highlightLayer.removeAll());return}const s=r[0];if(this.hitGraphic=s.graphic,s.layer.id==="OpenDriveLane"){const n=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(n===this.currentSectionCode)return;this.currentSectionCode=n;const a=this.allLaneGraphics.filter(l=>`${l.attributes.roadId}+${l.attributes.sectionId}`===n),o=await N.union(a.map(l=>l.geometry));this.highlightGraphic=new u({geometry:o,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}},attributes:{type:"OpenDriveSection",id:n,detail:""}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(s.layer.id==="OpenDriveJunction"){const n=this.hitGraphic.attributes.id;if(n===this.currentJunctionId)return;this.currentJunctionId=n,this.highlightGraphic=new u({geometry:this.hitGraphic.geometry,symbol:{type:"simple-marker",style:"circle",size:40,color:[0,0,0,0],outline:{color:[0,0,0,0]}},attributes:{type:"OpenDriveJunction",id:n}});const a=new u({geometry:this.hitGraphic.geometry,symbol:{type:"text",color:"black",backgroundColor:"gray",text:`${this.hitGraphic.attributes.name}
2
- ${this.hitGraphic.attributes.id}`,font:{size:10},yoffset:40}});this.highlightLayer.removeAll(),this.highlightLayer.addMany([this.highlightGraphic,a])}});this.mouseMoveHandler=this.view.on("pointer-move",async t=>{e(t).catch(()=>{})})}monitorMouseClick(){this.mouseClickHandler=this.view.on("immediate-click",async()=>{var e,t;if(this.hitGraphic&&!this.currentSectionCode){if(this.currentJunctionId)if(this.hitGraphic.getAttribute("selected")===!1){const i=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,r=await w.get(i,{params:{id:this.currentJunctionId,projectName:this.projectName}});r.status===200&&r.data.status===0&&((e=this.highlightGraphic)==null||e.setAttribute("detail",r.data.result),this.hitGraphic.setAttribute("selected",!0),this.hitGraphic.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(this.hitGraphic,50))}else(t=this.highlightGraphic)==null||t.setAttribute("detail",void 0),this.hitGraphic.setAttribute("selected",!1),this.hitGraphic.symbol.url="/GisViewerAssets/Images/point_green.png",this.decreasePictureMarkerSize(this.hitGraphic,30)}})}increasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s<t?e.symbol={type:"picture-marker",url:r.url,width:s+1,height:s+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,t){const i=setInterval(()=>{const r=e.symbol,s=r.width;s>t?e.symbol={type:"picture-marker",url:r.url,width:s-1,height:s-1}:clearInterval(i)},20)}async clearOpenDrive(){var t,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.wasmLoader.clear(),(t=this.mouseMoveHandler)==null||t.remove(),(i=this.mouseClickHandler)==null||i.remove()}async findSumo(e){const{id:t}=e,i=e.flash===void 0?!0:e.flash,r=t.split("+");if(r.length>2)return{status:-1,message:"id格式错误"};const s=r.length===2?Number(r[1]):void 0,h=r[0].split("#");if(h.length>2)return{status:-1,message:"id格式错误"};let n=h[0];n.startsWith("-")&&(n=n.slice(1));const a=h.length===2?Number(h[1]):void 0;return await this.findLane({roadsectId:n,segmentId:a,laneId:s,flash:i})}async findLane(e){let{segmentId:t,laneId:i}=e;const{roadsectId:r}=e;let s=this.allLaneGraphics.filter(a=>a.attributes.roadId===r);if(s.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(t!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.sectionId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),t>a.length-1)return{status:-1,message:"未找到。请检查基本段编号"};t=a[t],s=s.filter(o=>Number(o.attributes.sectionId)===t)}if(i!==void 0){const a=[];if(s.forEach(o=>{const l=Number(o.attributes.laneId);a.indexOf(l)===-1&&a.push(l)}),a.sort((o,l)=>o-l),i>a.length-1)return{status:-1,message:"未找到。请检查车道编号"};i=a[i],s=s.filter(o=>Number(o.attributes.laneId)===i)}const h=s.map(a=>a.geometry),n=await N.union(h);if(e.flash){this.highlightLayer.removeAll();const a=new u({geometry:n,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}}});this.highlightLayer.add(a);let o=0,l=!0;const d=setInterval(()=>{l?(this.highlightLayer.opacity-=.02,this.highlightLayer.opacity<=.1&&(l=!1,o++)):(this.highlightLayer.opacity+=.02,this.highlightLayer.opacity>=1&&(l=!0)),o>5&&(this.highlightLayer.removeAll(),this.highlightLayer.opacity=1,clearInterval(d))},20)}return await this.view.goTo(n,{duration:1e3}),{status:0,message:"ok"}}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=b;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/Graphic"),A=require("@arcgis/core/core/promiseUtils"),$=require("@arcgis/core/geometry"),M=require("@arcgis/core/geometry/geometryEngineAsync"),j=require("@arcgis/core/layers/FeatureLayer"),g=require("@arcgis/core/layers/GraphicsLayer"),w=require("axios"),J=require("md5"),G=require("pako"),C=require("../common-utils.js"),P=require("./wasm-loader.js");function N(p){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const s in p)if(s!=="default"){const i=Object.getOwnPropertyDescriptor(p,s);Object.defineProperty(e,s,i.get?i:{enumerable:!0,get:()=>p[s]})}}return e.default=p,Object.freeze(e)}const O=N(A),S=N(M);class v{constructor(e){this.wasmLoader=P.default.getInstance(),this.projectName="",this.openDriveServer="",this.currentSectionCode="",this.currentJunctionId="",this.view=e,this.view.popup.visibleElements={closeButton:!1,collapseButton:!1,actionBar:!1},this.laneLayer=new j({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 j({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 g({id:"OpenDriveJunction"}),this.sectionLayer=new g({id:"OpenDriveSection"}),this.highlightLayer=new g({id:"OpenDriveHighlight"}),this.flashLayer=new g({id:"OpenDriveFlash"}),this.view.map.addMany([this.laneLayer,this.junctionLayer,this.sectionLayer,this.roadNameLayer,this.highlightLayer,this.flashLayer])}static getInstance(e){return this.instance||(this.instance=new v(e)),this.instance}async makeMd5FromFile(e){const i=await(await fetch(e)).text();return J(i)}async showOpenDriveFromFile(e){var h,u;this.openDriveClickCallback=e.selectedCallback,this.projectName=await this.makeMd5FromFile(e.file),this.openDriveServer=e.server,await this.makeMd5FromFile(e.file);const s=`http://${this.openDriveServer}/api/openDrive/uploadXodr`;let i;try{i=await w.post(s,{},{params:{url:e.file,projectName:this.projectName}})}catch(y){return{status:-1,message:y.message}}if(i.status!==200)return{status:-1,message:i.statusText};console.time("渲染用时");const a=i.data.result.geoSetting;C.default.setGeoData(a.geoReference,a.offsetX,a.offsetY);let t=i.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e.server}${t}`);const r=await(await fetch(t)).arrayBuffer(),n=G.inflate(r,{to:"string"}),o=JSON.parse(n);await this.showAllLanes(o,((h=e.options)==null?void 0:h.showJunctionLane)||!1,((u=e.options)==null?void 0:u.showRoadName)||!0);const l=i.data.result.junctions;if(this.showJunction(l),e.options&&e.options.centerMap!==!1){const y=C.default.transformPointProjection([0,0]);await this.view.goTo(y)}return this.mouseMoveHandler||this.monitorMouseMove(),this.mouseClickHandler||this.monitorMouseClick(),console.timeEnd("渲染用时"),{status:0,message:"ok"}}async showOpenDriveFromServer(e,s){const i=`http://${e}/api/openDrive/analyzeXodr`,a=await w.get(i,{headers:{projectName:s},params:{analyze:!1,compressed:!0}});if(a.status!==200)throw new Error(`OpenDriveRenderer: ${a.statusText}`);let t=a.data.result.json;t.startsWith(window.location.protocol)||(t=`${window.location.protocol}//${e}${t}`);const r=await(await fetch(t)).arrayBuffer(),n=G.inflate(r,{to:"string"}),o=JSON.parse(n);return await this.showAllLanes(o,!1,!1),{status:0,message:"ok"}}async showAllLanes(e,s,i){const a=await this.laneLayer.queryFeatures();return a.features.length>0&&this.laneLayer.applyEdits({deleteFeatures:a.features}),this.roadNameLayer.visible=i,new Promise(t=>{let c=0;this.allLaneGraphics=[],this.allRefLineGraphics=[];const r=[];for(const o of e){if(!s&&o.junction!=="-1")continue;const{id:l,refLine:h}=o;let u=o.name;u.includes("(")&&(u=u.slice(0,u.indexOf("("))),u=u.replace(/(.)/g,"$1 ");const y=new d({geometry:{type:"polyline",paths:[h]},attributes:{ObjectID:c++,roadId:l,roadName:u}});this.allRefLineGraphics.push(y);for(const I of o.laneSections){const L=Number(I.id);for(const f of I.lanePaths){const m=Number(f.id);if(m===0)continue;const F=f.type,b=f.innerPath.concat(f.outerPath.reverse());if(b.length<=3){console.warn(`lane ${m} has less than 3 points`);continue}b.push(f.innerPath[0]);const D=new $.Polygon({rings:[b]});if(D){const k=new d({geometry:D,attributes:{ObjectID:c++,id:`${l}+${L}+${m}`,roadId:l,roadName:o.name,sectionId:L,laneId:m,type:F,sumoId:""}});this.allLaneGraphics.push(k),r.push(k)}}}}const n=setInterval(()=>{if(r.length>0||this.allRefLineGraphics.length>0){if(r.length>0){const o=r.splice(0,100);this.laneLayer.applyEdits({addFeatures:o})}if(this.allRefLineGraphics.length>0){const o=this.allRefLineGraphics.splice(0,10);this.roadNameLayer.applyEdits({addFeatures:o})}}else clearInterval(n),t()},10)})}showJunction(e){const s=[];for(const i of e){i.nodeType=i.type;const a=new d({geometry:{type:"point",x:i.coordinates[0],y:i.coordinates[1]},attributes:{...i,selected:!1,type:"OpenDriveJunction"},symbol:{type:"picture-marker",url:i.crossId?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",width:30,height:30}});s.push(a)}this.junctionLayer.addMany(s)}monitorMouseMove(){const e=O.debounce(async s=>{var c;const a=(c=(await this.view.hitTest(s,{include:[this.laneLayer,this.junctionLayer]})).results)==null?void 0:c.filter(r=>r.type==="graphic");if(a.length===0){this.currentSectionCode!==""&&(this.currentSectionCode="",this.highlightGraphic=void 0,this.highlightLayer.removeAll()),this.currentJunctionId!==""&&(this.currentJunctionId="",this.view.popup.close());return}const t=a[0];if(this.hitGraphic=t.graphic,t.layer.id==="OpenDriveLane"){const r=`${this.hitGraphic.attributes.roadId}+${this.hitGraphic.attributes.sectionId}`;if(r===this.currentSectionCode||this.sectionLayer.graphics.findIndex(h=>h.getAttribute("id")===r)>=0)return;this.currentSectionCode=r;const o=this.allLaneGraphics.filter(h=>`${h.attributes.roadId}+${h.attributes.sectionId}`===r),l=await S.union(o.map(h=>h.geometry));this.highlightGraphic=new d({geometry:l,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:2}},attributes:{type:"OpenDriveSection",id:r,selected:!1}}),this.highlightLayer.removeAll(),this.highlightLayer.add(this.highlightGraphic)}else if(t.layer.id==="OpenDriveJunction"){const r=this.hitGraphic.getAttribute("id");if(r===this.currentJunctionId)return;this.currentJunctionId=r;const n=this.hitGraphic.getAttribute("name"),o=this.hitGraphic.getAttribute("crossId");this.view.popup.open({title:n,content:`<table>
2
+ <tr><td>路口编号</td><td>${r}</td></tr>
3
+ <tr><td>信号机编号</td><td>${o||"无信控"}</td></tr>
4
+ </table>`,location:this.hitGraphic.geometry})}});this.mouseMoveHandler=this.view.on("pointer-move",async s=>{e(s).catch(()=>{})})}monitorMouseClick(){const e=O.debounce(async s=>{var n;const a=(n=(await this.view.hitTest(s,{include:[this.highlightLayer,this.junctionLayer,this.sectionLayer]})).results)==null?void 0:n.filter(o=>o.type==="graphic");if(a.length===0)return;const t=a[0].graphic,c=t.getAttribute("type"),r=t.getAttribute("id");if(c==="OpenDriveJunction")if(t.getAttribute("selected")===!1){const o=`http://${this.openDriveServer}/api/sumo/getSumoJunction`,l=await w.get(o,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&(this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:l.data.result}),t.setAttribute("selected",!0),t.symbol.url="/GisViewerAssets/Images/point_red.png",this.increasePictureMarkerSize(t,50))}else{this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveJunction",id:r,details:void 0}),t.setAttribute("selected",!1);const o=t.getAttribute("crossId");t.symbol.url=o?"/GisViewerAssets/Images/point_green.png":"/GisViewerAssets/Images/point_yellow.png",this.decreasePictureMarkerSize(t,30)}else if(c==="OpenDriveSection")if(t.getAttribute("selected"))this.sectionLayer.remove(t),this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:r,details:void 0});else{this.highlightLayer.remove(t),this.sectionLayer.add(t),t.setAttribute("selected",!0);const o=`http://${this.openDriveServer}/api/sumo/getSumoEdge`,l=await w.get(o,{params:{id:r,projectName:this.projectName}});l.status===200&&l.data.status===0&&this.openDriveClickCallback&&this.openDriveClickCallback({type:"OpenDriveSection",id:r,details:l.data.result})}});this.mouseClickHandler=this.view.on("immediate-click",async s=>{e(s).catch(()=>{})})}increasePictureMarkerSize(e,s){const i=setInterval(()=>{const a=e.symbol,t=a.width;t<s?e.symbol={type:"picture-marker",url:a.url,width:t+1,height:t+1}:clearInterval(i)},20)}decreasePictureMarkerSize(e,s){const i=setInterval(()=>{const a=e.symbol,t=a.width;t>s?e.symbol={type:"picture-marker",url:a.url,width:t-1,height:t-1}:clearInterval(i)},20)}async clearOpenDrive(){var s,i;let e=await this.laneLayer.queryFeatures();e.features.length>0&&await this.laneLayer.applyEdits({deleteFeatures:e.features}),e=await this.roadNameLayer.queryFeatures(),e.features.length>0&&await this.roadNameLayer.applyEdits({deleteFeatures:e.features}),this.highlightLayer.removeAll(),this.junctionLayer.removeAll(),this.wasmLoader.clear(),(s=this.mouseMoveHandler)==null||s.remove(),(i=this.mouseClickHandler)==null||i.remove()}async findSumo(e){const{type:s,id:i}=e,a=e.flash===void 0?!0:e.flash;if(s==="junction")return await this.findJunction(i,a);if(s==="edge"){const t=i.split("+");if(t.length>2)return{status:-1,message:"id格式错误"};const c=t.length===2?Number(t[1]):void 0,r=t[0].split("#");if(r.length>2)return{status:-1,message:"id格式错误"};const n=r[0],o=r.length===2?Number(r[1]):void 0;return await this.findLane({roadsectId:n,segmentId:o,laneId:c,flash:a})}else return{status:-1,message:"未知类型"}}async findJunction(e,s){const i=this.junctionLayer.graphics.find(a=>a.attributes.id===e);if(!i)return{status:-1,message:"未找到。请检查路口编号"};if(s){const a=new d({geometry:i.geometry,symbol:{type:"simple-marker",style:"circle",size:30,color:[255,0,0,.6],outline:{color:"red",width:1}}});this.flashGraphic(a)}return await this.view.goTo(i.geometry,{duration:1e3}),{status:0,message:"ok"}}async findLane(e){let{roadsectId:s,segmentId:i,laneId:a}=e;s.startsWith("-")&&(s=s.slice(1));let t=this.allLaneGraphics.filter(n=>n.attributes.roadId===s);if(t.length===0)return{status:-1,message:"未找到。请检查路段编号"};if(i!==void 0){const n=[];if(t.forEach(o=>{const l=Number(o.attributes.sectionId);n.indexOf(l)===-1&&n.push(l)}),n.sort((o,l)=>o-l),i>n.length-1)return{status:-1,message:"未找到。请检查基本段编号"};i=n[i],t=t.filter(o=>Number(o.attributes.sectionId)===i)}if(a!==void 0){const n=[];if(t.forEach(o=>{const l=Number(o.attributes.laneId);n.indexOf(l)===-1&&n.push(l)}),n.sort((o,l)=>o-l),a>n.length-1)return{status:-1,message:"未找到。请检查车道编号"};a=n[a],t=t.filter(o=>Number(o.attributes.laneId)===a)}const c=t.map(n=>n.geometry),r=await S.union(c);if(e.flash){const n=new d({geometry:r,symbol:{type:"simple-fill",color:[255,0,0,.5],style:"solid",outline:{color:"red",width:0}}});this.flashGraphic(n)}return await this.view.goTo(r,{duration:1e3}),{status:0,message:"ok"}}flashGraphic(e){this.flashLayer.removeAll(),this.flashLayer.add(e);let s=0,i=!0;const a=setInterval(()=>{i?(this.flashLayer.opacity-=.02,this.flashLayer.opacity<=.1&&(i=!1,s++)):(this.flashLayer.opacity+=.02,this.flashLayer.opacity>=1&&(i=!0)),s>=5&&(this.flashLayer.removeAll(),this.flashLayer.opacity=1,clearInterval(a))},10)}async splitLane(e){return{status:0,message:"ok",result:e}}}exports.default=v;
@@ -216,8 +216,10 @@ export interface IShowOpenDriveFromFileParams {
216
216
  showRoadName: boolean;
217
217
  centerMap?: boolean;
218
218
  };
219
+ selectedCallback?: (info: any) => void;
219
220
  }
220
221
  export interface IFindSumoParams {
222
+ type: string;
221
223
  id: string;
222
224
  flash?: boolean;
223
225
  }
@@ -229,6 +231,7 @@ export interface ISplitOpenDriveLaneParams {
229
231
  export interface IJunctionTableData {
230
232
  id: string;
231
233
  name: string;
234
+ nodeType: string;
232
235
  type: string;
233
236
  coordinates: number[];
234
237
  district: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gisviewer-vue3-arcgis",
3
- "version": "1.0.121",
3
+ "version": "1.0.123",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "files": [
@@ -33,6 +33,7 @@
33
33
  "@vitest/coverage-c8": "^0.29.2",
34
34
  "axios": "^1.4.0",
35
35
  "fast-xml-parser": "^4.4.0",
36
+ "md5": "^2.3.0",
36
37
  "pako": "^2.1.0",
37
38
  "pinia": "^2.0.33",
38
39
  "proj4": "^2.11.0",