gisviewer-vue3-arcgis 1.0.211 → 1.0.213
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.
- package/es/src/gis-map/utils/map-initializer.mjs +2 -2
- package/es/src/gis-map/utils/signal-control-area-controller/show-area.d.ts +1 -0
- package/es/src/gis-map/utils/signal-control-area-controller/show-area.mjs +235 -13
- package/es/src/gis-map/utils/sketchView.d.ts +1 -0
- package/es/src/gis-map/utils/sketchView.mjs +31 -11
- package/lib/src/gis-map/utils/map-initializer.js +1 -1
- package/lib/src/gis-map/utils/signal-control-area-controller/show-area.d.ts +1 -0
- package/lib/src/gis-map/utils/signal-control-area-controller/show-area.js +1 -1
- package/lib/src/gis-map/utils/sketchView.d.ts +1 -0
- package/lib/src/gis-map/utils/sketchView.js +1 -1
- package/package.json +1 -1
|
@@ -50,8 +50,8 @@ class Z {
|
|
|
50
50
|
}), this.view.popup.visibleElements = {
|
|
51
51
|
closeButton: !0,
|
|
52
52
|
collapseButton: !1,
|
|
53
|
-
actionBar: !
|
|
54
|
-
featureNavigation: !
|
|
53
|
+
actionBar: !0,
|
|
54
|
+
featureNavigation: !0
|
|
55
55
|
}, this.view.popup.dockOptions = {
|
|
56
56
|
buttonEnabled: !1,
|
|
57
57
|
breakpoint: !1
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import d from "@arcgis/core/Graphic";
|
|
2
2
|
import l from "@arcgis/core/layers/FeatureLayer";
|
|
3
3
|
import c from "@turf/buffer";
|
|
4
4
|
import p from "@turf/convex";
|
|
5
5
|
import * as n from "@turf/helpers";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import m from "concaveman";
|
|
7
|
+
import h from "../../stores/index.mjs";
|
|
8
8
|
import g from "./district-controller.mjs";
|
|
9
9
|
class S {
|
|
10
10
|
constructor(e) {
|
|
11
11
|
var t;
|
|
12
12
|
this.districtControllerOid = 0, this.subDistrictControllerOid = 0, this.signalOid = 0, this.districtGraphics = [], this.subDistrictGraphics = [], this.signalGraphics = [], this.view = e, this.hasGpu = localStorage.getItem("gpu") !== "Unknown";
|
|
13
|
-
const s =
|
|
13
|
+
const s = h.useAppDataStore.mapConfig;
|
|
14
14
|
this.openDriveServer = (t = s.openDriveServer) == null ? void 0 : t.url, this.districtControllerDashLayer = new l({
|
|
15
15
|
id: "districtController",
|
|
16
16
|
spatialReference: e.spatialReference,
|
|
@@ -307,6 +307,220 @@ class S {
|
|
|
307
307
|
}
|
|
308
308
|
]
|
|
309
309
|
}
|
|
310
|
+
}), this.signalClusterLayer = new l({
|
|
311
|
+
id: "signalLayer",
|
|
312
|
+
spatialReference: e.spatialReference,
|
|
313
|
+
source: [],
|
|
314
|
+
objectIdField: "ObjectID",
|
|
315
|
+
outFields: ["*"],
|
|
316
|
+
geometryType: "point",
|
|
317
|
+
maxScale: 5e3,
|
|
318
|
+
fields: [
|
|
319
|
+
{
|
|
320
|
+
name: "ObjectID",
|
|
321
|
+
type: "oid"
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
name: "id",
|
|
325
|
+
type: "string"
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
name: "name",
|
|
329
|
+
type: "string"
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
name: "signalId",
|
|
333
|
+
type: "string"
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: "nodeId",
|
|
337
|
+
type: "string"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: "isKey",
|
|
341
|
+
type: "string"
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: "districtId",
|
|
345
|
+
type: "string"
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
name: "districtName",
|
|
349
|
+
type: "string"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: "subDistrictId",
|
|
353
|
+
type: "string"
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "subDistrictName",
|
|
357
|
+
type: "string"
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
featureReduction: {
|
|
361
|
+
type: "cluster",
|
|
362
|
+
clusterRadius: "120px",
|
|
363
|
+
clusterMaxSize: "50px",
|
|
364
|
+
clusterMinSize: "30px",
|
|
365
|
+
symbol: {
|
|
366
|
+
type: "cim",
|
|
367
|
+
data: {
|
|
368
|
+
type: "CIMSymbolReference",
|
|
369
|
+
primitiveOverrides: [
|
|
370
|
+
{
|
|
371
|
+
// 将textGraphic的TextString替换为graphic.attributes.name
|
|
372
|
+
type: "CIMPrimitiveOverride",
|
|
373
|
+
primitiveName: "textGraphic",
|
|
374
|
+
propertyName: "TextString",
|
|
375
|
+
valueExpressionInfo: {
|
|
376
|
+
type: "CIMExpressionInfo",
|
|
377
|
+
title: "Custom",
|
|
378
|
+
expression: "$feature.cluster_count",
|
|
379
|
+
returnType: "Default"
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
],
|
|
383
|
+
symbol: {
|
|
384
|
+
type: "CIMPointSymbol",
|
|
385
|
+
symbolLayers: [
|
|
386
|
+
// 路口名称
|
|
387
|
+
{
|
|
388
|
+
type: "CIMVectorMarker",
|
|
389
|
+
size: 32,
|
|
390
|
+
colorLocked: !0,
|
|
391
|
+
anchorPointUnits: "Relative",
|
|
392
|
+
frame: { xmin: -16, ymin: -16, xmax: 16, ymax: 16 },
|
|
393
|
+
markerGraphics: [
|
|
394
|
+
{
|
|
395
|
+
type: "CIMMarkerGraphic",
|
|
396
|
+
primitiveName: "textGraphic",
|
|
397
|
+
geometry: { x: 0, y: 0 },
|
|
398
|
+
symbol: {
|
|
399
|
+
type: "CIMTextSymbol",
|
|
400
|
+
height: 16,
|
|
401
|
+
horizontalAlignment: "Center",
|
|
402
|
+
offsetX: 0,
|
|
403
|
+
offsetY: 30,
|
|
404
|
+
symbol: {
|
|
405
|
+
type: "CIMPolygonSymbol",
|
|
406
|
+
symbolLayers: [
|
|
407
|
+
{
|
|
408
|
+
type: "CIMSolidFill",
|
|
409
|
+
enable: !0,
|
|
410
|
+
color: [255, 255, 255, 255]
|
|
411
|
+
}
|
|
412
|
+
]
|
|
413
|
+
},
|
|
414
|
+
verticalAlignment: "Center"
|
|
415
|
+
},
|
|
416
|
+
textString: ""
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
type: "CIMMarkerGraphic",
|
|
420
|
+
geometry: {
|
|
421
|
+
rings: [
|
|
422
|
+
[
|
|
423
|
+
[-15, 40],
|
|
424
|
+
[15, 40],
|
|
425
|
+
[15, 20],
|
|
426
|
+
[-15, 20],
|
|
427
|
+
[-15, 40]
|
|
428
|
+
]
|
|
429
|
+
]
|
|
430
|
+
},
|
|
431
|
+
symbol: {
|
|
432
|
+
type: "CIMPolygonSymbol",
|
|
433
|
+
symbolLayers: [
|
|
434
|
+
{
|
|
435
|
+
type: "CIMSolidFill",
|
|
436
|
+
enable: !0,
|
|
437
|
+
color: [2, 72, 200, 255]
|
|
438
|
+
},
|
|
439
|
+
// 边框
|
|
440
|
+
{
|
|
441
|
+
type: "CIMSolidStroke",
|
|
442
|
+
enable: !0,
|
|
443
|
+
width: 5,
|
|
444
|
+
color: [2, 72, 200, 128]
|
|
445
|
+
}
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
],
|
|
450
|
+
scaleSymbolsProportionally: !0,
|
|
451
|
+
respectFrame: !0
|
|
452
|
+
},
|
|
453
|
+
// 路口图标
|
|
454
|
+
{
|
|
455
|
+
type: "CIMPictureMarker",
|
|
456
|
+
enable: !0,
|
|
457
|
+
anchorPoint: {
|
|
458
|
+
x: 0,
|
|
459
|
+
y: 0
|
|
460
|
+
},
|
|
461
|
+
anchorPointUnits: "Relative",
|
|
462
|
+
size: 40,
|
|
463
|
+
rotateClockwise: !0,
|
|
464
|
+
textureFilter: "Picture",
|
|
465
|
+
url: "/GisViewerAssets/Images/cross/gis_xhj_blue.png"
|
|
466
|
+
}
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
popupTemplate: {
|
|
472
|
+
title: "聚合详情",
|
|
473
|
+
content: "聚合信号机 <b>{cluster_count}</b> 个",
|
|
474
|
+
fieldInfos: [
|
|
475
|
+
{
|
|
476
|
+
fieldName: "cluster_count",
|
|
477
|
+
format: {
|
|
478
|
+
digitSeparator: !0,
|
|
479
|
+
places: 0
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
},
|
|
485
|
+
popupTemplate: {
|
|
486
|
+
title: "{name}信号机",
|
|
487
|
+
content: [
|
|
488
|
+
{
|
|
489
|
+
type: "fields",
|
|
490
|
+
fieldInfos: [
|
|
491
|
+
{
|
|
492
|
+
fieldName: "districtName",
|
|
493
|
+
label: "区控名称"
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
fieldName: "subDistrictName",
|
|
497
|
+
label: "子区名称"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
fieldName: "signalId",
|
|
501
|
+
label: "信号机编号"
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
fieldName: "nodeId",
|
|
505
|
+
label: "路口编号"
|
|
506
|
+
}
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
},
|
|
511
|
+
renderer: {
|
|
512
|
+
type: "simple",
|
|
513
|
+
symbol: {
|
|
514
|
+
type: "simple-marker",
|
|
515
|
+
style: "circle",
|
|
516
|
+
color: [5, 116, 255],
|
|
517
|
+
size: 8,
|
|
518
|
+
outline: {
|
|
519
|
+
color: "white",
|
|
520
|
+
width: 1
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
310
524
|
}), this.signalPictureLayer = new l({
|
|
311
525
|
id: "signalLayer",
|
|
312
526
|
spatialReference: e.spatialReference,
|
|
@@ -582,7 +796,8 @@ class S {
|
|
|
582
796
|
this.districtControllerDashLayer,
|
|
583
797
|
this.subDistrictControllerLayer,
|
|
584
798
|
this.signalMarkerLayer,
|
|
585
|
-
this.signalPictureLayer
|
|
799
|
+
this.signalPictureLayer,
|
|
800
|
+
this.signalClusterLayer
|
|
586
801
|
]);
|
|
587
802
|
}
|
|
588
803
|
/**
|
|
@@ -591,7 +806,7 @@ class S {
|
|
|
591
806
|
* @returns
|
|
592
807
|
*/
|
|
593
808
|
async showSignalControlArea(e) {
|
|
594
|
-
await this.clearSignalControlArea(), this.districtControllerDashLayer.visible = !
|
|
809
|
+
await this.clearSignalControlArea(), this.districtControllerDashLayer.visible = !1, this.districtControllerSolidLayer.visible = !1, this.subDistrictControllerLayer.visible = !1, this.signalMarkerLayer.visible = !1, this.signalPictureLayer.visible = !1, this.signalClusterLayer.visible = !0;
|
|
595
810
|
for (const i of e.areaList) {
|
|
596
811
|
const s = new g(
|
|
597
812
|
i,
|
|
@@ -609,6 +824,8 @@ class S {
|
|
|
609
824
|
addFeatures: this.signalGraphics
|
|
610
825
|
}), await this.signalPictureLayer.applyEdits({
|
|
611
826
|
addFeatures: this.signalGraphics
|
|
827
|
+
}), await this.signalClusterLayer.applyEdits({
|
|
828
|
+
addFeatures: this.signalGraphics
|
|
612
829
|
}), this.signalGraphics = [], { status: 0, message: "ok" };
|
|
613
830
|
}
|
|
614
831
|
/**
|
|
@@ -628,7 +845,9 @@ class S {
|
|
|
628
845
|
deleteFeatures: e.features
|
|
629
846
|
}), this.signalMarkerLayer.definitionExpression = "1=1", e = await this.signalPictureLayer.queryFeatures(), await this.signalPictureLayer.applyEdits({
|
|
630
847
|
deleteFeatures: e.features
|
|
631
|
-
}), this.signalPictureLayer.definitionExpression = "1=1",
|
|
848
|
+
}), this.signalPictureLayer.definitionExpression = "1=1", e = await this.signalClusterLayer.queryFeatures(), await this.signalClusterLayer.applyEdits({
|
|
849
|
+
deleteFeatures: e.features
|
|
850
|
+
}), this.signalClusterLayer.definitionExpression = "1=1", { status: 0, message: "ok" };
|
|
632
851
|
}
|
|
633
852
|
/**
|
|
634
853
|
* 设置区控、子区、信号机图层可见性
|
|
@@ -646,6 +865,9 @@ class S {
|
|
|
646
865
|
case "signal":
|
|
647
866
|
this.signalMarkerLayer.visible = e.visible, this.signalPictureLayer.visible = e.visible;
|
|
648
867
|
break;
|
|
868
|
+
case "signalCluster":
|
|
869
|
+
this.signalClusterLayer.visible = e.visible;
|
|
870
|
+
break;
|
|
649
871
|
}
|
|
650
872
|
return { status: 0, message: "ok" };
|
|
651
873
|
}
|
|
@@ -764,11 +986,11 @@ class S {
|
|
|
764
986
|
else {
|
|
765
987
|
if (i) {
|
|
766
988
|
const a = n.featureCollection(
|
|
767
|
-
t.map((
|
|
989
|
+
t.map((y) => n.point(y))
|
|
768
990
|
);
|
|
769
991
|
r = p(a);
|
|
770
992
|
} else {
|
|
771
|
-
const a =
|
|
993
|
+
const a = m(t, 0.5);
|
|
772
994
|
a.length >= 4 && (r = n.polygon([a]));
|
|
773
995
|
}
|
|
774
996
|
r || (r = n.lineString(t));
|
|
@@ -784,7 +1006,7 @@ class S {
|
|
|
784
1006
|
{
|
|
785
1007
|
units: "meters"
|
|
786
1008
|
}
|
|
787
|
-
),
|
|
1009
|
+
), u = new d({
|
|
788
1010
|
geometry: {
|
|
789
1011
|
type: "polyline",
|
|
790
1012
|
paths: o.geometry.coordinates
|
|
@@ -800,11 +1022,11 @@ class S {
|
|
|
800
1022
|
style: s
|
|
801
1023
|
}
|
|
802
1024
|
});
|
|
803
|
-
i ? this.districtGraphics.push(
|
|
1025
|
+
i ? this.districtGraphics.push(u) : this.subDistrictGraphics.push(u);
|
|
804
1026
|
for (const a of e.subDistricts)
|
|
805
1027
|
this.generateGraphic(a, !1, s);
|
|
806
1028
|
e.signals.forEach((a) => {
|
|
807
|
-
const
|
|
1029
|
+
const y = new d({
|
|
808
1030
|
geometry: {
|
|
809
1031
|
type: "point",
|
|
810
1032
|
x: a.longitude,
|
|
@@ -823,7 +1045,7 @@ class S {
|
|
|
823
1045
|
subDistrictName: i ? "" : e.name
|
|
824
1046
|
}
|
|
825
1047
|
});
|
|
826
|
-
this.signalGraphics.push(
|
|
1048
|
+
this.signalGraphics.push(y);
|
|
827
1049
|
});
|
|
828
1050
|
}
|
|
829
1051
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as L from "@arcgis/core/geometry/geometryEngine.js";
|
|
2
|
+
import G from "@arcgis/core/geometry/Polygon";
|
|
3
|
+
import P from "@arcgis/core/geometry/Polyline";
|
|
2
4
|
import * as g from "@arcgis/core/geometry/support/webMercatorUtils.js";
|
|
3
5
|
import l from "@arcgis/core/Graphic";
|
|
4
6
|
import f from "@arcgis/core/layers/GraphicsLayer";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import S from "@arcgis/core/geometry/Polygon.js";
|
|
8
|
-
import k from "@arcgis/core/geometry/Polyline.js";
|
|
7
|
+
import k from "@arcgis/core/widgets/Sketch";
|
|
8
|
+
import S from "@arcgis/core/widgets/Sketch/SketchViewModel";
|
|
9
9
|
import * as d from "@turf/helpers";
|
|
10
10
|
import b from "@turf/intersect";
|
|
11
11
|
import { v4 as M } from "uuid";
|
|
@@ -56,10 +56,30 @@ class C {
|
|
|
56
56
|
this.viewer = t, this.options = {
|
|
57
57
|
...x,
|
|
58
58
|
...e
|
|
59
|
-
}, this.graphicsLayer = new f({ ...this.options.GraphicsLayer }), this.TextGraphicsLayer = new f(), this.viewer.map.
|
|
59
|
+
}, this.graphicsLayer = new f({ ...this.options.GraphicsLayer }), this.TextGraphicsLayer = new f(), this.viewer.map.addMany([this.graphicsLayer, this.TextGraphicsLayer]), this.init();
|
|
60
|
+
}
|
|
61
|
+
updateSketch(t) {
|
|
62
|
+
const e = new l({
|
|
63
|
+
geometry: {
|
|
64
|
+
type: "polygon",
|
|
65
|
+
rings: [t]
|
|
66
|
+
},
|
|
67
|
+
symbol: {
|
|
68
|
+
type: "simple-fill",
|
|
69
|
+
color: [227, 139, 79, 0.4],
|
|
70
|
+
outline: {
|
|
71
|
+
color: [255, 255, 255],
|
|
72
|
+
width: 1
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
this.graphicsLayer.add(e), this.sketchViewModel.update([e], {
|
|
77
|
+
tool: "reshape",
|
|
78
|
+
enableRotation: !0
|
|
79
|
+
});
|
|
60
80
|
}
|
|
61
81
|
init() {
|
|
62
|
-
this.sketchViewModel = new
|
|
82
|
+
this.sketchViewModel = new S({
|
|
63
83
|
layer: this.graphicsLayer,
|
|
64
84
|
view: this.viewer,
|
|
65
85
|
updateOnGraphicClick: !0,
|
|
@@ -68,7 +88,7 @@ class C {
|
|
|
68
88
|
...this.options.sketchViewModelItemSymbol
|
|
69
89
|
});
|
|
70
90
|
const t = this.findLayerById("TrafficMarkings"), e = [];
|
|
71
|
-
t && e.push({ layer: t, enabled: !0 }), this.sketch = new
|
|
91
|
+
t && e.push({ layer: t, enabled: !0 }), this.sketch = new k({
|
|
72
92
|
view: this.viewer,
|
|
73
93
|
viewModel: this.sketchViewModel,
|
|
74
94
|
layer: this.graphicsLayer,
|
|
@@ -159,7 +179,7 @@ class C {
|
|
|
159
179
|
}), i;
|
|
160
180
|
}
|
|
161
181
|
createPolylineGraphic(t, e, i) {
|
|
162
|
-
const s = new
|
|
182
|
+
const s = new P({
|
|
163
183
|
paths: t
|
|
164
184
|
}), r = g.geographicToWebMercator(s);
|
|
165
185
|
return new l({
|
|
@@ -171,7 +191,7 @@ class C {
|
|
|
171
191
|
});
|
|
172
192
|
}
|
|
173
193
|
createPolygonGraphic(t, e, i) {
|
|
174
|
-
const s = new
|
|
194
|
+
const s = new G({
|
|
175
195
|
rings: t
|
|
176
196
|
}), r = g.geographicToWebMercator(s);
|
|
177
197
|
return new l({
|
|
@@ -208,7 +228,7 @@ class C {
|
|
|
208
228
|
t && t("update", o, i);
|
|
209
229
|
}
|
|
210
230
|
}), this.sketchViewModel.on("delete", function(i) {
|
|
211
|
-
if (console.log("delete", i
|
|
231
|
+
if (console.log("delete", i), i.graphics.length > 0) {
|
|
212
232
|
const r = i.graphics[0].geometry, o = e.getGraphicPoint(r);
|
|
213
233
|
t && t("delete", o, i);
|
|
214
234
|
}
|
|
@@ -332,7 +352,7 @@ class C {
|
|
|
332
352
|
* @returns
|
|
333
353
|
* @memberof SketchView
|
|
334
354
|
*/
|
|
335
|
-
getGraphicPoint(t, e = !
|
|
355
|
+
getGraphicPoint(t, e = !1) {
|
|
336
356
|
let i = t;
|
|
337
357
|
this.viewer.spatialReference.isWebMercator && (i = g.webMercatorToGeographic(t));
|
|
338
358
|
let s;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),d=require("@arcgis/core/config"),z=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),L=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/MapImageLayer"),x=require("@arcgis/core/layers/TileLayer"),I=require("@arcgis/core/layers/WebTileLayer"),S=require("@arcgis/core/Map"),R=require("@arcgis/core/views/MapView"),H=require("@arcgis/core/views/SceneView"),_=require("@turf/destination"),G=require("@turf/helpers"),j=require("./custom-layer/custom-wmts-layer.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const T=b(z),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const k=require("@arcgis/core/Basemap"),d=require("@arcgis/core/config"),z=require("@arcgis/core/core/reactiveUtils"),g=require("@arcgis/core/geometry"),L=require("@arcgis/core/geometry/support/webMercatorUtils"),W=require("@arcgis/core/layers/GeoJSONLayer"),O=require("@arcgis/core/layers/MapImageLayer"),x=require("@arcgis/core/layers/TileLayer"),I=require("@arcgis/core/layers/WebTileLayer"),S=require("@arcgis/core/Map"),R=require("@arcgis/core/views/MapView"),H=require("@arcgis/core/views/SceneView"),_=require("@turf/destination"),G=require("@turf/helpers"),j=require("./custom-layer/custom-wmts-layer.js");function b(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const T=b(z),w=b(L),B=b(G);function q(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){var u,y,v,M;this.mapConfig=e.mapConfig;const{container:t,markerClickCallback:s,mapClickCallback:o}=e;d.assetsPath=`${this.mapConfig.assetsRoot}/ArcgisAssets`,d.fontsUrl=`${this.mapConfig.assetsRoot}/fonts`,d.apiKey="AAPKf5a3e1044d7a4faeb3b1ec7060f5c68equIrP2KbRyL-t_b40Kk4GTWUQ1BFCyttvyQPQnWpFmBd7kp9gkrVihjfmcKBwxjW";const n=new S;if(((u=this.mapConfig)==null?void 0:u.mapOptions.mode.toLowerCase())==="2d"?(this.view=new R({map:n,container:t,...this.mapConfig.mapOptions}),this.view.on("drag",i=>{i.button===2&&i.stopPropagation()})):this.view=new H({map:n,container:t,environment:{atmosphereEnabled:!0,lighting:{type:"virtual"}},...(y=this.mapConfig)==null?void 0:y.mapOptions}),this.view.popup.visibleElements={closeButton:!0,collapseButton:!1,actionBar:!0,featureNavigation:!0},this.view.popup.dockOptions={buttonEnabled:!1,breakpoint:!1},this.view.on("click",async i=>{var C,P;if(o){let a=i.mapPoint;a.spatialReference.isWebMercator&&(a=w.webMercatorToGeographic(a)),o([a.x,a.y],[i.screenPoint.x,i.screenPoint.y],i)}if(this.view.type==="3d"){const a=this.view.camera;if(this.view.spatialReference.isWebMercator){const p=w.webMercatorToGeographic(a.position),m={heading:a.heading,tilt:a.tilt,position:p.toJSON()};console.log(m),(C=navigator.clipboard)==null||C.writeText(JSON.stringify(m))}else console.log(a.toJSON());console.log(this.view.zoom,this.view.scale)}else{let a=this.view.center;this.view.spatialReference.isWebMercator&&(a=w.webMercatorToGeographic(a)),console.log({center:a.toJSON(),zoom:this.view.zoom,scale:this.view.scale})}const c=(P=(await this.view.hitTest(i)).results)==null?void 0:P.filter(a=>a.type==="graphic");c.length>0&&c.forEach(a=>{var m;const p=a.graphic;(m=p.attributes)!=null&&m.type&&s&&s(p.attributes.type,p.attributes.id,p.attributes,i)})}),(v=this.mapConfig)!=null&&v.baseLayers?this.mapConfig.baseLayers.forEach(i=>{const h=q(i.url,this.mapConfig.assetsRoot);switch(i.type.toLowerCase()){case"webTile".toLowerCase():{const c=new I({urlTemplate:h,...i.options});n.add(c);break}case"tile":{const c=new x({url:h,...i.options});n.add(c);break}case"customWMTS".toLowerCase():{const c=new j.default({urlTemplate:h,...i.options});n.add(c);break}case"mapImage".toLowerCase():{const c=new O({url:h,...i.options});n.add(c);break}case"arcgis":{const c=new k(i.options);n.basemap=c;break}}}):n.basemap=new k({style:{id:"arcgis/light-gray",language:"zh-CN"}}),(M=this.mapConfig)!=null&&M.hdLayers){const i=this.mapConfig.hdLayers.map(h=>new W({url:q(h.url,this.mapConfig.assetsRoot),...h.options,title:h.options.id}));n.addMany(i)}this.view.ui.remove("attribution"),await this.view.when();const f=this.mapConfig.camera;let l;if(this.view.type==="2d"){let i=this.view.center;this.view.spatialReference.isWebMercator&&(i=w.webMercatorToGeographic(i)),l={center:[i.x,i.y],zoom:this.view.zoom}}else{let i=this.view.camera.position;this.view.spatialReference.isWebMercator&&(i=w.webMercatorToGeographic(i)),l={position:i,heading:this.view.camera.heading,tilt:this.view.camera.tilt}}return f?f.home=l:this.mapConfig.camera={home:l},this.view}setLayerVisibility(e){const{id:t,visible:s}=e,o=this.view.map.findLayerById(t);return o?(o.visible=s,{status:0,message:"ok"}):{status:-1,message:"未找到图层"}}async setMapCenter(e){var t;if(!this.view)return{status:-1,message:"未初始化"};if(e.center||e.target){switch((t=e.target)==null?void 0:t.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 t=e.tilt||0,s=e.heading||0;if(t===0)await this.view.goTo({position:{x:e.center[0],y:e.center[1],z:e.height},heading:s,tilt:0},{duration:(e.duration||2)*1e3});else{const o=Math.tan(t*Math.PI/180)*e.height,n=_(B.point(e.center),o,s+180,{units:"meters"});await this.view.goTo({position:{x:n.geometry.coordinates[0],y:n.geometry.coordinates[1],z:e.height},heading:s,tilt:t},{duration:(e.duration||2)*1e3})}}async setMapCamera(e){if(!this.view)return{status:-1,message:"未初始化"};const{name:t,duration:s=0}=e,{camera:o}=this.mapConfig;if(!o)return{status:-1,message:"未配置camera"};const n=o[t];return n?(await this.view.goTo(n,{duration:s*1e3}),{status:0,message:"成功"}):{status:-1,message:"未配置camera"}}requestCoordinateTransform(e,t){let s=0;const n=1e3/30,f=T.watch(()=>this.view.center,()=>{const l=this.transformPoints(e),u=Date.now();u-s>n&&(t(l),s=u)});return this.handleIndex++,this.watchHandleMap.set(this.handleIndex,f),{handle:this.handleIndex,points:this.transformPoints(e)}}transformPoints(e){return e.map(t=>{const s=new g.Point({x:t[0],y:t[1]}),o=this.view.toScreen(s);return[o.x,o.y]})}cancelCoordinateTransform(e){const t=this.watchHandleMap.get(e);t&&(t.remove(),this.watchHandleMap.delete(e))}setMapZoomRange(e){const{min:t,max:s}=e;!t&&!s||(this.zoomWatchHandle&&this.zoomWatchHandle.remove(),this.zoomWatchHandle=T.watch(()=>this.view.zoom,o=>{t&&o<=t&&(this.view.zoom=t),s&&o>=s&&(this.view.zoom=s)}))}}exports.default=N;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("@arcgis/core/Graphic"),o=require("@arcgis/core/layers/FeatureLayer"),p=require("@turf/buffer"),h=require("@turf/convex"),m=require("@turf/helpers"),g=require("concaveman"),f=require("../../stores/index.js"),b=require("./district-controller.js");function C(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const l=C(m);class I{constructor(e){var i;this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0,this.districtGraphics=[],this.subDistrictGraphics=[],this.signalGraphics=[],this.view=e,this.hasGpu=localStorage.getItem("gpu")!=="Unknown";const s=f.default.useAppDataStore.mapConfig;this.openDriveServer=(i=s.openDriveServer)==null?void 0:i.url,this.districtControllerDashLayer=new o({id:"districtController",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",geometryType:"polyline",outFields:["*"],fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"subDistrictCount",type:"integer"},{name:"signalCount",type:"integer"}],renderer:{type:"simple",symbol:{type:"simple-line",style:"long-dash",color:[111,100,255],width:3}}}),this.districtControllerSolidLayer=new o({id:"districtController",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"polyline",fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"subDistrictCount",type:"integer"},{name:"signalCount",type:"integer"}],popupTemplate:{title:"{name}",content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"区控编号"},{fieldName:"subDistrictCount",label:"子区数量"},{fieldName:"signalCount",label:"信号机数量"}]}]},renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[111,100,255,.4],width:3}}}),this.subDistrictControllerLayer=new o({id:"subDistrictController",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"polyline",fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"parentId",type:"string"},{name:"parentName",type:"string"},{name:"signalCount",type:"integer"},{name:"style",type:"string"}],popupTemplate:{title:"{name} 子区",content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"区控编号"},{fieldName:"parentName",label:"所属区控"},{fieldName:"signalCount",label:"信号机数量"}]}]},renderer:{type:"unique-value",field:"style",defaultSymbol:{type:"simple-line",style:"solid",color:[5,196,104],width:3},uniqueValueInfos:[{value:"alert",symbol:{type:"simple-line",style:"solid",color:[255,0,0],width:3}}]}}),this.signalMarkerLayer=new o({id:"signalLayer",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"point",maxScale:5e3,fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"signalId",type:"string"},{name:"nodeId",type:"string"},{name:"isKey",type:"string"},{name:"districtId",type:"string"},{name:"districtName",type:"string"},{name:"subDistrictId",type:"string"},{name:"subDistrictName",type:"string"}],popupTemplate:{title:"{name}信号机",content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"signalId",label:"信号机编号"},{fieldName:"nodeId",label:"路口编号"}]}]},renderer:{type:"unique-value",field:"isKey",defaultSymbol:{type:"simple-marker",style:"circle",color:"gray",size:4,outline:{color:"white",width:1}},uniqueValueInfos:[{value:"true",symbol:{type:"simple-marker",style:"circle",color:[254,172,22],size:12,outline:{color:"white",width:1}}},{value:"false",symbol:{type:"simple-marker",style:"circle",color:[5,116,255],size:8,outline:{color:"white",width:1}}}]}}),this.signalPictureLayer=new o({id:"signalLayer",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"point",minScale:5e3,fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"signalId",type:"string"},{name:"nodeId",type:"string"},{name:"isKey",type:"string"},{name:"districtId",type:"string"},{name:"districtName",type:"string"},{name:"subDistrictId",type:"string"},{name:"subDistrictName",type:"string"}],popupTemplate:{title:"{name}信号机",content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"signalId",label:"信号机编号"},{fieldName:"nodeId",label:"路口编号"}]}]},renderer:{type:"unique-value",field:"isKey",defaultSymbol:{type:"simple-marker",style:"circle",color:"gray",size:4,outline:{color:"white",width:1}},uniqueValueInfos:[{value:"true",symbol:{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:30,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:40,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_gjxklk_orange.png"}]}}}},{value:"false",symbol:{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:15,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:20,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}}]}}),this.view.map.addMany([this.districtControllerSolidLayer,this.districtControllerDashLayer,this.subDistrictControllerLayer,this.signalMarkerLayer,this.signalPictureLayer])}async showSignalControlArea(e){await this.clearSignalControlArea(),this.districtControllerDashLayer.visible=!0,this.districtControllerSolidLayer.visible=!0,this.subDistrictControllerLayer.visible=!1,this.signalMarkerLayer.visible=!1,this.signalPictureLayer.visible=!1;for(const t of e.areaList){const s=new b.default(t,e.style||"");this.generateGraphic(s,!0,e.style)}return await this.districtControllerDashLayer.applyEdits({addFeatures:this.districtGraphics}),await this.districtControllerSolidLayer.applyEdits({addFeatures:this.districtGraphics}),this.view.goTo(this.districtGraphics),this.districtGraphics=[],await this.subDistrictControllerLayer.applyEdits({addFeatures:this.subDistrictGraphics}),this.subDistrictGraphics=[],await this.signalMarkerLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalPictureLayer.applyEdits({addFeatures:this.signalGraphics}),this.signalGraphics=[],{status:0,message:"ok"}}async clearSignalControlArea(){this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0;let e=await this.districtControllerDashLayer.queryFeatures();return await this.districtControllerDashLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerDashLayer.definitionExpression="1=1",e=await this.districtControllerSolidLayer.queryFeatures(),await this.districtControllerSolidLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerSolidLayer.definitionExpression="1=1",e=await this.subDistrictControllerLayer.queryFeatures(),await this.subDistrictControllerLayer.applyEdits({deleteFeatures:e.features}),this.subDistrictControllerLayer.definitionExpression="1=1",e=await this.signalMarkerLayer.queryFeatures(),await this.signalMarkerLayer.applyEdits({deleteFeatures:e.features}),this.signalMarkerLayer.definitionExpression="1=1",e=await this.signalPictureLayer.queryFeatures(),await this.signalPictureLayer.applyEdits({deleteFeatures:e.features}),this.signalPictureLayer.definitionExpression="1=1",{status:0,message:"ok"}}setLayerVisibility(e){switch(e.visible===!1&&this.view.closePopup(),e.id){case"district":this.districtControllerDashLayer.visible=e.visible,this.districtControllerSolidLayer.visible=e.visible;break;case"subDistrict":this.subDistrictControllerLayer.visible=e.visible;break;case"signal":this.signalMarkerLayer.visible=e.visible,this.signalPictureLayer.visible=e.visible;break}return{status:0,message:"ok"}}async locateSignalControlArea(e){switch(e.type){case"district":{const i=this.districtControllerDashLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.districtControllerDashLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo(r.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到区控"}}case"subDistrict":const t=this.subDistrictControllerLayer.createQuery();t.where=`id = '${e.id}'`,t.returnGeometry=!0,t.outFields=["*"];const s=await this.subDistrictControllerLayer.queryFeatures(t);return s.features.length>0?(await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到子区"};case"signal":{const i=this.signalMarkerLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.signalMarkerLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo({target:r.features[0],scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async highlightSignalControlArea(e){switch(e.type){case"district":{const t=this.districtControllerDashLayer.definitionExpression;this.districtControllerDashLayer.definitionExpression=`id = '${e.id}'`;const s=await this.districtControllerDashLayer.queryFeatures();return s.features.length>0?(this.districtControllerSolidLayer.definitionExpression=`id = '${e.id}'`,this.subDistrictControllerLayer.definitionExpression=`parentId = '${e.id}'`,this.signalMarkerLayer.definitionExpression=`districtId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`districtId = '${e.id}'`,await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):(this.districtControllerDashLayer.definitionExpression=t,{status:1,message:"未找到区控"})}case"subDistrict":{const t=this.subDistrictControllerLayer.definitionExpression;this.subDistrictControllerLayer.definitionExpression=`id = '${e.id}'`;const s=await this.subDistrictControllerLayer.queryFeatures();if(s.features.length>0){this.signalMarkerLayer.definitionExpression=`subDistrictId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`subDistrictId = '${e.id}'`;const r=s.features[0].attributes.parentId;return this.districtControllerDashLayer.definitionExpression=`id = '${r}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${r}'`,await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.subDistrictControllerLayer.definitionExpression=t,{status:1,message:"未找到子区"}}case"signal":{const t=this.signalMarkerLayer.definitionExpression;this.signalMarkerLayer.definitionExpression=`id = '${e.id}'`;const s=await this.signalMarkerLayer.queryFeatures();if(s.features.length>0){this.signalPictureLayer.definitionExpression=`id = '${e.id}'`;const i=s.features[0],{districtId:r,subDistrictId:u}=i.attributes;return this.districtControllerDashLayer.definitionExpression=`id = '${r}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${r}'`,this.subDistrictControllerLayer.definitionExpression=`id = '${u}'`,await this.view.goTo({target:s.features,scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.signalMarkerLayer.definitionExpression=t,{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async resetHighlight(){this.districtControllerDashLayer.definitionExpression="1=1",this.districtControllerSolidLayer.definitionExpression="1=1",this.subDistrictControllerLayer.definitionExpression="1=1",this.signalMarkerLayer.definitionExpression="1=1";const e=await this.districtControllerDashLayer.queryFeatures();return this.view.goTo(e.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}generateGraphic(e,t,s){const i=e.getAllSignalCoordinates();let r=null;if(i.length>=2)if(i.length===2)r=l.lineString(i);else{if(t){const a=l.featureCollection(i.map(d=>l.point(d)));r=h(a)}else{const a=g(i,.5);a.length>=4&&(r=l.polygon([a]))}r||(r=l.lineString(i))}else if(i.length===1)r=l.point(i[0]);else return;const u=p(r.geometry,t?200:30,{units:"meters"}),c=new y({geometry:{type:"polyline",paths:u.geometry.coordinates},attributes:{ObjectID:t?this.districtControllerOid++:this.subDistrictControllerOid++,id:e.id,name:e.name,subDistrictCount:e.subDistrictCount,signalCount:e.signalCount,parentId:e.parentId,parentName:e.parentName,style:s}});t?this.districtGraphics.push(c):this.subDistrictGraphics.push(c);for(const a of e.subDistricts)this.generateGraphic(a,!1,s);e.signals.forEach(a=>{const d=new y({geometry:{type:"point",x:a.longitude,y:a.latitude},attributes:{ObjectID:this.signalOid++,id:a.id,name:a.name,signalId:a.signalId,nodeId:a.nodeId,isKey:a.isKey,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name}});this.signalGraphics.push(d)})}}exports.default=I;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("@arcgis/core/Graphic"),l=require("@arcgis/core/layers/FeatureLayer"),p=require("@turf/buffer"),h=require("@turf/convex"),m=require("@turf/helpers"),g=require("concaveman"),f=require("../../stores/index.js"),b=require("./district-controller.js");function C(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const o=C(m);class I{constructor(e){var i;this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0,this.districtGraphics=[],this.subDistrictGraphics=[],this.signalGraphics=[],this.view=e,this.hasGpu=localStorage.getItem("gpu")!=="Unknown";const s=f.default.useAppDataStore.mapConfig;this.openDriveServer=(i=s.openDriveServer)==null?void 0:i.url,this.districtControllerDashLayer=new l({id:"districtController",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",geometryType:"polyline",outFields:["*"],fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"subDistrictCount",type:"integer"},{name:"signalCount",type:"integer"}],renderer:{type:"simple",symbol:{type:"simple-line",style:"long-dash",color:[111,100,255],width:3}}}),this.districtControllerSolidLayer=new l({id:"districtController",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"polyline",fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"subDistrictCount",type:"integer"},{name:"signalCount",type:"integer"}],popupTemplate:{title:"{name}",content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"区控编号"},{fieldName:"subDistrictCount",label:"子区数量"},{fieldName:"signalCount",label:"信号机数量"}]}]},renderer:{type:"simple",symbol:{type:"simple-line",style:"solid",color:[111,100,255,.4],width:3}}}),this.subDistrictControllerLayer=new l({id:"subDistrictController",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"polyline",fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"parentId",type:"string"},{name:"parentName",type:"string"},{name:"signalCount",type:"integer"},{name:"style",type:"string"}],popupTemplate:{title:"{name} 子区",content:[{type:"fields",fieldInfos:[{fieldName:"id",label:"区控编号"},{fieldName:"parentName",label:"所属区控"},{fieldName:"signalCount",label:"信号机数量"}]}]},renderer:{type:"unique-value",field:"style",defaultSymbol:{type:"simple-line",style:"solid",color:[5,196,104],width:3},uniqueValueInfos:[{value:"alert",symbol:{type:"simple-line",style:"solid",color:[255,0,0],width:3}}]}}),this.signalMarkerLayer=new l({id:"signalLayer",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"point",maxScale:5e3,fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"signalId",type:"string"},{name:"nodeId",type:"string"},{name:"isKey",type:"string"},{name:"districtId",type:"string"},{name:"districtName",type:"string"},{name:"subDistrictId",type:"string"},{name:"subDistrictName",type:"string"}],popupTemplate:{title:"{name}信号机",content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"signalId",label:"信号机编号"},{fieldName:"nodeId",label:"路口编号"}]}]},renderer:{type:"unique-value",field:"isKey",defaultSymbol:{type:"simple-marker",style:"circle",color:"gray",size:4,outline:{color:"white",width:1}},uniqueValueInfos:[{value:"true",symbol:{type:"simple-marker",style:"circle",color:[254,172,22],size:12,outline:{color:"white",width:1}}},{value:"false",symbol:{type:"simple-marker",style:"circle",color:[5,116,255],size:8,outline:{color:"white",width:1}}}]}}),this.signalClusterLayer=new l({id:"signalLayer",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"point",maxScale:5e3,fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"signalId",type:"string"},{name:"nodeId",type:"string"},{name:"isKey",type:"string"},{name:"districtId",type:"string"},{name:"districtName",type:"string"},{name:"subDistrictId",type:"string"},{name:"subDistrictName",type:"string"}],featureReduction:{type:"cluster",clusterRadius:"120px",clusterMaxSize:"50px",clusterMinSize:"30px",symbol:{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:"$feature.cluster_count",returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:16,horizontalAlignment:"Center",offsetX:0,offsetY:30,symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},verticalAlignment:"Center"},textString:""},{type:"CIMMarkerGraphic",geometry:{rings:[[[-15,40],[15,40],[15,20],[-15,20],[-15,40]]]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[2,72,200,255]},{type:"CIMSolidStroke",enable:!0,width:5,color:[2,72,200,128]}]}}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:40,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}},popupTemplate:{title:"聚合详情",content:"聚合信号机 <b>{cluster_count}</b> 个",fieldInfos:[{fieldName:"cluster_count",format:{digitSeparator:!0,places:0}}]}},popupTemplate:{title:"{name}信号机",content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"signalId",label:"信号机编号"},{fieldName:"nodeId",label:"路口编号"}]}]},renderer:{type:"simple",symbol:{type:"simple-marker",style:"circle",color:[5,116,255],size:8,outline:{color:"white",width:1}}}}),this.signalPictureLayer=new l({id:"signalLayer",spatialReference:e.spatialReference,source:[],objectIdField:"ObjectID",outFields:["*"],geometryType:"point",minScale:5e3,fields:[{name:"ObjectID",type:"oid"},{name:"id",type:"string"},{name:"name",type:"string"},{name:"signalId",type:"string"},{name:"nodeId",type:"string"},{name:"isKey",type:"string"},{name:"districtId",type:"string"},{name:"districtName",type:"string"},{name:"subDistrictId",type:"string"},{name:"subDistrictName",type:"string"}],popupTemplate:{title:"{name}信号机",content:[{type:"fields",fieldInfos:[{fieldName:"districtName",label:"区控名称"},{fieldName:"subDistrictName",label:"子区名称"},{fieldName:"signalId",label:"信号机编号"},{fieldName:"nodeId",label:"路口编号"}]}]},renderer:{type:"unique-value",field:"isKey",defaultSymbol:{type:"simple-marker",style:"circle",color:"gray",size:4,outline:{color:"white",width:1}},uniqueValueInfos:[{value:"true",symbol:{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:30,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:40,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_gjxklk_orange.png"}]}}}},{value:"false",symbol:{type:"cim",data:{type:"CIMSymbolReference",primitiveOverrides:[{type:"CIMPrimitiveOverride",primitiveName:"textGraphic",propertyName:"TextString",valueExpressionInfo:{type:"CIMExpressionInfo",title:"Custom",expression:'Replace($feature.name, "与", "/") + " " + $feature.signalId',returnType:"Default"}}],symbol:{type:"CIMPointSymbol",symbolLayers:[{type:"CIMVectorMarker",size:32,colorLocked:!0,anchorPointUnits:"Relative",frame:{xmin:-16,ymin:-16,xmax:16,ymax:16},markerGraphics:[{type:"CIMMarkerGraphic",primitiveName:"textGraphic",geometry:{x:0,y:0},symbol:{type:"CIMTextSymbol",height:12,horizontalAlignment:"Center",offsetX:0,offsetY:15,haloSize:1,haloSymbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[255,255,255,255]}]},symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[0,0,0,255]}]},verticalAlignment:"Center"},textString:""}],scaleSymbolsProportionally:!0,respectFrame:!0},{type:"CIMPictureMarker",enable:!0,anchorPoint:{x:0,y:0},anchorPointUnits:"Relative",size:20,rotateClockwise:!0,textureFilter:"Picture",url:"/GisViewerAssets/Images/cross/gis_xhj_blue.png"}]}}}}]}}),this.view.map.addMany([this.districtControllerSolidLayer,this.districtControllerDashLayer,this.subDistrictControllerLayer,this.signalMarkerLayer,this.signalPictureLayer,this.signalClusterLayer])}async showSignalControlArea(e){await this.clearSignalControlArea(),this.districtControllerDashLayer.visible=!1,this.districtControllerSolidLayer.visible=!1,this.subDistrictControllerLayer.visible=!1,this.signalMarkerLayer.visible=!1,this.signalPictureLayer.visible=!1,this.signalClusterLayer.visible=!0;for(const t of e.areaList){const s=new b.default(t,e.style||"");this.generateGraphic(s,!0,e.style)}return await this.districtControllerDashLayer.applyEdits({addFeatures:this.districtGraphics}),await this.districtControllerSolidLayer.applyEdits({addFeatures:this.districtGraphics}),this.view.goTo(this.districtGraphics),this.districtGraphics=[],await this.subDistrictControllerLayer.applyEdits({addFeatures:this.subDistrictGraphics}),this.subDistrictGraphics=[],await this.signalMarkerLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalPictureLayer.applyEdits({addFeatures:this.signalGraphics}),await this.signalClusterLayer.applyEdits({addFeatures:this.signalGraphics}),this.signalGraphics=[],{status:0,message:"ok"}}async clearSignalControlArea(){this.districtControllerOid=0,this.subDistrictControllerOid=0,this.signalOid=0;let e=await this.districtControllerDashLayer.queryFeatures();return await this.districtControllerDashLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerDashLayer.definitionExpression="1=1",e=await this.districtControllerSolidLayer.queryFeatures(),await this.districtControllerSolidLayer.applyEdits({deleteFeatures:e.features}),this.districtControllerSolidLayer.definitionExpression="1=1",e=await this.subDistrictControllerLayer.queryFeatures(),await this.subDistrictControllerLayer.applyEdits({deleteFeatures:e.features}),this.subDistrictControllerLayer.definitionExpression="1=1",e=await this.signalMarkerLayer.queryFeatures(),await this.signalMarkerLayer.applyEdits({deleteFeatures:e.features}),this.signalMarkerLayer.definitionExpression="1=1",e=await this.signalPictureLayer.queryFeatures(),await this.signalPictureLayer.applyEdits({deleteFeatures:e.features}),this.signalPictureLayer.definitionExpression="1=1",e=await this.signalClusterLayer.queryFeatures(),await this.signalClusterLayer.applyEdits({deleteFeatures:e.features}),this.signalClusterLayer.definitionExpression="1=1",{status:0,message:"ok"}}setLayerVisibility(e){switch(e.visible===!1&&this.view.closePopup(),e.id){case"district":this.districtControllerDashLayer.visible=e.visible,this.districtControllerSolidLayer.visible=e.visible;break;case"subDistrict":this.subDistrictControllerLayer.visible=e.visible;break;case"signal":this.signalMarkerLayer.visible=e.visible,this.signalPictureLayer.visible=e.visible;break;case"signalCluster":this.signalClusterLayer.visible=e.visible;break}return{status:0,message:"ok"}}async locateSignalControlArea(e){switch(e.type){case"district":{const i=this.districtControllerDashLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.districtControllerDashLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo(r.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到区控"}}case"subDistrict":const t=this.subDistrictControllerLayer.createQuery();t.where=`id = '${e.id}'`,t.returnGeometry=!0,t.outFields=["*"];const s=await this.subDistrictControllerLayer.queryFeatures(t);return s.features.length>0?(await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到子区"};case"signal":{const i=this.signalMarkerLayer.createQuery();i.where=`id = '${e.id}'`,i.returnGeometry=!0,i.outFields=["*"];const r=await this.signalMarkerLayer.queryFeatures(i);return r.features.length>0?(await this.view.goTo({target:r.features[0],scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async highlightSignalControlArea(e){switch(e.type){case"district":{const t=this.districtControllerDashLayer.definitionExpression;this.districtControllerDashLayer.definitionExpression=`id = '${e.id}'`;const s=await this.districtControllerDashLayer.queryFeatures();return s.features.length>0?(this.districtControllerSolidLayer.definitionExpression=`id = '${e.id}'`,this.subDistrictControllerLayer.definitionExpression=`parentId = '${e.id}'`,this.signalMarkerLayer.definitionExpression=`districtId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`districtId = '${e.id}'`,await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}):(this.districtControllerDashLayer.definitionExpression=t,{status:1,message:"未找到区控"})}case"subDistrict":{const t=this.subDistrictControllerLayer.definitionExpression;this.subDistrictControllerLayer.definitionExpression=`id = '${e.id}'`;const s=await this.subDistrictControllerLayer.queryFeatures();if(s.features.length>0){this.signalMarkerLayer.definitionExpression=`subDistrictId = '${e.id}'`,this.signalPictureLayer.definitionExpression=`subDistrictId = '${e.id}'`;const r=s.features[0].attributes.parentId;return this.districtControllerDashLayer.definitionExpression=`id = '${r}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${r}'`,await this.view.goTo(s.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.subDistrictControllerLayer.definitionExpression=t,{status:1,message:"未找到子区"}}case"signal":{const t=this.signalMarkerLayer.definitionExpression;this.signalMarkerLayer.definitionExpression=`id = '${e.id}'`;const s=await this.signalMarkerLayer.queryFeatures();if(s.features.length>0){this.signalPictureLayer.definitionExpression=`id = '${e.id}'`;const i=s.features[0],{districtId:r,subDistrictId:u}=i.attributes;return this.districtControllerDashLayer.definitionExpression=`id = '${r}'`,this.districtControllerSolidLayer.definitionExpression=`id = '${r}'`,this.subDistrictControllerLayer.definitionExpression=`id = '${u}'`,await this.view.goTo({target:s.features,scale:e.scale||1e3},{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}else return this.signalMarkerLayer.definitionExpression=t,{status:1,message:"未找到信号机"}}default:return{status:1,message:"未知类型"}}}async resetHighlight(){this.districtControllerDashLayer.definitionExpression="1=1",this.districtControllerSolidLayer.definitionExpression="1=1",this.subDistrictControllerLayer.definitionExpression="1=1",this.signalMarkerLayer.definitionExpression="1=1";const e=await this.districtControllerDashLayer.queryFeatures();return this.view.goTo(e.features,{duration:this.hasGpu?1e3:0}),{status:0,message:"ok"}}generateGraphic(e,t,s){const i=e.getAllSignalCoordinates();let r=null;if(i.length>=2)if(i.length===2)r=o.lineString(i);else{if(t){const a=o.featureCollection(i.map(y=>o.point(y)));r=h(a)}else{const a=g(i,.5);a.length>=4&&(r=o.polygon([a]))}r||(r=o.lineString(i))}else if(i.length===1)r=o.point(i[0]);else return;const u=p(r.geometry,t?200:30,{units:"meters"}),c=new d({geometry:{type:"polyline",paths:u.geometry.coordinates},attributes:{ObjectID:t?this.districtControllerOid++:this.subDistrictControllerOid++,id:e.id,name:e.name,subDistrictCount:e.subDistrictCount,signalCount:e.signalCount,parentId:e.parentId,parentName:e.parentName,style:s}});t?this.districtGraphics.push(c):this.subDistrictGraphics.push(c);for(const a of e.subDistricts)this.generateGraphic(a,!1,s);e.signals.forEach(a=>{const y=new d({geometry:{type:"point",x:a.longitude,y:a.latitude},attributes:{ObjectID:this.signalOid++,id:a.id,name:a.name,signalId:a.signalId,nodeId:a.nodeId,isKey:a.isKey,districtId:t?e.id:e.parentId,districtName:t?e.name:e.parentName,subDistrictId:t?"":e.id,subDistrictName:t?"":e.name}});this.signalGraphics.push(y)})}}exports.default=I;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/geometry/geometryEngine.js"),P=require("@arcgis/core/geometry/
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("@arcgis/core/geometry/geometryEngine.js"),P=require("@arcgis/core/geometry/Polygon"),G=require("@arcgis/core/geometry/Polyline"),S=require("@arcgis/core/geometry/support/webMercatorUtils.js"),l=require("@arcgis/core/Graphic"),d=require("@arcgis/core/layers/GraphicsLayer"),k=require("@arcgis/core/widgets/Sketch"),M=require("@arcgis/core/widgets/Sketch/SketchViewModel"),A=require("@turf/helpers"),x=require("@turf/intersect"),v=require("uuid"),E=require("../stores/index.js");function f(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const V=f(b),g=f(S),u=f(A);function w(a,e=[]){if(a===null||typeof a!="object")return a;if(Object.prototype.toString.call(a)==="[object Date]")return new Date(a);if(Object.prototype.toString.call(a)==="[object RegExp]")return new RegExp(a);if(Object.prototype.toString.call(a)==="[object Error]")return new Error(a);const t=e.filter(s=>s.original===a)[0];if(t)return t.copy;const i=Array.isArray(a)?[]:{};return e.push({original:a,copy:i}),Object.keys(a).forEach(s=>{i[s]=w(a[s],e)}),i}const O={maxAllowedGraphics:0,GraphicsLayer:{},sketchVisibleElements:{},sketchPosition:"top-right",defaultSketchVisible:!0,sketchViewModelItemSymbol:{}},m={type:"simple-line",color:"#556DEA",width:2},y={type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}};class D{constructor(e,t){this.viewer=e,this.options={...O,...t},this.graphicsLayer=new d({...this.options.GraphicsLayer}),this.TextGraphicsLayer=new d,this.viewer.map.addMany([this.graphicsLayer,this.TextGraphicsLayer]),this.init()}updateSketch(e){const t=new l({geometry:{type:"polygon",rings:[e]},symbol:{type:"simple-fill",color:[227,139,79,.4],outline:{color:[255,255,255],width:1}}});this.graphicsLayer.add(t),this.sketchViewModel.update([t],{tool:"reshape",enableRotation:!0})}init(){this.sketchViewModel=new M({layer:this.graphicsLayer,view:this.viewer,updateOnGraphicClick:!0,polylineSymbol:m,polygonSymbol:y,...this.options.sketchViewModelItemSymbol});const e=this.findLayerById("TrafficMarkings"),t=[];e&&t.push({layer:e,enabled:!0}),this.sketch=new k({view:this.viewer,viewModel:this.sketchViewModel,layer:this.graphicsLayer,visible:this.options.defaultSketchVisible,creationMode:this.options.creationMode||"single",snappingOptions:{enabled:!0,featureSources:t}}),this.sketch.visibleElements={...this.options.sketchVisibleElements},this.viewer.ui.add(this.sketch,this.options.sketchPosition);const i=E.default.useAppDataStore;this.sketch.on("create",s=>{s.state==="complete"?i.isSketching=!1:s.state==="start"&&(i.isSketching=!0)})}initPoint(e,t="all",i=!1){if(!e)return;const{crossArea:s,sectionArea:r}=e;if(s&&(t=="crossArea"||t=="all")){const o=this.initCrossArea(s);this.graphicsLayer.add(o)}if(r&&(t=="sectionArea"||t=="all")){const o=this.initSectionArea(r,i);this.graphicsLayer.addMany(o)}}initEntranceFusionZone(e){const t=[];e.map(i=>{t.push(this.createPolygonGraphic(i,y,{}))}),this.graphicsLayer.addMany(t)}initCrossArea(e){return this.createPolygonGraphic(e,y,{})}initSectionArea(e,t=!1){const i=[],s={type:"simple-line",color:[0,0,255],width:2};return Object.keys(e).map(r=>{const o=e[r][0],c=e[r][1];t&&(o.reverse(),c.reverse());const n=v.v4(),h=this.createPolylineGraphic(o,m,{type:"draw",id:n}),p=this.createPolylineGraphic(c,s,{type:"shiftLine",id:n});i.push(h,p)}),i}createPolylineGraphic(e,t,i){const s=new G({paths:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}createPolygonGraphic(e,t,i){const s=new P({rings:e}),r=g.geographicToWebMercator(s);return new l({geometry:r,symbol:t,attributes:i})}on(e){const t=this;this.sketchViewModel.on("create",function(i){var r,o,c;const s=t.graphicsLayer.graphics;if((r=t.options)!=null&&r.maxAllowedGraphics&&s.length>((o=t.options)==null?void 0:o.maxAllowedGraphics)){t.graphicsLayer.remove(i.graphic),console.log("已达到最大图形数量,无法继续绘制!");return}if(i.state==="complete"&&((c=i.graphic)!=null&&c.geometry)){const n=i.graphic.geometry;i.graphic.setAttribute("type","draw"),i.graphic.setAttribute("id",new Date().getTime());const h=t.getGraphicPoint(n);e&&e("create",h,i)}}),this.sketchViewModel.on("update",function(i){if(i.aborted){const s=i.graphics[0];t.graphicsLayer.remove(s);return}if(i.state==="complete"&&i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("update",o,i)}}),this.sketchViewModel.on("delete",function(i){if(console.log("delete",i),i.graphics.length>0){const r=i.graphics[0].geometry,o=t.getGraphicPoint(r);e&&e("delete",o,i)}})}graphicPoint(){const e=[];return this.graphicsLayer.graphics.map(t=>{var r;const i=t.geometry,s=this.getGraphicPoint(i);e.push({point:s,type:(r=t.attributes)==null?void 0:r.type,attributes:t.attributes})}),e}getEntranceRoad(){const e={},t=this.graphicPoint().filter(n=>n.point.type==="polyline");if(console.log("🚀 ~ file: sketchView.ts:378 ~ SketchView ~ getEntranceRoad ~ graphics:",t),!t.length)return!1;const i=t.filter(n=>n.type=="draw"),s=t.filter(n=>n.type=="shiftLine");if(s.length==0)throw"未绘制平移!";if(i.length!=s.length)throw"绘制的线和平移的线数量不一致!";const r=i.sort((n,h)=>n.point.angle-h.point.angle),o=r.findIndex(n=>n.point.angle>135);return[...r.slice(o),...r.slice(0,o).reverse()].map((n,h)=>{const p=s.find(L=>L.attributes.id==n.attributes.id);if(!p)throw"绘制的线和平移的线不匹配!";console.log("🚀 ~ file: sketchView.ts:393 ~ SketchView ~ getEntranceRoad ~ m:",n,p),e[h+1]={0:[n.point.paths[0],n.point.paths[n.point.paths.length-1]],1:[p.point.paths[0],p.point.paths[p.point.paths.length-1]]}}),e}getEntranceFusionZone(e){const t=[],i={};this.graphicsLayer.graphics.map(r=>{var n;const o=r.geometry,c=this.getGraphicPoint(o,!1);t.push({point:c,type:(n=r.attributes)==null?void 0:n.type,attributes:r.attributes})});const s=t;return e.map((r,o)=>{i[r]=t[o]}),{graphics:i,rawData:s}}getIntersectionArea(e,t){const i=Object.keys(e);let s=!1;for(let r=0;r<i.length;r++){const o=i[r],c=e[o];if(x(u.polygon(t),u.polygon(c))){s=o;break}}return s}filterData(e){const t=w(e);return t.length>0&&t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&t.pop(),t}getGraphicPoint(e,t=!1){let i=e;this.viewer.spatialReference.isWebMercator&&(i=g.webMercatorToGeographic(e));let s;if(e.type==="point")s={type:e.type,x:i.x,y:i.y};else if(e.type==="polyline"){s={type:e.type,paths:[]},i.paths.forEach(n=>{let h=n;t&&(h=this.filterData(n)),h.forEach(p=>{s.paths.push(p)})});const r={x:s.paths[0][0],y:s.paths[0][1]},o={x:s.paths[s.paths.length-1][0],y:s.paths[s.paths.length-1][1]},c=this.getAngle(r,o);s.angle=c}else e.type==="polygon"&&(s={type:e.type,rings:[]},i.rings.forEach(r=>{let o=r;t&&(o=this.filterData(r)),o.forEach(c=>{s.rings.push(c)})}));return s}close(){this.sketch.visible=!1}show(){this.sketch.visible=!0}removeAll(){this.graphicsLayer.removeAll()}getAngle(e,t){const i=t.x-e.x,s=t.y-e.y;return Math.atan2(s,i)*180/Math.PI}getShiftLine(e,t,i="meters"){const s=e,r=-t;return V.offset(s,r,i)}setShiftLine(e,t="meters",i){i||(i={type:"simple-line",color:[0,0,255],width:2}),this.removeShiftLine(),this.graphicsLayer.graphics.map(s=>{const r=s.geometry,o=s.attributes;if((r==null?void 0:r.type)==="polyline"&&(o==null?void 0:o.type)==="draw"){const c=o.id,n=this.getShiftLine(r,e,t),h=new l({geometry:n,symbol:i,attributes:{type:"shiftLine",id:c}});this.graphicsLayer.add(h)}})}removeShiftLine(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="shiftLine"&&e.push(t)}),this.graphicsLayer.removeMany(e)}removeDraw(){const e=[];this.graphicsLayer.graphics.map(t=>{const i=t.attributes;(i==null?void 0:i.type)==="draw"&&e.push(t)}),this.graphicsLayer.removeMany(e)}addGraphic(e,t={type:"simple-line",color:[0,0,255],width:2},i){const s=new l({geometry:e,symbol:t,attributes:i});this.graphicsLayer.add(s)}getDirection(e,t){const i=t.x-e.x,s=t.y-e.y,o=Math.atan2(s,i)*180/Math.PI;return o>=-45&&o<=45?0:o>45&&o<=135?1:o>135||o<=-135?2:3}findLayerById(e){return this.viewer.map.findLayerById(e)}findShiftLineGraphicsById(e){return this.graphicsLayer.graphics.find(i=>i.attributes.id===e&&i.attributes.type==="shiftLine")}remove(e){this.graphicsLayer.remove(e)}setMaxAllowedGraphics(e){this.options.maxAllowedGraphics=e===0?void 0:e}destroy(){var e,t;this.viewer.map.remove(this.graphicsLayer),this.viewer.map.remove(this.TextGraphicsLayer),(e=this.sketch)==null||e.destroy(),(t=this.sketchViewModel)==null||t.destroy()}}exports.default=D;
|