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