gisviewer-vue3-arcgis 1.0.85
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/README.md +103 -0
- package/es/index.d.ts +8 -0
- package/es/index.mjs +16 -0
- package/es/src/components.d.ts +9 -0
- package/es/src/gis-map/gis-map.vue.d.ts +91 -0
- package/es/src/gis-map/gis-map.vue.mjs +124 -0
- package/es/src/gis-map/gis-map.vue2.mjs +4 -0
- package/es/src/gis-map/index.d.ts +81 -0
- package/es/src/gis-map/index.mjs +7 -0
- package/es/src/gis-map/stores/appData.d.ts +3 -0
- package/es/src/gis-map/stores/appData.mjs +9 -0
- package/es/src/gis-map/stores/index.d.ts +7 -0
- package/es/src/gis-map/stores/index.mjs +10 -0
- package/es/src/gis-map/style/index.css +13 -0
- package/es/src/gis-map/utils/FlyToPoints.d.ts +37 -0
- package/es/src/gis-map/utils/FlyToPoints.mjs +67 -0
- package/es/src/gis-map/utils/GreenWaveline.mjs +193 -0
- package/es/src/gis-map/utils/Layers.d.ts +31 -0
- package/es/src/gis-map/utils/Layers.mjs +99 -0
- package/es/src/gis-map/utils/common-utils.d.ts +65 -0
- package/es/src/gis-map/utils/common-utils.mjs +159 -0
- package/es/src/gis-map/utils/holo-flow/index.d.ts +15 -0
- package/es/src/gis-map/utils/holo-flow/index.mjs +50 -0
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +40 -0
- package/es/src/gis-map/utils/holo-flow/signal-holo-flow.mjs +209 -0
- package/es/src/gis-map/utils/holo-flow/trace-external-renderer.d.ts +69 -0
- package/es/src/gis-map/utils/holo-flow/trace-external-renderer.mjs +316 -0
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +18 -0
- package/es/src/gis-map/utils/holo-flow/trace-holo-flow.mjs +75 -0
- package/es/src/gis-map/utils/holo-flow/trace-layer-renderer.d.ts +35 -0
- package/es/src/gis-map/utils/holo-flow/trace-layer-renderer.mjs +286 -0
- package/es/src/gis-map/utils/index.d.ts +21 -0
- package/es/src/gis-map/utils/index.mjs +23 -0
- package/es/src/gis-map/utils/map-initializer.d.ts +50 -0
- package/es/src/gis-map/utils/map-initializer.mjs +248 -0
- package/es/src/gis-map/utils/open-drive-renderer/index.d.ts +9 -0
- package/es/src/gis-map/utils/open-drive-renderer/index.mjs +271 -0
- package/es/src/gis-map/utils/overlay.d.ts +83 -0
- package/es/src/gis-map/utils/overlay.mjs +149 -0
- package/es/src/gis-map/utils/queue-length.d.ts +14 -0
- package/es/src/gis-map/utils/queue-length.mjs +83 -0
- package/es/src/gis-map/utils/renderer/greenWaveline.d.ts +2 -0
- package/es/src/gis-map/utils/renderer/greenWaveline.mjs +169 -0
- package/es/src/gis-map/utils/road-config-tool/cross.d.ts +51 -0
- package/es/src/gis-map/utils/road-config-tool/cross.mjs +127 -0
- package/es/src/gis-map/utils/road-config-tool/entrance.d.ts +24 -0
- package/es/src/gis-map/utils/road-config-tool/entrance.mjs +79 -0
- package/es/src/gis-map/utils/road-config-tool/exit.d.ts +18 -0
- package/es/src/gis-map/utils/road-config-tool/exit.mjs +86 -0
- package/es/src/gis-map/utils/road-config-tool/index.d.ts +44 -0
- package/es/src/gis-map/utils/road-config-tool/index.mjs +112 -0
- package/es/src/gis-map/utils/road-config-tool/indicator-area.d.ts +22 -0
- package/es/src/gis-map/utils/road-config-tool/indicator-area.mjs +44 -0
- package/es/src/gis-map/utils/road-config-tool/lane.d.ts +21 -0
- package/es/src/gis-map/utils/road-config-tool/lane.mjs +35 -0
- package/es/src/gis-map/utils/road-config-tool/search-nearby-lanes.d.ts +62 -0
- package/es/src/gis-map/utils/road-config-tool/search-nearby-lanes.mjs +265 -0
- package/es/src/gis-map/utils/sketchView.d.ts +209 -0
- package/es/src/gis-map/utils/sketchView.mjs +516 -0
- package/es/src/gis-map/utils/sketchViewTool.d.ts +259 -0
- package/es/src/gis-map/utils/sketchViewTool.mjs +503 -0
- package/es/src/gis-map/utils/syncMapView.d.ts +43 -0
- package/es/src/gis-map/utils/syncMapView.mjs +64 -0
- package/es/src/gis-map/utils/traffic-flow.d.ts +66 -0
- package/es/src/gis-map/utils/traffic-flow.mjs +308 -0
- package/es/src/index.d.ts +1 -0
- package/es/src/index.mjs +4 -0
- package/es/src/types/index.d.ts +142 -0
- package/es/src/types/index.mjs +5 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +1 -0
- package/lib/src/components.d.ts +9 -0
- package/lib/src/gis-map/gis-map.vue.d.ts +91 -0
- package/lib/src/gis-map/gis-map.vue.js +1 -0
- package/lib/src/gis-map/gis-map.vue2.js +1 -0
- package/lib/src/gis-map/index.d.ts +81 -0
- package/lib/src/gis-map/index.js +1 -0
- package/lib/src/gis-map/stores/appData.d.ts +3 -0
- package/lib/src/gis-map/stores/appData.js +1 -0
- package/lib/src/gis-map/stores/index.d.ts +7 -0
- package/lib/src/gis-map/stores/index.js +1 -0
- package/lib/src/gis-map/style/index.css +13 -0
- package/lib/src/gis-map/utils/FlyToPoints.d.ts +37 -0
- package/lib/src/gis-map/utils/FlyToPoints.js +1 -0
- package/lib/src/gis-map/utils/GreenWaveline.js +1 -0
- package/lib/src/gis-map/utils/Layers.d.ts +31 -0
- package/lib/src/gis-map/utils/Layers.js +1 -0
- package/lib/src/gis-map/utils/common-utils.d.ts +65 -0
- package/lib/src/gis-map/utils/common-utils.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/index.d.ts +15 -0
- package/lib/src/gis-map/utils/holo-flow/index.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.d.ts +40 -0
- package/lib/src/gis-map/utils/holo-flow/signal-holo-flow.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-external-renderer.d.ts +69 -0
- package/lib/src/gis-map/utils/holo-flow/trace-external-renderer.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.d.ts +18 -0
- package/lib/src/gis-map/utils/holo-flow/trace-holo-flow.js +1 -0
- package/lib/src/gis-map/utils/holo-flow/trace-layer-renderer.d.ts +35 -0
- package/lib/src/gis-map/utils/holo-flow/trace-layer-renderer.js +1 -0
- package/lib/src/gis-map/utils/index.d.ts +21 -0
- package/lib/src/gis-map/utils/index.js +1 -0
- package/lib/src/gis-map/utils/map-initializer.d.ts +50 -0
- package/lib/src/gis-map/utils/map-initializer.js +1 -0
- package/lib/src/gis-map/utils/open-drive-renderer/index.d.ts +9 -0
- package/lib/src/gis-map/utils/open-drive-renderer/index.js +1 -0
- package/lib/src/gis-map/utils/overlay.d.ts +83 -0
- package/lib/src/gis-map/utils/overlay.js +1 -0
- package/lib/src/gis-map/utils/queue-length.d.ts +14 -0
- package/lib/src/gis-map/utils/queue-length.js +1 -0
- package/lib/src/gis-map/utils/renderer/greenWaveline.d.ts +2 -0
- package/lib/src/gis-map/utils/renderer/greenWaveline.js +43 -0
- package/lib/src/gis-map/utils/road-config-tool/cross.d.ts +51 -0
- package/lib/src/gis-map/utils/road-config-tool/cross.js +1 -0
- package/lib/src/gis-map/utils/road-config-tool/entrance.d.ts +24 -0
- package/lib/src/gis-map/utils/road-config-tool/entrance.js +1 -0
- package/lib/src/gis-map/utils/road-config-tool/exit.d.ts +18 -0
- package/lib/src/gis-map/utils/road-config-tool/exit.js +1 -0
- package/lib/src/gis-map/utils/road-config-tool/index.d.ts +44 -0
- package/lib/src/gis-map/utils/road-config-tool/index.js +1 -0
- package/lib/src/gis-map/utils/road-config-tool/indicator-area.d.ts +22 -0
- package/lib/src/gis-map/utils/road-config-tool/indicator-area.js +1 -0
- package/lib/src/gis-map/utils/road-config-tool/lane.d.ts +21 -0
- package/lib/src/gis-map/utils/road-config-tool/lane.js +1 -0
- package/lib/src/gis-map/utils/road-config-tool/search-nearby-lanes.d.ts +62 -0
- package/lib/src/gis-map/utils/road-config-tool/search-nearby-lanes.js +1 -0
- package/lib/src/gis-map/utils/sketchView.d.ts +209 -0
- package/lib/src/gis-map/utils/sketchView.js +1 -0
- package/lib/src/gis-map/utils/sketchViewTool.d.ts +259 -0
- package/lib/src/gis-map/utils/sketchViewTool.js +1 -0
- package/lib/src/gis-map/utils/syncMapView.d.ts +43 -0
- package/lib/src/gis-map/utils/syncMapView.js +1 -0
- package/lib/src/gis-map/utils/traffic-flow.d.ts +66 -0
- package/lib/src/gis-map/utils/traffic-flow.js +1 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +1 -0
- package/lib/src/types/index.d.ts +142 -0
- package/lib/src/types/index.js +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import GraphicsLayer from '@arcgis/core/layers/GraphicsLayer';
|
|
2
|
+
import MapView from '@arcgis/core/views/MapView';
|
|
3
|
+
import SceneView from '@arcgis/core/views/SceneView';
|
|
4
|
+
import SketchViewModel from '@arcgis/core/widgets/Sketch/SketchViewModel';
|
|
5
|
+
import Sketch from '@arcgis/core/widgets/Sketch';
|
|
6
|
+
import Graphic from '@arcgis/core/Graphic';
|
|
7
|
+
interface sketchViewOptions {
|
|
8
|
+
/**
|
|
9
|
+
* 最大允许绘制的图形数量
|
|
10
|
+
*/
|
|
11
|
+
maxAllowedGraphics?: number;
|
|
12
|
+
/**
|
|
13
|
+
* 图形图层配置
|
|
14
|
+
*/
|
|
15
|
+
GraphicsLayer?: {};
|
|
16
|
+
/**
|
|
17
|
+
* 绘制工具显示的元素
|
|
18
|
+
*/
|
|
19
|
+
sketchvisibleElements?: {};
|
|
20
|
+
/**
|
|
21
|
+
* 绘制工具显示的位置
|
|
22
|
+
*/
|
|
23
|
+
sketchPosition?: string;
|
|
24
|
+
/**
|
|
25
|
+
* 绘制工具默认是否显示
|
|
26
|
+
*
|
|
27
|
+
* @type {boolean}
|
|
28
|
+
* @memberof sketchViewOptions
|
|
29
|
+
*/
|
|
30
|
+
defaultsketchVisible?: boolean;
|
|
31
|
+
sketchViewModelItemSymbol?: {
|
|
32
|
+
polylineSymbol?: any;
|
|
33
|
+
polygonSymbol?: any;
|
|
34
|
+
pointSymbol?: any;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
interface ITPoint {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}
|
|
41
|
+
declare type LinearUnits = 'meters' | 'feet' | 'kilometers' | 'miles' | 'nautical-miles' | 'yards' | number;
|
|
42
|
+
export default class SketchView {
|
|
43
|
+
private viewer;
|
|
44
|
+
graphicsLayer: GraphicsLayer;
|
|
45
|
+
TextgraphicsLayer: GraphicsLayer;
|
|
46
|
+
sketchViewModel: SketchViewModel;
|
|
47
|
+
sketch: Sketch;
|
|
48
|
+
options: sketchViewOptions;
|
|
49
|
+
constructor(view: MapView | SceneView, options?: sketchViewOptions);
|
|
50
|
+
init(): void;
|
|
51
|
+
/**
|
|
52
|
+
* 初始化绘图
|
|
53
|
+
*
|
|
54
|
+
* @param {*} data
|
|
55
|
+
* @param {string} [type='crossArea']
|
|
56
|
+
* @param {boolean} [reverse=false] 是否反转
|
|
57
|
+
* @returns
|
|
58
|
+
* @memberof SketchView
|
|
59
|
+
*/
|
|
60
|
+
initPoint(data: any, type?: string, reverse?: boolean): void;
|
|
61
|
+
/**
|
|
62
|
+
* 初始化进口道融合区
|
|
63
|
+
*
|
|
64
|
+
* @param {any[]} data
|
|
65
|
+
* @memberof SketchView
|
|
66
|
+
*/
|
|
67
|
+
initEntranceFusionZone(data: any[]): void;
|
|
68
|
+
initCrossArea(data: any): Graphic;
|
|
69
|
+
/**
|
|
70
|
+
* 初始进出口道计算区域
|
|
71
|
+
*
|
|
72
|
+
* @param {*} data
|
|
73
|
+
* @param {boolean} [reverse=false] 是否反转
|
|
74
|
+
* @returns
|
|
75
|
+
* @memberof SketchView
|
|
76
|
+
*/
|
|
77
|
+
inintSectionArea(data: any, reverse?: boolean): any;
|
|
78
|
+
createPolylineGraphic(paths: any, lineSymbol: any, attributes: any): Graphic;
|
|
79
|
+
createPolygonGraphic(rings: any, lineSymbol: any, attributes: any): Graphic;
|
|
80
|
+
on(callcack?: (type: string, points: any, event?: any) => void): void;
|
|
81
|
+
/**
|
|
82
|
+
* 获取当前绘制的计算区域
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
graphicPoint(): any[];
|
|
86
|
+
/**
|
|
87
|
+
* 获取进口道区域
|
|
88
|
+
*
|
|
89
|
+
* @memberof SketchView
|
|
90
|
+
*/
|
|
91
|
+
getEntranceRoad(): any;
|
|
92
|
+
/**
|
|
93
|
+
* 获进口道融合区
|
|
94
|
+
*
|
|
95
|
+
* @param {armData} armData 进口道编号区域
|
|
96
|
+
* @param {number[]} armNoList 进口道编号列表
|
|
97
|
+
* @returns
|
|
98
|
+
* @memberof SketchView
|
|
99
|
+
*/
|
|
100
|
+
getEntranceFusionZone(armNoList: number[]): {
|
|
101
|
+
graphics: {
|
|
102
|
+
[key: number]: {
|
|
103
|
+
point: any;
|
|
104
|
+
type: string;
|
|
105
|
+
attributes: any;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
rawdata: {
|
|
109
|
+
point: any;
|
|
110
|
+
type: string;
|
|
111
|
+
attributes: any;
|
|
112
|
+
}[];
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* 获取进口道所在的进口道编号
|
|
116
|
+
*
|
|
117
|
+
* @param {armData} armData 进口道编号区域
|
|
118
|
+
* @param {*} graphicPpolygon 绘制的区域
|
|
119
|
+
* @returns
|
|
120
|
+
* @memberof SketchView
|
|
121
|
+
*/
|
|
122
|
+
private getIntersectionArea;
|
|
123
|
+
private filterData;
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
* @param {*} geometry
|
|
129
|
+
* @param {boolean} [isfilterData=true] 是否过滤首尾相同点数据
|
|
130
|
+
* @returns
|
|
131
|
+
* @memberof SketchView
|
|
132
|
+
*/
|
|
133
|
+
private getGraphicPoint;
|
|
134
|
+
close(): void;
|
|
135
|
+
show(): void;
|
|
136
|
+
removeAll(): void;
|
|
137
|
+
/**
|
|
138
|
+
* 获取两点的角度
|
|
139
|
+
*
|
|
140
|
+
* @param {ITPoint} startPoint
|
|
141
|
+
* @param {ITPoint} endPoint
|
|
142
|
+
* @returns
|
|
143
|
+
* @memberof SketchView
|
|
144
|
+
*/
|
|
145
|
+
getAngle(startPoint: ITPoint, endPoint: ITPoint): number;
|
|
146
|
+
/**
|
|
147
|
+
* 获取线平移后的坐标
|
|
148
|
+
*
|
|
149
|
+
* @param {Polyline} lineGeometry 线的几何图形
|
|
150
|
+
* @param {number} distance 平移的距离,默认米
|
|
151
|
+
* @param {LinearUnits} [offsetUnit='meters']
|
|
152
|
+
* @returns
|
|
153
|
+
* @memberof SketchView
|
|
154
|
+
*/
|
|
155
|
+
getshiftLine(lineGeometry: __esri.Geometry, distance: number, offsetUnit?: LinearUnits): __esri.Geometry | __esri.Geometry[];
|
|
156
|
+
/**
|
|
157
|
+
* 设置线的平移
|
|
158
|
+
*
|
|
159
|
+
* @param {number} distance 平移的距离,默认米
|
|
160
|
+
* @param {LinearUnits} [offsetUnit='meters'] 平移的单位
|
|
161
|
+
* @param {*} symbol 线的样式
|
|
162
|
+
* @memberof SketchView
|
|
163
|
+
*/
|
|
164
|
+
setshiftLine(distance: number, offsetUnit?: LinearUnits, symbol?: any): void;
|
|
165
|
+
/**
|
|
166
|
+
* 移除平移线
|
|
167
|
+
*
|
|
168
|
+
* @memberof SketchView
|
|
169
|
+
*/
|
|
170
|
+
removeShiftLine(): void;
|
|
171
|
+
/**
|
|
172
|
+
* 移除绘制的线
|
|
173
|
+
*
|
|
174
|
+
* @memberof SketchView
|
|
175
|
+
*/
|
|
176
|
+
removedraw(): void;
|
|
177
|
+
addGraphic(geometry: any, symbol?: any, attributes?: any): void;
|
|
178
|
+
/**
|
|
179
|
+
* 获取方向
|
|
180
|
+
*
|
|
181
|
+
* @param {ITPoint} startPoint 起点
|
|
182
|
+
* @param {ITPoint} endPoint 终点
|
|
183
|
+
* @returns
|
|
184
|
+
* @memberof SketchView
|
|
185
|
+
*/
|
|
186
|
+
getDirection(startPoint: ITPoint, endPoint: ITPoint): 0 | 1 | 3 | 2;
|
|
187
|
+
findLayerById(id: string): __esri.Layer;
|
|
188
|
+
/**
|
|
189
|
+
* 根据id查找平移线graphic
|
|
190
|
+
*
|
|
191
|
+
* @param {string} id
|
|
192
|
+
* @returns
|
|
193
|
+
* @memberof SketchView
|
|
194
|
+
*/
|
|
195
|
+
findShiftLineGraphicsById(id: string): Graphic;
|
|
196
|
+
/**
|
|
197
|
+
* 删除指定的图形
|
|
198
|
+
* @param graphic 删除指定的图形
|
|
199
|
+
*/
|
|
200
|
+
remove(graphic: any): void;
|
|
201
|
+
/**
|
|
202
|
+
* 设置最大允许绘制的图形数量
|
|
203
|
+
* @param num 数量
|
|
204
|
+
*/
|
|
205
|
+
setmaxAllowedGraphics(num: number): void;
|
|
206
|
+
deepClone(obj: any): void;
|
|
207
|
+
destroy(): void;
|
|
208
|
+
}
|
|
209
|
+
export {};
|
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
import d from "@arcgis/core/layers/GraphicsLayer";
|
|
2
|
+
import L from "@arcgis/core/widgets/Sketch/SketchViewModel";
|
|
3
|
+
import b from "@arcgis/core/widgets/Sketch";
|
|
4
|
+
import * as y from "@arcgis/core/geometry/support/webMercatorUtils.js";
|
|
5
|
+
import * as G from "@arcgis/core/geometry/geometryEngine.js";
|
|
6
|
+
import l from "@arcgis/core/Graphic";
|
|
7
|
+
import { v4 as P } from "uuid";
|
|
8
|
+
import k from "@arcgis/core/geometry/Polygon.js";
|
|
9
|
+
import x from "@arcgis/core/geometry/Polyline.js";
|
|
10
|
+
import A from "@turf/intersect";
|
|
11
|
+
import * as m from "@turf/helpers";
|
|
12
|
+
function w(c, e = []) {
|
|
13
|
+
if (c === null || typeof c != "object")
|
|
14
|
+
return c;
|
|
15
|
+
if (Object.prototype.toString.call(c) === "[object Date]")
|
|
16
|
+
return new Date(c);
|
|
17
|
+
if (Object.prototype.toString.call(c) === "[object RegExp]")
|
|
18
|
+
return new RegExp(c);
|
|
19
|
+
if (Object.prototype.toString.call(c) === "[object Error]")
|
|
20
|
+
return new Error(c);
|
|
21
|
+
const t = e.filter((s) => s.original === c)[0];
|
|
22
|
+
if (t)
|
|
23
|
+
return t.copy;
|
|
24
|
+
const i = Array.isArray(c) ? [] : {};
|
|
25
|
+
return e.push({
|
|
26
|
+
original: c,
|
|
27
|
+
copy: i
|
|
28
|
+
}), Object.keys(c).forEach((s) => {
|
|
29
|
+
i[s] = w(c[s], e);
|
|
30
|
+
}), i;
|
|
31
|
+
}
|
|
32
|
+
const S = {
|
|
33
|
+
maxAllowedGraphics: 0,
|
|
34
|
+
GraphicsLayer: {},
|
|
35
|
+
sketchvisibleElements: {},
|
|
36
|
+
sketchPosition: "top-left",
|
|
37
|
+
defaultsketchVisible: !0,
|
|
38
|
+
sketchViewModelItemSymbol: {}
|
|
39
|
+
}, u = {
|
|
40
|
+
type: "simple-line",
|
|
41
|
+
color: "#556DEA",
|
|
42
|
+
width: 2
|
|
43
|
+
}, f = {
|
|
44
|
+
type: "simple-fill",
|
|
45
|
+
// autocasts as new SimpleFillSymbol()
|
|
46
|
+
color: [227, 139, 79, 0.4],
|
|
47
|
+
outline: {
|
|
48
|
+
// autocasts as new SimpleLineSymbol()
|
|
49
|
+
color: [255, 255, 255],
|
|
50
|
+
width: 1
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
class C {
|
|
54
|
+
constructor(e, t) {
|
|
55
|
+
this.viewer = e, this.options = {
|
|
56
|
+
...S,
|
|
57
|
+
...t
|
|
58
|
+
}, this.graphicsLayer = new d({ ...this.options.GraphicsLayer }), this.TextgraphicsLayer = new d(), this.viewer.map.layers.add(this.graphicsLayer), this.viewer.map.layers.add(this.TextgraphicsLayer), this.init();
|
|
59
|
+
}
|
|
60
|
+
init() {
|
|
61
|
+
this.sketchViewModel = new L({
|
|
62
|
+
layer: this.graphicsLayer,
|
|
63
|
+
view: this.viewer,
|
|
64
|
+
updateOnGraphicClick: !0,
|
|
65
|
+
polylineSymbol: u,
|
|
66
|
+
polygonSymbol: f,
|
|
67
|
+
...this.options.sketchViewModelItemSymbol
|
|
68
|
+
});
|
|
69
|
+
const e = this.findLayerById("TrafficMarkings"), t = [];
|
|
70
|
+
e && t.push({ layer: e, enabled: !0 }), this.sketch = new b({
|
|
71
|
+
view: this.viewer,
|
|
72
|
+
viewModel: this.sketchViewModel,
|
|
73
|
+
layer: this.graphicsLayer,
|
|
74
|
+
visible: this.options.defaultsketchVisible,
|
|
75
|
+
snappingOptions: {
|
|
76
|
+
// autocasts to SnappingOptions()
|
|
77
|
+
enabled: !0,
|
|
78
|
+
// global snapping is turned on
|
|
79
|
+
// assigns a collection of FeatureSnappingLayerSource() and enables feature snapping on this layer
|
|
80
|
+
featureSources: t
|
|
81
|
+
}
|
|
82
|
+
}), this.sketch.visibleElements = {
|
|
83
|
+
...this.options.sketchvisibleElements
|
|
84
|
+
}, this.viewer.ui.add(this.sketch, this.options.sketchPosition);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 初始化绘图
|
|
88
|
+
*
|
|
89
|
+
* @param {*} data
|
|
90
|
+
* @param {string} [type='crossArea']
|
|
91
|
+
* @param {boolean} [reverse=false] 是否反转
|
|
92
|
+
* @returns
|
|
93
|
+
* @memberof SketchView
|
|
94
|
+
*/
|
|
95
|
+
initPoint(e, t = "all", i = !1) {
|
|
96
|
+
if (!e)
|
|
97
|
+
return;
|
|
98
|
+
const { crossArea: s, sectionArea: r } = e;
|
|
99
|
+
if (s && (t == "crossArea" || t == "all")) {
|
|
100
|
+
const o = this.initCrossArea(s);
|
|
101
|
+
this.graphicsLayer.add(o);
|
|
102
|
+
}
|
|
103
|
+
if (r && (t == "sectionArea" || t == "all")) {
|
|
104
|
+
const o = this.inintSectionArea(r, i);
|
|
105
|
+
this.graphicsLayer.addMany(o);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 初始化进口道融合区
|
|
110
|
+
*
|
|
111
|
+
* @param {any[]} data
|
|
112
|
+
* @memberof SketchView
|
|
113
|
+
*/
|
|
114
|
+
initEntranceFusionZone(e) {
|
|
115
|
+
const t = [], i = f;
|
|
116
|
+
e.map((s) => {
|
|
117
|
+
t.push(this.createPolygonGraphic(s, i, {}));
|
|
118
|
+
}), this.graphicsLayer.addMany(t);
|
|
119
|
+
}
|
|
120
|
+
initCrossArea(e) {
|
|
121
|
+
const t = f;
|
|
122
|
+
return this.createPolygonGraphic(e, t, {});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* 初始进出口道计算区域
|
|
126
|
+
*
|
|
127
|
+
* @param {*} data
|
|
128
|
+
* @param {boolean} [reverse=false] 是否反转
|
|
129
|
+
* @returns
|
|
130
|
+
* @memberof SketchView
|
|
131
|
+
*/
|
|
132
|
+
inintSectionArea(e, t = !1) {
|
|
133
|
+
const i = [], s = u, r = {
|
|
134
|
+
type: "simple-line",
|
|
135
|
+
color: [0, 0, 255],
|
|
136
|
+
width: 2
|
|
137
|
+
};
|
|
138
|
+
return Object.keys(e).map((o) => {
|
|
139
|
+
const a = e[o][0], n = e[o][1];
|
|
140
|
+
t && (a.reverse(), n.reverse());
|
|
141
|
+
const h = P(), p = this.createPolylineGraphic(a, s, {
|
|
142
|
+
type: "draw",
|
|
143
|
+
id: h
|
|
144
|
+
}), g = this.createPolylineGraphic(n, r, {
|
|
145
|
+
type: "shiftLine",
|
|
146
|
+
id: h
|
|
147
|
+
});
|
|
148
|
+
i.push(p, g);
|
|
149
|
+
}), i;
|
|
150
|
+
}
|
|
151
|
+
createPolylineGraphic(e, t, i) {
|
|
152
|
+
const s = new x({
|
|
153
|
+
paths: e
|
|
154
|
+
}), r = y.geographicToWebMercator(s);
|
|
155
|
+
return new l({
|
|
156
|
+
geometry: r,
|
|
157
|
+
// Add the geometry created in step 3
|
|
158
|
+
symbol: t,
|
|
159
|
+
// Add the symbol created in step 4
|
|
160
|
+
attributes: i
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
createPolygonGraphic(e, t, i) {
|
|
164
|
+
const s = new k({
|
|
165
|
+
rings: e
|
|
166
|
+
}), r = y.geographicToWebMercator(s);
|
|
167
|
+
return new l({
|
|
168
|
+
geometry: r,
|
|
169
|
+
// Add the geometry created in step 3
|
|
170
|
+
symbol: t,
|
|
171
|
+
// Add the symbol created in step 4
|
|
172
|
+
attributes: i
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
on(e) {
|
|
176
|
+
const t = this;
|
|
177
|
+
this.sketchViewModel.on("create", function(i) {
|
|
178
|
+
var r, o, a;
|
|
179
|
+
const s = t.graphicsLayer.graphics;
|
|
180
|
+
if ((r = t.options) != null && r.maxAllowedGraphics && s.length > ((o = t.options) == null ? void 0 : o.maxAllowedGraphics)) {
|
|
181
|
+
t.graphicsLayer.remove(i.graphic), console.log("已达到最大图形数量,无法继续绘制!");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (i.state === "complete" && ((a = i.graphic) != null && a.geometry)) {
|
|
185
|
+
console.log(i.graphic);
|
|
186
|
+
const n = i.graphic.geometry;
|
|
187
|
+
i.graphic.setAttribute("type", "draw"), i.graphic.setAttribute("id", new Date().getTime());
|
|
188
|
+
const h = t.getGraphicPoint(n);
|
|
189
|
+
e && e("create", h, i);
|
|
190
|
+
}
|
|
191
|
+
}), this.sketchViewModel.on("update", function(i) {
|
|
192
|
+
if (console.log("update", i), i.aborted) {
|
|
193
|
+
const s = i.graphics[0];
|
|
194
|
+
t.graphicsLayer.remove(s);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (i.state === "complete" && i.graphics.length > 0) {
|
|
198
|
+
const r = i.graphics[0].geometry, o = t.getGraphicPoint(r);
|
|
199
|
+
e && e("update", o, i);
|
|
200
|
+
}
|
|
201
|
+
}), this.sketchViewModel.on("delete", function(i) {
|
|
202
|
+
if (console.log("delete", i, t.graphicsLayer.graphics), i.graphics.length > 0) {
|
|
203
|
+
const r = i.graphics[0].geometry, o = t.getGraphicPoint(r);
|
|
204
|
+
e && e("delete", o, i);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* 获取当前绘制的计算区域
|
|
210
|
+
* @returns
|
|
211
|
+
*/
|
|
212
|
+
graphicPoint() {
|
|
213
|
+
const e = [];
|
|
214
|
+
return this.graphicsLayer.graphics.map((t) => {
|
|
215
|
+
var r;
|
|
216
|
+
const i = t.geometry, s = this.getGraphicPoint(i);
|
|
217
|
+
e.push({
|
|
218
|
+
point: s,
|
|
219
|
+
type: (r = t.attributes) == null ? void 0 : r.type,
|
|
220
|
+
attributes: t.attributes
|
|
221
|
+
});
|
|
222
|
+
}), e;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* 获取进口道区域
|
|
226
|
+
*
|
|
227
|
+
* @memberof SketchView
|
|
228
|
+
*/
|
|
229
|
+
getEntranceRoad() {
|
|
230
|
+
const e = {}, t = this.graphicPoint().filter(
|
|
231
|
+
(n) => n.point.type === "polyline"
|
|
232
|
+
);
|
|
233
|
+
if (console.log(
|
|
234
|
+
"🚀 ~ file: sketchView.ts:378 ~ SketchView ~ getEntranceRoad ~ graphics:",
|
|
235
|
+
t
|
|
236
|
+
), !t.length)
|
|
237
|
+
return !1;
|
|
238
|
+
const i = t.filter((n) => n.type == "draw"), s = t.filter((n) => n.type == "shiftLine");
|
|
239
|
+
if (s.length == 0)
|
|
240
|
+
throw "未绘制平移!";
|
|
241
|
+
if (i.length != s.length)
|
|
242
|
+
throw "绘制的线和平移的线数量不一致!";
|
|
243
|
+
const r = i.sort((n, h) => n.point.angle - h.point.angle), o = r.findIndex((n) => n.point.angle > 135);
|
|
244
|
+
return [
|
|
245
|
+
...r.slice(o),
|
|
246
|
+
...r.slice(0, o).reverse()
|
|
247
|
+
].map((n, h) => {
|
|
248
|
+
const p = s.find(
|
|
249
|
+
(g) => g.attributes.id == n.attributes.id
|
|
250
|
+
);
|
|
251
|
+
if (!p)
|
|
252
|
+
throw "绘制的线和平移的线不匹配!";
|
|
253
|
+
console.log(
|
|
254
|
+
"🚀 ~ file: sketchView.ts:393 ~ SketchView ~ getEntranceRoad ~ m:",
|
|
255
|
+
n,
|
|
256
|
+
p
|
|
257
|
+
), e[h + 1] = {
|
|
258
|
+
0: [n.point.paths[0], n.point.paths[n.point.paths.length - 1]],
|
|
259
|
+
1: [
|
|
260
|
+
p.point.paths[0],
|
|
261
|
+
p.point.paths[p.point.paths.length - 1]
|
|
262
|
+
]
|
|
263
|
+
};
|
|
264
|
+
}), e;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* 获进口道融合区
|
|
268
|
+
*
|
|
269
|
+
* @param {armData} armData 进口道编号区域
|
|
270
|
+
* @param {number[]} armNoList 进口道编号列表
|
|
271
|
+
* @returns
|
|
272
|
+
* @memberof SketchView
|
|
273
|
+
*/
|
|
274
|
+
getEntranceFusionZone(e) {
|
|
275
|
+
const t = [], i = {};
|
|
276
|
+
this.graphicsLayer.graphics.map((r) => {
|
|
277
|
+
var n;
|
|
278
|
+
const o = r.geometry, a = this.getGraphicPoint(o, !1);
|
|
279
|
+
t.push({
|
|
280
|
+
point: a,
|
|
281
|
+
type: (n = r.attributes) == null ? void 0 : n.type,
|
|
282
|
+
attributes: r.attributes
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
const s = t;
|
|
286
|
+
return e.map((r, o) => {
|
|
287
|
+
i[r] = t[o];
|
|
288
|
+
}), { graphics: i, rawdata: s };
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* 获取进口道所在的进口道编号
|
|
292
|
+
*
|
|
293
|
+
* @param {armData} armData 进口道编号区域
|
|
294
|
+
* @param {*} graphicPpolygon 绘制的区域
|
|
295
|
+
* @returns
|
|
296
|
+
* @memberof SketchView
|
|
297
|
+
*/
|
|
298
|
+
getIntersectionArea(e, t) {
|
|
299
|
+
const i = Object.keys(e);
|
|
300
|
+
let s = !1;
|
|
301
|
+
for (let r = 0; r < i.length; r++) {
|
|
302
|
+
const o = i[r], a = e[o];
|
|
303
|
+
if (A(
|
|
304
|
+
m.polygon(t),
|
|
305
|
+
m.polygon(a)
|
|
306
|
+
)) {
|
|
307
|
+
s = o;
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return s;
|
|
312
|
+
}
|
|
313
|
+
filterData(e) {
|
|
314
|
+
const t = w(e);
|
|
315
|
+
return t.length > 0 && t[0][0] === t[t.length - 1][0] && t[0][1] === t[t.length - 1][1] && t.pop(), t;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
*
|
|
320
|
+
* @private
|
|
321
|
+
* @param {*} geometry
|
|
322
|
+
* @param {boolean} [isfilterData=true] 是否过滤首尾相同点数据
|
|
323
|
+
* @returns
|
|
324
|
+
* @memberof SketchView
|
|
325
|
+
*/
|
|
326
|
+
getGraphicPoint(e, t = !0) {
|
|
327
|
+
const i = y.webMercatorToGeographic(e);
|
|
328
|
+
let s;
|
|
329
|
+
if (e.type === "point")
|
|
330
|
+
s = {
|
|
331
|
+
type: e.type,
|
|
332
|
+
x: i.x,
|
|
333
|
+
y: i.y
|
|
334
|
+
};
|
|
335
|
+
else if (e.type === "polyline") {
|
|
336
|
+
s = {
|
|
337
|
+
type: e.type,
|
|
338
|
+
paths: []
|
|
339
|
+
}, i.paths.forEach((n) => {
|
|
340
|
+
let h = n;
|
|
341
|
+
t && (h = this.filterData(n)), h.forEach((p) => {
|
|
342
|
+
s.paths.push(p);
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
const r = {
|
|
346
|
+
x: s.paths[0][0],
|
|
347
|
+
y: s.paths[0][1]
|
|
348
|
+
}, o = {
|
|
349
|
+
x: s.paths[s.paths.length - 1][0],
|
|
350
|
+
y: s.paths[s.paths.length - 1][1]
|
|
351
|
+
}, a = this.getAngle(r, o);
|
|
352
|
+
s.angle = a;
|
|
353
|
+
} else
|
|
354
|
+
e.type === "polygon" && (s = {
|
|
355
|
+
type: e.type,
|
|
356
|
+
rings: []
|
|
357
|
+
}, i.rings.forEach((r) => {
|
|
358
|
+
let o = r;
|
|
359
|
+
t && (o = this.filterData(r)), o.forEach((a) => {
|
|
360
|
+
s.rings.push(a);
|
|
361
|
+
});
|
|
362
|
+
}));
|
|
363
|
+
return s;
|
|
364
|
+
}
|
|
365
|
+
close() {
|
|
366
|
+
this.sketch.visible = !1;
|
|
367
|
+
}
|
|
368
|
+
show() {
|
|
369
|
+
this.sketch.visible = !0;
|
|
370
|
+
}
|
|
371
|
+
removeAll() {
|
|
372
|
+
this.graphicsLayer.removeAll();
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* 获取两点的角度
|
|
376
|
+
*
|
|
377
|
+
* @param {ITPoint} startPoint
|
|
378
|
+
* @param {ITPoint} endPoint
|
|
379
|
+
* @returns
|
|
380
|
+
* @memberof SketchView
|
|
381
|
+
*/
|
|
382
|
+
getAngle(e, t) {
|
|
383
|
+
const i = t.x - e.x, s = t.y - e.y;
|
|
384
|
+
return Math.atan2(s, i) * 180 / Math.PI;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* 获取线平移后的坐标
|
|
388
|
+
*
|
|
389
|
+
* @param {Polyline} lineGeometry 线的几何图形
|
|
390
|
+
* @param {number} distance 平移的距离,默认米
|
|
391
|
+
* @param {LinearUnits} [offsetUnit='meters']
|
|
392
|
+
* @returns
|
|
393
|
+
* @memberof SketchView
|
|
394
|
+
*/
|
|
395
|
+
getshiftLine(e, t, i = "meters") {
|
|
396
|
+
const s = e, r = -t;
|
|
397
|
+
return G.offset(
|
|
398
|
+
s,
|
|
399
|
+
r,
|
|
400
|
+
i
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* 设置线的平移
|
|
405
|
+
*
|
|
406
|
+
* @param {number} distance 平移的距离,默认米
|
|
407
|
+
* @param {LinearUnits} [offsetUnit='meters'] 平移的单位
|
|
408
|
+
* @param {*} symbol 线的样式
|
|
409
|
+
* @memberof SketchView
|
|
410
|
+
*/
|
|
411
|
+
setshiftLine(e, t = "meters", i) {
|
|
412
|
+
i || (i = {
|
|
413
|
+
type: "simple-line",
|
|
414
|
+
color: [0, 0, 255],
|
|
415
|
+
width: 2
|
|
416
|
+
}), this.removeShiftLine(), this.graphicsLayer.graphics.map((s) => {
|
|
417
|
+
const r = s.geometry, o = s.attributes;
|
|
418
|
+
if ((r == null ? void 0 : r.type) === "polyline" && (o == null ? void 0 : o.type) === "draw") {
|
|
419
|
+
const a = o.id, n = this.getshiftLine(
|
|
420
|
+
r,
|
|
421
|
+
e,
|
|
422
|
+
t
|
|
423
|
+
), h = new l({
|
|
424
|
+
geometry: n,
|
|
425
|
+
symbol: i,
|
|
426
|
+
attributes: { type: "shiftLine", id: a }
|
|
427
|
+
});
|
|
428
|
+
this.graphicsLayer.add(h);
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* 移除平移线
|
|
434
|
+
*
|
|
435
|
+
* @memberof SketchView
|
|
436
|
+
*/
|
|
437
|
+
removeShiftLine() {
|
|
438
|
+
const e = [];
|
|
439
|
+
this.graphicsLayer.graphics.map((t) => {
|
|
440
|
+
const i = t.attributes;
|
|
441
|
+
(i == null ? void 0 : i.type) === "shiftLine" && e.push(t);
|
|
442
|
+
}), this.graphicsLayer.removeMany(e);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* 移除绘制的线
|
|
446
|
+
*
|
|
447
|
+
* @memberof SketchView
|
|
448
|
+
*/
|
|
449
|
+
removedraw() {
|
|
450
|
+
const e = [];
|
|
451
|
+
this.graphicsLayer.graphics.map((t) => {
|
|
452
|
+
const i = t.attributes;
|
|
453
|
+
(i == null ? void 0 : i.type) === "draw" && e.push(t);
|
|
454
|
+
}), this.graphicsLayer.removeMany(e);
|
|
455
|
+
}
|
|
456
|
+
addGraphic(e, t = {
|
|
457
|
+
type: "simple-line",
|
|
458
|
+
color: [0, 0, 255],
|
|
459
|
+
width: 2
|
|
460
|
+
}, i) {
|
|
461
|
+
const s = new l({
|
|
462
|
+
geometry: e,
|
|
463
|
+
symbol: t,
|
|
464
|
+
attributes: i
|
|
465
|
+
});
|
|
466
|
+
this.graphicsLayer.add(s);
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* 获取方向
|
|
470
|
+
*
|
|
471
|
+
* @param {ITPoint} startPoint 起点
|
|
472
|
+
* @param {ITPoint} endPoint 终点
|
|
473
|
+
* @returns
|
|
474
|
+
* @memberof SketchView
|
|
475
|
+
*/
|
|
476
|
+
getDirection(e, t) {
|
|
477
|
+
const i = t.x - e.x, s = t.y - e.y, o = Math.atan2(s, i) * 180 / Math.PI;
|
|
478
|
+
return o >= -45 && o <= 45 ? 0 : o > 45 && o <= 135 ? 1 : o > 135 || o <= -135 ? 2 : 3;
|
|
479
|
+
}
|
|
480
|
+
findLayerById(e) {
|
|
481
|
+
return this.viewer.map.findLayerById(e);
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* 根据id查找平移线graphic
|
|
485
|
+
*
|
|
486
|
+
* @param {string} id
|
|
487
|
+
* @returns
|
|
488
|
+
* @memberof SketchView
|
|
489
|
+
*/
|
|
490
|
+
findShiftLineGraphicsById(e) {
|
|
491
|
+
return this.graphicsLayer.graphics.find((i) => i.attributes.id === e && i.attributes.type === "shiftLine");
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* 删除指定的图形
|
|
495
|
+
* @param graphic 删除指定的图形
|
|
496
|
+
*/
|
|
497
|
+
remove(e) {
|
|
498
|
+
this.graphicsLayer.remove(e);
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* 设置最大允许绘制的图形数量
|
|
502
|
+
* @param num 数量
|
|
503
|
+
*/
|
|
504
|
+
setmaxAllowedGraphics(e) {
|
|
505
|
+
this.options.maxAllowedGraphics = e === 0 ? void 0 : e;
|
|
506
|
+
}
|
|
507
|
+
deepClone(e) {
|
|
508
|
+
}
|
|
509
|
+
destroy() {
|
|
510
|
+
var e, t;
|
|
511
|
+
this.viewer.map.remove(this.graphicsLayer), this.viewer.map.remove(this.TextgraphicsLayer), (e = this.sketch) == null || e.destroy(), (t = this.sketchViewModel) == null || t.destroy();
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
export {
|
|
515
|
+
C as default
|
|
516
|
+
};
|