@vunk/form 1.1.21 → 1.1.24

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.
Files changed (33) hide show
  1. package/components/esri-input-geojson/index.css +38 -0
  2. package/components/esri-input-geojson/index.d.ts +5 -0
  3. package/components/esri-input-geojson/index.js +1526 -0
  4. package/components/esri-input-geojson/src/append.vue.d.ts +30 -0
  5. package/components/esri-input-geojson/src/const.d.ts +8 -0
  6. package/components/esri-input-geojson/src/const.js +29 -0
  7. package/components/esri-input-geojson/src/ctx.d.ts +213 -0
  8. package/components/esri-input-geojson/src/ctx.js +90 -0
  9. package/components/esri-input-geojson/src/index.vue.d.ts +494 -0
  10. package/components/esri-input-geojson/src/types.d.ts +13 -0
  11. package/components/esri-input-geojson/src/types.js +1 -0
  12. package/components/esri-input-geojson/src/viewer.vue.d.ts +12 -0
  13. package/components/select/src/ctx.d.ts +4 -0
  14. package/components/select/src/index.vue.d.ts +16 -0
  15. package/components/slider/index.js +1 -4
  16. package/components/slider/src/ctx.d.ts +11 -15
  17. package/components/slider/src/ctx.js +1 -4
  18. package/components/slider/src/index.vue.d.ts +2 -9
  19. package/components/switch/index.js +1 -4
  20. package/components/switch/src/ctx.d.ts +25 -17
  21. package/components/switch/src/ctx.js +1 -4
  22. package/components/switch/src/index.vue.d.ts +28 -9
  23. package/components/templates-esri/index.d.ts +4 -0
  24. package/components/templates-esri/index.js +64 -0
  25. package/components/templates-esri/src/ctx.d.ts +11 -0
  26. package/components/templates-esri/src/ctx.js +11 -0
  27. package/components/templates-esri/src/index.vue.d.ts +20 -0
  28. package/components/templates-esri/src/types.d.ts +2 -0
  29. package/components/templates-esri/src/types.js +1 -0
  30. package/index.css +39 -0
  31. package/package.json +1 -1
  32. package/shared/element-plus/ctx.d.ts +1 -1
  33. package/shared/types/source/index.d.ts +2 -1
@@ -0,0 +1,1526 @@
1
+ import { openBlock, createElementBlock, createElementVNode, defineComponent, resolveComponent, createBlock, withCtx, createVNode, createCommentVNode, provide, renderSlot, shallowRef, computed, onMounted, ref, mergeProps, toHandlers, withDirectives, vShow } from 'vue';
2
+ import { _VkfInputCtx, VkfInput } from '@vunk/form/components/input';
3
+ import { EMPTY_FEATURE_COLLECTION } from '@vumap/core/shared/static';
4
+ import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
5
+ import { ElButton, ElIcon, ElButtonGroup, ElUpload, ElMessage } from 'element-plus';
6
+ import { VaTdtBasemap, VaMapView, VaSketch, VaGraphicsLayer } from '@vuesri/core';
7
+ import MapView from '@arcgis/core/views/MapView';
8
+ import SceneView from '@arcgis/core/views/SceneView';
9
+ import { VkAsyncTeleport } from '@vunk/core';
10
+ import Graphic from '@arcgis/core/Graphic';
11
+ import { useComputedReadonly } from '@vunk/form/composables';
12
+
13
+ var __defProp = Object.defineProperty;
14
+ var __defProps = Object.defineProperties;
15
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
16
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
19
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
20
+ var __spreadValues = (a, b) => {
21
+ for (var prop in b || (b = {}))
22
+ if (__hasOwnProp.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ if (__getOwnPropSymbols)
25
+ for (var prop of __getOwnPropSymbols(b)) {
26
+ if (__propIsEnum.call(b, prop))
27
+ __defNormalProp(a, prop, b[prop]);
28
+ }
29
+ return a;
30
+ };
31
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
32
+ const props = __spreadProps(__spreadValues({}, _VkfInputCtx.props), {
33
+ readonly: {
34
+ type: Boolean,
35
+ default: void 0
36
+ },
37
+ view: {
38
+ type: Object
39
+ },
40
+ editTypes: {
41
+ type: [Array, String],
42
+ default: () => "polygon"
43
+ },
44
+ viewModelActiveFillSymbol: {
45
+ type: Object,
46
+ default: () => ({
47
+ type: "simple-fill",
48
+ color: [0, 0, 0, 0],
49
+ style: "solid",
50
+ outline: {
51
+ color: [255, 0, 0, 1],
52
+ width: 2,
53
+ style: "dash"
54
+ }
55
+ })
56
+ },
57
+ viewModelActiveLineSymbol: null,
58
+ viewModelActivePointSymbol: null,
59
+ modelValue: {
60
+ type: Object,
61
+ default: () => EMPTY_FEATURE_COLLECTION
62
+ },
63
+ multiple: {
64
+ type: Boolean,
65
+ default: true
66
+ },
67
+ mapTo: {
68
+ type: [Object, String],
69
+ default: void 0
70
+ },
71
+ skipSave: {
72
+ type: Boolean,
73
+ default: false
74
+ },
75
+ showMap: {
76
+ type: Boolean,
77
+ default: false
78
+ },
79
+ dialogEdit: {
80
+ type: Boolean,
81
+ default: true
82
+ },
83
+ dialogEditFullscreen: {
84
+ type: Boolean,
85
+ default: true
86
+ },
87
+ dialogEditTitle: {
88
+ type: String,
89
+ default: "\u7ED8\u5236\u56FE\u6591"
90
+ }
91
+ });
92
+ bindPropsFactory(props);
93
+ const emits = __spreadProps(__spreadValues({}, _VkfInputCtx.emits), {
94
+ "update:modelValue": (e) => e
95
+ });
96
+ onEmitsFactory(emits);
97
+
98
+ var EDIT_TYPE = /* @__PURE__ */ ((EDIT_TYPE2) => {
99
+ EDIT_TYPE2["POINT"] = "point";
100
+ EDIT_TYPE2["POLYGON"] = "polygon";
101
+ EDIT_TYPE2["LINE_STRING"] = "line_string";
102
+ return EDIT_TYPE2;
103
+ })(EDIT_TYPE || {});
104
+ const EDIT_TYPE_OPTIONS = [
105
+ {
106
+ label: "\u70B9",
107
+ value: "point" /* POINT */,
108
+ availableCreatureTools: ["point"]
109
+ },
110
+ {
111
+ label: "\u7EBF",
112
+ value: "line_string" /* LINE_STRING */,
113
+ availableCreatureTools: ["polyline"]
114
+ },
115
+ {
116
+ label: "\u9762",
117
+ value: "polygon" /* POLYGON */,
118
+ availableCreatureTools: ["polygon", "circle", "rectangle"]
119
+ }
120
+ ];
121
+ const EDIT_TYPE_REFLECT = EDIT_TYPE_OPTIONS.reduce((acc, cur) => {
122
+ acc[cur.value] = cur;
123
+ return acc;
124
+ }, {});
125
+
126
+ /*! Element Plus Icons Vue v2.1.0 */
127
+
128
+ // unplugin-vue:/plugin-vue/export-helper
129
+ var export_helper_default = (sfc, props) => {
130
+ let target = sfc.__vccOpts || sfc;
131
+ for (let [key, val] of props)
132
+ target[key] = val;
133
+ return target;
134
+ };
135
+
136
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/document-checked.vue?vue&type=script&lang.ts
137
+ var document_checked_vue_vue_type_script_lang_default = {
138
+ name: "DocumentChecked"
139
+ };
140
+ var _hoisted_186 = {
141
+ xmlns: "http://www.w3.org/2000/svg",
142
+ viewBox: "0 0 1024 1024"
143
+ }, _hoisted_286 = /* @__PURE__ */ createElementVNode(
144
+ "path",
145
+ {
146
+ fill: "currentColor",
147
+ d: "M805.504 320 640 154.496V320h165.504zM832 384H576V128H192v768h640V384zM160 64h480l256 256v608a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V96a32 32 0 0 1 32-32zm318.4 582.144 180.992-180.992L704.64 510.4 478.4 736.64 320 578.304l45.248-45.312L478.4 646.144z"
148
+ },
149
+ null,
150
+ -1
151
+ /* HOISTED */
152
+ ), _hoisted_385 = [
153
+ _hoisted_286
154
+ ];
155
+ function _sfc_render86(_ctx, _cache, $props, $setup, $data, $options) {
156
+ return openBlock(), createElementBlock("svg", _hoisted_186, _hoisted_385);
157
+ }
158
+ var document_checked_default = /* @__PURE__ */ export_helper_default(document_checked_vue_vue_type_script_lang_default, [["render", _sfc_render86], ["__file", "document-checked.vue"]]);
159
+
160
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/edit.vue?vue&type=script&lang.ts
161
+ var edit_vue_vue_type_script_lang_default = {
162
+ name: "Edit"
163
+ };
164
+ var _hoisted_194 = {
165
+ xmlns: "http://www.w3.org/2000/svg",
166
+ viewBox: "0 0 1024 1024"
167
+ }, _hoisted_294 = /* @__PURE__ */ createElementVNode(
168
+ "path",
169
+ {
170
+ fill: "currentColor",
171
+ d: "M832 512a32 32 0 1 1 64 0v352a32 32 0 0 1-32 32H160a32 32 0 0 1-32-32V160a32 32 0 0 1 32-32h352a32 32 0 0 1 0 64H192v640h640V512z"
172
+ },
173
+ null,
174
+ -1
175
+ /* HOISTED */
176
+ ), _hoisted_393 = /* @__PURE__ */ createElementVNode(
177
+ "path",
178
+ {
179
+ fill: "currentColor",
180
+ d: "m469.952 554.24 52.8-7.552L847.104 222.4a32 32 0 1 0-45.248-45.248L477.44 501.44l-7.552 52.8zm422.4-422.4a96 96 0 0 1 0 135.808l-331.84 331.84a32 32 0 0 1-18.112 9.088L436.8 623.68a32 32 0 0 1-36.224-36.224l15.104-105.6a32 32 0 0 1 9.024-18.112l331.904-331.84a96 96 0 0 1 135.744 0z"
181
+ },
182
+ null,
183
+ -1
184
+ /* HOISTED */
185
+ ), _hoisted_431 = [
186
+ _hoisted_294,
187
+ _hoisted_393
188
+ ];
189
+ function _sfc_render94(_ctx, _cache, $props, $setup, $data, $options) {
190
+ return openBlock(), createElementBlock("svg", _hoisted_194, _hoisted_431);
191
+ }
192
+ var edit_default = /* @__PURE__ */ export_helper_default(edit_vue_vue_type_script_lang_default, [["render", _sfc_render94], ["__file", "edit.vue"]]);
193
+
194
+ // unplugin-vue:/home/runner/work/element-plus-icons/element-plus-icons/packages/vue/src/components/upload.vue?vue&type=script&lang.ts
195
+ var upload_vue_vue_type_script_lang_default = {
196
+ name: "Upload"
197
+ };
198
+ var _hoisted_1275 = {
199
+ xmlns: "http://www.w3.org/2000/svg",
200
+ viewBox: "0 0 1024 1024"
201
+ }, _hoisted_2275 = /* @__PURE__ */ createElementVNode(
202
+ "path",
203
+ {
204
+ fill: "currentColor",
205
+ d: "M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64zm384-578.304V704h-64V247.296L237.248 490.048 192 444.8 508.8 128l316.8 316.8-45.312 45.248L544 253.696z"
206
+ },
207
+ null,
208
+ -1
209
+ /* HOISTED */
210
+ ), _hoisted_3274 = [
211
+ _hoisted_2275
212
+ ];
213
+ function _sfc_render275(_ctx, _cache, $props, $setup, $data, $options) {
214
+ return openBlock(), createElementBlock("svg", _hoisted_1275, _hoisted_3274);
215
+ }
216
+ var upload_default = /* @__PURE__ */ export_helper_default(upload_vue_vue_type_script_lang_default, [["render", _sfc_render275], ["__file", "upload.vue"]]);
217
+
218
+ var _export_sfc = (sfc, props) => {
219
+ const target = sfc.__vccOpts || sfc;
220
+ for (const [key, val] of props) {
221
+ target[key] = val;
222
+ }
223
+ return target;
224
+ };
225
+
226
+ const _sfc_main$2 = defineComponent({
227
+ components: {
228
+ ElButton,
229
+ ElIcon,
230
+ ElButtonGroup,
231
+ Upload: upload_default,
232
+ Edit: edit_default,
233
+ ElUpload
234
+ },
235
+ props: {
236
+ disabled: Boolean,
237
+ dialog: Boolean,
238
+ upload: {
239
+ type: Boolean,
240
+ default: true
241
+ }
242
+ },
243
+ emits: {
244
+ upload: (e) => e,
245
+ edit: null
246
+ },
247
+ methods: {
248
+ getFile(file) {
249
+ this.$emit("upload", file);
250
+ },
251
+ uploadClick(e) {
252
+ const target = e.target.querySelector("input[type=file]");
253
+ if (!target)
254
+ return;
255
+ target.click();
256
+ }
257
+ }
258
+ });
259
+ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
260
+ const _component_Upload = resolveComponent("Upload");
261
+ const _component_ElIcon = resolveComponent("ElIcon");
262
+ const _component_ElUpload = resolveComponent("ElUpload");
263
+ const _component_Edit = resolveComponent("Edit");
264
+ const _component_ElButton = resolveComponent("ElButton");
265
+ const _component_ElButtonGroup = resolveComponent("ElButtonGroup");
266
+ return openBlock(), createBlock(_component_ElButtonGroup, null, {
267
+ default: withCtx(() => [
268
+ _ctx.upload ? (openBlock(), createBlock(_component_ElUpload, {
269
+ key: 0,
270
+ class: "el-button el-button--default vkf-esri-input-geojson__upload",
271
+ action: "",
272
+ accept: "file",
273
+ multiple: false,
274
+ "show-file-list": false,
275
+ "auto-upload": false,
276
+ "on-change": _ctx.getFile,
277
+ disabled: _ctx.disabled,
278
+ onClick: _ctx.uploadClick
279
+ }, {
280
+ default: withCtx(() => [
281
+ createVNode(_component_ElIcon, { color: "var(--el-color-primary)" }, {
282
+ default: withCtx(() => [
283
+ createVNode(_component_Upload)
284
+ ]),
285
+ _: 1
286
+ }, 8, ["color"])
287
+ ]),
288
+ _: 1
289
+ }, 8, ["on-change", "disabled", "onClick"])) : createCommentVNode("v-if", true),
290
+ _ctx.dialog ? (openBlock(), createBlock(_component_ElButton, {
291
+ key: 1,
292
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("edit")),
293
+ disabled: _ctx.disabled
294
+ }, {
295
+ default: withCtx(() => [
296
+ createVNode(_component_ElIcon, { color: "var(--el-color-primary)" }, {
297
+ default: withCtx(() => [
298
+ createVNode(_component_Edit)
299
+ ]),
300
+ _: 1
301
+ }, 8, ["color"])
302
+ ]),
303
+ _: 1
304
+ }, 8, ["disabled"])) : createCommentVNode("v-if", true)
305
+ ]),
306
+ _: 1
307
+ });
308
+ }
309
+ var AppendVue = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2], ["__file", "append.vue"]]);
310
+
311
+ const _sfc_main$1 = defineComponent({
312
+ components: {
313
+ VaTdtBasemap,
314
+ VaMapView
315
+ },
316
+ props: {
317
+ view: {
318
+ type: Object
319
+ }
320
+ },
321
+ setup(props) {
322
+ if (props.view) {
323
+ provide("vaView", props.view);
324
+ if (props.view instanceof MapView) {
325
+ provide("vaMapView", props.view);
326
+ }
327
+ if (props.view instanceof SceneView) {
328
+ provide("vaSceneView", props.view);
329
+ }
330
+ }
331
+ return {};
332
+ }
333
+ });
334
+ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
335
+ const _component_VaTdtBasemap = resolveComponent("VaTdtBasemap");
336
+ const _component_VaMapView = resolveComponent("VaMapView");
337
+ return !_ctx.view ? (openBlock(), createBlock(_component_VaMapView, { key: 0 }, {
338
+ default: withCtx(() => [
339
+ createVNode(_component_VaTdtBasemap),
340
+ renderSlot(_ctx.$slots, "default")
341
+ ]),
342
+ _: 3
343
+ })) : renderSlot(_ctx.$slots, "default", { key: 1 });
344
+ }
345
+ var ViewerVue = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1], ["__file", "viewer.vue"]]);
346
+
347
+ function array_cancel() {
348
+ this._array = null;
349
+ return Promise.resolve();
350
+ }
351
+
352
+ function array_read() {
353
+ var array = this._array;
354
+ this._array = null;
355
+ return Promise.resolve(array ? {done: false, value: array} : {done: true, value: undefined});
356
+ }
357
+
358
+ function array(array) {
359
+ return new ArraySource(array instanceof Uint8Array ? array : new Uint8Array(array));
360
+ }
361
+
362
+ function ArraySource(array) {
363
+ this._array = array;
364
+ }
365
+
366
+ ArraySource.prototype.read = array_read;
367
+ ArraySource.prototype.cancel = array_cancel;
368
+
369
+ function fetchPath(url) {
370
+ return fetch(url).then(function(response) {
371
+ return response.body && response.body.getReader
372
+ ? response.body.getReader()
373
+ : response.arrayBuffer().then(array);
374
+ });
375
+ }
376
+
377
+ function requestPath(url) {
378
+ return new Promise(function(resolve, reject) {
379
+ var request = new XMLHttpRequest;
380
+ request.responseType = "arraybuffer";
381
+ request.onload = function() { resolve(array(request.response)); };
382
+ request.onerror = reject;
383
+ request.ontimeout = reject;
384
+ request.open("GET", url, true);
385
+ request.send();
386
+ });
387
+ }
388
+
389
+ function path(path) {
390
+ return (typeof fetch === "function" ? fetchPath : requestPath)(path);
391
+ }
392
+
393
+ function stream(source) {
394
+ return typeof source.read === "function" ? source : source.getReader();
395
+ }
396
+
397
+ var empty = new Uint8Array(0);
398
+
399
+ function slice_cancel() {
400
+ return this._source.cancel();
401
+ }
402
+
403
+ function concat$1(a, b) {
404
+ if (!a.length) return b;
405
+ if (!b.length) return a;
406
+ var c = new Uint8Array(a.length + b.length);
407
+ c.set(a);
408
+ c.set(b, a.length);
409
+ return c;
410
+ }
411
+
412
+ function slice_read() {
413
+ var that = this, array = that._array.subarray(that._index);
414
+ return that._source.read().then(function(result) {
415
+ that._array = empty;
416
+ that._index = 0;
417
+ return result.done ? (array.length > 0
418
+ ? {done: false, value: array}
419
+ : {done: true, value: undefined})
420
+ : {done: false, value: concat$1(array, result.value)};
421
+ });
422
+ }
423
+
424
+ function slice_slice(length) {
425
+ if ((length |= 0) < 0) throw new Error("invalid length");
426
+ var that = this, index = this._array.length - this._index;
427
+
428
+ // If the request fits within the remaining buffer, resolve it immediately.
429
+ if (this._index + length <= this._array.length) {
430
+ return Promise.resolve(this._array.subarray(this._index, this._index += length));
431
+ }
432
+
433
+ // Otherwise, read chunks repeatedly until the request is fulfilled.
434
+ var array = new Uint8Array(length);
435
+ array.set(this._array.subarray(this._index));
436
+ return (function read() {
437
+ return that._source.read().then(function(result) {
438
+
439
+ // When done, it’s possible the request wasn’t fully fullfilled!
440
+ // If so, the pre-allocated array is too big and needs slicing.
441
+ if (result.done) {
442
+ that._array = empty;
443
+ that._index = 0;
444
+ return index > 0 ? array.subarray(0, index) : null;
445
+ }
446
+
447
+ // If this chunk fulfills the request, return the resulting array.
448
+ if (index + result.value.length >= length) {
449
+ that._array = result.value;
450
+ that._index = length - index;
451
+ array.set(result.value.subarray(0, length - index), index);
452
+ return array;
453
+ }
454
+
455
+ // Otherwise copy this chunk into the array, then read the next chunk.
456
+ array.set(result.value, index);
457
+ index += result.value.length;
458
+ return read();
459
+ });
460
+ })();
461
+ }
462
+
463
+ function slice(source) {
464
+ return typeof source.slice === "function" ? source :
465
+ new SliceSource(typeof source.read === "function" ? source
466
+ : source.getReader());
467
+ }
468
+
469
+ function SliceSource(source) {
470
+ this._source = source;
471
+ this._array = empty;
472
+ this._index = 0;
473
+ }
474
+
475
+ SliceSource.prototype.read = slice_read;
476
+ SliceSource.prototype.slice = slice_slice;
477
+ SliceSource.prototype.cancel = slice_cancel;
478
+
479
+ function dbf_cancel() {
480
+ return this._source.cancel();
481
+ }
482
+
483
+ function readBoolean(value) {
484
+ return /^[nf]$/i.test(value) ? false
485
+ : /^[yt]$/i.test(value) ? true
486
+ : null;
487
+ }
488
+
489
+ function readDate(value) {
490
+ return new Date(+value.substring(0, 4), value.substring(4, 6) - 1, +value.substring(6, 8));
491
+ }
492
+
493
+ function readNumber(value) {
494
+ return !(value = value.trim()) || isNaN(value = +value) ? null : value;
495
+ }
496
+
497
+ function readString(value) {
498
+ return value.trim() || null;
499
+ }
500
+
501
+ var types$1 = {
502
+ B: readNumber,
503
+ C: readString,
504
+ D: readDate,
505
+ F: readNumber,
506
+ L: readBoolean,
507
+ M: readNumber,
508
+ N: readNumber
509
+ };
510
+
511
+ function dbf_read() {
512
+ var that = this, i = 1;
513
+ return that._source.slice(that._recordLength).then(function(value) {
514
+ return value && (value[0] !== 0x1a) ? {done: false, value: that._fields.reduce(function(p, f) {
515
+ p[f.name] = types$1[f.type](that._decode(value.subarray(i, i += f.length)));
516
+ return p;
517
+ }, {})} : {done: true, value: undefined};
518
+ });
519
+ }
520
+
521
+ function view(array) {
522
+ return new DataView(array.buffer, array.byteOffset, array.byteLength);
523
+ }
524
+
525
+ function dbf(source, decoder) {
526
+ source = slice(source);
527
+ return source.slice(32).then(function(array) {
528
+ var head = view(array);
529
+ return source.slice(head.getUint16(8, true) - 32).then(function(array) {
530
+ return new Dbf(source, decoder, head, view(array));
531
+ });
532
+ });
533
+ }
534
+
535
+ function Dbf(source, decoder, head, body) {
536
+ this._source = source;
537
+ this._decode = decoder.decode.bind(decoder);
538
+ this._recordLength = head.getUint16(10, true);
539
+ this._fields = [];
540
+ for (var n = 0; body.getUint8(n) !== 0x0d; n += 32) {
541
+ for (var j = 0; j < 11; ++j) if (body.getUint8(n + j) === 0) break;
542
+ this._fields.push({
543
+ name: this._decode(new Uint8Array(body.buffer, body.byteOffset + n, j)),
544
+ type: String.fromCharCode(body.getUint8(n + 11)),
545
+ length: body.getUint8(n + 16)
546
+ });
547
+ }
548
+ }
549
+
550
+ var prototype$2 = Dbf.prototype;
551
+ prototype$2.read = dbf_read;
552
+ prototype$2.cancel = dbf_cancel;
553
+
554
+ function cancel() {
555
+ return this._source.cancel();
556
+ }
557
+
558
+ function parseMultiPoint(record) {
559
+ var i = 40, j, n = record.getInt32(36, true), coordinates = new Array(n);
560
+ for (j = 0; j < n; ++j, i += 16) coordinates[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
561
+ return {type: "MultiPoint", coordinates: coordinates};
562
+ }
563
+
564
+ function parseNull() {
565
+ return null;
566
+ }
567
+
568
+ function parsePoint(record) {
569
+ return {type: "Point", coordinates: [record.getFloat64(4, true), record.getFloat64(12, true)]};
570
+ }
571
+
572
+ function parsePolygon(record) {
573
+ var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m), polygons = [], holes = [];
574
+ for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true);
575
+ for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
576
+
577
+ parts.forEach(function(i, j) {
578
+ var ring = points.slice(i, parts[j + 1]);
579
+ if (ringClockwise(ring)) polygons.push([ring]);
580
+ else holes.push(ring);
581
+ });
582
+
583
+ holes.forEach(function(hole) {
584
+ polygons.some(function(polygon) {
585
+ if (ringContainsSome(polygon[0], hole)) {
586
+ polygon.push(hole);
587
+ return true;
588
+ }
589
+ }) || polygons.push([hole]);
590
+ });
591
+
592
+ return polygons.length === 1
593
+ ? {type: "Polygon", coordinates: polygons[0]}
594
+ : {type: "MultiPolygon", coordinates: polygons};
595
+ }
596
+ function ringClockwise(ring) {
597
+ if ((n = ring.length) < 4) return false;
598
+ var i = 0, n, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1];
599
+ while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1];
600
+ return area >= 0;
601
+ }
602
+
603
+ function ringContainsSome(ring, hole) {
604
+ var i = -1, n = hole.length, c;
605
+ while (++i < n) {
606
+ if (c = ringContains(ring, hole[i])) {
607
+ return c > 0;
608
+ }
609
+ }
610
+ return false;
611
+ }
612
+
613
+ function ringContains(ring, point) {
614
+ var x = point[0], y = point[1], contains = -1;
615
+ for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
616
+ var pi = ring[i], xi = pi[0], yi = pi[1],
617
+ pj = ring[j], xj = pj[0], yj = pj[1];
618
+ if (segmentContains(pi, pj, point)) {
619
+ return 0;
620
+ }
621
+ if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) {
622
+ contains = -contains;
623
+ }
624
+ }
625
+ return contains;
626
+ }
627
+
628
+ function segmentContains(p0, p1, p2) {
629
+ var x20 = p2[0] - p0[0], y20 = p2[1] - p0[1];
630
+ if (x20 === 0 && y20 === 0) return true;
631
+ var x10 = p1[0] - p0[0], y10 = p1[1] - p0[1];
632
+ if (x10 === 0 && y10 === 0) return false;
633
+ var t = (x20 * x10 + y20 * y10) / (x10 * x10 + y10 * y10);
634
+ return t < 0 || t > 1 ? false : t === 0 || t === 1 ? true : t * x10 === x20 && t * y10 === y20;
635
+ }
636
+
637
+ function parsePolyLine(record) {
638
+ var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m);
639
+ for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true);
640
+ for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
641
+ return n === 1
642
+ ? {type: "LineString", coordinates: points}
643
+ : {type: "MultiLineString", coordinates: parts.map(function(i, j) { return points.slice(i, parts[j + 1]); })};
644
+ }
645
+
646
+ function concat(a, b) {
647
+ var ab = new Uint8Array(a.length + b.length);
648
+ ab.set(a, 0);
649
+ ab.set(b, a.length);
650
+ return ab;
651
+ }
652
+
653
+ function shp_read() {
654
+ var that = this;
655
+ ++that._index;
656
+ return that._source.slice(12).then(function(array) {
657
+ if (array == null) return {done: true, value: undefined};
658
+ var header = view(array);
659
+
660
+ // If the record starts with an invalid shape type (see #36), scan ahead in
661
+ // four-byte increments to find the next valid record, identified by the
662
+ // expected index, a non-empty content length and a valid shape type.
663
+ function skip() {
664
+ return that._source.slice(4).then(function(chunk) {
665
+ if (chunk == null) return {done: true, value: undefined};
666
+ header = view(array = concat(array.slice(4), chunk));
667
+ return header.getInt32(0, false) !== that._index ? skip() : read();
668
+ });
669
+ }
670
+
671
+ // All records should have at least four bytes (for the record shape type),
672
+ // so an invalid content length indicates corruption.
673
+ function read() {
674
+ var length = header.getInt32(4, false) * 2 - 4, type = header.getInt32(8, true);
675
+ return length < 0 || (type && type !== that._type) ? skip() : that._source.slice(length).then(function(chunk) {
676
+ return {done: false, value: type ? that._parse(view(concat(array.slice(8), chunk))) : null};
677
+ });
678
+ }
679
+
680
+ return read();
681
+ });
682
+ }
683
+
684
+ var parsers = {
685
+ 0: parseNull,
686
+ 1: parsePoint,
687
+ 3: parsePolyLine,
688
+ 5: parsePolygon,
689
+ 8: parseMultiPoint,
690
+ 11: parsePoint, // PointZ
691
+ 13: parsePolyLine, // PolyLineZ
692
+ 15: parsePolygon, // PolygonZ
693
+ 18: parseMultiPoint, // MultiPointZ
694
+ 21: parsePoint, // PointM
695
+ 23: parsePolyLine, // PolyLineM
696
+ 25: parsePolygon, // PolygonM
697
+ 28: parseMultiPoint // MultiPointM
698
+ };
699
+
700
+ function shp(source) {
701
+ source = slice(source);
702
+ return source.slice(100).then(function(array) {
703
+ return new Shp(source, view(array));
704
+ });
705
+ }
706
+ function Shp(source, header) {
707
+ var type = header.getInt32(32, true);
708
+ if (!(type in parsers)) throw new Error("unsupported shape type: " + type);
709
+ this._source = source;
710
+ this._type = type;
711
+ this._index = 0;
712
+ this._parse = parsers[type];
713
+ this.bbox = [header.getFloat64(36, true), header.getFloat64(44, true), header.getFloat64(52, true), header.getFloat64(60, true)];
714
+ }
715
+
716
+ var prototype$1 = Shp.prototype;
717
+ prototype$1.read = shp_read;
718
+ prototype$1.cancel = cancel;
719
+
720
+ function noop() {}
721
+
722
+ function shapefile_cancel() {
723
+ return Promise.all([
724
+ this._dbf && this._dbf.cancel(),
725
+ this._shp.cancel()
726
+ ]).then(noop);
727
+ }
728
+
729
+ function shapefile_read() {
730
+ var that = this;
731
+ return Promise.all([
732
+ that._dbf ? that._dbf.read() : {value: {}},
733
+ that._shp.read()
734
+ ]).then(function(results) {
735
+ var dbf = results[0], shp = results[1];
736
+ return shp.done ? shp : {
737
+ done: false,
738
+ value: {
739
+ type: "Feature",
740
+ properties: dbf.value,
741
+ geometry: shp.value
742
+ }
743
+ };
744
+ });
745
+ }
746
+
747
+ function shapefile(shpSource, dbfSource, decoder) {
748
+ return Promise.all([
749
+ shp(shpSource),
750
+ dbfSource && dbf(dbfSource, decoder)
751
+ ]).then(function(sources) {
752
+ return new Shapefile(sources[0], sources[1]);
753
+ });
754
+ }
755
+
756
+ function Shapefile(shp, dbf) {
757
+ this._shp = shp;
758
+ this._dbf = dbf;
759
+ this.bbox = shp.bbox;
760
+ }
761
+
762
+ var prototype = Shapefile.prototype;
763
+ prototype.read = shapefile_read;
764
+ prototype.cancel = shapefile_cancel;
765
+
766
+ function open(shp, dbf, options) {
767
+ if (typeof dbf === "string") {
768
+ if (!/\.dbf$/.test(dbf)) dbf += ".dbf";
769
+ dbf = path(dbf);
770
+ } else if (dbf instanceof ArrayBuffer || dbf instanceof Uint8Array) {
771
+ dbf = array(dbf);
772
+ } else if (dbf != null) {
773
+ dbf = stream(dbf);
774
+ }
775
+ if (typeof shp === "string") {
776
+ if (!/\.shp$/.test(shp)) shp += ".shp";
777
+ if (dbf === undefined) dbf = path(shp.substring(0, shp.length - 4) + ".dbf").catch(function() {});
778
+ shp = path(shp);
779
+ } else if (shp instanceof ArrayBuffer || shp instanceof Uint8Array) {
780
+ shp = array(shp);
781
+ } else {
782
+ shp = stream(shp);
783
+ }
784
+ return Promise.all([shp, dbf]).then(function(sources) {
785
+ var shp = sources[0], dbf = sources[1], encoding = "windows-1252";
786
+ if (options && options.encoding != null) encoding = options.encoding;
787
+ return shapefile(shp, dbf, dbf && new TextDecoder(encoding));
788
+ });
789
+ }
790
+
791
+ const shpToGeojson = (file) => {
792
+ return new Promise((resolve, reject) => {
793
+ const reader = new FileReader();
794
+ reader.readAsArrayBuffer(file);
795
+ const data = {
796
+ type: "FeatureCollection",
797
+ features: []
798
+ };
799
+ reader.onload = function() {
800
+ open(this.result).then((source) => source.read().then(
801
+ function log(result) {
802
+ if (!result.done) {
803
+ data.features.push(result.value);
804
+ source.read().then(log);
805
+ } else {
806
+ if (result.value) {
807
+ data.features.push(result.value);
808
+ }
809
+ resolve(data);
810
+ }
811
+ }
812
+ )).catch(reject);
813
+ };
814
+ });
815
+ };
816
+
817
+ const toGeojson = (file) => {
818
+ const actions = {
819
+ shp: shpToGeojson
820
+ };
821
+ return new Promise((resolve, reject) => {
822
+ const suffix = file.name.split(".").pop();
823
+ if (suffix && actions[suffix]) {
824
+ resolve(actions[suffix](file));
825
+ } else {
826
+ reject(new Error(`Can't resolve the .${suffix} file`));
827
+ }
828
+ });
829
+ };
830
+
831
+ /* @preserve
832
+ * @terraformer/arcgis - v2.1.1 - MIT
833
+ * Copyright (c) 2012-2022 Environmental Systems Research Institute, Inc.
834
+ * Tue Aug 02 2022 14:23:48 GMT-0700 (Pacific Daylight Time)
835
+ */
836
+ /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.
837
+ * Apache-2.0 */
838
+
839
+ var edgeIntersectsEdge = function edgeIntersectsEdge(a1, a2, b1, b2) {
840
+ var uaT = (b2[0] - b1[0]) * (a1[1] - b1[1]) - (b2[1] - b1[1]) * (a1[0] - b1[0]);
841
+ var ubT = (a2[0] - a1[0]) * (a1[1] - b1[1]) - (a2[1] - a1[1]) * (a1[0] - b1[0]);
842
+ var uB = (b2[1] - b1[1]) * (a2[0] - a1[0]) - (b2[0] - b1[0]) * (a2[1] - a1[1]);
843
+
844
+ if (uB !== 0) {
845
+ var ua = uaT / uB;
846
+ var ub = ubT / uB;
847
+
848
+ if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {
849
+ return true;
850
+ }
851
+ }
852
+
853
+ return false;
854
+ };
855
+ var coordinatesContainPoint = function coordinatesContainPoint(coordinates, point) {
856
+ var contains = false;
857
+
858
+ for (var i = -1, l = coordinates.length, j = l - 1; ++i < l; j = i) {
859
+ if ((coordinates[i][1] <= point[1] && point[1] < coordinates[j][1] || coordinates[j][1] <= point[1] && point[1] < coordinates[i][1]) && point[0] < (coordinates[j][0] - coordinates[i][0]) * (point[1] - coordinates[i][1]) / (coordinates[j][1] - coordinates[i][1]) + coordinates[i][0]) {
860
+ contains = !contains;
861
+ }
862
+ }
863
+
864
+ return contains;
865
+ };
866
+ var pointsEqual = function pointsEqual(a, b) {
867
+ for (var i = 0; i < a.length; i++) {
868
+ if (a[i] !== b[i]) {
869
+ return false;
870
+ }
871
+ }
872
+
873
+ return true;
874
+ };
875
+ var arrayIntersectsArray = function arrayIntersectsArray(a, b) {
876
+ for (var i = 0; i < a.length - 1; i++) {
877
+ for (var j = 0; j < b.length - 1; j++) {
878
+ if (edgeIntersectsEdge(a[i], a[i + 1], b[j], b[j + 1])) {
879
+ return true;
880
+ }
881
+ }
882
+ }
883
+
884
+ return false;
885
+ };
886
+
887
+ /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.
888
+ * Apache-2.0 */
889
+
890
+ var closeRing = function closeRing(coordinates) {
891
+ if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) {
892
+ coordinates.push(coordinates[0]);
893
+ }
894
+
895
+ return coordinates;
896
+ }; // determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring
897
+ // or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-
898
+ // points-are-in-clockwise-order
899
+
900
+ var ringIsClockwise = function ringIsClockwise(ringToTest) {
901
+ var total = 0;
902
+ var i = 0;
903
+ var rLength = ringToTest.length;
904
+ var pt1 = ringToTest[i];
905
+ var pt2;
906
+
907
+ for (i; i < rLength - 1; i++) {
908
+ pt2 = ringToTest[i + 1];
909
+ total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);
910
+ pt1 = pt2;
911
+ }
912
+
913
+ return total >= 0;
914
+ }; // This function ensures that rings are oriented in the right directions
915
+ // from http://jsperf.com/cloning-an-object/2
916
+
917
+ var shallowClone = function shallowClone(obj) {
918
+ var target = {};
919
+
920
+ for (var i in obj) {
921
+ // both arcgis attributes and geojson props are just hardcoded keys
922
+ if (obj.hasOwnProperty(i)) {
923
+ // eslint-disable-line no-prototype-builtins
924
+ target[i] = obj[i];
925
+ }
926
+ }
927
+
928
+ return target;
929
+ };
930
+
931
+ /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.
932
+ * Apache-2.0 */
933
+
934
+ var coordinatesContainCoordinates = function coordinatesContainCoordinates(outer, inner) {
935
+ var intersects = arrayIntersectsArray(outer, inner);
936
+ var contains = coordinatesContainPoint(outer, inner[0]);
937
+
938
+ if (!intersects && contains) {
939
+ return true;
940
+ }
941
+
942
+ return false;
943
+ }; // do any polygons in this array contain any other polygons in this array?
944
+ // used for checking for holes in arcgis rings
945
+
946
+
947
+ var convertRingsToGeoJSON = function convertRingsToGeoJSON(rings) {
948
+ var outerRings = [];
949
+ var holes = [];
950
+ var x; // iterator
951
+
952
+ var outerRing; // current outer ring being evaluated
953
+
954
+ var hole; // current hole being evaluated
955
+ // for each ring
956
+
957
+ for (var r = 0; r < rings.length; r++) {
958
+ var ring = closeRing(rings[r].slice(0));
959
+
960
+ if (ring.length < 4) {
961
+ continue;
962
+ } // is this ring an outer ring? is it clockwise?
963
+
964
+
965
+ if (ringIsClockwise(ring)) {
966
+ var polygon = [ring.slice().reverse()]; // wind outer rings counterclockwise for RFC 7946 compliance
967
+
968
+ outerRings.push(polygon); // push to outer rings
969
+ } else {
970
+ holes.push(ring.slice().reverse()); // wind inner rings clockwise for RFC 7946 compliance
971
+ }
972
+ }
973
+
974
+ var uncontainedHoles = []; // while there are holes left...
975
+
976
+ while (holes.length) {
977
+ // pop a hole off out stack
978
+ hole = holes.pop(); // loop over all outer rings and see if they contain our hole.
979
+
980
+ var contained = false;
981
+
982
+ for (x = outerRings.length - 1; x >= 0; x--) {
983
+ outerRing = outerRings[x][0];
984
+
985
+ if (coordinatesContainCoordinates(outerRing, hole)) {
986
+ // the hole is contained push it into our polygon
987
+ outerRings[x].push(hole);
988
+ contained = true;
989
+ break;
990
+ }
991
+ } // ring is not contained in any outer ring
992
+ // sometimes this happens https://github.com/Esri/esri-leaflet/issues/320
993
+
994
+
995
+ if (!contained) {
996
+ uncontainedHoles.push(hole);
997
+ }
998
+ } // if we couldn't match any holes using contains we can try intersects...
999
+
1000
+
1001
+ while (uncontainedHoles.length) {
1002
+ // pop a hole off out stack
1003
+ hole = uncontainedHoles.pop(); // loop over all outer rings and see if any intersect our hole.
1004
+
1005
+ var intersects = false;
1006
+
1007
+ for (x = outerRings.length - 1; x >= 0; x--) {
1008
+ outerRing = outerRings[x][0];
1009
+
1010
+ if (arrayIntersectsArray(outerRing, hole)) {
1011
+ // the hole is contained push it into our polygon
1012
+ outerRings[x].push(hole);
1013
+ intersects = true;
1014
+ break;
1015
+ }
1016
+ }
1017
+
1018
+ if (!intersects) {
1019
+ outerRings.push([hole.reverse()]);
1020
+ }
1021
+ }
1022
+
1023
+ if (outerRings.length === 1) {
1024
+ return {
1025
+ type: 'Polygon',
1026
+ coordinates: outerRings[0]
1027
+ };
1028
+ } else {
1029
+ return {
1030
+ type: 'MultiPolygon',
1031
+ coordinates: outerRings
1032
+ };
1033
+ }
1034
+ };
1035
+
1036
+ var getId = function getId(attributes, idAttribute) {
1037
+ var keys = idAttribute ? [idAttribute, 'OBJECTID', 'FID'] : ['OBJECTID', 'FID'];
1038
+
1039
+ for (var i = 0; i < keys.length; i++) {
1040
+ var key = keys[i];
1041
+
1042
+ if (key in attributes && (typeof attributes[key] === 'string' || typeof attributes[key] === 'number')) {
1043
+ return attributes[key];
1044
+ }
1045
+ }
1046
+
1047
+ throw Error('No valid id attribute found');
1048
+ };
1049
+
1050
+ var arcgisToGeoJSON = function arcgisToGeoJSON(arcgis, idAttribute) {
1051
+ var geojson = {};
1052
+
1053
+ if (arcgis.features) {
1054
+ geojson.type = 'FeatureCollection';
1055
+ geojson.features = [];
1056
+
1057
+ for (var i = 0; i < arcgis.features.length; i++) {
1058
+ geojson.features.push(arcgisToGeoJSON(arcgis.features[i], idAttribute));
1059
+ }
1060
+ }
1061
+
1062
+ if (typeof arcgis.x === 'number' && typeof arcgis.y === 'number') {
1063
+ geojson.type = 'Point';
1064
+ geojson.coordinates = [arcgis.x, arcgis.y];
1065
+
1066
+ if (typeof arcgis.z === 'number') {
1067
+ geojson.coordinates.push(arcgis.z);
1068
+ }
1069
+ }
1070
+
1071
+ if (arcgis.points) {
1072
+ geojson.type = 'MultiPoint';
1073
+ geojson.coordinates = arcgis.points.slice(0);
1074
+ }
1075
+
1076
+ if (arcgis.paths) {
1077
+ if (arcgis.paths.length === 1) {
1078
+ geojson.type = 'LineString';
1079
+ geojson.coordinates = arcgis.paths[0].slice(0);
1080
+ } else {
1081
+ geojson.type = 'MultiLineString';
1082
+ geojson.coordinates = arcgis.paths.slice(0);
1083
+ }
1084
+ }
1085
+
1086
+ if (arcgis.rings) {
1087
+ geojson = convertRingsToGeoJSON(arcgis.rings.slice(0));
1088
+ }
1089
+
1090
+ if (typeof arcgis.xmin === 'number' && typeof arcgis.ymin === 'number' && typeof arcgis.xmax === 'number' && typeof arcgis.ymax === 'number') {
1091
+ geojson.type = 'Polygon';
1092
+ geojson.coordinates = [[[arcgis.xmax, arcgis.ymax], [arcgis.xmin, arcgis.ymax], [arcgis.xmin, arcgis.ymin], [arcgis.xmax, arcgis.ymin], [arcgis.xmax, arcgis.ymax]]];
1093
+ }
1094
+
1095
+ if (arcgis.geometry || arcgis.attributes) {
1096
+ geojson.type = 'Feature';
1097
+ geojson.geometry = arcgis.geometry ? arcgisToGeoJSON(arcgis.geometry) : null;
1098
+ geojson.properties = arcgis.attributes ? shallowClone(arcgis.attributes) : null;
1099
+
1100
+ if (arcgis.attributes) {
1101
+ try {
1102
+ geojson.id = getId(arcgis.attributes, idAttribute);
1103
+ } catch (err) {// don't set an id
1104
+ }
1105
+ }
1106
+ } // if no valid geometry was encountered
1107
+
1108
+
1109
+ if (JSON.stringify(geojson.geometry) === JSON.stringify({})) {
1110
+ geojson.geometry = null;
1111
+ }
1112
+
1113
+ if (arcgis.spatialReference && arcgis.spatialReference.wkid && arcgis.spatialReference.wkid !== 4326) {
1114
+ console.warn('Object converted in non-standard crs - ' + JSON.stringify(arcgis.spatialReference));
1115
+ }
1116
+
1117
+ return geojson;
1118
+ };
1119
+
1120
+ /* Copyright (c) 2012-2019 Environmental Systems Research Institute, Inc.
1121
+ * Apache-2.0 */
1122
+ // outer rings are clockwise, holes are counterclockwise
1123
+ // used for converting GeoJSON Polygons to ArcGIS Polygons
1124
+
1125
+ var orientRings = function orientRings(poly) {
1126
+ var output = [];
1127
+ var polygon = poly.slice(0);
1128
+ var outerRing = closeRing(polygon.shift().slice(0));
1129
+
1130
+ if (outerRing.length >= 4) {
1131
+ if (!ringIsClockwise(outerRing)) {
1132
+ outerRing.reverse();
1133
+ }
1134
+
1135
+ output.push(outerRing);
1136
+
1137
+ for (var i = 0; i < polygon.length; i++) {
1138
+ var hole = closeRing(polygon[i].slice(0));
1139
+
1140
+ if (hole.length >= 4) {
1141
+ if (ringIsClockwise(hole)) {
1142
+ hole.reverse();
1143
+ }
1144
+
1145
+ output.push(hole);
1146
+ }
1147
+ }
1148
+ }
1149
+
1150
+ return output;
1151
+ }; // This function flattens holes in multipolygons to one array of polygons
1152
+ // used for converting GeoJSON Polygons to ArcGIS Polygons
1153
+
1154
+
1155
+ var flattenMultiPolygonRings = function flattenMultiPolygonRings(rings) {
1156
+ var output = [];
1157
+
1158
+ for (var i = 0; i < rings.length; i++) {
1159
+ var polygon = orientRings(rings[i]);
1160
+
1161
+ for (var x = polygon.length - 1; x >= 0; x--) {
1162
+ var ring = polygon[x].slice(0);
1163
+ output.push(ring);
1164
+ }
1165
+ }
1166
+
1167
+ return output;
1168
+ };
1169
+
1170
+ var geojsonToArcGIS = function geojsonToArcGIS(geojson, idAttribute) {
1171
+ idAttribute = idAttribute || 'OBJECTID';
1172
+ var spatialReference = {
1173
+ wkid: 4326
1174
+ };
1175
+ var result = {};
1176
+ var i;
1177
+
1178
+ switch (geojson.type) {
1179
+ case 'Point':
1180
+ result.x = geojson.coordinates[0];
1181
+ result.y = geojson.coordinates[1];
1182
+
1183
+ if (geojson.coordinates[2] != null) {
1184
+ result.z = geojson.coordinates[2];
1185
+ }
1186
+
1187
+ result.spatialReference = spatialReference;
1188
+ break;
1189
+
1190
+ case 'MultiPoint':
1191
+ result.points = geojson.coordinates.slice(0);
1192
+
1193
+ if (geojson.coordinates[0][2] != null) {
1194
+ result.hasZ = true;
1195
+ }
1196
+
1197
+ result.spatialReference = spatialReference;
1198
+ break;
1199
+
1200
+ case 'LineString':
1201
+ result.paths = [geojson.coordinates.slice(0)];
1202
+
1203
+ if (geojson.coordinates[0][2] != null) {
1204
+ result.hasZ = true;
1205
+ }
1206
+
1207
+ result.spatialReference = spatialReference;
1208
+ break;
1209
+
1210
+ case 'MultiLineString':
1211
+ result.paths = geojson.coordinates.slice(0);
1212
+
1213
+ if (geojson.coordinates[0][0][2] != null) {
1214
+ result.hasZ = true;
1215
+ }
1216
+
1217
+ result.spatialReference = spatialReference;
1218
+ break;
1219
+
1220
+ case 'Polygon':
1221
+ result.rings = orientRings(geojson.coordinates.slice(0));
1222
+
1223
+ if (geojson.coordinates[0][0][2] != null) {
1224
+ result.hasZ = true;
1225
+ }
1226
+
1227
+ result.spatialReference = spatialReference;
1228
+ break;
1229
+
1230
+ case 'MultiPolygon':
1231
+ result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0));
1232
+
1233
+ if (geojson.coordinates[0][0][0][2] != null) {
1234
+ result.hasZ = true;
1235
+ }
1236
+
1237
+ result.spatialReference = spatialReference;
1238
+ break;
1239
+
1240
+ case 'Feature':
1241
+ if (geojson.geometry) {
1242
+ result.geometry = geojsonToArcGIS(geojson.geometry, idAttribute);
1243
+ }
1244
+
1245
+ result.attributes = geojson.properties ? shallowClone(geojson.properties) : {};
1246
+
1247
+ if (geojson.id) {
1248
+ result.attributes[idAttribute] = geojson.id;
1249
+ }
1250
+
1251
+ break;
1252
+
1253
+ case 'FeatureCollection':
1254
+ result = [];
1255
+
1256
+ for (i = 0; i < geojson.features.length; i++) {
1257
+ result.push(geojsonToArcGIS(geojson.features[i], idAttribute));
1258
+ }
1259
+
1260
+ break;
1261
+
1262
+ case 'GeometryCollection':
1263
+ result = [];
1264
+
1265
+ for (i = 0; i < geojson.geometries.length; i++) {
1266
+ result.push(geojsonToArcGIS(geojson.geometries[i], idAttribute));
1267
+ }
1268
+
1269
+ break;
1270
+ }
1271
+
1272
+ return result;
1273
+ };
1274
+
1275
+ var _sfc_main = defineComponent({
1276
+ name: "VkfEsriInputGeojson",
1277
+ components: {
1278
+ VkfInput,
1279
+ VaSketch,
1280
+ ViewerVue,
1281
+ VkAsyncTeleport,
1282
+ DocumentChecked: document_checked_default,
1283
+ VaGraphicsLayer
1284
+ },
1285
+ emits,
1286
+ props,
1287
+ setup(props2, {
1288
+ emit
1289
+ }) {
1290
+ const inputBindProps = _VkfInputCtx.createBindProps(props2, ["inputSlots", "readonly", "modelValue"]);
1291
+ const inputOnEmits = _VkfInputCtx.createOnEmits(emit, ["update:modelValue"]);
1292
+ const readonly = useComputedReadonly(props2);
1293
+ const sketchRef = shallowRef();
1294
+ const shetchPanel = computed(() => {
1295
+ var _a;
1296
+ const container = (_a = sketchRef.value) == null ? void 0 : _a.container;
1297
+ return container == null ? void 0 : container.querySelector(".esri-sketch__panel");
1298
+ });
1299
+ const sketchLoad = async (e) => {
1300
+ await e.sketch.when();
1301
+ sketchRef.value = e.sketch;
1302
+ };
1303
+ const availableCreatureTools = computed(() => {
1304
+ if (Array.isArray(props2.editTypes)) {
1305
+ return props2.editTypes.reduce((pre, cur) => {
1306
+ return pre.concat(EDIT_TYPE_REFLECT[cur].availableCreatureTools);
1307
+ }, []);
1308
+ } else {
1309
+ return EDIT_TYPE_REFLECT[props2.editTypes].availableCreatureTools;
1310
+ }
1311
+ });
1312
+ const sketchValue = shallowRef([]);
1313
+ uSketchValue();
1314
+ const handleUpdateSketchValue = (e) => {
1315
+ sketchValue.value = e;
1316
+ if (props2.skipSave) {
1317
+ u();
1318
+ }
1319
+ };
1320
+ const normalMapRef = shallowRef();
1321
+ const dialogMapRef = shallowRef();
1322
+ const mapTo = shallowRef();
1323
+ onMounted(() => {
1324
+ mapTo.value = normalMapRef.value;
1325
+ });
1326
+ const dialogShow = ref(false);
1327
+ const dialogOnOpen = async () => {
1328
+ mapTo.value = dialogMapRef.value;
1329
+ };
1330
+ const dialogOnClose = async () => {
1331
+ mapTo.value = normalMapRef.value;
1332
+ };
1333
+ const doSave = () => {
1334
+ u();
1335
+ ElMessage({
1336
+ message: "\u4FDD\u5B58\u6210\u529F",
1337
+ type: "success"
1338
+ });
1339
+ dialogShow.value = false;
1340
+ };
1341
+ const append = () => createVNode(AppendVue, {
1342
+ "dialog": props2.dialogEdit,
1343
+ "upload": !readonly.value,
1344
+ "disabled": props2.disabled,
1345
+ "onUpload": onUpload,
1346
+ "onEdit": onEdit
1347
+ }, null);
1348
+ async function onUpload(e) {
1349
+ if (!e.raw)
1350
+ return;
1351
+ toGeojson(e.raw).then((res) => {
1352
+ emit("update:modelValue", res);
1353
+ }).then(uSketchValue).then(() => {
1354
+ ElMessage.success("\u4E0A\u4F20\u6210\u529F");
1355
+ }).then(async () => {
1356
+ var _a;
1357
+ const view = (_a = sketchRef.value) == null ? void 0 : _a.view;
1358
+ if (!view)
1359
+ return;
1360
+ await view.when();
1361
+ view.goTo(sketchValue.value);
1362
+ });
1363
+ }
1364
+ function onEdit() {
1365
+ dialogShow.value = true;
1366
+ }
1367
+ function u() {
1368
+ const features = sketchValue.value.map((item) => {
1369
+ return arcgisToGeoJSON(item);
1370
+ });
1371
+ emit("update:modelValue", {
1372
+ type: "FeatureCollection",
1373
+ features
1374
+ });
1375
+ }
1376
+ function uSketchValue() {
1377
+ const esriData = geojsonToArcGIS(props2.modelValue);
1378
+ const graphics = esriData.map((item) => {
1379
+ const g = item.geometry;
1380
+ if (g.rings) {
1381
+ g.type = "polygon";
1382
+ item.symbol = props2.viewModelActiveFillSymbol;
1383
+ } else if (g.paths) {
1384
+ g.type = "polyline";
1385
+ item.symbol = props2.viewModelActiveLineSymbol;
1386
+ } else if (g.x) {
1387
+ g.type = "point";
1388
+ item.symbol = props2.viewModelActivePointSymbol;
1389
+ }
1390
+ return new Graphic(item);
1391
+ });
1392
+ sketchValue.value = graphics;
1393
+ }
1394
+ return {
1395
+ inputBindProps,
1396
+ inputOnEmits,
1397
+ append,
1398
+ availableCreatureTools,
1399
+ sketchValue,
1400
+ handleUpdateSketchValue,
1401
+ sketchRef,
1402
+ sketchLoad,
1403
+ shetchPanel,
1404
+ dialogShow,
1405
+ normalMapRef,
1406
+ dialogMapRef,
1407
+ dialogOnOpen,
1408
+ dialogOnClose,
1409
+ mapTo,
1410
+ doSave,
1411
+ readonly
1412
+ };
1413
+ }
1414
+ });
1415
+
1416
+ const _hoisted_1 = { class: "vkf-form-item" };
1417
+ const _hoisted_2 = {
1418
+ class: "vkf-esri-input-geojson__map",
1419
+ ref: "normalMapRef"
1420
+ };
1421
+ const _hoisted_3 = {
1422
+ ref: "dialogMapRef",
1423
+ class: "vkf-esri-input-geojson-dialog__map"
1424
+ };
1425
+
1426
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
1427
+ const _component_VkfInput = resolveComponent("VkfInput");
1428
+ const _component_VaGraphicsLayer = resolveComponent("VaGraphicsLayer");
1429
+ const _component_DocumentChecked = resolveComponent("DocumentChecked");
1430
+ const _component_ElIcon = resolveComponent("ElIcon");
1431
+ const _component_VkAsyncTeleport = resolveComponent("VkAsyncTeleport");
1432
+ const _component_VaSketch = resolveComponent("VaSketch");
1433
+ const _component_ViewerVue = resolveComponent("ViewerVue");
1434
+ const _component_ElDialog = resolveComponent("ElDialog");
1435
+
1436
+ return (openBlock(), createElementBlock("div", _hoisted_1, [
1437
+ createVNode(_component_VkfInput, mergeProps({
1438
+ readonly: true,
1439
+ modelValue: JSON.stringify(_ctx.modelValue)
1440
+ }, _ctx.inputBindProps, toHandlers(_ctx.inputOnEmits), {
1441
+ inputSlots: {
1442
+ append: _ctx.append
1443
+ }
1444
+ }), null, 16 /* FULL_PROPS */, ["modelValue", "inputSlots"]),
1445
+ createVNode(_component_VkAsyncTeleport, { to: _ctx.mapTo }, {
1446
+ default: withCtx(() => [
1447
+ createVNode(_component_ViewerVue, { view: _ctx.view }, {
1448
+ default: withCtx(() => [
1449
+ (_ctx.readonly)
1450
+ ? (openBlock(), createBlock(_component_VaGraphicsLayer, {
1451
+ key: 0,
1452
+ graphics: _ctx.sketchValue
1453
+ }, null, 8 /* PROPS */, ["graphics"]))
1454
+ : (openBlock(), createBlock(_component_VaSketch, {
1455
+ key: 1,
1456
+ viewModelActiveFillSymbol: _ctx.viewModelActiveFillSymbol,
1457
+ viewModelActiveLineSymbol: _ctx.viewModelActiveLineSymbol,
1458
+ viewModelActivePointSymbol: _ctx.viewModelActivePointSymbol,
1459
+ multiple: _ctx.multiple,
1460
+ availableCreatureTools: _ctx.availableCreatureTools,
1461
+ modelValue: _ctx.sketchValue,
1462
+ "onUpdate:modelValue": _ctx.handleUpdateSketchValue,
1463
+ onLoad: _ctx.sketchLoad
1464
+ }, {
1465
+ default: withCtx(() => [
1466
+ (!_ctx.skipSave && _ctx.shetchPanel)
1467
+ ? (openBlock(), createBlock(_component_VkAsyncTeleport, {
1468
+ key: 0,
1469
+ to: _ctx.shetchPanel
1470
+ }, {
1471
+ default: withCtx(() => [
1472
+ createVNode(_component_ElIcon, {
1473
+ class: "esri-sketch-ui-save esri-widget--button",
1474
+ onClick: _ctx.doSave
1475
+ }, {
1476
+ default: withCtx(() => [
1477
+ createVNode(_component_DocumentChecked)
1478
+ ]),
1479
+ _: 1 /* STABLE */
1480
+ }, 8 /* PROPS */, ["onClick"])
1481
+ ]),
1482
+ _: 1 /* STABLE */
1483
+ }, 8 /* PROPS */, ["to"]))
1484
+ : createCommentVNode("v-if", true)
1485
+ ]),
1486
+ _: 1 /* STABLE */
1487
+ }, 8 /* PROPS */, ["viewModelActiveFillSymbol", "viewModelActiveLineSymbol", "viewModelActivePointSymbol", "multiple", "availableCreatureTools", "modelValue", "onUpdate:modelValue", "onLoad"]))
1488
+ ]),
1489
+ _: 1 /* STABLE */
1490
+ }, 8 /* PROPS */, ["view"])
1491
+ ]),
1492
+ _: 1 /* STABLE */
1493
+ }, 8 /* PROPS */, ["to"]),
1494
+ withDirectives(createElementVNode("div", _hoisted_2, null, 512 /* NEED_PATCH */), [
1495
+ [vShow, _ctx.showMap]
1496
+ ]),
1497
+ createVNode(_component_ElDialog, {
1498
+ modelValue: _ctx.dialogShow,
1499
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((_ctx.dialogShow) = $event)),
1500
+ title: _ctx.dialogEditTitle,
1501
+ fullscreen: _ctx.dialogEditFullscreen,
1502
+ modalClass: "vkf-esri-input-geojson-dialog",
1503
+ appendToBody: true,
1504
+ onOpen: _ctx.dialogOnOpen,
1505
+ onClose: _ctx.dialogOnClose,
1506
+ closeOnClickModal: false,
1507
+ draggable: true
1508
+ }, {
1509
+ default: withCtx(() => [
1510
+ createElementVNode("div", _hoisted_3, null, 512 /* NEED_PATCH */)
1511
+ ]),
1512
+ _: 1 /* STABLE */
1513
+ }, 8 /* PROPS */, ["modelValue", "title", "fullscreen", "onOpen", "onClose"])
1514
+ ]))
1515
+ }
1516
+ var VkfEsriInputGeojson = /*#__PURE__*/_export_sfc(_sfc_main, [['render',_sfc_render],['__file',"index.vue"]]);
1517
+
1518
+ var types = /*#__PURE__*/Object.freeze({
1519
+ __proto__: null
1520
+ });
1521
+
1522
+ VkfEsriInputGeojson.install = (app) => {
1523
+ app.component(VkfEsriInputGeojson.name, VkfEsriInputGeojson);
1524
+ };
1525
+
1526
+ export { EDIT_TYPE, EDIT_TYPE_OPTIONS, EDIT_TYPE_REFLECT, VkfEsriInputGeojson, types as __VkfEsriInputGeojson, VkfEsriInputGeojson as default };