1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/l7')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', '@antv/l7'], factory) :
|
4 | (global = global || self, factory((global.L7 = global.L7 || {}, global.L7.Draw = {}), global.L7));
|
5 | }(this, (function (exports, l7) { 'use strict';
|
6 |
|
7 | function _classCallCheck(instance, Constructor) {
|
8 | if (!(instance instanceof Constructor)) {
|
9 | throw new TypeError("Cannot call a class as a function");
|
10 | }
|
11 | }
|
12 |
|
13 | function _defineProperties(target, props) {
|
14 | for (var i = 0; i < props.length; i++) {
|
15 | var descriptor = props[i];
|
16 | descriptor.enumerable = descriptor.enumerable || false;
|
17 | descriptor.configurable = true;
|
18 | if ("value" in descriptor) descriptor.writable = true;
|
19 | Object.defineProperty(target, descriptor.key, descriptor);
|
20 | }
|
21 | }
|
22 |
|
23 | function _createClass(Constructor, protoProps, staticProps) {
|
24 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
25 | if (staticProps) _defineProperties(Constructor, staticProps);
|
26 | return Constructor;
|
27 | }
|
28 |
|
29 | function _defineProperty(obj, key, value) {
|
30 | if (key in obj) {
|
31 | Object.defineProperty(obj, key, {
|
32 | value: value,
|
33 | enumerable: true,
|
34 | configurable: true,
|
35 | writable: true
|
36 | });
|
37 | } else {
|
38 | obj[key] = value;
|
39 | }
|
40 |
|
41 | return obj;
|
42 | }
|
43 |
|
44 | function ownKeys(object, enumerableOnly) {
|
45 | var keys = Object.keys(object);
|
46 |
|
47 | if (Object.getOwnPropertySymbols) {
|
48 | var symbols = Object.getOwnPropertySymbols(object);
|
49 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
50 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
51 | });
|
52 | keys.push.apply(keys, symbols);
|
53 | }
|
54 |
|
55 | return keys;
|
56 | }
|
57 |
|
58 | function _objectSpread2(target) {
|
59 | for (var i = 1; i < arguments.length; i++) {
|
60 | var source = arguments[i] != null ? arguments[i] : {};
|
61 |
|
62 | if (i % 2) {
|
63 | ownKeys(Object(source), true).forEach(function (key) {
|
64 | _defineProperty(target, key, source[key]);
|
65 | });
|
66 | } else if (Object.getOwnPropertyDescriptors) {
|
67 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
68 | } else {
|
69 | ownKeys(Object(source)).forEach(function (key) {
|
70 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
71 | });
|
72 | }
|
73 | }
|
74 |
|
75 | return target;
|
76 | }
|
77 |
|
78 | function _inherits(subClass, superClass) {
|
79 | if (typeof superClass !== "function" && superClass !== null) {
|
80 | throw new TypeError("Super expression must either be null or a function");
|
81 | }
|
82 |
|
83 | subClass.prototype = Object.create(superClass && superClass.prototype, {
|
84 | constructor: {
|
85 | value: subClass,
|
86 | writable: true,
|
87 | configurable: true
|
88 | }
|
89 | });
|
90 | if (superClass) _setPrototypeOf(subClass, superClass);
|
91 | }
|
92 |
|
93 | function _getPrototypeOf(o) {
|
94 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
95 | return o.__proto__ || Object.getPrototypeOf(o);
|
96 | };
|
97 | return _getPrototypeOf(o);
|
98 | }
|
99 |
|
100 | function _setPrototypeOf(o, p) {
|
101 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
102 | o.__proto__ = p;
|
103 | return o;
|
104 | };
|
105 |
|
106 | return _setPrototypeOf(o, p);
|
107 | }
|
108 |
|
109 | function _isNativeReflectConstruct() {
|
110 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
111 | if (Reflect.construct.sham) return false;
|
112 | if (typeof Proxy === "function") return true;
|
113 |
|
114 | try {
|
115 | Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
116 | return true;
|
117 | } catch (e) {
|
118 | return false;
|
119 | }
|
120 | }
|
121 |
|
122 | function _assertThisInitialized(self) {
|
123 | if (self === void 0) {
|
124 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
125 | }
|
126 |
|
127 | return self;
|
128 | }
|
129 |
|
130 | function _possibleConstructorReturn(self, call) {
|
131 | if (call && (typeof call === "object" || typeof call === "function")) {
|
132 | return call;
|
133 | }
|
134 |
|
135 | return _assertThisInitialized(self);
|
136 | }
|
137 |
|
138 | function _createSuper(Derived) {
|
139 | var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
140 |
|
141 | return function _createSuperInternal() {
|
142 | var Super = _getPrototypeOf(Derived),
|
143 | result;
|
144 |
|
145 | if (hasNativeReflectConstruct) {
|
146 | var NewTarget = _getPrototypeOf(this).constructor;
|
147 |
|
148 | result = Reflect.construct(Super, arguments, NewTarget);
|
149 | } else {
|
150 | result = Super.apply(this, arguments);
|
151 | }
|
152 |
|
153 | return _possibleConstructorReturn(this, result);
|
154 | };
|
155 | }
|
156 |
|
157 | function _superPropBase(object, property) {
|
158 | while (!Object.prototype.hasOwnProperty.call(object, property)) {
|
159 | object = _getPrototypeOf(object);
|
160 | if (object === null) break;
|
161 | }
|
162 |
|
163 | return object;
|
164 | }
|
165 |
|
166 | function _get(target, property, receiver) {
|
167 | if (typeof Reflect !== "undefined" && Reflect.get) {
|
168 | _get = Reflect.get;
|
169 | } else {
|
170 | _get = function _get(target, property, receiver) {
|
171 | var base = _superPropBase(target, property);
|
172 |
|
173 | if (!base) return;
|
174 | var desc = Object.getOwnPropertyDescriptor(base, property);
|
175 |
|
176 | if (desc.get) {
|
177 | return desc.get.call(receiver);
|
178 | }
|
179 |
|
180 | return desc.value;
|
181 | };
|
182 | }
|
183 |
|
184 | return _get(target, property, receiver || target);
|
185 | }
|
186 |
|
187 | function _unsupportedIterableToArray(o, minLen) {
|
188 | if (!o) return;
|
189 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
190 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
191 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
192 | if (n === "Map" || n === "Set") return Array.from(o);
|
193 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
194 | }
|
195 |
|
196 | function _arrayLikeToArray(arr, len) {
|
197 | if (len == null || len > arr.length) len = arr.length;
|
198 |
|
199 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
200 |
|
201 | return arr2;
|
202 | }
|
203 |
|
204 | function _createForOfIteratorHelper(o, allowArrayLike) {
|
205 | var it;
|
206 |
|
207 | if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
208 | if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
209 | if (it) o = it;
|
210 | var i = 0;
|
211 |
|
212 | var F = function () {};
|
213 |
|
214 | return {
|
215 | s: F,
|
216 | n: function () {
|
217 | if (i >= o.length) return {
|
218 | done: true
|
219 | };
|
220 | return {
|
221 | done: false,
|
222 | value: o[i++]
|
223 | };
|
224 | },
|
225 | e: function (e) {
|
226 | throw e;
|
227 | },
|
228 | f: F
|
229 | };
|
230 | }
|
231 |
|
232 | throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
233 | }
|
234 |
|
235 | var normalCompletion = true,
|
236 | didErr = false,
|
237 | err;
|
238 | return {
|
239 | s: function () {
|
240 | it = o[Symbol.iterator]();
|
241 | },
|
242 | n: function () {
|
243 | var step = it.next();
|
244 | normalCompletion = step.done;
|
245 | return step;
|
246 | },
|
247 | e: function (e) {
|
248 | didErr = true;
|
249 | err = e;
|
250 | },
|
251 | f: function () {
|
252 | try {
|
253 | if (!normalCompletion && it.return != null) it.return();
|
254 | } finally {
|
255 | if (didErr) throw err;
|
256 | }
|
257 | }
|
258 | };
|
259 | }
|
260 |
|
261 | var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
262 |
|
263 | function unwrapExports (x) {
|
264 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
265 | }
|
266 |
|
267 | function createCommonjsModule(fn, module) {
|
268 | return module = { exports: {} }, fn(module, module.exports), module.exports;
|
269 | }
|
270 |
|
271 | var helpers = createCommonjsModule(function (module, exports) {
|
272 | Object.defineProperty(exports, "__esModule", { value: true });
|
273 | |
274 |
|
275 |
|
276 | |
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 | exports.earthRadius = 6371008.8;
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 | exports.factors = {
|
290 | centimeters: exports.earthRadius * 100,
|
291 | centimetres: exports.earthRadius * 100,
|
292 | degrees: exports.earthRadius / 111325,
|
293 | feet: exports.earthRadius * 3.28084,
|
294 | inches: exports.earthRadius * 39.370,
|
295 | kilometers: exports.earthRadius / 1000,
|
296 | kilometres: exports.earthRadius / 1000,
|
297 | meters: exports.earthRadius,
|
298 | metres: exports.earthRadius,
|
299 | miles: exports.earthRadius / 1609.344,
|
300 | millimeters: exports.earthRadius * 1000,
|
301 | millimetres: exports.earthRadius * 1000,
|
302 | nauticalmiles: exports.earthRadius / 1852,
|
303 | radians: 1,
|
304 | yards: exports.earthRadius / 1.0936,
|
305 | };
|
306 | |
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | exports.unitsFactors = {
|
313 | centimeters: 100,
|
314 | centimetres: 100,
|
315 | degrees: 1 / 111325,
|
316 | feet: 3.28084,
|
317 | inches: 39.370,
|
318 | kilometers: 1 / 1000,
|
319 | kilometres: 1 / 1000,
|
320 | meters: 1,
|
321 | metres: 1,
|
322 | miles: 1 / 1609.344,
|
323 | millimeters: 1000,
|
324 | millimetres: 1000,
|
325 | nauticalmiles: 1 / 1852,
|
326 | radians: 1 / exports.earthRadius,
|
327 | yards: 1 / 1.0936,
|
328 | };
|
329 | |
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 | exports.areaFactors = {
|
336 | acres: 0.000247105,
|
337 | centimeters: 10000,
|
338 | centimetres: 10000,
|
339 | feet: 10.763910417,
|
340 | inches: 1550.003100006,
|
341 | kilometers: 0.000001,
|
342 | kilometres: 0.000001,
|
343 | meters: 1,
|
344 | metres: 1,
|
345 | miles: 3.86e-7,
|
346 | millimeters: 1000000,
|
347 | millimetres: 1000000,
|
348 | yards: 1.195990046,
|
349 | };
|
350 | |
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 | function feature(geom, properties, options) {
|
371 | if (options === void 0) { options = {}; }
|
372 | var feat = { type: "Feature" };
|
373 | if (options.id === 0 || options.id) {
|
374 | feat.id = options.id;
|
375 | }
|
376 | if (options.bbox) {
|
377 | feat.bbox = options.bbox;
|
378 | }
|
379 | feat.properties = properties || {};
|
380 | feat.geometry = geom;
|
381 | return feat;
|
382 | }
|
383 | exports.feature = feature;
|
384 | |
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 | function geometry(type, coordinates, options) {
|
400 | switch (type) {
|
401 | case "Point": return point(coordinates).geometry;
|
402 | case "LineString": return lineString(coordinates).geometry;
|
403 | case "Polygon": return polygon(coordinates).geometry;
|
404 | case "MultiPoint": return multiPoint(coordinates).geometry;
|
405 | case "MultiLineString": return multiLineString(coordinates).geometry;
|
406 | case "MultiPolygon": return multiPolygon(coordinates).geometry;
|
407 | default: throw new Error(type + " is invalid");
|
408 | }
|
409 | }
|
410 | exports.geometry = geometry;
|
411 | |
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 |
|
426 | function point(coordinates, properties, options) {
|
427 | if (options === void 0) { options = {}; }
|
428 | var geom = {
|
429 | type: "Point",
|
430 | coordinates: coordinates,
|
431 | };
|
432 | return feature(geom, properties, options);
|
433 | }
|
434 | exports.point = point;
|
435 | |
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 | function points(coordinates, properties, options) {
|
456 | if (options === void 0) { options = {}; }
|
457 | return featureCollection(coordinates.map(function (coords) {
|
458 | return point(coords, properties);
|
459 | }), options);
|
460 | }
|
461 | exports.points = points;
|
462 | |
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 | function polygon(coordinates, properties, options) {
|
478 | if (options === void 0) { options = {}; }
|
479 | for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
|
480 | var ring = coordinates_1[_i];
|
481 | if (ring.length < 4) {
|
482 | throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
|
483 | }
|
484 | for (var j = 0; j < ring[ring.length - 1].length; j++) {
|
485 |
|
486 | if (ring[ring.length - 1][j] !== ring[0][j]) {
|
487 | throw new Error("First and last Position are not equivalent.");
|
488 | }
|
489 | }
|
490 | }
|
491 | var geom = {
|
492 | type: "Polygon",
|
493 | coordinates: coordinates,
|
494 | };
|
495 | return feature(geom, properties, options);
|
496 | }
|
497 | exports.polygon = polygon;
|
498 | |
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 |
|
514 |
|
515 |
|
516 | function polygons(coordinates, properties, options) {
|
517 | if (options === void 0) { options = {}; }
|
518 | return featureCollection(coordinates.map(function (coords) {
|
519 | return polygon(coords, properties);
|
520 | }), options);
|
521 | }
|
522 | exports.polygons = polygons;
|
523 | |
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 |
|
538 |
|
539 |
|
540 | function lineString(coordinates, properties, options) {
|
541 | if (options === void 0) { options = {}; }
|
542 | if (coordinates.length < 2) {
|
543 | throw new Error("coordinates must be an array of two or more positions");
|
544 | }
|
545 | var geom = {
|
546 | type: "LineString",
|
547 | coordinates: coordinates,
|
548 | };
|
549 | return feature(geom, properties, options);
|
550 | }
|
551 | exports.lineString = lineString;
|
552 | |
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 | function lineStrings(coordinates, properties, options) {
|
572 | if (options === void 0) { options = {}; }
|
573 | return featureCollection(coordinates.map(function (coords) {
|
574 | return lineString(coords, properties);
|
575 | }), options);
|
576 | }
|
577 | exports.lineStrings = lineStrings;
|
578 | |
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 | function featureCollection(features, options) {
|
601 | if (options === void 0) { options = {}; }
|
602 | var fc = { type: "FeatureCollection" };
|
603 | if (options.id) {
|
604 | fc.id = options.id;
|
605 | }
|
606 | if (options.bbox) {
|
607 | fc.bbox = options.bbox;
|
608 | }
|
609 | fc.features = features;
|
610 | return fc;
|
611 | }
|
612 | exports.featureCollection = featureCollection;
|
613 | |
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 |
|
628 |
|
629 |
|
630 | function multiLineString(coordinates, properties, options) {
|
631 | if (options === void 0) { options = {}; }
|
632 | var geom = {
|
633 | type: "MultiLineString",
|
634 | coordinates: coordinates,
|
635 | };
|
636 | return feature(geom, properties, options);
|
637 | }
|
638 | exports.multiLineString = multiLineString;
|
639 | |
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 |
|
647 |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 | function multiPoint(coordinates, properties, options) {
|
657 | if (options === void 0) { options = {}; }
|
658 | var geom = {
|
659 | type: "MultiPoint",
|
660 | coordinates: coordinates,
|
661 | };
|
662 | return feature(geom, properties, options);
|
663 | }
|
664 | exports.multiPoint = multiPoint;
|
665 | |
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 | function multiPolygon(coordinates, properties, options) {
|
684 | if (options === void 0) { options = {}; }
|
685 | var geom = {
|
686 | type: "MultiPolygon",
|
687 | coordinates: coordinates,
|
688 | };
|
689 | return feature(geom, properties, options);
|
690 | }
|
691 | exports.multiPolygon = multiPolygon;
|
692 | |
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 | function geometryCollection(geometries, properties, options) {
|
711 | if (options === void 0) { options = {}; }
|
712 | var geom = {
|
713 | type: "GeometryCollection",
|
714 | geometries: geometries,
|
715 | };
|
716 | return feature(geom, properties, options);
|
717 | }
|
718 | exports.geometryCollection = geometryCollection;
|
719 | |
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 | function round(num, precision) {
|
733 | if (precision === void 0) { precision = 0; }
|
734 | if (precision && !(precision >= 0)) {
|
735 | throw new Error("precision must be a positive number");
|
736 | }
|
737 | var multiplier = Math.pow(10, precision || 0);
|
738 | return Math.round(num * multiplier) / multiplier;
|
739 | }
|
740 | exports.round = round;
|
741 | |
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 | function radiansToLength(radians, units) {
|
752 | if (units === void 0) { units = "kilometers"; }
|
753 | var factor = exports.factors[units];
|
754 | if (!factor) {
|
755 | throw new Error(units + " units is invalid");
|
756 | }
|
757 | return radians * factor;
|
758 | }
|
759 | exports.radiansToLength = radiansToLength;
|
760 | |
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 | function lengthToRadians(distance, units) {
|
771 | if (units === void 0) { units = "kilometers"; }
|
772 | var factor = exports.factors[units];
|
773 | if (!factor) {
|
774 | throw new Error(units + " units is invalid");
|
775 | }
|
776 | return distance / factor;
|
777 | }
|
778 | exports.lengthToRadians = lengthToRadians;
|
779 | |
780 |
|
781 |
|
782 |
|
783 |
|
784 |
|
785 |
|
786 |
|
787 |
|
788 |
|
789 | function lengthToDegrees(distance, units) {
|
790 | return radiansToDegrees(lengthToRadians(distance, units));
|
791 | }
|
792 | exports.lengthToDegrees = lengthToDegrees;
|
793 | |
794 |
|
795 |
|
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 | function bearingToAzimuth(bearing) {
|
802 | var angle = bearing % 360;
|
803 | if (angle < 0) {
|
804 | angle += 360;
|
805 | }
|
806 | return angle;
|
807 | }
|
808 | exports.bearingToAzimuth = bearingToAzimuth;
|
809 | |
810 |
|
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 | function radiansToDegrees(radians) {
|
817 | var degrees = radians % (2 * Math.PI);
|
818 | return degrees * 180 / Math.PI;
|
819 | }
|
820 | exports.radiansToDegrees = radiansToDegrees;
|
821 | |
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 | function degreesToRadians(degrees) {
|
829 | var radians = degrees % 360;
|
830 | return radians * Math.PI / 180;
|
831 | }
|
832 | exports.degreesToRadians = degreesToRadians;
|
833 | |
834 |
|
835 |
|
836 |
|
837 |
|
838 |
|
839 |
|
840 |
|
841 |
|
842 | function convertLength(length, originalUnit, finalUnit) {
|
843 | if (originalUnit === void 0) { originalUnit = "kilometers"; }
|
844 | if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
845 | if (!(length >= 0)) {
|
846 | throw new Error("length must be a positive number");
|
847 | }
|
848 | return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
|
849 | }
|
850 | exports.convertLength = convertLength;
|
851 | |
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 | function convertArea(area, originalUnit, finalUnit) {
|
860 | if (originalUnit === void 0) { originalUnit = "meters"; }
|
861 | if (finalUnit === void 0) { finalUnit = "kilometers"; }
|
862 | if (!(area >= 0)) {
|
863 | throw new Error("area must be a positive number");
|
864 | }
|
865 | var startFactor = exports.areaFactors[originalUnit];
|
866 | if (!startFactor) {
|
867 | throw new Error("invalid original units");
|
868 | }
|
869 | var finalFactor = exports.areaFactors[finalUnit];
|
870 | if (!finalFactor) {
|
871 | throw new Error("invalid final units");
|
872 | }
|
873 | return (area / startFactor) * finalFactor;
|
874 | }
|
875 | exports.convertArea = convertArea;
|
876 | |
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 | function isNumber(num) {
|
888 | return !isNaN(num) && num !== null && !Array.isArray(num) && !/^\s*$/.test(num);
|
889 | }
|
890 | exports.isNumber = isNumber;
|
891 | |
892 |
|
893 |
|
894 |
|
895 |
|
896 |
|
897 |
|
898 |
|
899 |
|
900 |
|
901 |
|
902 | function isObject(input) {
|
903 | return (!!input) && (input.constructor === Object);
|
904 | }
|
905 | exports.isObject = isObject;
|
906 | |
907 |
|
908 |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 | function validateBBox(bbox) {
|
928 | if (!bbox) {
|
929 | throw new Error("bbox is required");
|
930 | }
|
931 | if (!Array.isArray(bbox)) {
|
932 | throw new Error("bbox must be an Array");
|
933 | }
|
934 | if (bbox.length !== 4 && bbox.length !== 6) {
|
935 | throw new Error("bbox must be an Array of 4 or 6 numbers");
|
936 | }
|
937 | bbox.forEach(function (num) {
|
938 | if (!isNumber(num)) {
|
939 | throw new Error("bbox must only contain numbers");
|
940 | }
|
941 | });
|
942 | }
|
943 | exports.validateBBox = validateBBox;
|
944 | |
945 |
|
946 |
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 | function validateId(id) {
|
966 | if (!id) {
|
967 | throw new Error("id is required");
|
968 | }
|
969 | if (["string", "number"].indexOf(typeof id) === -1) {
|
970 | throw new Error("id must be a number or a string");
|
971 | }
|
972 | }
|
973 | exports.validateId = validateId;
|
974 |
|
975 | function radians2degrees() {
|
976 | throw new Error("method has been renamed to `radiansToDegrees`");
|
977 | }
|
978 | exports.radians2degrees = radians2degrees;
|
979 | function degrees2radians() {
|
980 | throw new Error("method has been renamed to `degreesToRadians`");
|
981 | }
|
982 | exports.degrees2radians = degrees2radians;
|
983 | function distanceToDegrees() {
|
984 | throw new Error("method has been renamed to `lengthToDegrees`");
|
985 | }
|
986 | exports.distanceToDegrees = distanceToDegrees;
|
987 | function distanceToRadians() {
|
988 | throw new Error("method has been renamed to `lengthToRadians`");
|
989 | }
|
990 | exports.distanceToRadians = distanceToRadians;
|
991 | function radiansToDistance() {
|
992 | throw new Error("method has been renamed to `radiansToLength`");
|
993 | }
|
994 | exports.radiansToDistance = radiansToDistance;
|
995 | function bearingToAngle() {
|
996 | throw new Error("method has been renamed to `bearingToAzimuth`");
|
997 | }
|
998 | exports.bearingToAngle = bearingToAngle;
|
999 | function convertDistance() {
|
1000 | throw new Error("method has been renamed to `convertLength`");
|
1001 | }
|
1002 | exports.convertDistance = convertDistance;
|
1003 | });
|
1004 |
|
1005 | unwrapExports(helpers);
|
1006 | var helpers_1 = helpers.earthRadius;
|
1007 | var helpers_2 = helpers.factors;
|
1008 | var helpers_3 = helpers.unitsFactors;
|
1009 | var helpers_4 = helpers.areaFactors;
|
1010 | var helpers_5 = helpers.feature;
|
1011 | var helpers_6 = helpers.geometry;
|
1012 | var helpers_7 = helpers.point;
|
1013 | var helpers_8 = helpers.points;
|
1014 | var helpers_9 = helpers.polygon;
|
1015 | var helpers_10 = helpers.polygons;
|
1016 | var helpers_11 = helpers.lineString;
|
1017 | var helpers_12 = helpers.lineStrings;
|
1018 | var helpers_13 = helpers.featureCollection;
|
1019 | var helpers_14 = helpers.multiLineString;
|
1020 | var helpers_15 = helpers.multiPoint;
|
1021 | var helpers_16 = helpers.multiPolygon;
|
1022 | var helpers_17 = helpers.geometryCollection;
|
1023 | var helpers_18 = helpers.round;
|
1024 | var helpers_19 = helpers.radiansToLength;
|
1025 | var helpers_20 = helpers.lengthToRadians;
|
1026 | var helpers_21 = helpers.lengthToDegrees;
|
1027 | var helpers_22 = helpers.bearingToAzimuth;
|
1028 | var helpers_23 = helpers.radiansToDegrees;
|
1029 | var helpers_24 = helpers.degreesToRadians;
|
1030 | var helpers_25 = helpers.convertLength;
|
1031 | var helpers_26 = helpers.convertArea;
|
1032 | var helpers_27 = helpers.isNumber;
|
1033 | var helpers_28 = helpers.isObject;
|
1034 | var helpers_29 = helpers.validateBBox;
|
1035 | var helpers_30 = helpers.validateId;
|
1036 | var helpers_31 = helpers.radians2degrees;
|
1037 | var helpers_32 = helpers.degrees2radians;
|
1038 | var helpers_33 = helpers.distanceToDegrees;
|
1039 | var helpers_34 = helpers.distanceToRadians;
|
1040 | var helpers_35 = helpers.radiansToDistance;
|
1041 | var helpers_36 = helpers.bearingToAngle;
|
1042 | var helpers_37 = helpers.convertDistance;
|
1043 |
|
1044 | var DrawEvent;
|
1045 |
|
1046 | (function (DrawEvent) {
|
1047 | DrawEvent["CREATE"] = "draw.create";
|
1048 | DrawEvent["DELETE"] = "draw.delete";
|
1049 | DrawEvent["Move"] = "draw.move";
|
1050 | DrawEvent["Edit"] = "draw.edit";
|
1051 | DrawEvent["UPDATE"] = "draw.update";
|
1052 | DrawEvent["CHANGE"] = "draw.change";
|
1053 | DrawEvent["SELECTION_CHANGE"] = "draw.selectionchange";
|
1054 | DrawEvent["MODE_CHANGE"] = "draw.modechange";
|
1055 | DrawEvent["ACTIONABLE"] = "draw.actionable";
|
1056 | DrawEvent["RENDER"] = "draw.render";
|
1057 | DrawEvent["COMBINE_FEATURES"] = "draw.combine";
|
1058 | DrawEvent["UNCOMBINE_FEATURES"] = "draw.uncombine";
|
1059 | })(DrawEvent || (DrawEvent = {}));
|
1060 |
|
1061 | var DrawModes;
|
1062 |
|
1063 | (function (DrawModes) {
|
1064 | DrawModes["DRAW_Circle"] = "draw_circle";
|
1065 | DrawModes["DRAW_Rect"] = "draw_react";
|
1066 | DrawModes["DRAW_LINE_STRING"] = "draw_line_string";
|
1067 | DrawModes["DRAW_POLYGON"] = "draw_polygon";
|
1068 | DrawModes["DRAW_POINT"] = "draw_point";
|
1069 | DrawModes["SIMPLE_SELECT"] = "simple_select";
|
1070 | DrawModes["DIRECT_SELECT"] = "direct_select";
|
1071 | DrawModes["STATIC"] = "static";
|
1072 | })(DrawModes || (DrawModes = {}));
|
1073 |
|
1074 | var FeatureType;
|
1075 |
|
1076 | (function (FeatureType) {
|
1077 | FeatureType["FEATURE"] = "Feature";
|
1078 | FeatureType["POLYGON"] = "Polygon";
|
1079 | FeatureType["LINE_STRING"] = "LineString";
|
1080 | FeatureType["POINT"] = "Point";
|
1081 | FeatureType["FEATURE_COLLECTION"] = "FeatureCollection";
|
1082 | FeatureType["MULTI_PREFIX"] = "Multi";
|
1083 | FeatureType["MULTI_POINT"] = "MultiPoint";
|
1084 | FeatureType["MULTI_LINE_STRING"] = "MultiLineString";
|
1085 | FeatureType["MULTI_POLYGON"] = "MultiPolygon";
|
1086 | })(FeatureType || (FeatureType = {}));
|
1087 |
|
1088 | var invariant = createCommonjsModule(function (module, exports) {
|
1089 | Object.defineProperty(exports, "__esModule", { value: true });
|
1090 |
|
1091 | |
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 | function getCoord(coord) {
|
1104 | if (!coord) {
|
1105 | throw new Error("coord is required");
|
1106 | }
|
1107 | if (!Array.isArray(coord)) {
|
1108 | if (coord.type === "Feature" && coord.geometry !== null && coord.geometry.type === "Point") {
|
1109 | return coord.geometry.coordinates;
|
1110 | }
|
1111 | if (coord.type === "Point") {
|
1112 | return coord.coordinates;
|
1113 | }
|
1114 | }
|
1115 | if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
|
1116 | return coord;
|
1117 | }
|
1118 | throw new Error("coord must be GeoJSON Point or an Array of numbers");
|
1119 | }
|
1120 | exports.getCoord = getCoord;
|
1121 | |
1122 |
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 | function getCoords(coords) {
|
1134 | if (Array.isArray(coords)) {
|
1135 | return coords;
|
1136 | }
|
1137 |
|
1138 | if (coords.type === "Feature") {
|
1139 | if (coords.geometry !== null) {
|
1140 | return coords.geometry.coordinates;
|
1141 | }
|
1142 | }
|
1143 | else {
|
1144 |
|
1145 | if (coords.coordinates) {
|
1146 | return coords.coordinates;
|
1147 | }
|
1148 | }
|
1149 | throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array");
|
1150 | }
|
1151 | exports.getCoords = getCoords;
|
1152 | |
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 | function containsNumber(coordinates) {
|
1160 | if (coordinates.length > 1 && helpers.isNumber(coordinates[0]) && helpers.isNumber(coordinates[1])) {
|
1161 | return true;
|
1162 | }
|
1163 | if (Array.isArray(coordinates[0]) && coordinates[0].length) {
|
1164 | return containsNumber(coordinates[0]);
|
1165 | }
|
1166 | throw new Error("coordinates must only contain numbers");
|
1167 | }
|
1168 | exports.containsNumber = containsNumber;
|
1169 | |
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 | function geojsonType(value, type, name) {
|
1179 | if (!type || !name) {
|
1180 | throw new Error("type and name required");
|
1181 | }
|
1182 | if (!value || value.type !== type) {
|
1183 | throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + value.type);
|
1184 | }
|
1185 | }
|
1186 | exports.geojsonType = geojsonType;
|
1187 | |
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 |
|
1197 | function featureOf(feature, type, name) {
|
1198 | if (!feature) {
|
1199 | throw new Error("No feature passed");
|
1200 | }
|
1201 | if (!name) {
|
1202 | throw new Error(".featureOf() requires a name");
|
1203 | }
|
1204 | if (!feature || feature.type !== "Feature" || !feature.geometry) {
|
1205 | throw new Error("Invalid input to " + name + ", Feature with geometry required");
|
1206 | }
|
1207 | if (!feature.geometry || feature.geometry.type !== type) {
|
1208 | throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + feature.geometry.type);
|
1209 | }
|
1210 | }
|
1211 | exports.featureOf = featureOf;
|
1212 | |
1213 |
|
1214 |
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 | function collectionOf(featureCollection, type, name) {
|
1223 | if (!featureCollection) {
|
1224 | throw new Error("No featureCollection passed");
|
1225 | }
|
1226 | if (!name) {
|
1227 | throw new Error(".collectionOf() requires a name");
|
1228 | }
|
1229 | if (!featureCollection || featureCollection.type !== "FeatureCollection") {
|
1230 | throw new Error("Invalid input to " + name + ", FeatureCollection required");
|
1231 | }
|
1232 | for (var _i = 0, _a = featureCollection.features; _i < _a.length; _i++) {
|
1233 | var feature = _a[_i];
|
1234 | if (!feature || feature.type !== "Feature" || !feature.geometry) {
|
1235 | throw new Error("Invalid input to " + name + ", Feature with geometry required");
|
1236 | }
|
1237 | if (!feature.geometry || feature.geometry.type !== type) {
|
1238 | throw new Error("Invalid input to " + name + ": must be a " + type + ", given " + feature.geometry.type);
|
1239 | }
|
1240 | }
|
1241 | }
|
1242 | exports.collectionOf = collectionOf;
|
1243 | |
1244 |
|
1245 |
|
1246 |
|
1247 |
|
1248 |
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 |
|
1259 |
|
1260 |
|
1261 | function getGeom(geojson) {
|
1262 | if (geojson.type === "Feature") {
|
1263 | return geojson.geometry;
|
1264 | }
|
1265 | return geojson;
|
1266 | }
|
1267 | exports.getGeom = getGeom;
|
1268 | |
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 |
|
1274 |
|
1275 |
|
1276 |
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 |
|
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 | function getType(geojson, name) {
|
1287 | if (geojson.type === "FeatureCollection") {
|
1288 | return "FeatureCollection";
|
1289 | }
|
1290 | if (geojson.type === "GeometryCollection") {
|
1291 | return "GeometryCollection";
|
1292 | }
|
1293 | if (geojson.type === "Feature" && geojson.geometry !== null) {
|
1294 | return geojson.geometry.type;
|
1295 | }
|
1296 | return geojson.type;
|
1297 | }
|
1298 | exports.getType = getType;
|
1299 | });
|
1300 |
|
1301 | unwrapExports(invariant);
|
1302 | var invariant_1 = invariant.getCoord;
|
1303 | var invariant_2 = invariant.getCoords;
|
1304 | var invariant_3 = invariant.containsNumber;
|
1305 | var invariant_4 = invariant.geojsonType;
|
1306 | var invariant_5 = invariant.featureOf;
|
1307 | var invariant_6 = invariant.collectionOf;
|
1308 | var invariant_7 = invariant.getGeom;
|
1309 | var invariant_8 = invariant.getType;
|
1310 |
|
1311 | var destination_1 = createCommonjsModule(function (module, exports) {
|
1312 | Object.defineProperty(exports, "__esModule", { value: true });
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 | |
1318 |
|
1319 |
|
1320 |
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 |
|
1330 |
|
1331 |
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 | function destination(origin, distance, bearing, options) {
|
1344 | if (options === void 0) { options = {}; }
|
1345 |
|
1346 | var coordinates1 = invariant.getCoord(origin);
|
1347 | var longitude1 = helpers.degreesToRadians(coordinates1[0]);
|
1348 | var latitude1 = helpers.degreesToRadians(coordinates1[1]);
|
1349 | var bearingRad = helpers.degreesToRadians(bearing);
|
1350 | var radians = helpers.lengthToRadians(distance, options.units);
|
1351 |
|
1352 | var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
|
1353 | Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad));
|
1354 | var longitude2 = longitude1 + Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1), Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
|
1355 | var lng = helpers.radiansToDegrees(longitude2);
|
1356 | var lat = helpers.radiansToDegrees(latitude2);
|
1357 | return helpers.point([lng, lat], options.properties);
|
1358 | }
|
1359 | exports.default = destination;
|
1360 | });
|
1361 |
|
1362 | unwrapExports(destination_1);
|
1363 |
|
1364 | var circle_1 = createCommonjsModule(function (module, exports) {
|
1365 | Object.defineProperty(exports, "__esModule", { value: true });
|
1366 |
|
1367 |
|
1368 | |
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 |
|
1374 |
|
1375 |
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 |
|
1386 |
|
1387 |
|
1388 | function circle(center, radius, options) {
|
1389 | if (options === void 0) { options = {}; }
|
1390 |
|
1391 | var steps = options.steps || 64;
|
1392 | var properties = options.properties ? options.properties : (!Array.isArray(center) && center.type === 'Feature' && center.properties) ? center.properties : {};
|
1393 |
|
1394 | var coordinates = [];
|
1395 | for (var i = 0; i < steps; i++) {
|
1396 | coordinates.push(destination_1.default(center, radius, i * -360 / steps, options).geometry.coordinates);
|
1397 | }
|
1398 | coordinates.push(coordinates[0]);
|
1399 | return helpers.polygon([coordinates], properties);
|
1400 | }
|
1401 | exports.default = circle;
|
1402 | });
|
1403 |
|
1404 | var turfCircle = unwrapExports(circle_1);
|
1405 |
|
1406 | var distance_1 = createCommonjsModule(function (module, exports) {
|
1407 | Object.defineProperty(exports, "__esModule", { value: true });
|
1408 |
|
1409 |
|
1410 |
|
1411 |
|
1412 | |
1413 |
|
1414 |
|
1415 |
|
1416 |
|
1417 |
|
1418 |
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 |
|
1425 |
|
1426 |
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 | function distance(from, to, options) {
|
1435 | if (options === void 0) { options = {}; }
|
1436 | var coordinates1 = invariant.getCoord(from);
|
1437 | var coordinates2 = invariant.getCoord(to);
|
1438 | var dLat = helpers.degreesToRadians((coordinates2[1] - coordinates1[1]));
|
1439 | var dLon = helpers.degreesToRadians((coordinates2[0] - coordinates1[0]));
|
1440 | var lat1 = helpers.degreesToRadians(coordinates1[1]);
|
1441 | var lat2 = helpers.degreesToRadians(coordinates2[1]);
|
1442 | var a = Math.pow(Math.sin(dLat / 2), 2) +
|
1443 | Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
|
1444 | return helpers.radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), options.units);
|
1445 | }
|
1446 | exports.default = distance;
|
1447 | });
|
1448 |
|
1449 | var turfDistance = unwrapExports(distance_1);
|
1450 |
|
1451 | function createCircle(center, endPoint, options) {
|
1452 | var radius = turfDistance(helpers_7(center), helpers_7(endPoint), options);
|
1453 | var feature = turfCircle(center, radius, {
|
1454 | units: options.units,
|
1455 | steps: options.steps,
|
1456 | properties: _objectSpread2(_objectSpread2({}, options), {}, {
|
1457 | active: true,
|
1458 | type: 'circle',
|
1459 | radius: radius,
|
1460 | startPoint: {
|
1461 | lng: center[0],
|
1462 | lat: center[1]
|
1463 | },
|
1464 | endPoint: {
|
1465 | lng: endPoint[0],
|
1466 | lat: endPoint[1]
|
1467 | }
|
1468 | })
|
1469 | });
|
1470 | return feature;
|
1471 | }
|
1472 | function createRect(startPoint, endPoint, options) {
|
1473 | var minX = Math.min(startPoint[0], endPoint[0]);
|
1474 | var minY = Math.min(startPoint[1], endPoint[1]);
|
1475 | var maxX = Math.max(startPoint[0], endPoint[0]);
|
1476 | var maxY = Math.max(startPoint[1], endPoint[1]);
|
1477 | var feature = {
|
1478 | type: 'Feature',
|
1479 | properties: _objectSpread2({
|
1480 | type: 'rect',
|
1481 | active: true,
|
1482 | startPoint: {
|
1483 | lng: startPoint[0],
|
1484 | lat: startPoint[1]
|
1485 | },
|
1486 | endPoint: {
|
1487 | lng: endPoint[0],
|
1488 | lat: endPoint[1]
|
1489 | }
|
1490 | }, options),
|
1491 | geometry: {
|
1492 | type: 'Polygon',
|
1493 | coordinates: [[[minX, minY], [minX, maxY], [maxX, maxY], [maxX, minY], [minX, minY]]]
|
1494 | }
|
1495 | };
|
1496 | return feature;
|
1497 | }
|
1498 | function createPolygon(points, options) {
|
1499 | var coords = points.map(function (p) {
|
1500 | return [p.lng, p.lat];
|
1501 | });
|
1502 |
|
1503 | if (points.length < 2) {
|
1504 | return helpers_7(coords[0], options);
|
1505 | } else if (points.length < 3) {
|
1506 | return helpers_11(coords, options);
|
1507 | } else {
|
1508 | coords.push(coords[0]);
|
1509 | return helpers_9([coords], options);
|
1510 | }
|
1511 | }
|
1512 | function createLine(points, options) {
|
1513 | var coords = points.map(function (p) {
|
1514 | return [p.lng, p.lat];
|
1515 | });
|
1516 |
|
1517 | if (points.length < 2) {
|
1518 | return helpers_7(coords[0], options);
|
1519 | } else {
|
1520 | return helpers_11(coords, options);
|
1521 | }
|
1522 | }
|
1523 | function createPoint(points) {
|
1524 | var features = points.map(function (p, index) {
|
1525 | return helpers_7([p.lng, p.lat], {
|
1526 | active: true,
|
1527 | id: index.toString()
|
1528 | });
|
1529 | });
|
1530 | return helpers_13(features);
|
1531 | }
|
1532 |
|
1533 | function moveFeatures (features, delta) {
|
1534 | features.forEach(function (feature) {
|
1535 | var geometry = feature.geometry;
|
1536 | var nextCoord;
|
1537 | var type = geometry.type,
|
1538 | coordinates = geometry.coordinates;
|
1539 |
|
1540 | switch (type) {
|
1541 | case FeatureType.POINT:
|
1542 | nextCoord = movePoint(coordinates, delta);
|
1543 | break;
|
1544 |
|
1545 | case FeatureType.LINE_STRING:
|
1546 | case FeatureType.MULTI_POINT:
|
1547 | nextCoord = moveRing(coordinates, delta);
|
1548 | break;
|
1549 |
|
1550 | case FeatureType.POLYGON:
|
1551 | case FeatureType.MULTI_LINE_STRING:
|
1552 | nextCoord = moveMultiPolygon(coordinates, delta);
|
1553 | break;
|
1554 |
|
1555 | case FeatureType.MULTI_POLYGON:
|
1556 | nextCoord = coordinates.map(function (mult) {
|
1557 | return moveMultiPolygon(mult, delta);
|
1558 | });
|
1559 | break;
|
1560 | }
|
1561 |
|
1562 | if (nextCoord) {
|
1563 | geometry.coordinates = nextCoord;
|
1564 | }
|
1565 | });
|
1566 | return features;
|
1567 | }
|
1568 | function movePoint(coord, delta) {
|
1569 | return [coord[0] + delta.lng, coord[1] + delta.lat];
|
1570 | }
|
1571 | function moveRing(coords, delta) {
|
1572 | return coords.map(function (coord) {
|
1573 | return movePoint(coord, delta);
|
1574 | });
|
1575 | }
|
1576 | function moveMultiPolygon(mult, delta) {
|
1577 | return mult.map(function (ring) {
|
1578 | return moveRing(ring, delta);
|
1579 | });
|
1580 | }
|
1581 |
|
1582 | function renderFeature(fe, style) {
|
1583 | var _fe$features$, _fe$features$$geometr;
|
1584 |
|
1585 | var type = (_fe$features$ = fe.features[0]) === null || _fe$features$ === void 0 ? void 0 : (_fe$features$$geometr = _fe$features$.geometry) === null || _fe$features$$geometr === void 0 ? void 0 : _fe$features$$geometr.type;
|
1586 | var layers;
|
1587 |
|
1588 | switch (type) {
|
1589 | case 'Point':
|
1590 | layers = drawPoint(fe, style.point);
|
1591 | break;
|
1592 |
|
1593 | case 'LineString':
|
1594 | layers = drawLine(fe, style.line);
|
1595 | break;
|
1596 |
|
1597 | case 'Polygon':
|
1598 | layers = drawPolyon(fe, style.polygon);
|
1599 | break;
|
1600 | }
|
1601 |
|
1602 | return layers;
|
1603 | }
|
1604 |
|
1605 | function drawPoint(fe, style) {
|
1606 | var layer = new l7.PointLayer({
|
1607 | zIndex: 2,
|
1608 | pickingBuffer: 3
|
1609 | }).source(fe).shape('circle').color(style.color).size(style.size).style(style.style);
|
1610 | return [layer];
|
1611 | }
|
1612 |
|
1613 | function drawLine(fe, style) {
|
1614 | var layer = new l7.LineLayer({
|
1615 | pickingBuffer: 3
|
1616 | }).source(fe).shape('line').color(style.color).size(style.size).style(style.style);
|
1617 | return [layer];
|
1618 | }
|
1619 |
|
1620 | function drawPolyon(fe, style) {
|
1621 | var fill = new l7.PolygonLayer().source(fe).shape('fill').color(style.color).size(style.size).style({
|
1622 | opacity: style.style.opacity
|
1623 | });
|
1624 | var line = new l7.PolygonLayer().source(fe).shape('line').color(style.style.stroke).size(style.style.strokeWidth).style({
|
1625 | opacity: style.style.strokeOpacity,
|
1626 | lineType: style.style.lineType,
|
1627 | dashArray: style.style.dashArray
|
1628 | });
|
1629 | return [fill, line];
|
1630 | }
|
1631 |
|
1632 | var BaseRenderLayer = function () {
|
1633 | function BaseRenderLayer(draw) {
|
1634 | _classCallCheck(this, BaseRenderLayer);
|
1635 |
|
1636 | this.drawLayers = [];
|
1637 | this.draw = draw;
|
1638 | }
|
1639 |
|
1640 | _createClass(BaseRenderLayer, [{
|
1641 | key: "update",
|
1642 | value: function update(feature) {
|
1643 | if (this.drawLayers.length > 0) {
|
1644 | this.updateData(feature);
|
1645 | }
|
1646 |
|
1647 | this.removeLayers();
|
1648 | var style = this.draw.getStyle('normal');
|
1649 | this.drawLayers = renderFeature(feature, style);
|
1650 | this.addLayers();
|
1651 | }
|
1652 | }, {
|
1653 | key: "on",
|
1654 | value: function on(type, handler) {
|
1655 | var layer = this.drawLayers[0];
|
1656 | layer.on(type, handler);
|
1657 | }
|
1658 | }, {
|
1659 | key: "off",
|
1660 | value: function off(type, handler) {
|
1661 | var layer = this.drawLayers[0];
|
1662 | layer.off(type, handler);
|
1663 | }
|
1664 | }, {
|
1665 | key: "emit",
|
1666 | value: function emit(type, e) {
|
1667 | var layer = this.drawLayers[0];
|
1668 | layer.emit(type, e);
|
1669 | }
|
1670 | }, {
|
1671 | key: "updateData",
|
1672 | value: function updateData(data) {
|
1673 | if (this.drawLayers.length === 0) {
|
1674 | this.update(data);
|
1675 | }
|
1676 |
|
1677 | this.drawLayers.forEach(function (layer) {
|
1678 | return layer.setData(data);
|
1679 | });
|
1680 | }
|
1681 | }, {
|
1682 | key: "destroy",
|
1683 | value: function destroy() {
|
1684 | this.removeLayers();
|
1685 | }
|
1686 | }, {
|
1687 | key: "removeLayers",
|
1688 | value: function removeLayers() {
|
1689 | var _this = this;
|
1690 |
|
1691 | if (this.drawLayers.length !== 0) {
|
1692 | this.drawLayers.forEach(function (layer) {
|
1693 | return _this.draw.scene.removeLayer(layer);
|
1694 | });
|
1695 | }
|
1696 | }
|
1697 | }, {
|
1698 | key: "addLayers",
|
1699 | value: function addLayers() {
|
1700 | var _this2 = this;
|
1701 |
|
1702 | this.drawLayers.forEach(function (layer) {
|
1703 | return _this2.draw.scene.addLayer(layer);
|
1704 | });
|
1705 | }
|
1706 | }, {
|
1707 | key: "show",
|
1708 | value: function show() {
|
1709 | this.drawLayers.forEach(function (layer) {
|
1710 | return layer.show();
|
1711 | });
|
1712 | }
|
1713 | }, {
|
1714 | key: "hide",
|
1715 | value: function hide() {
|
1716 | this.drawLayers.forEach(function (layer) {
|
1717 | return layer.hide();
|
1718 | });
|
1719 | }
|
1720 | }]);
|
1721 |
|
1722 | return BaseRenderLayer;
|
1723 | }();
|
1724 |
|
1725 | var DrawLayer = function (_BaseRender) {
|
1726 | _inherits(DrawLayer, _BaseRender);
|
1727 |
|
1728 | var _super = _createSuper(DrawLayer);
|
1729 |
|
1730 | function DrawLayer() {
|
1731 | var _this;
|
1732 |
|
1733 | _classCallCheck(this, DrawLayer);
|
1734 |
|
1735 | _this = _super.apply(this, arguments);
|
1736 |
|
1737 | _this.onMouseMove = function (e) {
|
1738 | _this.draw.setCursor('move');
|
1739 |
|
1740 | _this.draw.selectMode.enable();
|
1741 | };
|
1742 |
|
1743 | _this.onUnMouseMove = function (e) {
|
1744 | _this.draw.resetCursor();
|
1745 |
|
1746 | _this.draw.selectMode.disable();
|
1747 | };
|
1748 |
|
1749 | _this.onClick = function (e) {
|
1750 | _this.draw.selectMode.disable();
|
1751 |
|
1752 | _this.draw.editMode.enable();
|
1753 |
|
1754 | _this.disableSelect();
|
1755 |
|
1756 | _this.draw.resetCursor();
|
1757 |
|
1758 | _this.enableEdit();
|
1759 |
|
1760 | _this.draw.setCurrentFeature(e.feature);
|
1761 |
|
1762 | _this.draw.emit(DrawEvent.MODE_CHANGE, DrawModes.DIRECT_SELECT);
|
1763 | };
|
1764 |
|
1765 | _this.onUnClick = function (e) {
|
1766 | _this.draw.selectMode.disable();
|
1767 |
|
1768 | _this.draw.editMode.disable();
|
1769 |
|
1770 | _this.draw.source.setFeatureUnActive(_this.draw.getCurrentFeature());
|
1771 |
|
1772 | _this.disableSelect();
|
1773 |
|
1774 | _this.disableEdit();
|
1775 |
|
1776 | _this.hide();
|
1777 |
|
1778 | _this.draw.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
|
1779 | };
|
1780 |
|
1781 | return _this;
|
1782 | }
|
1783 |
|
1784 | _createClass(DrawLayer, [{
|
1785 | key: "update",
|
1786 | value: function update(feature) {
|
1787 | this.removeLayers();
|
1788 | var style = this.draw.getStyle('active');
|
1789 | this.drawLayers = renderFeature(feature, style);
|
1790 | this.addLayers();
|
1791 | }
|
1792 | }, {
|
1793 | key: "enableSelect",
|
1794 | value: function enableSelect() {
|
1795 | this.show();
|
1796 |
|
1797 | if (this.isEnableDrag) {
|
1798 | return;
|
1799 | }
|
1800 |
|
1801 | var layer = this.drawLayers[0];
|
1802 | layer.on('mouseenter', this.onMouseMove);
|
1803 | layer.on('mouseout', this.onUnMouseMove);
|
1804 |
|
1805 | if (this.draw.editEnable) {
|
1806 | layer.on('click', this.onClick);
|
1807 | }
|
1808 |
|
1809 | layer.on('unclick', this.onUnClick);
|
1810 | this.isEnableDrag = true;
|
1811 | }
|
1812 | }, {
|
1813 | key: "disableSelect",
|
1814 | value: function disableSelect() {
|
1815 | if (!this.isEnableDrag) {
|
1816 | return;
|
1817 | }
|
1818 |
|
1819 | var layer = this.drawLayers[0];
|
1820 | layer.off('mouseenter', this.onMouseMove);
|
1821 | layer.off('mouseout', this.onUnMouseMove);
|
1822 | layer.off('click', this.onClick);
|
1823 | layer.off('unclick', this.onUnClick);
|
1824 | this.isEnableDrag = false;
|
1825 | }
|
1826 | }, {
|
1827 | key: "enableEdit",
|
1828 | value: function enableEdit() {
|
1829 | if (this.isEnableEdit) {
|
1830 | return;
|
1831 | }
|
1832 |
|
1833 | var layer = this.drawLayers[0];
|
1834 | layer.on('unclick', this.onUnClick);
|
1835 | this.isEnableDrag = true;
|
1836 | }
|
1837 | }, {
|
1838 | key: "disableEdit",
|
1839 | value: function disableEdit() {
|
1840 | if (!this.isEnableEdit) {
|
1841 | return;
|
1842 | }
|
1843 |
|
1844 | var layer = this.drawLayers[0];
|
1845 | layer.off('unclick', this.onUnClick);
|
1846 | this.isEnableDrag = false;
|
1847 | }
|
1848 | }]);
|
1849 |
|
1850 | return DrawLayer;
|
1851 | }(BaseRenderLayer);
|
1852 |
|
1853 | var DrawResultLayer = function (_BaseRender) {
|
1854 | _inherits(DrawResultLayer, _BaseRender);
|
1855 |
|
1856 | var _super = _createSuper(DrawResultLayer);
|
1857 |
|
1858 | function DrawResultLayer() {
|
1859 | var _this;
|
1860 |
|
1861 | _classCallCheck(this, DrawResultLayer);
|
1862 |
|
1863 | _this = _super.apply(this, arguments);
|
1864 |
|
1865 | _this.onClick = function (e) {
|
1866 | _this.draw.source.setFeatureUnActive(_this.draw.getCurrentFeature());
|
1867 |
|
1868 | _this.draw.setCurrentFeature(e.feature);
|
1869 |
|
1870 | _this.draw.source.setFeatureActive(e.feature);
|
1871 |
|
1872 | _this.updateData(_this.draw.source.data);
|
1873 |
|
1874 | _this.draw.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
|
1875 | };
|
1876 |
|
1877 | _this.onDeleteClick = function (e) {
|
1878 | _this.draw.source.removeFeature(e.feature);
|
1879 |
|
1880 | _this.updateData(_this.draw.source.data);
|
1881 | };
|
1882 |
|
1883 | return _this;
|
1884 | }
|
1885 |
|
1886 | _createClass(DrawResultLayer, [{
|
1887 | key: "update",
|
1888 | value: function update(feature) {
|
1889 | if (this.drawLayers.length > 0) {
|
1890 | this.updateData(feature);
|
1891 | return;
|
1892 | }
|
1893 |
|
1894 | this.removeLayers();
|
1895 | var style = this.draw.getStyle('normal');
|
1896 | this.drawLayers = renderFeature(feature, style);
|
1897 | this.addFilter();
|
1898 | this.addLayers();
|
1899 | }
|
1900 | }, {
|
1901 | key: "enableSelect",
|
1902 | value: function enableSelect() {
|
1903 | if (this.isEnableDrag) {
|
1904 | return;
|
1905 | }
|
1906 |
|
1907 | if (!this.draw.selectEnable) {
|
1908 | return;
|
1909 | }
|
1910 |
|
1911 | var layer = this.drawLayers[0];
|
1912 | layer.on('click', this.onClick);
|
1913 | this.isEnableDrag = true;
|
1914 | }
|
1915 | }, {
|
1916 | key: "disableSelect",
|
1917 | value: function disableSelect() {
|
1918 | if (!this.isEnableDrag) {
|
1919 | return;
|
1920 | }
|
1921 |
|
1922 | var layer = this.drawLayers[0];
|
1923 | layer.off('click', this.onClick);
|
1924 | this.isEnableDrag = false;
|
1925 | }
|
1926 | }, {
|
1927 | key: "enableDelete",
|
1928 | value: function enableDelete() {
|
1929 | this.disableSelect();
|
1930 | var layer = this.drawLayers[0];
|
1931 | layer.on('click', this.onDeleteClick);
|
1932 | }
|
1933 | }, {
|
1934 | key: "disableDelete",
|
1935 | value: function disableDelete() {
|
1936 | var layer = this.drawLayers[0];
|
1937 | layer.off('click', this.onDeleteClick);
|
1938 | }
|
1939 | }, {
|
1940 | key: "addFilter",
|
1941 | value: function addFilter() {
|
1942 | this.drawLayers.forEach(function (layer) {
|
1943 | return layer.filter('active', function (active) {
|
1944 | return !active;
|
1945 | });
|
1946 | });
|
1947 | }
|
1948 | }]);
|
1949 |
|
1950 | return DrawResultLayer;
|
1951 | }(BaseRenderLayer);
|
1952 |
|
1953 | var DrawVertexLayer = function (_BaseRender) {
|
1954 | _inherits(DrawVertexLayer, _BaseRender);
|
1955 |
|
1956 | var _super = _createSuper(DrawVertexLayer);
|
1957 |
|
1958 | function DrawVertexLayer() {
|
1959 | var _this;
|
1960 |
|
1961 | _classCallCheck(this, DrawVertexLayer);
|
1962 |
|
1963 | _this = _super.apply(this, arguments);
|
1964 |
|
1965 | _this.onMouseEnter = function (e) {
|
1966 | _this.draw.setCursor('move');
|
1967 |
|
1968 | _this.draw.setCurrentVertex(e.feature);
|
1969 |
|
1970 | _this.draw.editMode.enable();
|
1971 | };
|
1972 |
|
1973 | _this.onMouseOut = function (e) {
|
1974 | _this.draw.resetCursor();
|
1975 |
|
1976 | _this.draw.editMode.disable();
|
1977 | };
|
1978 |
|
1979 | _this.onClick = function (e) {
|
1980 | _this.draw.setCurrentVertex(e.feature);
|
1981 |
|
1982 | _this.draw.editMode.enable();
|
1983 | };
|
1984 |
|
1985 | return _this;
|
1986 | }
|
1987 |
|
1988 | _createClass(DrawVertexLayer, [{
|
1989 | key: "update",
|
1990 | value: function update(feature) {
|
1991 | this.removeLayers();
|
1992 | var style = this.draw.getStyle('active');
|
1993 | this.drawLayers = renderFeature(feature, style);
|
1994 | this.addLayers();
|
1995 | }
|
1996 | }, {
|
1997 | key: "enableSelect",
|
1998 | value: function enableSelect() {
|
1999 | return;
|
2000 | }
|
2001 | }, {
|
2002 | key: "disableSelect",
|
2003 | value: function disableSelect() {
|
2004 | return;
|
2005 | }
|
2006 | }, {
|
2007 | key: "enableEdit",
|
2008 | value: function enableEdit() {
|
2009 | if (this.isEnableEdit) {
|
2010 | return;
|
2011 | }
|
2012 |
|
2013 | var layer = this.drawLayers[0];
|
2014 | layer.on('mouseenter', this.onMouseEnter);
|
2015 | layer.on('mouseout', this.onMouseOut);
|
2016 | layer.on('click', this.onClick);
|
2017 | this.isEnableEdit = true;
|
2018 | }
|
2019 | }, {
|
2020 | key: "disableEdit",
|
2021 | value: function disableEdit() {
|
2022 | if (!this.isEnableEdit) {
|
2023 | return;
|
2024 | }
|
2025 |
|
2026 | var layer = this.drawLayers[0];
|
2027 | layer.off('mouseenter', this.onMouseEnter);
|
2028 | layer.off('mouseout', this.onMouseOut);
|
2029 | layer.off('click', this.onClick);
|
2030 | this.isEnableEdit = false;
|
2031 | }
|
2032 | }]);
|
2033 |
|
2034 | return DrawVertexLayer;
|
2035 | }(BaseRenderLayer);
|
2036 |
|
2037 | var eventemitter3 = createCommonjsModule(function (module) {
|
2038 |
|
2039 | var has = Object.prototype.hasOwnProperty
|
2040 | , prefix = '~';
|
2041 |
|
2042 | |
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 | function Events() {}
|
2050 |
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 | if (Object.create) {
|
2059 | Events.prototype = Object.create(null);
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 | if (!new Events().__proto__) prefix = false;
|
2066 | }
|
2067 |
|
2068 | |
2069 |
|
2070 |
|
2071 |
|
2072 |
|
2073 |
|
2074 |
|
2075 |
|
2076 |
|
2077 | function EE(fn, context, once) {
|
2078 | this.fn = fn;
|
2079 | this.context = context;
|
2080 | this.once = once || false;
|
2081 | }
|
2082 |
|
2083 | |
2084 |
|
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 |
|
2094 | function addListener(emitter, event, fn, context, once) {
|
2095 | if (typeof fn !== 'function') {
|
2096 | throw new TypeError('The listener must be a function');
|
2097 | }
|
2098 |
|
2099 | var listener = new EE(fn, context || emitter, once)
|
2100 | , evt = prefix ? prefix + event : event;
|
2101 |
|
2102 | if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
2103 | else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
2104 | else emitter._events[evt] = [emitter._events[evt], listener];
|
2105 |
|
2106 | return emitter;
|
2107 | }
|
2108 |
|
2109 | |
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 | function clearEvent(emitter, evt) {
|
2117 | if (--emitter._eventsCount === 0) emitter._events = new Events();
|
2118 | else delete emitter._events[evt];
|
2119 | }
|
2120 |
|
2121 | |
2122 |
|
2123 |
|
2124 |
|
2125 |
|
2126 |
|
2127 |
|
2128 | function EventEmitter() {
|
2129 | this._events = new Events();
|
2130 | this._eventsCount = 0;
|
2131 | }
|
2132 |
|
2133 | |
2134 |
|
2135 |
|
2136 |
|
2137 |
|
2138 |
|
2139 |
|
2140 | EventEmitter.prototype.eventNames = function eventNames() {
|
2141 | var names = []
|
2142 | , events
|
2143 | , name;
|
2144 |
|
2145 | if (this._eventsCount === 0) return names;
|
2146 |
|
2147 | for (name in (events = this._events)) {
|
2148 | if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
2149 | }
|
2150 |
|
2151 | if (Object.getOwnPropertySymbols) {
|
2152 | return names.concat(Object.getOwnPropertySymbols(events));
|
2153 | }
|
2154 |
|
2155 | return names;
|
2156 | };
|
2157 |
|
2158 | |
2159 |
|
2160 |
|
2161 |
|
2162 |
|
2163 |
|
2164 |
|
2165 | EventEmitter.prototype.listeners = function listeners(event) {
|
2166 | var evt = prefix ? prefix + event : event
|
2167 | , handlers = this._events[evt];
|
2168 |
|
2169 | if (!handlers) return [];
|
2170 | if (handlers.fn) return [handlers.fn];
|
2171 |
|
2172 | for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
2173 | ee[i] = handlers[i].fn;
|
2174 | }
|
2175 |
|
2176 | return ee;
|
2177 | };
|
2178 |
|
2179 | |
2180 |
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 | EventEmitter.prototype.listenerCount = function listenerCount(event) {
|
2187 | var evt = prefix ? prefix + event : event
|
2188 | , listeners = this._events[evt];
|
2189 |
|
2190 | if (!listeners) return 0;
|
2191 | if (listeners.fn) return 1;
|
2192 | return listeners.length;
|
2193 | };
|
2194 |
|
2195 | |
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 | EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
2203 | var evt = prefix ? prefix + event : event;
|
2204 |
|
2205 | if (!this._events[evt]) return false;
|
2206 |
|
2207 | var listeners = this._events[evt]
|
2208 | , len = arguments.length
|
2209 | , args
|
2210 | , i;
|
2211 |
|
2212 | if (listeners.fn) {
|
2213 | if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
|
2214 |
|
2215 | switch (len) {
|
2216 | case 1: return listeners.fn.call(listeners.context), true;
|
2217 | case 2: return listeners.fn.call(listeners.context, a1), true;
|
2218 | case 3: return listeners.fn.call(listeners.context, a1, a2), true;
|
2219 | case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
|
2220 | case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
|
2221 | case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
|
2222 | }
|
2223 |
|
2224 | for (i = 1, args = new Array(len -1); i < len; i++) {
|
2225 | args[i - 1] = arguments[i];
|
2226 | }
|
2227 |
|
2228 | listeners.fn.apply(listeners.context, args);
|
2229 | } else {
|
2230 | var length = listeners.length
|
2231 | , j;
|
2232 |
|
2233 | for (i = 0; i < length; i++) {
|
2234 | if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
|
2235 |
|
2236 | switch (len) {
|
2237 | case 1: listeners[i].fn.call(listeners[i].context); break;
|
2238 | case 2: listeners[i].fn.call(listeners[i].context, a1); break;
|
2239 | case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
|
2240 | case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
|
2241 | default:
|
2242 | if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
|
2243 | args[j - 1] = arguments[j];
|
2244 | }
|
2245 |
|
2246 | listeners[i].fn.apply(listeners[i].context, args);
|
2247 | }
|
2248 | }
|
2249 | }
|
2250 |
|
2251 | return true;
|
2252 | };
|
2253 |
|
2254 | |
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 | EventEmitter.prototype.on = function on(event, fn, context) {
|
2264 | return addListener(this, event, fn, context, false);
|
2265 | };
|
2266 |
|
2267 | |
2268 |
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 | EventEmitter.prototype.once = function once(event, fn, context) {
|
2277 | return addListener(this, event, fn, context, true);
|
2278 | };
|
2279 |
|
2280 | |
2281 |
|
2282 |
|
2283 |
|
2284 |
|
2285 |
|
2286 |
|
2287 |
|
2288 |
|
2289 |
|
2290 | EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
|
2291 | var evt = prefix ? prefix + event : event;
|
2292 |
|
2293 | if (!this._events[evt]) return this;
|
2294 | if (!fn) {
|
2295 | clearEvent(this, evt);
|
2296 | return this;
|
2297 | }
|
2298 |
|
2299 | var listeners = this._events[evt];
|
2300 |
|
2301 | if (listeners.fn) {
|
2302 | if (
|
2303 | listeners.fn === fn &&
|
2304 | (!once || listeners.once) &&
|
2305 | (!context || listeners.context === context)
|
2306 | ) {
|
2307 | clearEvent(this, evt);
|
2308 | }
|
2309 | } else {
|
2310 | for (var i = 0, events = [], length = listeners.length; i < length; i++) {
|
2311 | if (
|
2312 | listeners[i].fn !== fn ||
|
2313 | (once && !listeners[i].once) ||
|
2314 | (context && listeners[i].context !== context)
|
2315 | ) {
|
2316 | events.push(listeners[i]);
|
2317 | }
|
2318 | }
|
2319 |
|
2320 |
|
2321 |
|
2322 |
|
2323 | if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
|
2324 | else clearEvent(this, evt);
|
2325 | }
|
2326 |
|
2327 | return this;
|
2328 | };
|
2329 |
|
2330 | |
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 |
|
2336 |
|
2337 | EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
|
2338 | var evt;
|
2339 |
|
2340 | if (event) {
|
2341 | evt = prefix ? prefix + event : event;
|
2342 | if (this._events[evt]) clearEvent(this, evt);
|
2343 | } else {
|
2344 | this._events = new Events();
|
2345 | this._eventsCount = 0;
|
2346 | }
|
2347 |
|
2348 | return this;
|
2349 | };
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 | EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
2355 | EventEmitter.prototype.addListener = EventEmitter.prototype.on;
|
2356 |
|
2357 |
|
2358 |
|
2359 |
|
2360 | EventEmitter.prefixed = prefix;
|
2361 |
|
2362 |
|
2363 |
|
2364 |
|
2365 | EventEmitter.EventEmitter = EventEmitter;
|
2366 |
|
2367 |
|
2368 |
|
2369 |
|
2370 | {
|
2371 | module.exports = EventEmitter;
|
2372 | }
|
2373 | });
|
2374 | var eventemitter3_1 = eventemitter3.EventEmitter;
|
2375 |
|
2376 | |
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 | function listCacheClear() {
|
2384 | this.__data__ = [];
|
2385 | this.size = 0;
|
2386 | }
|
2387 |
|
2388 | var _listCacheClear = listCacheClear;
|
2389 |
|
2390 | |
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 |
|
2397 |
|
2398 |
|
2399 |
|
2400 |
|
2401 |
|
2402 |
|
2403 |
|
2404 |
|
2405 |
|
2406 |
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |
|
2415 |
|
2416 |
|
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 | function eq(value, other) {
|
2423 | return value === other || (value !== value && other !== other);
|
2424 | }
|
2425 |
|
2426 | var eq_1 = eq;
|
2427 |
|
2428 | |
2429 |
|
2430 |
|
2431 |
|
2432 |
|
2433 |
|
2434 |
|
2435 |
|
2436 | function assocIndexOf(array, key) {
|
2437 | var length = array.length;
|
2438 | while (length--) {
|
2439 | if (eq_1(array[length][0], key)) {
|
2440 | return length;
|
2441 | }
|
2442 | }
|
2443 | return -1;
|
2444 | }
|
2445 |
|
2446 | var _assocIndexOf = assocIndexOf;
|
2447 |
|
2448 |
|
2449 | var arrayProto = Array.prototype;
|
2450 |
|
2451 |
|
2452 | var splice = arrayProto.splice;
|
2453 |
|
2454 | |
2455 |
|
2456 |
|
2457 |
|
2458 |
|
2459 |
|
2460 |
|
2461 |
|
2462 |
|
2463 | function listCacheDelete(key) {
|
2464 | var data = this.__data__,
|
2465 | index = _assocIndexOf(data, key);
|
2466 |
|
2467 | if (index < 0) {
|
2468 | return false;
|
2469 | }
|
2470 | var lastIndex = data.length - 1;
|
2471 | if (index == lastIndex) {
|
2472 | data.pop();
|
2473 | } else {
|
2474 | splice.call(data, index, 1);
|
2475 | }
|
2476 | --this.size;
|
2477 | return true;
|
2478 | }
|
2479 |
|
2480 | var _listCacheDelete = listCacheDelete;
|
2481 |
|
2482 | |
2483 |
|
2484 |
|
2485 |
|
2486 |
|
2487 |
|
2488 |
|
2489 |
|
2490 |
|
2491 | function listCacheGet(key) {
|
2492 | var data = this.__data__,
|
2493 | index = _assocIndexOf(data, key);
|
2494 |
|
2495 | return index < 0 ? undefined : data[index][1];
|
2496 | }
|
2497 |
|
2498 | var _listCacheGet = listCacheGet;
|
2499 |
|
2500 | |
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 | function listCacheHas(key) {
|
2510 | return _assocIndexOf(this.__data__, key) > -1;
|
2511 | }
|
2512 |
|
2513 | var _listCacheHas = listCacheHas;
|
2514 |
|
2515 | |
2516 |
|
2517 |
|
2518 |
|
2519 |
|
2520 |
|
2521 |
|
2522 |
|
2523 |
|
2524 |
|
2525 | function listCacheSet(key, value) {
|
2526 | var data = this.__data__,
|
2527 | index = _assocIndexOf(data, key);
|
2528 |
|
2529 | if (index < 0) {
|
2530 | ++this.size;
|
2531 | data.push([key, value]);
|
2532 | } else {
|
2533 | data[index][1] = value;
|
2534 | }
|
2535 | return this;
|
2536 | }
|
2537 |
|
2538 | var _listCacheSet = listCacheSet;
|
2539 |
|
2540 | |
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 | function ListCache(entries) {
|
2548 | var index = -1,
|
2549 | length = entries == null ? 0 : entries.length;
|
2550 |
|
2551 | this.clear();
|
2552 | while (++index < length) {
|
2553 | var entry = entries[index];
|
2554 | this.set(entry[0], entry[1]);
|
2555 | }
|
2556 | }
|
2557 |
|
2558 |
|
2559 | ListCache.prototype.clear = _listCacheClear;
|
2560 | ListCache.prototype['delete'] = _listCacheDelete;
|
2561 | ListCache.prototype.get = _listCacheGet;
|
2562 | ListCache.prototype.has = _listCacheHas;
|
2563 | ListCache.prototype.set = _listCacheSet;
|
2564 |
|
2565 | var _ListCache = ListCache;
|
2566 |
|
2567 | |
2568 |
|
2569 |
|
2570 |
|
2571 |
|
2572 |
|
2573 |
|
2574 | function stackClear() {
|
2575 | this.__data__ = new _ListCache;
|
2576 | this.size = 0;
|
2577 | }
|
2578 |
|
2579 | var _stackClear = stackClear;
|
2580 |
|
2581 | |
2582 |
|
2583 |
|
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 | function stackDelete(key) {
|
2591 | var data = this.__data__,
|
2592 | result = data['delete'](key);
|
2593 |
|
2594 | this.size = data.size;
|
2595 | return result;
|
2596 | }
|
2597 |
|
2598 | var _stackDelete = stackDelete;
|
2599 |
|
2600 | |
2601 |
|
2602 |
|
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 |
|
2609 | function stackGet(key) {
|
2610 | return this.__data__.get(key);
|
2611 | }
|
2612 |
|
2613 | var _stackGet = stackGet;
|
2614 |
|
2615 | |
2616 |
|
2617 |
|
2618 |
|
2619 |
|
2620 |
|
2621 |
|
2622 |
|
2623 |
|
2624 | function stackHas(key) {
|
2625 | return this.__data__.has(key);
|
2626 | }
|
2627 |
|
2628 | var _stackHas = stackHas;
|
2629 |
|
2630 |
|
2631 | var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
2632 |
|
2633 | var _freeGlobal = freeGlobal;
|
2634 |
|
2635 |
|
2636 | var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
2637 |
|
2638 |
|
2639 | var root = _freeGlobal || freeSelf || Function('return this')();
|
2640 |
|
2641 | var _root = root;
|
2642 |
|
2643 |
|
2644 | var Symbol$1 = _root.Symbol;
|
2645 |
|
2646 | var _Symbol = Symbol$1;
|
2647 |
|
2648 |
|
2649 | var objectProto = Object.prototype;
|
2650 |
|
2651 |
|
2652 | var hasOwnProperty = objectProto.hasOwnProperty;
|
2653 |
|
2654 | |
2655 |
|
2656 |
|
2657 |
|
2658 |
|
2659 | var nativeObjectToString = objectProto.toString;
|
2660 |
|
2661 |
|
2662 | var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
|
2663 |
|
2664 | |
2665 |
|
2666 |
|
2667 |
|
2668 |
|
2669 |
|
2670 |
|
2671 | function getRawTag(value) {
|
2672 | var isOwn = hasOwnProperty.call(value, symToStringTag),
|
2673 | tag = value[symToStringTag];
|
2674 |
|
2675 | try {
|
2676 | value[symToStringTag] = undefined;
|
2677 | var unmasked = true;
|
2678 | } catch (e) {}
|
2679 |
|
2680 | var result = nativeObjectToString.call(value);
|
2681 | if (unmasked) {
|
2682 | if (isOwn) {
|
2683 | value[symToStringTag] = tag;
|
2684 | } else {
|
2685 | delete value[symToStringTag];
|
2686 | }
|
2687 | }
|
2688 | return result;
|
2689 | }
|
2690 |
|
2691 | var _getRawTag = getRawTag;
|
2692 |
|
2693 |
|
2694 | var objectProto$1 = Object.prototype;
|
2695 |
|
2696 | |
2697 |
|
2698 |
|
2699 |
|
2700 |
|
2701 | var nativeObjectToString$1 = objectProto$1.toString;
|
2702 |
|
2703 | |
2704 |
|
2705 |
|
2706 |
|
2707 |
|
2708 |
|
2709 |
|
2710 | function objectToString(value) {
|
2711 | return nativeObjectToString$1.call(value);
|
2712 | }
|
2713 |
|
2714 | var _objectToString = objectToString;
|
2715 |
|
2716 |
|
2717 | var nullTag = '[object Null]',
|
2718 | undefinedTag = '[object Undefined]';
|
2719 |
|
2720 |
|
2721 | var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
|
2722 |
|
2723 | |
2724 |
|
2725 |
|
2726 |
|
2727 |
|
2728 |
|
2729 |
|
2730 | function baseGetTag(value) {
|
2731 | if (value == null) {
|
2732 | return value === undefined ? undefinedTag : nullTag;
|
2733 | }
|
2734 | return (symToStringTag$1 && symToStringTag$1 in Object(value))
|
2735 | ? _getRawTag(value)
|
2736 | : _objectToString(value);
|
2737 | }
|
2738 |
|
2739 | var _baseGetTag = baseGetTag;
|
2740 |
|
2741 | |
2742 |
|
2743 |
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 |
|
2764 |
|
2765 |
|
2766 | function isObject(value) {
|
2767 | var type = typeof value;
|
2768 | return value != null && (type == 'object' || type == 'function');
|
2769 | }
|
2770 |
|
2771 | var isObject_1 = isObject;
|
2772 |
|
2773 |
|
2774 | var asyncTag = '[object AsyncFunction]',
|
2775 | funcTag = '[object Function]',
|
2776 | genTag = '[object GeneratorFunction]',
|
2777 | proxyTag = '[object Proxy]';
|
2778 |
|
2779 | |
2780 |
|
2781 |
|
2782 |
|
2783 |
|
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 |
|
2791 |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 | function isFunction(value) {
|
2797 | if (!isObject_1(value)) {
|
2798 | return false;
|
2799 | }
|
2800 |
|
2801 |
|
2802 | var tag = _baseGetTag(value);
|
2803 | return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
2804 | }
|
2805 |
|
2806 | var isFunction_1 = isFunction;
|
2807 |
|
2808 |
|
2809 | var coreJsData = _root['__core-js_shared__'];
|
2810 |
|
2811 | var _coreJsData = coreJsData;
|
2812 |
|
2813 |
|
2814 | var maskSrcKey = (function() {
|
2815 | var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
|
2816 | return uid ? ('Symbol(src)_1.' + uid) : '';
|
2817 | }());
|
2818 |
|
2819 | |
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 | function isMasked(func) {
|
2827 | return !!maskSrcKey && (maskSrcKey in func);
|
2828 | }
|
2829 |
|
2830 | var _isMasked = isMasked;
|
2831 |
|
2832 |
|
2833 | var funcProto = Function.prototype;
|
2834 |
|
2835 |
|
2836 | var funcToString = funcProto.toString;
|
2837 |
|
2838 | |
2839 |
|
2840 |
|
2841 |
|
2842 |
|
2843 |
|
2844 |
|
2845 | function toSource(func) {
|
2846 | if (func != null) {
|
2847 | try {
|
2848 | return funcToString.call(func);
|
2849 | } catch (e) {}
|
2850 | try {
|
2851 | return (func + '');
|
2852 | } catch (e) {}
|
2853 | }
|
2854 | return '';
|
2855 | }
|
2856 |
|
2857 | var _toSource = toSource;
|
2858 |
|
2859 | |
2860 |
|
2861 |
|
2862 |
|
2863 | var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
2864 |
|
2865 |
|
2866 | var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
2867 |
|
2868 |
|
2869 | var funcProto$1 = Function.prototype,
|
2870 | objectProto$2 = Object.prototype;
|
2871 |
|
2872 |
|
2873 | var funcToString$1 = funcProto$1.toString;
|
2874 |
|
2875 |
|
2876 | var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
|
2877 |
|
2878 |
|
2879 | var reIsNative = RegExp('^' +
|
2880 | funcToString$1.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
|
2881 | .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
2882 | );
|
2883 |
|
2884 | |
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 | function baseIsNative(value) {
|
2893 | if (!isObject_1(value) || _isMasked(value)) {
|
2894 | return false;
|
2895 | }
|
2896 | var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
|
2897 | return pattern.test(_toSource(value));
|
2898 | }
|
2899 |
|
2900 | var _baseIsNative = baseIsNative;
|
2901 |
|
2902 | |
2903 |
|
2904 |
|
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 | function getValue(object, key) {
|
2911 | return object == null ? undefined : object[key];
|
2912 | }
|
2913 |
|
2914 | var _getValue = getValue;
|
2915 |
|
2916 | |
2917 |
|
2918 |
|
2919 |
|
2920 |
|
2921 |
|
2922 |
|
2923 |
|
2924 | function getNative(object, key) {
|
2925 | var value = _getValue(object, key);
|
2926 | return _baseIsNative(value) ? value : undefined;
|
2927 | }
|
2928 |
|
2929 | var _getNative = getNative;
|
2930 |
|
2931 |
|
2932 | var Map = _getNative(_root, 'Map');
|
2933 |
|
2934 | var _Map = Map;
|
2935 |
|
2936 |
|
2937 | var nativeCreate = _getNative(Object, 'create');
|
2938 |
|
2939 | var _nativeCreate = nativeCreate;
|
2940 |
|
2941 | |
2942 |
|
2943 |
|
2944 |
|
2945 |
|
2946 |
|
2947 |
|
2948 | function hashClear() {
|
2949 | this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
|
2950 | this.size = 0;
|
2951 | }
|
2952 |
|
2953 | var _hashClear = hashClear;
|
2954 |
|
2955 | |
2956 |
|
2957 |
|
2958 |
|
2959 |
|
2960 |
|
2961 |
|
2962 |
|
2963 |
|
2964 |
|
2965 | function hashDelete(key) {
|
2966 | var result = this.has(key) && delete this.__data__[key];
|
2967 | this.size -= result ? 1 : 0;
|
2968 | return result;
|
2969 | }
|
2970 |
|
2971 | var _hashDelete = hashDelete;
|
2972 |
|
2973 |
|
2974 | var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
2975 |
|
2976 |
|
2977 | var objectProto$3 = Object.prototype;
|
2978 |
|
2979 |
|
2980 | var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
2981 |
|
2982 | |
2983 |
|
2984 |
|
2985 |
|
2986 |
|
2987 |
|
2988 |
|
2989 |
|
2990 |
|
2991 | function hashGet(key) {
|
2992 | var data = this.__data__;
|
2993 | if (_nativeCreate) {
|
2994 | var result = data[key];
|
2995 | return result === HASH_UNDEFINED ? undefined : result;
|
2996 | }
|
2997 | return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
|
2998 | }
|
2999 |
|
3000 | var _hashGet = hashGet;
|
3001 |
|
3002 |
|
3003 | var objectProto$4 = Object.prototype;
|
3004 |
|
3005 |
|
3006 | var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
|
3007 |
|
3008 | |
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 |
|
3015 |
|
3016 |
|
3017 | function hashHas(key) {
|
3018 | var data = this.__data__;
|
3019 | return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
|
3020 | }
|
3021 |
|
3022 | var _hashHas = hashHas;
|
3023 |
|
3024 |
|
3025 | var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
|
3026 |
|
3027 | |
3028 |
|
3029 |
|
3030 |
|
3031 |
|
3032 |
|
3033 |
|
3034 |
|
3035 |
|
3036 |
|
3037 | function hashSet(key, value) {
|
3038 | var data = this.__data__;
|
3039 | this.size += this.has(key) ? 0 : 1;
|
3040 | data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
|
3041 | return this;
|
3042 | }
|
3043 |
|
3044 | var _hashSet = hashSet;
|
3045 |
|
3046 | |
3047 |
|
3048 |
|
3049 |
|
3050 |
|
3051 |
|
3052 |
|
3053 | function Hash(entries) {
|
3054 | var index = -1,
|
3055 | length = entries == null ? 0 : entries.length;
|
3056 |
|
3057 | this.clear();
|
3058 | while (++index < length) {
|
3059 | var entry = entries[index];
|
3060 | this.set(entry[0], entry[1]);
|
3061 | }
|
3062 | }
|
3063 |
|
3064 |
|
3065 | Hash.prototype.clear = _hashClear;
|
3066 | Hash.prototype['delete'] = _hashDelete;
|
3067 | Hash.prototype.get = _hashGet;
|
3068 | Hash.prototype.has = _hashHas;
|
3069 | Hash.prototype.set = _hashSet;
|
3070 |
|
3071 | var _Hash = Hash;
|
3072 |
|
3073 | |
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 | function mapCacheClear() {
|
3081 | this.size = 0;
|
3082 | this.__data__ = {
|
3083 | 'hash': new _Hash,
|
3084 | 'map': new (_Map || _ListCache),
|
3085 | 'string': new _Hash
|
3086 | };
|
3087 | }
|
3088 |
|
3089 | var _mapCacheClear = mapCacheClear;
|
3090 |
|
3091 | |
3092 |
|
3093 |
|
3094 |
|
3095 |
|
3096 |
|
3097 |
|
3098 | function isKeyable(value) {
|
3099 | var type = typeof value;
|
3100 | return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
3101 | ? (value !== '__proto__')
|
3102 | : (value === null);
|
3103 | }
|
3104 |
|
3105 | var _isKeyable = isKeyable;
|
3106 |
|
3107 | |
3108 |
|
3109 |
|
3110 |
|
3111 |
|
3112 |
|
3113 |
|
3114 |
|
3115 | function getMapData(map, key) {
|
3116 | var data = map.__data__;
|
3117 | return _isKeyable(key)
|
3118 | ? data[typeof key == 'string' ? 'string' : 'hash']
|
3119 | : data.map;
|
3120 | }
|
3121 |
|
3122 | var _getMapData = getMapData;
|
3123 |
|
3124 | |
3125 |
|
3126 |
|
3127 |
|
3128 |
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 | function mapCacheDelete(key) {
|
3134 | var result = _getMapData(this, key)['delete'](key);
|
3135 | this.size -= result ? 1 : 0;
|
3136 | return result;
|
3137 | }
|
3138 |
|
3139 | var _mapCacheDelete = mapCacheDelete;
|
3140 |
|
3141 | |
3142 |
|
3143 |
|
3144 |
|
3145 |
|
3146 |
|
3147 |
|
3148 |
|
3149 |
|
3150 | function mapCacheGet(key) {
|
3151 | return _getMapData(this, key).get(key);
|
3152 | }
|
3153 |
|
3154 | var _mapCacheGet = mapCacheGet;
|
3155 |
|
3156 | |
3157 |
|
3158 |
|
3159 |
|
3160 |
|
3161 |
|
3162 |
|
3163 |
|
3164 |
|
3165 | function mapCacheHas(key) {
|
3166 | return _getMapData(this, key).has(key);
|
3167 | }
|
3168 |
|
3169 | var _mapCacheHas = mapCacheHas;
|
3170 |
|
3171 | |
3172 |
|
3173 |
|
3174 |
|
3175 |
|
3176 |
|
3177 |
|
3178 |
|
3179 |
|
3180 |
|
3181 | function mapCacheSet(key, value) {
|
3182 | var data = _getMapData(this, key),
|
3183 | size = data.size;
|
3184 |
|
3185 | data.set(key, value);
|
3186 | this.size += data.size == size ? 0 : 1;
|
3187 | return this;
|
3188 | }
|
3189 |
|
3190 | var _mapCacheSet = mapCacheSet;
|
3191 |
|
3192 | |
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 |
|
3199 | function MapCache(entries) {
|
3200 | var index = -1,
|
3201 | length = entries == null ? 0 : entries.length;
|
3202 |
|
3203 | this.clear();
|
3204 | while (++index < length) {
|
3205 | var entry = entries[index];
|
3206 | this.set(entry[0], entry[1]);
|
3207 | }
|
3208 | }
|
3209 |
|
3210 |
|
3211 | MapCache.prototype.clear = _mapCacheClear;
|
3212 | MapCache.prototype['delete'] = _mapCacheDelete;
|
3213 | MapCache.prototype.get = _mapCacheGet;
|
3214 | MapCache.prototype.has = _mapCacheHas;
|
3215 | MapCache.prototype.set = _mapCacheSet;
|
3216 |
|
3217 | var _MapCache = MapCache;
|
3218 |
|
3219 |
|
3220 | var LARGE_ARRAY_SIZE = 200;
|
3221 |
|
3222 | |
3223 |
|
3224 |
|
3225 |
|
3226 |
|
3227 |
|
3228 |
|
3229 |
|
3230 |
|
3231 |
|
3232 | function stackSet(key, value) {
|
3233 | var data = this.__data__;
|
3234 | if (data instanceof _ListCache) {
|
3235 | var pairs = data.__data__;
|
3236 | if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
|
3237 | pairs.push([key, value]);
|
3238 | this.size = ++data.size;
|
3239 | return this;
|
3240 | }
|
3241 | data = this.__data__ = new _MapCache(pairs);
|
3242 | }
|
3243 | data.set(key, value);
|
3244 | this.size = data.size;
|
3245 | return this;
|
3246 | }
|
3247 |
|
3248 | var _stackSet = stackSet;
|
3249 |
|
3250 | |
3251 |
|
3252 |
|
3253 |
|
3254 |
|
3255 |
|
3256 |
|
3257 | function Stack(entries) {
|
3258 | var data = this.__data__ = new _ListCache(entries);
|
3259 | this.size = data.size;
|
3260 | }
|
3261 |
|
3262 |
|
3263 | Stack.prototype.clear = _stackClear;
|
3264 | Stack.prototype['delete'] = _stackDelete;
|
3265 | Stack.prototype.get = _stackGet;
|
3266 | Stack.prototype.has = _stackHas;
|
3267 | Stack.prototype.set = _stackSet;
|
3268 |
|
3269 | var _Stack = Stack;
|
3270 |
|
3271 | var defineProperty = (function() {
|
3272 | try {
|
3273 | var func = _getNative(Object, 'defineProperty');
|
3274 | func({}, '', {});
|
3275 | return func;
|
3276 | } catch (e) {}
|
3277 | }());
|
3278 |
|
3279 | var _defineProperty$1 = defineProperty;
|
3280 |
|
3281 | |
3282 |
|
3283 |
|
3284 |
|
3285 |
|
3286 |
|
3287 |
|
3288 |
|
3289 |
|
3290 | function baseAssignValue(object, key, value) {
|
3291 | if (key == '__proto__' && _defineProperty$1) {
|
3292 | _defineProperty$1(object, key, {
|
3293 | 'configurable': true,
|
3294 | 'enumerable': true,
|
3295 | 'value': value,
|
3296 | 'writable': true
|
3297 | });
|
3298 | } else {
|
3299 | object[key] = value;
|
3300 | }
|
3301 | }
|
3302 |
|
3303 | var _baseAssignValue = baseAssignValue;
|
3304 |
|
3305 | |
3306 |
|
3307 |
|
3308 |
|
3309 |
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 | function assignMergeValue(object, key, value) {
|
3315 | if ((value !== undefined && !eq_1(object[key], value)) ||
|
3316 | (value === undefined && !(key in object))) {
|
3317 | _baseAssignValue(object, key, value);
|
3318 | }
|
3319 | }
|
3320 |
|
3321 | var _assignMergeValue = assignMergeValue;
|
3322 |
|
3323 | |
3324 |
|
3325 |
|
3326 |
|
3327 |
|
3328 |
|
3329 |
|
3330 | function createBaseFor(fromRight) {
|
3331 | return function(object, iteratee, keysFunc) {
|
3332 | var index = -1,
|
3333 | iterable = Object(object),
|
3334 | props = keysFunc(object),
|
3335 | length = props.length;
|
3336 |
|
3337 | while (length--) {
|
3338 | var key = props[fromRight ? length : ++index];
|
3339 | if (iteratee(iterable[key], key, iterable) === false) {
|
3340 | break;
|
3341 | }
|
3342 | }
|
3343 | return object;
|
3344 | };
|
3345 | }
|
3346 |
|
3347 | var _createBaseFor = createBaseFor;
|
3348 |
|
3349 | |
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 |
|
3355 |
|
3356 |
|
3357 |
|
3358 |
|
3359 |
|
3360 | var baseFor = _createBaseFor();
|
3361 |
|
3362 | var _baseFor = baseFor;
|
3363 |
|
3364 | var _cloneBuffer = createCommonjsModule(function (module, exports) {
|
3365 |
|
3366 | var freeExports = exports && !exports.nodeType && exports;
|
3367 |
|
3368 |
|
3369 | var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
3370 |
|
3371 |
|
3372 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
3373 |
|
3374 |
|
3375 | var Buffer = moduleExports ? _root.Buffer : undefined,
|
3376 | allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
|
3377 |
|
3378 | |
3379 |
|
3380 |
|
3381 |
|
3382 |
|
3383 |
|
3384 |
|
3385 |
|
3386 | function cloneBuffer(buffer, isDeep) {
|
3387 | if (isDeep) {
|
3388 | return buffer.slice();
|
3389 | }
|
3390 | var length = buffer.length,
|
3391 | result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
|
3392 |
|
3393 | buffer.copy(result);
|
3394 | return result;
|
3395 | }
|
3396 |
|
3397 | module.exports = cloneBuffer;
|
3398 | });
|
3399 |
|
3400 |
|
3401 | var Uint8Array = _root.Uint8Array;
|
3402 |
|
3403 | var _Uint8Array = Uint8Array;
|
3404 |
|
3405 | |
3406 |
|
3407 |
|
3408 |
|
3409 |
|
3410 |
|
3411 |
|
3412 | function cloneArrayBuffer(arrayBuffer) {
|
3413 | var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
3414 | new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
|
3415 | return result;
|
3416 | }
|
3417 |
|
3418 | var _cloneArrayBuffer = cloneArrayBuffer;
|
3419 |
|
3420 | |
3421 |
|
3422 |
|
3423 |
|
3424 |
|
3425 |
|
3426 |
|
3427 |
|
3428 | function cloneTypedArray(typedArray, isDeep) {
|
3429 | var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
|
3430 | return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
|
3431 | }
|
3432 |
|
3433 | var _cloneTypedArray = cloneTypedArray;
|
3434 |
|
3435 | |
3436 |
|
3437 |
|
3438 |
|
3439 |
|
3440 |
|
3441 |
|
3442 |
|
3443 | function copyArray(source, array) {
|
3444 | var index = -1,
|
3445 | length = source.length;
|
3446 |
|
3447 | array || (array = Array(length));
|
3448 | while (++index < length) {
|
3449 | array[index] = source[index];
|
3450 | }
|
3451 | return array;
|
3452 | }
|
3453 |
|
3454 | var _copyArray = copyArray;
|
3455 |
|
3456 |
|
3457 | var objectCreate = Object.create;
|
3458 |
|
3459 | |
3460 |
|
3461 |
|
3462 |
|
3463 |
|
3464 |
|
3465 |
|
3466 |
|
3467 | var baseCreate = (function() {
|
3468 | function object() {}
|
3469 | return function(proto) {
|
3470 | if (!isObject_1(proto)) {
|
3471 | return {};
|
3472 | }
|
3473 | if (objectCreate) {
|
3474 | return objectCreate(proto);
|
3475 | }
|
3476 | object.prototype = proto;
|
3477 | var result = new object;
|
3478 | object.prototype = undefined;
|
3479 | return result;
|
3480 | };
|
3481 | }());
|
3482 |
|
3483 | var _baseCreate = baseCreate;
|
3484 |
|
3485 | |
3486 |
|
3487 |
|
3488 |
|
3489 |
|
3490 |
|
3491 |
|
3492 |
|
3493 | function overArg(func, transform) {
|
3494 | return function(arg) {
|
3495 | return func(transform(arg));
|
3496 | };
|
3497 | }
|
3498 |
|
3499 | var _overArg = overArg;
|
3500 |
|
3501 |
|
3502 | var getPrototype = _overArg(Object.getPrototypeOf, Object);
|
3503 |
|
3504 | var _getPrototype = getPrototype;
|
3505 |
|
3506 |
|
3507 | var objectProto$5 = Object.prototype;
|
3508 |
|
3509 | |
3510 |
|
3511 |
|
3512 |
|
3513 |
|
3514 |
|
3515 |
|
3516 | function isPrototype(value) {
|
3517 | var Ctor = value && value.constructor,
|
3518 | proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
|
3519 |
|
3520 | return value === proto;
|
3521 | }
|
3522 |
|
3523 | var _isPrototype = isPrototype;
|
3524 |
|
3525 | |
3526 |
|
3527 |
|
3528 |
|
3529 |
|
3530 |
|
3531 |
|
3532 | function initCloneObject(object) {
|
3533 | return (typeof object.constructor == 'function' && !_isPrototype(object))
|
3534 | ? _baseCreate(_getPrototype(object))
|
3535 | : {};
|
3536 | }
|
3537 |
|
3538 | var _initCloneObject = initCloneObject;
|
3539 |
|
3540 | |
3541 |
|
3542 |
|
3543 |
|
3544 |
|
3545 |
|
3546 |
|
3547 |
|
3548 |
|
3549 |
|
3550 |
|
3551 |
|
3552 |
|
3553 |
|
3554 |
|
3555 |
|
3556 |
|
3557 |
|
3558 |
|
3559 |
|
3560 |
|
3561 |
|
3562 |
|
3563 |
|
3564 | function isObjectLike(value) {
|
3565 | return value != null && typeof value == 'object';
|
3566 | }
|
3567 |
|
3568 | var isObjectLike_1 = isObjectLike;
|
3569 |
|
3570 |
|
3571 | var argsTag = '[object Arguments]';
|
3572 |
|
3573 | |
3574 |
|
3575 |
|
3576 |
|
3577 |
|
3578 |
|
3579 |
|
3580 | function baseIsArguments(value) {
|
3581 | return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
|
3582 | }
|
3583 |
|
3584 | var _baseIsArguments = baseIsArguments;
|
3585 |
|
3586 |
|
3587 | var objectProto$6 = Object.prototype;
|
3588 |
|
3589 |
|
3590 | var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
|
3591 |
|
3592 |
|
3593 | var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
|
3594 |
|
3595 | |
3596 |
|
3597 |
|
3598 |
|
3599 |
|
3600 |
|
3601 |
|
3602 |
|
3603 |
|
3604 |
|
3605 |
|
3606 |
|
3607 |
|
3608 |
|
3609 |
|
3610 |
|
3611 |
|
3612 |
|
3613 | var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
|
3614 | return isObjectLike_1(value) && hasOwnProperty$4.call(value, 'callee') &&
|
3615 | !propertyIsEnumerable.call(value, 'callee');
|
3616 | };
|
3617 |
|
3618 | var isArguments_1 = isArguments;
|
3619 |
|
3620 | |
3621 |
|
3622 |
|
3623 |
|
3624 |
|
3625 |
|
3626 |
|
3627 |
|
3628 |
|
3629 |
|
3630 |
|
3631 |
|
3632 |
|
3633 |
|
3634 |
|
3635 |
|
3636 |
|
3637 |
|
3638 |
|
3639 |
|
3640 |
|
3641 |
|
3642 |
|
3643 | var isArray = Array.isArray;
|
3644 |
|
3645 | var isArray_1 = isArray;
|
3646 |
|
3647 |
|
3648 | var MAX_SAFE_INTEGER = 9007199254740991;
|
3649 |
|
3650 | |
3651 |
|
3652 |
|
3653 |
|
3654 |
|
3655 |
|
3656 |
|
3657 |
|
3658 |
|
3659 |
|
3660 |
|
3661 |
|
3662 |
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 |
|
3668 |
|
3669 |
|
3670 |
|
3671 |
|
3672 |
|
3673 |
|
3674 |
|
3675 |
|
3676 | function isLength(value) {
|
3677 | return typeof value == 'number' &&
|
3678 | value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
3679 | }
|
3680 |
|
3681 | var isLength_1 = isLength;
|
3682 |
|
3683 | |
3684 |
|
3685 |
|
3686 |
|
3687 |
|
3688 |
|
3689 |
|
3690 |
|
3691 |
|
3692 |
|
3693 |
|
3694 |
|
3695 |
|
3696 |
|
3697 |
|
3698 |
|
3699 |
|
3700 |
|
3701 |
|
3702 |
|
3703 |
|
3704 |
|
3705 |
|
3706 |
|
3707 |
|
3708 | function isArrayLike(value) {
|
3709 | return value != null && isLength_1(value.length) && !isFunction_1(value);
|
3710 | }
|
3711 |
|
3712 | var isArrayLike_1 = isArrayLike;
|
3713 |
|
3714 | |
3715 |
|
3716 |
|
3717 |
|
3718 |
|
3719 |
|
3720 |
|
3721 |
|
3722 |
|
3723 |
|
3724 |
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 |
|
3730 |
|
3731 |
|
3732 |
|
3733 |
|
3734 |
|
3735 |
|
3736 |
|
3737 |
|
3738 |
|
3739 | function isArrayLikeObject(value) {
|
3740 | return isObjectLike_1(value) && isArrayLike_1(value);
|
3741 | }
|
3742 |
|
3743 | var isArrayLikeObject_1 = isArrayLikeObject;
|
3744 |
|
3745 | |
3746 |
|
3747 |
|
3748 |
|
3749 |
|
3750 |
|
3751 |
|
3752 |
|
3753 |
|
3754 |
|
3755 |
|
3756 |
|
3757 |
|
3758 | function stubFalse() {
|
3759 | return false;
|
3760 | }
|
3761 |
|
3762 | var stubFalse_1 = stubFalse;
|
3763 |
|
3764 | var isBuffer_1 = createCommonjsModule(function (module, exports) {
|
3765 |
|
3766 | var freeExports = exports && !exports.nodeType && exports;
|
3767 |
|
3768 |
|
3769 | var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
3770 |
|
3771 |
|
3772 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
3773 |
|
3774 |
|
3775 | var Buffer = moduleExports ? _root.Buffer : undefined;
|
3776 |
|
3777 |
|
3778 | var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
|
3779 |
|
3780 | |
3781 |
|
3782 |
|
3783 |
|
3784 |
|
3785 |
|
3786 |
|
3787 |
|
3788 |
|
3789 |
|
3790 |
|
3791 |
|
3792 |
|
3793 |
|
3794 |
|
3795 |
|
3796 |
|
3797 | var isBuffer = nativeIsBuffer || stubFalse_1;
|
3798 |
|
3799 | module.exports = isBuffer;
|
3800 | });
|
3801 |
|
3802 |
|
3803 | var objectTag = '[object Object]';
|
3804 |
|
3805 |
|
3806 | var funcProto$2 = Function.prototype,
|
3807 | objectProto$7 = Object.prototype;
|
3808 |
|
3809 |
|
3810 | var funcToString$2 = funcProto$2.toString;
|
3811 |
|
3812 |
|
3813 | var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
|
3814 |
|
3815 |
|
3816 | var objectCtorString = funcToString$2.call(Object);
|
3817 |
|
3818 | |
3819 |
|
3820 |
|
3821 |
|
3822 |
|
3823 |
|
3824 |
|
3825 |
|
3826 |
|
3827 |
|
3828 |
|
3829 |
|
3830 |
|
3831 |
|
3832 |
|
3833 |
|
3834 |
|
3835 |
|
3836 |
|
3837 |
|
3838 |
|
3839 |
|
3840 |
|
3841 |
|
3842 |
|
3843 |
|
3844 |
|
3845 |
|
3846 | function isPlainObject(value) {
|
3847 | if (!isObjectLike_1(value) || _baseGetTag(value) != objectTag) {
|
3848 | return false;
|
3849 | }
|
3850 | var proto = _getPrototype(value);
|
3851 | if (proto === null) {
|
3852 | return true;
|
3853 | }
|
3854 | var Ctor = hasOwnProperty$5.call(proto, 'constructor') && proto.constructor;
|
3855 | return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
3856 | funcToString$2.call(Ctor) == objectCtorString;
|
3857 | }
|
3858 |
|
3859 | var isPlainObject_1 = isPlainObject;
|
3860 |
|
3861 |
|
3862 | var argsTag$1 = '[object Arguments]',
|
3863 | arrayTag = '[object Array]',
|
3864 | boolTag = '[object Boolean]',
|
3865 | dateTag = '[object Date]',
|
3866 | errorTag = '[object Error]',
|
3867 | funcTag$1 = '[object Function]',
|
3868 | mapTag = '[object Map]',
|
3869 | numberTag = '[object Number]',
|
3870 | objectTag$1 = '[object Object]',
|
3871 | regexpTag = '[object RegExp]',
|
3872 | setTag = '[object Set]',
|
3873 | stringTag = '[object String]',
|
3874 | weakMapTag = '[object WeakMap]';
|
3875 |
|
3876 | var arrayBufferTag = '[object ArrayBuffer]',
|
3877 | dataViewTag = '[object DataView]',
|
3878 | float32Tag = '[object Float32Array]',
|
3879 | float64Tag = '[object Float64Array]',
|
3880 | int8Tag = '[object Int8Array]',
|
3881 | int16Tag = '[object Int16Array]',
|
3882 | int32Tag = '[object Int32Array]',
|
3883 | uint8Tag = '[object Uint8Array]',
|
3884 | uint8ClampedTag = '[object Uint8ClampedArray]',
|
3885 | uint16Tag = '[object Uint16Array]',
|
3886 | uint32Tag = '[object Uint32Array]';
|
3887 |
|
3888 |
|
3889 | var typedArrayTags = {};
|
3890 | typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
|
3891 | typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
|
3892 | typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
|
3893 | typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
|
3894 | typedArrayTags[uint32Tag] = true;
|
3895 | typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
|
3896 | typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
|
3897 | typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
|
3898 | typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
|
3899 | typedArrayTags[mapTag] = typedArrayTags[numberTag] =
|
3900 | typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
|
3901 | typedArrayTags[setTag] = typedArrayTags[stringTag] =
|
3902 | typedArrayTags[weakMapTag] = false;
|
3903 |
|
3904 | |
3905 |
|
3906 |
|
3907 |
|
3908 |
|
3909 |
|
3910 |
|
3911 | function baseIsTypedArray(value) {
|
3912 | return isObjectLike_1(value) &&
|
3913 | isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
|
3914 | }
|
3915 |
|
3916 | var _baseIsTypedArray = baseIsTypedArray;
|
3917 |
|
3918 | |
3919 |
|
3920 |
|
3921 |
|
3922 |
|
3923 |
|
3924 |
|
3925 | function baseUnary(func) {
|
3926 | return function(value) {
|
3927 | return func(value);
|
3928 | };
|
3929 | }
|
3930 |
|
3931 | var _baseUnary = baseUnary;
|
3932 |
|
3933 | var _nodeUtil = createCommonjsModule(function (module, exports) {
|
3934 |
|
3935 | var freeExports = exports && !exports.nodeType && exports;
|
3936 |
|
3937 |
|
3938 | var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
|
3939 |
|
3940 |
|
3941 | var moduleExports = freeModule && freeModule.exports === freeExports;
|
3942 |
|
3943 |
|
3944 | var freeProcess = moduleExports && _freeGlobal.process;
|
3945 |
|
3946 |
|
3947 | var nodeUtil = (function() {
|
3948 | try {
|
3949 |
|
3950 | var types = freeModule && freeModule.require && freeModule.require('util').types;
|
3951 |
|
3952 | if (types) {
|
3953 | return types;
|
3954 | }
|
3955 |
|
3956 |
|
3957 | return freeProcess && freeProcess.binding && freeProcess.binding('util');
|
3958 | } catch (e) {}
|
3959 | }());
|
3960 |
|
3961 | module.exports = nodeUtil;
|
3962 | });
|
3963 |
|
3964 |
|
3965 | var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
|
3966 |
|
3967 | |
3968 |
|
3969 |
|
3970 |
|
3971 |
|
3972 |
|
3973 |
|
3974 |
|
3975 |
|
3976 |
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 |
|
3983 |
|
3984 | var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
|
3985 |
|
3986 | var isTypedArray_1 = isTypedArray;
|
3987 |
|
3988 | |
3989 |
|
3990 |
|
3991 |
|
3992 |
|
3993 |
|
3994 |
|
3995 |
|
3996 | function safeGet(object, key) {
|
3997 | if (key === 'constructor' && typeof object[key] === 'function') {
|
3998 | return;
|
3999 | }
|
4000 |
|
4001 | if (key == '__proto__') {
|
4002 | return;
|
4003 | }
|
4004 |
|
4005 | return object[key];
|
4006 | }
|
4007 |
|
4008 | var _safeGet = safeGet;
|
4009 |
|
4010 |
|
4011 | var objectProto$8 = Object.prototype;
|
4012 |
|
4013 |
|
4014 | var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
|
4015 |
|
4016 | |
4017 |
|
4018 |
|
4019 |
|
4020 |
|
4021 |
|
4022 |
|
4023 |
|
4024 |
|
4025 |
|
4026 | function assignValue(object, key, value) {
|
4027 | var objValue = object[key];
|
4028 | if (!(hasOwnProperty$6.call(object, key) && eq_1(objValue, value)) ||
|
4029 | (value === undefined && !(key in object))) {
|
4030 | _baseAssignValue(object, key, value);
|
4031 | }
|
4032 | }
|
4033 |
|
4034 | var _assignValue = assignValue;
|
4035 |
|
4036 | |
4037 |
|
4038 |
|
4039 |
|
4040 |
|
4041 |
|
4042 |
|
4043 |
|
4044 |
|
4045 |
|
4046 | function copyObject(source, props, object, customizer) {
|
4047 | var isNew = !object;
|
4048 | object || (object = {});
|
4049 |
|
4050 | var index = -1,
|
4051 | length = props.length;
|
4052 |
|
4053 | while (++index < length) {
|
4054 | var key = props[index];
|
4055 |
|
4056 | var newValue = customizer
|
4057 | ? customizer(object[key], source[key], key, object, source)
|
4058 | : undefined;
|
4059 |
|
4060 | if (newValue === undefined) {
|
4061 | newValue = source[key];
|
4062 | }
|
4063 | if (isNew) {
|
4064 | _baseAssignValue(object, key, newValue);
|
4065 | } else {
|
4066 | _assignValue(object, key, newValue);
|
4067 | }
|
4068 | }
|
4069 | return object;
|
4070 | }
|
4071 |
|
4072 | var _copyObject = copyObject;
|
4073 |
|
4074 | |
4075 |
|
4076 |
|
4077 |
|
4078 |
|
4079 |
|
4080 |
|
4081 |
|
4082 |
|
4083 | function baseTimes(n, iteratee) {
|
4084 | var index = -1,
|
4085 | result = Array(n);
|
4086 |
|
4087 | while (++index < n) {
|
4088 | result[index] = iteratee(index);
|
4089 | }
|
4090 | return result;
|
4091 | }
|
4092 |
|
4093 | var _baseTimes = baseTimes;
|
4094 |
|
4095 |
|
4096 | var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
4097 |
|
4098 |
|
4099 | var reIsUint = /^(?:0|[1-9]\d*)$/;
|
4100 |
|
4101 | |
4102 |
|
4103 |
|
4104 |
|
4105 |
|
4106 |
|
4107 |
|
4108 |
|
4109 | function isIndex(value, length) {
|
4110 | var type = typeof value;
|
4111 | length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
4112 |
|
4113 | return !!length &&
|
4114 | (type == 'number' ||
|
4115 | (type != 'symbol' && reIsUint.test(value))) &&
|
4116 | (value > -1 && value % 1 == 0 && value < length);
|
4117 | }
|
4118 |
|
4119 | var _isIndex = isIndex;
|
4120 |
|
4121 |
|
4122 | var objectProto$9 = Object.prototype;
|
4123 |
|
4124 |
|
4125 | var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
4126 |
|
4127 | |
4128 |
|
4129 |
|
4130 |
|
4131 |
|
4132 |
|
4133 |
|
4134 |
|
4135 | function arrayLikeKeys(value, inherited) {
|
4136 | var isArr = isArray_1(value),
|
4137 | isArg = !isArr && isArguments_1(value),
|
4138 | isBuff = !isArr && !isArg && isBuffer_1(value),
|
4139 | isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
|
4140 | skipIndexes = isArr || isArg || isBuff || isType,
|
4141 | result = skipIndexes ? _baseTimes(value.length, String) : [],
|
4142 | length = result.length;
|
4143 |
|
4144 | for (var key in value) {
|
4145 | if ((inherited || hasOwnProperty$7.call(value, key)) &&
|
4146 | !(skipIndexes && (
|
4147 |
|
4148 | key == 'length' ||
|
4149 |
|
4150 | (isBuff && (key == 'offset' || key == 'parent')) ||
|
4151 |
|
4152 | (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
|
4153 |
|
4154 | _isIndex(key, length)
|
4155 | ))) {
|
4156 | result.push(key);
|
4157 | }
|
4158 | }
|
4159 | return result;
|
4160 | }
|
4161 |
|
4162 | var _arrayLikeKeys = arrayLikeKeys;
|
4163 |
|
4164 | |
4165 |
|
4166 |
|
4167 |
|
4168 |
|
4169 |
|
4170 |
|
4171 |
|
4172 |
|
4173 | function nativeKeysIn(object) {
|
4174 | var result = [];
|
4175 | if (object != null) {
|
4176 | for (var key in Object(object)) {
|
4177 | result.push(key);
|
4178 | }
|
4179 | }
|
4180 | return result;
|
4181 | }
|
4182 |
|
4183 | var _nativeKeysIn = nativeKeysIn;
|
4184 |
|
4185 |
|
4186 | var objectProto$a = Object.prototype;
|
4187 |
|
4188 |
|
4189 | var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
|
4190 |
|
4191 | |
4192 |
|
4193 |
|
4194 |
|
4195 |
|
4196 |
|
4197 |
|
4198 | function baseKeysIn(object) {
|
4199 | if (!isObject_1(object)) {
|
4200 | return _nativeKeysIn(object);
|
4201 | }
|
4202 | var isProto = _isPrototype(object),
|
4203 | result = [];
|
4204 |
|
4205 | for (var key in object) {
|
4206 | if (!(key == 'constructor' && (isProto || !hasOwnProperty$8.call(object, key)))) {
|
4207 | result.push(key);
|
4208 | }
|
4209 | }
|
4210 | return result;
|
4211 | }
|
4212 |
|
4213 | var _baseKeysIn = baseKeysIn;
|
4214 |
|
4215 | |
4216 |
|
4217 |
|
4218 |
|
4219 |
|
4220 |
|
4221 |
|
4222 |
|
4223 |
|
4224 |
|
4225 |
|
4226 |
|
4227 |
|
4228 |
|
4229 |
|
4230 |
|
4231 |
|
4232 |
|
4233 |
|
4234 |
|
4235 |
|
4236 |
|
4237 |
|
4238 | function keysIn(object) {
|
4239 | return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
|
4240 | }
|
4241 |
|
4242 | var keysIn_1 = keysIn;
|
4243 |
|
4244 | |
4245 |
|
4246 |
|
4247 |
|
4248 |
|
4249 |
|
4250 |
|
4251 |
|
4252 |
|
4253 |
|
4254 |
|
4255 |
|
4256 |
|
4257 |
|
4258 |
|
4259 |
|
4260 |
|
4261 |
|
4262 |
|
4263 |
|
4264 |
|
4265 |
|
4266 |
|
4267 |
|
4268 | function toPlainObject(value) {
|
4269 | return _copyObject(value, keysIn_1(value));
|
4270 | }
|
4271 |
|
4272 | var toPlainObject_1 = toPlainObject;
|
4273 |
|
4274 | |
4275 |
|
4276 |
|
4277 |
|
4278 |
|
4279 |
|
4280 |
|
4281 |
|
4282 |
|
4283 |
|
4284 |
|
4285 |
|
4286 |
|
4287 |
|
4288 |
|
4289 | function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
|
4290 | var objValue = _safeGet(object, key),
|
4291 | srcValue = _safeGet(source, key),
|
4292 | stacked = stack.get(srcValue);
|
4293 |
|
4294 | if (stacked) {
|
4295 | _assignMergeValue(object, key, stacked);
|
4296 | return;
|
4297 | }
|
4298 | var newValue = customizer
|
4299 | ? customizer(objValue, srcValue, (key + ''), object, source, stack)
|
4300 | : undefined;
|
4301 |
|
4302 | var isCommon = newValue === undefined;
|
4303 |
|
4304 | if (isCommon) {
|
4305 | var isArr = isArray_1(srcValue),
|
4306 | isBuff = !isArr && isBuffer_1(srcValue),
|
4307 | isTyped = !isArr && !isBuff && isTypedArray_1(srcValue);
|
4308 |
|
4309 | newValue = srcValue;
|
4310 | if (isArr || isBuff || isTyped) {
|
4311 | if (isArray_1(objValue)) {
|
4312 | newValue = objValue;
|
4313 | }
|
4314 | else if (isArrayLikeObject_1(objValue)) {
|
4315 | newValue = _copyArray(objValue);
|
4316 | }
|
4317 | else if (isBuff) {
|
4318 | isCommon = false;
|
4319 | newValue = _cloneBuffer(srcValue, true);
|
4320 | }
|
4321 | else if (isTyped) {
|
4322 | isCommon = false;
|
4323 | newValue = _cloneTypedArray(srcValue, true);
|
4324 | }
|
4325 | else {
|
4326 | newValue = [];
|
4327 | }
|
4328 | }
|
4329 | else if (isPlainObject_1(srcValue) || isArguments_1(srcValue)) {
|
4330 | newValue = objValue;
|
4331 | if (isArguments_1(objValue)) {
|
4332 | newValue = toPlainObject_1(objValue);
|
4333 | }
|
4334 | else if (!isObject_1(objValue) || isFunction_1(objValue)) {
|
4335 | newValue = _initCloneObject(srcValue);
|
4336 | }
|
4337 | }
|
4338 | else {
|
4339 | isCommon = false;
|
4340 | }
|
4341 | }
|
4342 | if (isCommon) {
|
4343 |
|
4344 | stack.set(srcValue, newValue);
|
4345 | mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
|
4346 | stack['delete'](srcValue);
|
4347 | }
|
4348 | _assignMergeValue(object, key, newValue);
|
4349 | }
|
4350 |
|
4351 | var _baseMergeDeep = baseMergeDeep;
|
4352 |
|
4353 | |
4354 |
|
4355 |
|
4356 |
|
4357 |
|
4358 |
|
4359 |
|
4360 |
|
4361 |
|
4362 |
|
4363 |
|
4364 | function baseMerge(object, source, srcIndex, customizer, stack) {
|
4365 | if (object === source) {
|
4366 | return;
|
4367 | }
|
4368 | _baseFor(source, function(srcValue, key) {
|
4369 | stack || (stack = new _Stack);
|
4370 | if (isObject_1(srcValue)) {
|
4371 | _baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
|
4372 | }
|
4373 | else {
|
4374 | var newValue = customizer
|
4375 | ? customizer(_safeGet(object, key), srcValue, (key + ''), object, source, stack)
|
4376 | : undefined;
|
4377 |
|
4378 | if (newValue === undefined) {
|
4379 | newValue = srcValue;
|
4380 | }
|
4381 | _assignMergeValue(object, key, newValue);
|
4382 | }
|
4383 | }, keysIn_1);
|
4384 | }
|
4385 |
|
4386 | var _baseMerge = baseMerge;
|
4387 |
|
4388 | |
4389 |
|
4390 |
|
4391 |
|
4392 |
|
4393 |
|
4394 |
|
4395 |
|
4396 |
|
4397 |
|
4398 |
|
4399 |
|
4400 |
|
4401 |
|
4402 |
|
4403 |
|
4404 | function identity(value) {
|
4405 | return value;
|
4406 | }
|
4407 |
|
4408 | var identity_1 = identity;
|
4409 |
|
4410 | |
4411 |
|
4412 |
|
4413 |
|
4414 |
|
4415 |
|
4416 |
|
4417 |
|
4418 |
|
4419 |
|
4420 | function apply(func, thisArg, args) {
|
4421 | switch (args.length) {
|
4422 | case 0: return func.call(thisArg);
|
4423 | case 1: return func.call(thisArg, args[0]);
|
4424 | case 2: return func.call(thisArg, args[0], args[1]);
|
4425 | case 3: return func.call(thisArg, args[0], args[1], args[2]);
|
4426 | }
|
4427 | return func.apply(thisArg, args);
|
4428 | }
|
4429 |
|
4430 | var _apply = apply;
|
4431 |
|
4432 |
|
4433 | var nativeMax = Math.max;
|
4434 |
|
4435 | |
4436 |
|
4437 |
|
4438 |
|
4439 |
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 | function overRest(func, start, transform) {
|
4445 | start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
|
4446 | return function() {
|
4447 | var args = arguments,
|
4448 | index = -1,
|
4449 | length = nativeMax(args.length - start, 0),
|
4450 | array = Array(length);
|
4451 |
|
4452 | while (++index < length) {
|
4453 | array[index] = args[start + index];
|
4454 | }
|
4455 | index = -1;
|
4456 | var otherArgs = Array(start + 1);
|
4457 | while (++index < start) {
|
4458 | otherArgs[index] = args[index];
|
4459 | }
|
4460 | otherArgs[start] = transform(array);
|
4461 | return _apply(func, this, otherArgs);
|
4462 | };
|
4463 | }
|
4464 |
|
4465 | var _overRest = overRest;
|
4466 |
|
4467 | |
4468 |
|
4469 |
|
4470 |
|
4471 |
|
4472 |
|
4473 |
|
4474 |
|
4475 |
|
4476 |
|
4477 |
|
4478 |
|
4479 |
|
4480 |
|
4481 |
|
4482 |
|
4483 |
|
4484 |
|
4485 |
|
4486 | function constant(value) {
|
4487 | return function() {
|
4488 | return value;
|
4489 | };
|
4490 | }
|
4491 |
|
4492 | var constant_1 = constant;
|
4493 |
|
4494 | |
4495 |
|
4496 |
|
4497 |
|
4498 |
|
4499 |
|
4500 |
|
4501 |
|
4502 | var baseSetToString = !_defineProperty$1 ? identity_1 : function(func, string) {
|
4503 | return _defineProperty$1(func, 'toString', {
|
4504 | 'configurable': true,
|
4505 | 'enumerable': false,
|
4506 | 'value': constant_1(string),
|
4507 | 'writable': true
|
4508 | });
|
4509 | };
|
4510 |
|
4511 | var _baseSetToString = baseSetToString;
|
4512 |
|
4513 |
|
4514 | var HOT_COUNT = 800,
|
4515 | HOT_SPAN = 16;
|
4516 |
|
4517 |
|
4518 | var nativeNow = Date.now;
|
4519 |
|
4520 | |
4521 |
|
4522 |
|
4523 |
|
4524 |
|
4525 |
|
4526 |
|
4527 |
|
4528 |
|
4529 | function shortOut(func) {
|
4530 | var count = 0,
|
4531 | lastCalled = 0;
|
4532 |
|
4533 | return function() {
|
4534 | var stamp = nativeNow(),
|
4535 | remaining = HOT_SPAN - (stamp - lastCalled);
|
4536 |
|
4537 | lastCalled = stamp;
|
4538 | if (remaining > 0) {
|
4539 | if (++count >= HOT_COUNT) {
|
4540 | return arguments[0];
|
4541 | }
|
4542 | } else {
|
4543 | count = 0;
|
4544 | }
|
4545 | return func.apply(undefined, arguments);
|
4546 | };
|
4547 | }
|
4548 |
|
4549 | var _shortOut = shortOut;
|
4550 |
|
4551 | |
4552 |
|
4553 |
|
4554 |
|
4555 |
|
4556 |
|
4557 |
|
4558 |
|
4559 | var setToString = _shortOut(_baseSetToString);
|
4560 |
|
4561 | var _setToString = setToString;
|
4562 |
|
4563 | |
4564 |
|
4565 |
|
4566 |
|
4567 |
|
4568 |
|
4569 |
|
4570 |
|
4571 | function baseRest(func, start) {
|
4572 | return _setToString(_overRest(func, start, identity_1), func + '');
|
4573 | }
|
4574 |
|
4575 | var _baseRest = baseRest;
|
4576 |
|
4577 | |
4578 |
|
4579 |
|
4580 |
|
4581 |
|
4582 |
|
4583 |
|
4584 |
|
4585 |
|
4586 |
|
4587 | function isIterateeCall(value, index, object) {
|
4588 | if (!isObject_1(object)) {
|
4589 | return false;
|
4590 | }
|
4591 | var type = typeof index;
|
4592 | if (type == 'number'
|
4593 | ? (isArrayLike_1(object) && _isIndex(index, object.length))
|
4594 | : (type == 'string' && index in object)
|
4595 | ) {
|
4596 | return eq_1(object[index], value);
|
4597 | }
|
4598 | return false;
|
4599 | }
|
4600 |
|
4601 | var _isIterateeCall = isIterateeCall;
|
4602 |
|
4603 | |
4604 |
|
4605 |
|
4606 |
|
4607 |
|
4608 |
|
4609 |
|
4610 | function createAssigner(assigner) {
|
4611 | return _baseRest(function(object, sources) {
|
4612 | var index = -1,
|
4613 | length = sources.length,
|
4614 | customizer = length > 1 ? sources[length - 1] : undefined,
|
4615 | guard = length > 2 ? sources[2] : undefined;
|
4616 |
|
4617 | customizer = (assigner.length > 3 && typeof customizer == 'function')
|
4618 | ? (length--, customizer)
|
4619 | : undefined;
|
4620 |
|
4621 | if (guard && _isIterateeCall(sources[0], sources[1], guard)) {
|
4622 | customizer = length < 3 ? undefined : customizer;
|
4623 | length = 1;
|
4624 | }
|
4625 | object = Object(object);
|
4626 | while (++index < length) {
|
4627 | var source = sources[index];
|
4628 | if (source) {
|
4629 | assigner(object, source, index, customizer);
|
4630 | }
|
4631 | }
|
4632 | return object;
|
4633 | });
|
4634 | }
|
4635 |
|
4636 | var _createAssigner = createAssigner;
|
4637 |
|
4638 | |
4639 |
|
4640 |
|
4641 |
|
4642 |
|
4643 |
|
4644 |
|
4645 |
|
4646 |
|
4647 |
|
4648 |
|
4649 |
|
4650 |
|
4651 |
|
4652 |
|
4653 |
|
4654 |
|
4655 |
|
4656 |
|
4657 |
|
4658 |
|
4659 |
|
4660 |
|
4661 |
|
4662 |
|
4663 |
|
4664 |
|
4665 |
|
4666 |
|
4667 |
|
4668 |
|
4669 | var merge = _createAssigner(function(object, source, srcIndex) {
|
4670 | _baseMerge(object, source, srcIndex);
|
4671 | });
|
4672 |
|
4673 | var merge_1 = merge;
|
4674 |
|
4675 | |
4676 |
|
4677 |
|
4678 |
|
4679 |
|
4680 |
|
4681 |
|
4682 |
|
4683 |
|
4684 | function arrayEach(array, iteratee) {
|
4685 | var index = -1,
|
4686 | length = array == null ? 0 : array.length;
|
4687 |
|
4688 | while (++index < length) {
|
4689 | if (iteratee(array[index], index, array) === false) {
|
4690 | break;
|
4691 | }
|
4692 | }
|
4693 | return array;
|
4694 | }
|
4695 |
|
4696 | var _arrayEach = arrayEach;
|
4697 |
|
4698 |
|
4699 | var nativeKeys = _overArg(Object.keys, Object);
|
4700 |
|
4701 | var _nativeKeys = nativeKeys;
|
4702 |
|
4703 |
|
4704 | var objectProto$b = Object.prototype;
|
4705 |
|
4706 |
|
4707 | var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
|
4708 |
|
4709 | |
4710 |
|
4711 |
|
4712 |
|
4713 |
|
4714 |
|
4715 |
|
4716 | function baseKeys(object) {
|
4717 | if (!_isPrototype(object)) {
|
4718 | return _nativeKeys(object);
|
4719 | }
|
4720 | var result = [];
|
4721 | for (var key in Object(object)) {
|
4722 | if (hasOwnProperty$9.call(object, key) && key != 'constructor') {
|
4723 | result.push(key);
|
4724 | }
|
4725 | }
|
4726 | return result;
|
4727 | }
|
4728 |
|
4729 | var _baseKeys = baseKeys;
|
4730 |
|
4731 | |
4732 |
|
4733 |
|
4734 |
|
4735 |
|
4736 |
|
4737 |
|
4738 |
|
4739 |
|
4740 |
|
4741 |
|
4742 |
|
4743 |
|
4744 |
|
4745 |
|
4746 |
|
4747 |
|
4748 |
|
4749 |
|
4750 |
|
4751 |
|
4752 |
|
4753 |
|
4754 |
|
4755 |
|
4756 |
|
4757 |
|
4758 |
|
4759 | function keys(object) {
|
4760 | return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
|
4761 | }
|
4762 |
|
4763 | var keys_1 = keys;
|
4764 |
|
4765 | |
4766 |
|
4767 |
|
4768 |
|
4769 |
|
4770 |
|
4771 |
|
4772 |
|
4773 |
|
4774 | function baseAssign(object, source) {
|
4775 | return object && _copyObject(source, keys_1(source), object);
|
4776 | }
|
4777 |
|
4778 | var _baseAssign = baseAssign;
|
4779 |
|
4780 | |
4781 |
|
4782 |
|
4783 |
|
4784 |
|
4785 |
|
4786 |
|
4787 |
|
4788 |
|
4789 | function baseAssignIn(object, source) {
|
4790 | return object && _copyObject(source, keysIn_1(source), object);
|
4791 | }
|
4792 |
|
4793 | var _baseAssignIn = baseAssignIn;
|
4794 |
|
4795 | |
4796 |
|
4797 |
|
4798 |
|
4799 |
|
4800 |
|
4801 |
|
4802 |
|
4803 |
|
4804 | function arrayFilter(array, predicate) {
|
4805 | var index = -1,
|
4806 | length = array == null ? 0 : array.length,
|
4807 | resIndex = 0,
|
4808 | result = [];
|
4809 |
|
4810 | while (++index < length) {
|
4811 | var value = array[index];
|
4812 | if (predicate(value, index, array)) {
|
4813 | result[resIndex++] = value;
|
4814 | }
|
4815 | }
|
4816 | return result;
|
4817 | }
|
4818 |
|
4819 | var _arrayFilter = arrayFilter;
|
4820 |
|
4821 | |
4822 |
|
4823 |
|
4824 |
|
4825 |
|
4826 |
|
4827 |
|
4828 |
|
4829 |
|
4830 |
|
4831 |
|
4832 |
|
4833 |
|
4834 |
|
4835 |
|
4836 |
|
4837 |
|
4838 |
|
4839 | function stubArray() {
|
4840 | return [];
|
4841 | }
|
4842 |
|
4843 | var stubArray_1 = stubArray;
|
4844 |
|
4845 |
|
4846 | var objectProto$c = Object.prototype;
|
4847 |
|
4848 |
|
4849 | var propertyIsEnumerable$1 = objectProto$c.propertyIsEnumerable;
|
4850 |
|
4851 |
|
4852 | var nativeGetSymbols = Object.getOwnPropertySymbols;
|
4853 |
|
4854 | |
4855 |
|
4856 |
|
4857 |
|
4858 |
|
4859 |
|
4860 |
|
4861 | var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
|
4862 | if (object == null) {
|
4863 | return [];
|
4864 | }
|
4865 | object = Object(object);
|
4866 | return _arrayFilter(nativeGetSymbols(object), function(symbol) {
|
4867 | return propertyIsEnumerable$1.call(object, symbol);
|
4868 | });
|
4869 | };
|
4870 |
|
4871 | var _getSymbols = getSymbols;
|
4872 |
|
4873 | |
4874 |
|
4875 |
|
4876 |
|
4877 |
|
4878 |
|
4879 |
|
4880 |
|
4881 | function copySymbols(source, object) {
|
4882 | return _copyObject(source, _getSymbols(source), object);
|
4883 | }
|
4884 |
|
4885 | var _copySymbols = copySymbols;
|
4886 |
|
4887 | |
4888 |
|
4889 |
|
4890 |
|
4891 |
|
4892 |
|
4893 |
|
4894 |
|
4895 | function arrayPush(array, values) {
|
4896 | var index = -1,
|
4897 | length = values.length,
|
4898 | offset = array.length;
|
4899 |
|
4900 | while (++index < length) {
|
4901 | array[offset + index] = values[index];
|
4902 | }
|
4903 | return array;
|
4904 | }
|
4905 |
|
4906 | var _arrayPush = arrayPush;
|
4907 |
|
4908 |
|
4909 | var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
|
4910 |
|
4911 | |
4912 |
|
4913 |
|
4914 |
|
4915 |
|
4916 |
|
4917 |
|
4918 | var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
|
4919 | var result = [];
|
4920 | while (object) {
|
4921 | _arrayPush(result, _getSymbols(object));
|
4922 | object = _getPrototype(object);
|
4923 | }
|
4924 | return result;
|
4925 | };
|
4926 |
|
4927 | var _getSymbolsIn = getSymbolsIn;
|
4928 |
|
4929 | |
4930 |
|
4931 |
|
4932 |
|
4933 |
|
4934 |
|
4935 |
|
4936 |
|
4937 | function copySymbolsIn(source, object) {
|
4938 | return _copyObject(source, _getSymbolsIn(source), object);
|
4939 | }
|
4940 |
|
4941 | var _copySymbolsIn = copySymbolsIn;
|
4942 |
|
4943 | |
4944 |
|
4945 |
|
4946 |
|
4947 |
|
4948 |
|
4949 |
|
4950 |
|
4951 |
|
4952 |
|
4953 |
|
4954 | function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
4955 | var result = keysFunc(object);
|
4956 | return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
|
4957 | }
|
4958 |
|
4959 | var _baseGetAllKeys = baseGetAllKeys;
|
4960 |
|
4961 | |
4962 |
|
4963 |
|
4964 |
|
4965 |
|
4966 |
|
4967 |
|
4968 | function getAllKeys(object) {
|
4969 | return _baseGetAllKeys(object, keys_1, _getSymbols);
|
4970 | }
|
4971 |
|
4972 | var _getAllKeys = getAllKeys;
|
4973 |
|
4974 | |
4975 |
|
4976 |
|
4977 |
|
4978 |
|
4979 |
|
4980 |
|
4981 |
|
4982 | function getAllKeysIn(object) {
|
4983 | return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
|
4984 | }
|
4985 |
|
4986 | var _getAllKeysIn = getAllKeysIn;
|
4987 |
|
4988 |
|
4989 | var DataView = _getNative(_root, 'DataView');
|
4990 |
|
4991 | var _DataView = DataView;
|
4992 |
|
4993 |
|
4994 | var Promise = _getNative(_root, 'Promise');
|
4995 |
|
4996 | var _Promise = Promise;
|
4997 |
|
4998 |
|
4999 | var Set = _getNative(_root, 'Set');
|
5000 |
|
5001 | var _Set = Set;
|
5002 |
|
5003 |
|
5004 | var WeakMap = _getNative(_root, 'WeakMap');
|
5005 |
|
5006 | var _WeakMap = WeakMap;
|
5007 |
|
5008 |
|
5009 | var mapTag$1 = '[object Map]',
|
5010 | objectTag$2 = '[object Object]',
|
5011 | promiseTag = '[object Promise]',
|
5012 | setTag$1 = '[object Set]',
|
5013 | weakMapTag$1 = '[object WeakMap]';
|
5014 |
|
5015 | var dataViewTag$1 = '[object DataView]';
|
5016 |
|
5017 |
|
5018 | var dataViewCtorString = _toSource(_DataView),
|
5019 | mapCtorString = _toSource(_Map),
|
5020 | promiseCtorString = _toSource(_Promise),
|
5021 | setCtorString = _toSource(_Set),
|
5022 | weakMapCtorString = _toSource(_WeakMap);
|
5023 |
|
5024 | |
5025 |
|
5026 |
|
5027 |
|
5028 |
|
5029 |
|
5030 |
|
5031 | var getTag = _baseGetTag;
|
5032 |
|
5033 |
|
5034 | if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
|
5035 | (_Map && getTag(new _Map) != mapTag$1) ||
|
5036 | (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
|
5037 | (_Set && getTag(new _Set) != setTag$1) ||
|
5038 | (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
|
5039 | getTag = function(value) {
|
5040 | var result = _baseGetTag(value),
|
5041 | Ctor = result == objectTag$2 ? value.constructor : undefined,
|
5042 | ctorString = Ctor ? _toSource(Ctor) : '';
|
5043 |
|
5044 | if (ctorString) {
|
5045 | switch (ctorString) {
|
5046 | case dataViewCtorString: return dataViewTag$1;
|
5047 | case mapCtorString: return mapTag$1;
|
5048 | case promiseCtorString: return promiseTag;
|
5049 | case setCtorString: return setTag$1;
|
5050 | case weakMapCtorString: return weakMapTag$1;
|
5051 | }
|
5052 | }
|
5053 | return result;
|
5054 | };
|
5055 | }
|
5056 |
|
5057 | var _getTag = getTag;
|
5058 |
|
5059 |
|
5060 | var objectProto$d = Object.prototype;
|
5061 |
|
5062 |
|
5063 | var hasOwnProperty$a = objectProto$d.hasOwnProperty;
|
5064 |
|
5065 | |
5066 |
|
5067 |
|
5068 |
|
5069 |
|
5070 |
|
5071 |
|
5072 | function initCloneArray(array) {
|
5073 | var length = array.length,
|
5074 | result = new array.constructor(length);
|
5075 |
|
5076 |
|
5077 | if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
|
5078 | result.index = array.index;
|
5079 | result.input = array.input;
|
5080 | }
|
5081 | return result;
|
5082 | }
|
5083 |
|
5084 | var _initCloneArray = initCloneArray;
|
5085 |
|
5086 | |
5087 |
|
5088 |
|
5089 |
|
5090 |
|
5091 |
|
5092 |
|
5093 |
|
5094 | function cloneDataView(dataView, isDeep) {
|
5095 | var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
5096 | return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
5097 | }
|
5098 |
|
5099 | var _cloneDataView = cloneDataView;
|
5100 |
|
5101 |
|
5102 | var reFlags = /\w*$/;
|
5103 |
|
5104 | |
5105 |
|
5106 |
|
5107 |
|
5108 |
|
5109 |
|
5110 |
|
5111 | function cloneRegExp(regexp) {
|
5112 | var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
5113 | result.lastIndex = regexp.lastIndex;
|
5114 | return result;
|
5115 | }
|
5116 |
|
5117 | var _cloneRegExp = cloneRegExp;
|
5118 |
|
5119 |
|
5120 | var symbolProto = _Symbol ? _Symbol.prototype : undefined,
|
5121 | symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
|
5122 |
|
5123 | |
5124 |
|
5125 |
|
5126 |
|
5127 |
|
5128 |
|
5129 |
|
5130 | function cloneSymbol(symbol) {
|
5131 | return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
|
5132 | }
|
5133 |
|
5134 | var _cloneSymbol = cloneSymbol;
|
5135 |
|
5136 |
|
5137 | var boolTag$1 = '[object Boolean]',
|
5138 | dateTag$1 = '[object Date]',
|
5139 | mapTag$2 = '[object Map]',
|
5140 | numberTag$1 = '[object Number]',
|
5141 | regexpTag$1 = '[object RegExp]',
|
5142 | setTag$2 = '[object Set]',
|
5143 | stringTag$1 = '[object String]',
|
5144 | symbolTag = '[object Symbol]';
|
5145 |
|
5146 | var arrayBufferTag$1 = '[object ArrayBuffer]',
|
5147 | dataViewTag$2 = '[object DataView]',
|
5148 | float32Tag$1 = '[object Float32Array]',
|
5149 | float64Tag$1 = '[object Float64Array]',
|
5150 | int8Tag$1 = '[object Int8Array]',
|
5151 | int16Tag$1 = '[object Int16Array]',
|
5152 | int32Tag$1 = '[object Int32Array]',
|
5153 | uint8Tag$1 = '[object Uint8Array]',
|
5154 | uint8ClampedTag$1 = '[object Uint8ClampedArray]',
|
5155 | uint16Tag$1 = '[object Uint16Array]',
|
5156 | uint32Tag$1 = '[object Uint32Array]';
|
5157 |
|
5158 | |
5159 |
|
5160 |
|
5161 |
|
5162 |
|
5163 |
|
5164 |
|
5165 |
|
5166 |
|
5167 |
|
5168 |
|
5169 |
|
5170 | function initCloneByTag(object, tag, isDeep) {
|
5171 | var Ctor = object.constructor;
|
5172 | switch (tag) {
|
5173 | case arrayBufferTag$1:
|
5174 | return _cloneArrayBuffer(object);
|
5175 |
|
5176 | case boolTag$1:
|
5177 | case dateTag$1:
|
5178 | return new Ctor(+object);
|
5179 |
|
5180 | case dataViewTag$2:
|
5181 | return _cloneDataView(object, isDeep);
|
5182 |
|
5183 | case float32Tag$1: case float64Tag$1:
|
5184 | case int8Tag$1: case int16Tag$1: case int32Tag$1:
|
5185 | case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
|
5186 | return _cloneTypedArray(object, isDeep);
|
5187 |
|
5188 | case mapTag$2:
|
5189 | return new Ctor;
|
5190 |
|
5191 | case numberTag$1:
|
5192 | case stringTag$1:
|
5193 | return new Ctor(object);
|
5194 |
|
5195 | case regexpTag$1:
|
5196 | return _cloneRegExp(object);
|
5197 |
|
5198 | case setTag$2:
|
5199 | return new Ctor;
|
5200 |
|
5201 | case symbolTag:
|
5202 | return _cloneSymbol(object);
|
5203 | }
|
5204 | }
|
5205 |
|
5206 | var _initCloneByTag = initCloneByTag;
|
5207 |
|
5208 |
|
5209 | var mapTag$3 = '[object Map]';
|
5210 |
|
5211 | |
5212 |
|
5213 |
|
5214 |
|
5215 |
|
5216 |
|
5217 |
|
5218 | function baseIsMap(value) {
|
5219 | return isObjectLike_1(value) && _getTag(value) == mapTag$3;
|
5220 | }
|
5221 |
|
5222 | var _baseIsMap = baseIsMap;
|
5223 |
|
5224 |
|
5225 | var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
|
5226 |
|
5227 | |
5228 |
|
5229 |
|
5230 |
|
5231 |
|
5232 |
|
5233 |
|
5234 |
|
5235 |
|
5236 |
|
5237 |
|
5238 |
|
5239 |
|
5240 |
|
5241 |
|
5242 |
|
5243 |
|
5244 | var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
|
5245 |
|
5246 | var isMap_1 = isMap;
|
5247 |
|
5248 |
|
5249 | var setTag$3 = '[object Set]';
|
5250 |
|
5251 | |
5252 |
|
5253 |
|
5254 |
|
5255 |
|
5256 |
|
5257 |
|
5258 | function baseIsSet(value) {
|
5259 | return isObjectLike_1(value) && _getTag(value) == setTag$3;
|
5260 | }
|
5261 |
|
5262 | var _baseIsSet = baseIsSet;
|
5263 |
|
5264 |
|
5265 | var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
|
5266 |
|
5267 | |
5268 |
|
5269 |
|
5270 |
|
5271 |
|
5272 |
|
5273 |
|
5274 |
|
5275 |
|
5276 |
|
5277 |
|
5278 |
|
5279 |
|
5280 |
|
5281 |
|
5282 |
|
5283 |
|
5284 | var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
|
5285 |
|
5286 | var isSet_1 = isSet;
|
5287 |
|
5288 |
|
5289 | var CLONE_DEEP_FLAG = 1,
|
5290 | CLONE_FLAT_FLAG = 2,
|
5291 | CLONE_SYMBOLS_FLAG = 4;
|
5292 |
|
5293 |
|
5294 | var argsTag$2 = '[object Arguments]',
|
5295 | arrayTag$1 = '[object Array]',
|
5296 | boolTag$2 = '[object Boolean]',
|
5297 | dateTag$2 = '[object Date]',
|
5298 | errorTag$1 = '[object Error]',
|
5299 | funcTag$2 = '[object Function]',
|
5300 | genTag$1 = '[object GeneratorFunction]',
|
5301 | mapTag$4 = '[object Map]',
|
5302 | numberTag$2 = '[object Number]',
|
5303 | objectTag$3 = '[object Object]',
|
5304 | regexpTag$2 = '[object RegExp]',
|
5305 | setTag$4 = '[object Set]',
|
5306 | stringTag$2 = '[object String]',
|
5307 | symbolTag$1 = '[object Symbol]',
|
5308 | weakMapTag$2 = '[object WeakMap]';
|
5309 |
|
5310 | var arrayBufferTag$2 = '[object ArrayBuffer]',
|
5311 | dataViewTag$3 = '[object DataView]',
|
5312 | float32Tag$2 = '[object Float32Array]',
|
5313 | float64Tag$2 = '[object Float64Array]',
|
5314 | int8Tag$2 = '[object Int8Array]',
|
5315 | int16Tag$2 = '[object Int16Array]',
|
5316 | int32Tag$2 = '[object Int32Array]',
|
5317 | uint8Tag$2 = '[object Uint8Array]',
|
5318 | uint8ClampedTag$2 = '[object Uint8ClampedArray]',
|
5319 | uint16Tag$2 = '[object Uint16Array]',
|
5320 | uint32Tag$2 = '[object Uint32Array]';
|
5321 |
|
5322 |
|
5323 | var cloneableTags = {};
|
5324 | cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
|
5325 | cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
|
5326 | cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
|
5327 | cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
|
5328 | cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
|
5329 | cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
|
5330 | cloneableTags[numberTag$2] = cloneableTags[objectTag$3] =
|
5331 | cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
|
5332 | cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
|
5333 | cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
|
5334 | cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
|
5335 | cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
|
5336 | cloneableTags[weakMapTag$2] = false;
|
5337 |
|
5338 | |
5339 |
|
5340 |
|
5341 |
|
5342 |
|
5343 |
|
5344 |
|
5345 |
|
5346 |
|
5347 |
|
5348 |
|
5349 |
|
5350 |
|
5351 |
|
5352 |
|
5353 |
|
5354 | function baseClone(value, bitmask, customizer, key, object, stack) {
|
5355 | var result,
|
5356 | isDeep = bitmask & CLONE_DEEP_FLAG,
|
5357 | isFlat = bitmask & CLONE_FLAT_FLAG,
|
5358 | isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
5359 |
|
5360 | if (customizer) {
|
5361 | result = object ? customizer(value, key, object, stack) : customizer(value);
|
5362 | }
|
5363 | if (result !== undefined) {
|
5364 | return result;
|
5365 | }
|
5366 | if (!isObject_1(value)) {
|
5367 | return value;
|
5368 | }
|
5369 | var isArr = isArray_1(value);
|
5370 | if (isArr) {
|
5371 | result = _initCloneArray(value);
|
5372 | if (!isDeep) {
|
5373 | return _copyArray(value, result);
|
5374 | }
|
5375 | } else {
|
5376 | var tag = _getTag(value),
|
5377 | isFunc = tag == funcTag$2 || tag == genTag$1;
|
5378 |
|
5379 | if (isBuffer_1(value)) {
|
5380 | return _cloneBuffer(value, isDeep);
|
5381 | }
|
5382 | if (tag == objectTag$3 || tag == argsTag$2 || (isFunc && !object)) {
|
5383 | result = (isFlat || isFunc) ? {} : _initCloneObject(value);
|
5384 | if (!isDeep) {
|
5385 | return isFlat
|
5386 | ? _copySymbolsIn(value, _baseAssignIn(result, value))
|
5387 | : _copySymbols(value, _baseAssign(result, value));
|
5388 | }
|
5389 | } else {
|
5390 | if (!cloneableTags[tag]) {
|
5391 | return object ? value : {};
|
5392 | }
|
5393 | result = _initCloneByTag(value, tag, isDeep);
|
5394 | }
|
5395 | }
|
5396 |
|
5397 | stack || (stack = new _Stack);
|
5398 | var stacked = stack.get(value);
|
5399 | if (stacked) {
|
5400 | return stacked;
|
5401 | }
|
5402 | stack.set(value, result);
|
5403 |
|
5404 | if (isSet_1(value)) {
|
5405 | value.forEach(function(subValue) {
|
5406 | result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
5407 | });
|
5408 | } else if (isMap_1(value)) {
|
5409 | value.forEach(function(subValue, key) {
|
5410 | result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
5411 | });
|
5412 | }
|
5413 |
|
5414 | var keysFunc = isFull
|
5415 | ? (isFlat ? _getAllKeysIn : _getAllKeys)
|
5416 | : (isFlat ? keysIn_1 : keys_1);
|
5417 |
|
5418 | var props = isArr ? undefined : keysFunc(value);
|
5419 | _arrayEach(props || value, function(subValue, key) {
|
5420 | if (props) {
|
5421 | key = subValue;
|
5422 | subValue = value[key];
|
5423 | }
|
5424 |
|
5425 | _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
5426 | });
|
5427 | return result;
|
5428 | }
|
5429 |
|
5430 | var _baseClone = baseClone;
|
5431 |
|
5432 |
|
5433 | var CLONE_DEEP_FLAG$1 = 1,
|
5434 | CLONE_SYMBOLS_FLAG$1 = 4;
|
5435 |
|
5436 | |
5437 |
|
5438 |
|
5439 |
|
5440 |
|
5441 |
|
5442 |
|
5443 |
|
5444 |
|
5445 |
|
5446 |
|
5447 |
|
5448 |
|
5449 |
|
5450 |
|
5451 |
|
5452 |
|
5453 |
|
5454 | function cloneDeep(value) {
|
5455 | return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
|
5456 | }
|
5457 |
|
5458 | var cloneDeep_1 = cloneDeep;
|
5459 |
|
5460 | var DrawSource = function () {
|
5461 | function DrawSource(data) {
|
5462 | _classCallCheck(this, DrawSource);
|
5463 |
|
5464 | this.data = data || this.getDefaultData();
|
5465 | }
|
5466 |
|
5467 | _createClass(DrawSource, [{
|
5468 | key: "addFeature",
|
5469 | value: function addFeature(feature) {
|
5470 | this.data.features.push(feature);
|
5471 | }
|
5472 | }, {
|
5473 | key: "getData",
|
5474 | value: function getData() {
|
5475 | var features = cloneDeep_1(this.data.features).map(function (feature) {
|
5476 | var _feature$properties, _feature$properties2;
|
5477 |
|
5478 | feature.properties = {
|
5479 | id: feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id,
|
5480 | type: feature === null || feature === void 0 ? void 0 : (_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2.type
|
5481 | };
|
5482 | return feature;
|
5483 | });
|
5484 | return {
|
5485 | type: 'FeatureCollection',
|
5486 | features: features
|
5487 | };
|
5488 | }
|
5489 | }, {
|
5490 | key: "getFeature",
|
5491 | value: function getFeature(id) {
|
5492 | var result = this.data.features.find(function (fe) {
|
5493 | var _fe$properties;
|
5494 |
|
5495 | return (fe === null || fe === void 0 ? void 0 : (_fe$properties = fe.properties) === null || _fe$properties === void 0 ? void 0 : _fe$properties.id) === id;
|
5496 | });
|
5497 | return result;
|
5498 | }
|
5499 | }, {
|
5500 | key: "removeAllFeatures",
|
5501 | value: function removeAllFeatures() {
|
5502 | this.data = this.getDefaultData();
|
5503 | }
|
5504 | }, {
|
5505 | key: "removeFeature",
|
5506 | value: function removeFeature(feature) {
|
5507 | var index = this.getFeatureIndex(feature);
|
5508 |
|
5509 | if (index !== undefined) {
|
5510 | this.data.features.splice(index, 1);
|
5511 | }
|
5512 | }
|
5513 | }, {
|
5514 | key: "setFeatureActive",
|
5515 | value: function setFeatureActive(feature) {
|
5516 | var _feature$properties3;
|
5517 |
|
5518 | var fe = this.getFeature(feature === null || feature === void 0 ? void 0 : (_feature$properties3 = feature.properties) === null || _feature$properties3 === void 0 ? void 0 : _feature$properties3.id);
|
5519 |
|
5520 | if (fe && fe.properties) {
|
5521 | fe.properties.active = true;
|
5522 | }
|
5523 | }
|
5524 | }, {
|
5525 | key: "setFeatureUnActive",
|
5526 | value: function setFeatureUnActive(feature) {
|
5527 | var _feature$properties4;
|
5528 |
|
5529 | var fe = this.getFeature(feature === null || feature === void 0 ? void 0 : (_feature$properties4 = feature.properties) === null || _feature$properties4 === void 0 ? void 0 : _feature$properties4.id);
|
5530 |
|
5531 | if (fe && fe.properties) {
|
5532 | fe.properties.active = false;
|
5533 | }
|
5534 | }
|
5535 | }, {
|
5536 | key: "clearFeatureActive",
|
5537 | value: function clearFeatureActive() {
|
5538 | this.data.features.forEach(function (fe) {
|
5539 | if (fe && fe.properties) {
|
5540 | fe.properties.active = false;
|
5541 | }
|
5542 | });
|
5543 | }
|
5544 | }, {
|
5545 | key: "updateFeature",
|
5546 | value: function updateFeature(feature) {
|
5547 | this.removeFeature(feature);
|
5548 | this.addFeature(feature);
|
5549 | }
|
5550 | }, {
|
5551 | key: "destroy",
|
5552 | value: function destroy() {
|
5553 | this.data = this.getDefaultData();
|
5554 | }
|
5555 | }, {
|
5556 | key: "getDefaultData",
|
5557 | value: function getDefaultData() {
|
5558 | return {
|
5559 | type: 'FeatureCollection',
|
5560 | features: []
|
5561 | };
|
5562 | }
|
5563 | }, {
|
5564 | key: "getFeatureIndex",
|
5565 | value: function getFeatureIndex(feature) {
|
5566 | return this.data.features.findIndex(function (fe) {
|
5567 | var _fe$properties2, _feature$properties5;
|
5568 |
|
5569 | return (fe === null || fe === void 0 ? void 0 : (_fe$properties2 = fe.properties) === null || _fe$properties2 === void 0 ? void 0 : _fe$properties2.id) === (feature === null || feature === void 0 ? void 0 : (_feature$properties5 = feature.properties) === null || _feature$properties5 === void 0 ? void 0 : _feature$properties5.id);
|
5570 | });
|
5571 | }
|
5572 | }]);
|
5573 |
|
5574 | return DrawSource;
|
5575 | }();
|
5576 |
|
5577 | var LayerStyles = {
|
5578 | active: {
|
5579 | point: {
|
5580 | type: 'PointLayer',
|
5581 | shape: 'circle',
|
5582 | color: '#fbb03b',
|
5583 | size: 5,
|
5584 | style: {
|
5585 | stroke: '#fff',
|
5586 | strokeWidth: 2
|
5587 | }
|
5588 | },
|
5589 | line: {
|
5590 | type: 'LineLayer',
|
5591 | shape: 'line',
|
5592 | color: '#fbb03b',
|
5593 | size: 1,
|
5594 | style: {
|
5595 | opacity: 1,
|
5596 | lineType: 'dash',
|
5597 | dashArray: [2, 2]
|
5598 | }
|
5599 | },
|
5600 | polygon: {
|
5601 | shape: 'fill',
|
5602 | color: '#fbb03b',
|
5603 | style: {
|
5604 | opacity: 0.1,
|
5605 | stroke: '#fbb03b',
|
5606 | strokeWidth: 1,
|
5607 | strokeOpacity: 1,
|
5608 | lineType: 'dash',
|
5609 | dashArray: [2, 2]
|
5610 | }
|
5611 | }
|
5612 | },
|
5613 | normal: {
|
5614 | polygon: {
|
5615 | type: 'PolygonLayer',
|
5616 | shape: 'fill',
|
5617 | color: '#3bb2d0',
|
5618 | style: {
|
5619 | opacity: 0.1,
|
5620 | stroke: '#3bb2d0',
|
5621 | strokeWidth: 1,
|
5622 | strokeOpacity: 1,
|
5623 | lineType: 'solid',
|
5624 | dashArray: [2, 2]
|
5625 | }
|
5626 | },
|
5627 | line: {
|
5628 | type: 'LineLayer',
|
5629 | shape: 'line',
|
5630 | size: 1,
|
5631 | color: '#3bb2d0',
|
5632 | style: {
|
5633 | opacity: 1
|
5634 | }
|
5635 | },
|
5636 | point: {
|
5637 | type: 'PointLayer',
|
5638 | shape: 'circle',
|
5639 | color: '#3bb2d0',
|
5640 | size: 3,
|
5641 | style: {
|
5642 | stroke: '#fff',
|
5643 | strokeWidth: 2
|
5644 | }
|
5645 | }
|
5646 | },
|
5647 | normal_point: {
|
5648 | type: 'PointLayer',
|
5649 | shape: 'circle',
|
5650 | color: '#3bb2d0',
|
5651 | size: 3,
|
5652 | style: {
|
5653 | stroke: '#fff',
|
5654 | strokeWidth: 2
|
5655 | }
|
5656 | },
|
5657 | mid_point: {
|
5658 | point: {
|
5659 | type: 'PointLayer',
|
5660 | shape: 'circle',
|
5661 | color: '#fbb03b',
|
5662 | size: 3,
|
5663 | style: {}
|
5664 | }
|
5665 | }
|
5666 | };
|
5667 |
|
5668 | var DrawFeatureId = 0;
|
5669 |
|
5670 | var DrawMode = function (_EventEmitter) {
|
5671 | _inherits(DrawMode, _EventEmitter);
|
5672 |
|
5673 | var _super = _createSuper(DrawMode);
|
5674 |
|
5675 | function DrawMode(scene) {
|
5676 | var _this;
|
5677 |
|
5678 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5679 |
|
5680 | _classCallCheck(this, DrawMode);
|
5681 |
|
5682 | _this = _super.call(this);
|
5683 | _this.isEnable = false;
|
5684 | _this.options = {
|
5685 | style: LayerStyles
|
5686 | };
|
5687 | _this.drawStatus = 'Drawing';
|
5688 | var data = options.data;
|
5689 | _this.scene = scene;
|
5690 | _this.source = new DrawSource(data);
|
5691 | _this.options = merge_1(_this.options, _this.getDefaultOptions(), options);
|
5692 | _this.title = _this.getOption('title');
|
5693 | return _this;
|
5694 | }
|
5695 |
|
5696 | _createClass(DrawMode, [{
|
5697 | key: "enable",
|
5698 | value: function enable() {
|
5699 | if (this.isEnable) {
|
5700 | return;
|
5701 | }
|
5702 |
|
5703 |
|
5704 | this.scene.setMapStatus({
|
5705 | dragEnable: false
|
5706 | });
|
5707 | this.scene.on('dragstart', this.onDragStart);
|
5708 | this.scene.on('dragging', this.onDragging);
|
5709 | this.scene.on('dragend', this.onDragEnd);
|
5710 | this.scene.on('click', this.onClick);
|
5711 | this.setCursor(this.getOption('cursor'));
|
5712 | this.isEnable = true;
|
5713 | }
|
5714 | }, {
|
5715 | key: "disable",
|
5716 | value: function disable() {
|
5717 | if (!this.isEnable) {
|
5718 | return;
|
5719 | }
|
5720 |
|
5721 | this.scene.off('dragstart', this.onDragStart);
|
5722 | this.scene.off('dragging', this.onDragging);
|
5723 | this.scene.off('dragend', this.onDragEnd);
|
5724 | this.scene.off('click', this.onClick);
|
5725 | this.resetCursor();
|
5726 |
|
5727 | this.scene.setMapStatus({
|
5728 | dragEnable: true
|
5729 | });
|
5730 | this.isEnable = false;
|
5731 | }
|
5732 | }, {
|
5733 | key: "setCurrentFeature",
|
5734 | value: function setCurrentFeature(feature) {
|
5735 | this.currentFeature = feature;
|
5736 | this.source.setFeatureActive(feature);
|
5737 | }
|
5738 | }, {
|
5739 | key: "setCurrentVertex",
|
5740 | value: function setCurrentVertex(feature) {
|
5741 | this.currentVertex = feature;
|
5742 | }
|
5743 | }, {
|
5744 | key: "deleteCurrentFeature",
|
5745 | value: function deleteCurrentFeature() {
|
5746 | throw new Error('子类未实现该方法');
|
5747 | }
|
5748 | }, {
|
5749 | key: "getCurrentVertex",
|
5750 | value: function getCurrentVertex() {
|
5751 | return this.currentVertex;
|
5752 | }
|
5753 | }, {
|
5754 | key: "getCurrentFeature",
|
5755 | value: function getCurrentFeature() {
|
5756 | return this.currentFeature;
|
5757 | }
|
5758 | }, {
|
5759 | key: "getOption",
|
5760 | value: function getOption(key) {
|
5761 | return this.options[key];
|
5762 | }
|
5763 | }, {
|
5764 | key: "getStyle",
|
5765 | value: function getStyle(id) {
|
5766 | return this.getOption('style')[id];
|
5767 | }
|
5768 | }, {
|
5769 | key: "getUniqId",
|
5770 | value: function getUniqId() {
|
5771 | return DrawFeatureId++;
|
5772 | }
|
5773 | }, {
|
5774 | key: "setCursor",
|
5775 | value: function setCursor(cursor) {
|
5776 | var container = this.scene.getMapCanvasContainer();
|
5777 |
|
5778 | if (container) {
|
5779 | container.style.cursor = cursor;
|
5780 | }
|
5781 | }
|
5782 | }, {
|
5783 | key: "resetCursor",
|
5784 | value: function resetCursor() {
|
5785 | var container = this.scene.getMapCanvasContainer();
|
5786 |
|
5787 | if (container) {
|
5788 | container.removeAttribute('style');
|
5789 | }
|
5790 | }
|
5791 | }, {
|
5792 | key: "destroy",
|
5793 | value: function destroy() {
|
5794 | DrawFeatureId = 0;
|
5795 | this.removeAllListeners();
|
5796 | this.disable();
|
5797 | }
|
5798 | }, {
|
5799 | key: "getDefaultOptions",
|
5800 | value: function getDefaultOptions() {
|
5801 | return {};
|
5802 | }
|
5803 | }, {
|
5804 | key: "onClick",
|
5805 | value: function onClick(e) {
|
5806 | return null;
|
5807 | }
|
5808 | }]);
|
5809 |
|
5810 | return DrawMode;
|
5811 | }(eventemitter3_1);
|
5812 |
|
5813 | var DrawDelete = function (_DrawFeature) {
|
5814 | _inherits(DrawDelete, _DrawFeature);
|
5815 |
|
5816 | var _super = _createSuper(DrawDelete);
|
5817 |
|
5818 |
|
5819 | function DrawDelete(scene) {
|
5820 | var _this;
|
5821 |
|
5822 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5823 |
|
5824 | _classCallCheck(this, DrawDelete);
|
5825 |
|
5826 | _this = _super.call(this, scene, options);
|
5827 |
|
5828 | _this.onDragging = function (e) {
|
5829 | return;
|
5830 | };
|
5831 |
|
5832 | _this.onDragEnd = function () {
|
5833 | throw new Error('Method not implemented.');
|
5834 | };
|
5835 |
|
5836 | _this.onClick = function () {
|
5837 | return null;
|
5838 | };
|
5839 |
|
5840 | return _this;
|
5841 | }
|
5842 |
|
5843 | _createClass(DrawDelete, [{
|
5844 | key: "enable",
|
5845 | value: function enable() {
|
5846 | this.emit(DrawEvent.DELETE, '');
|
5847 | }
|
5848 | }, {
|
5849 | key: "disable",
|
5850 | value: function disable() {
|
5851 | return null;
|
5852 | }
|
5853 | }, {
|
5854 | key: "getDefaultOptions",
|
5855 | value: function getDefaultOptions() {
|
5856 | return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawDelete.prototype), "getDefaultOptions", this).call(this)), {}, {
|
5857 | title: '删除图形'
|
5858 | });
|
5859 | }
|
5860 | }, {
|
5861 | key: "onDragStart",
|
5862 | value: function onDragStart(e) {
|
5863 | throw new Error('Method not implemented.');
|
5864 | }
|
5865 | }]);
|
5866 |
|
5867 | return DrawDelete;
|
5868 | }(DrawMode);
|
5869 |
|
5870 | var DrawEdit = function (_DrawFeature) {
|
5871 | _inherits(DrawEdit, _DrawFeature);
|
5872 |
|
5873 | var _super = _createSuper(DrawEdit);
|
5874 |
|
5875 |
|
5876 | function DrawEdit(scene) {
|
5877 | var _this;
|
5878 |
|
5879 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5880 |
|
5881 | _classCallCheck(this, DrawEdit);
|
5882 |
|
5883 | _this = _super.call(this, scene, options);
|
5884 |
|
5885 | _this.onDragStart = function (e) {
|
5886 | };
|
5887 |
|
5888 | _this.onDragging = function (e) {
|
5889 | _this.endPoint = e.lngLat;
|
5890 |
|
5891 | _this.emit(DrawEvent.Edit, _this.endPoint);
|
5892 |
|
5893 | return;
|
5894 | };
|
5895 |
|
5896 | _this.onDragEnd = function () {
|
5897 | _this.emit(DrawEvent.UPDATE, _this.currentFeature);
|
5898 |
|
5899 | _this.resetCursor();
|
5900 |
|
5901 | _this.disable();
|
5902 | };
|
5903 |
|
5904 | _this.onClick = function () {
|
5905 | return null;
|
5906 | };
|
5907 |
|
5908 | return _this;
|
5909 | }
|
5910 |
|
5911 | _createClass(DrawEdit, [{
|
5912 | key: "setEditFeature",
|
5913 | value: function setEditFeature(feature) {
|
5914 | this.currentFeature = feature;
|
5915 | }
|
5916 | }, {
|
5917 | key: "getDefaultOptions",
|
5918 | value: function getDefaultOptions() {
|
5919 | return {
|
5920 | steps: 64,
|
5921 | units: 'kilometres',
|
5922 | cursor: 'move'
|
5923 | };
|
5924 | }
|
5925 | }]);
|
5926 |
|
5927 | return DrawEdit;
|
5928 | }(DrawMode);
|
5929 |
|
5930 | var DrawSelect = function (_DrawFeature) {
|
5931 | _inherits(DrawSelect, _DrawFeature);
|
5932 |
|
5933 | var _super = _createSuper(DrawSelect);
|
5934 |
|
5935 |
|
5936 | function DrawSelect(scene) {
|
5937 | var _this;
|
5938 |
|
5939 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
5940 |
|
5941 | _classCallCheck(this, DrawSelect);
|
5942 |
|
5943 | _this = _super.call(this, scene, options);
|
5944 |
|
5945 | _this.onDragStart = function (e) {
|
5946 | _this.scene.setMapStatus({
|
5947 | dragEnable: false
|
5948 | });
|
5949 |
|
5950 | _this.dragStartPoint = e.lngLat;
|
5951 | };
|
5952 |
|
5953 | _this.onDragging = function (e) {
|
5954 | var delta = {
|
5955 | lng: e.lngLat.lng - _this.dragStartPoint.lng,
|
5956 | lat: e.lngLat.lat - _this.dragStartPoint.lat
|
5957 | };
|
5958 |
|
5959 | _this.emit(DrawEvent.Move, delta);
|
5960 |
|
5961 | _this.dragStartPoint = e.lngLat;
|
5962 | return;
|
5963 | };
|
5964 |
|
5965 | _this.onDragEnd = function () {
|
5966 | _this.emit(DrawEvent.UPDATE, _this.currentFeature);
|
5967 | };
|
5968 |
|
5969 | _this.onClick = function () {
|
5970 | return null;
|
5971 | };
|
5972 |
|
5973 | return _this;
|
5974 | }
|
5975 |
|
5976 | _createClass(DrawSelect, [{
|
5977 | key: "setSelectedFeature",
|
5978 | value: function setSelectedFeature(feature) {
|
5979 | this.currentFeature = feature;
|
5980 | }
|
5981 | }, {
|
5982 | key: "getDefaultOptions",
|
5983 | value: function getDefaultOptions() {
|
5984 | return {
|
5985 | steps: 64,
|
5986 | units: 'kilometers',
|
5987 | cursor: 'move'
|
5988 | };
|
5989 | }
|
5990 | }]);
|
5991 |
|
5992 | return DrawSelect;
|
5993 | }(DrawMode);
|
5994 |
|
5995 | var DrawFeature = function (_DrawMode) {
|
5996 | _inherits(DrawFeature, _DrawMode);
|
5997 |
|
5998 | var _super = _createSuper(DrawFeature);
|
5999 |
|
6000 | function DrawFeature(scene) {
|
6001 | var _this;
|
6002 |
|
6003 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
6004 |
|
6005 | _classCallCheck(this, DrawFeature);
|
6006 |
|
6007 | _this = _super.call(this, scene, options);
|
6008 |
|
6009 | _this.onModeChange = function (mode) {
|
6010 | var _this$currentFeature, _this$currentFeature$, _this$currentFeature2, _this$currentFeature3;
|
6011 |
|
6012 | switch (mode) {
|
6013 | case DrawModes.DIRECT_SELECT:
|
6014 | if (!_this.editEnable) {
|
6015 | return;
|
6016 | }
|
6017 |
|
6018 | _this.editMode.enable();
|
6019 |
|
6020 | _this.editMode.setEditFeature(_this.currentFeature);
|
6021 |
|
6022 | _this.drawLayer.updateData(helpers_13([_this.currentFeature]));
|
6023 |
|
6024 | _this.drawVertexLayer.updateData(helpers_13((_this$currentFeature = _this.currentFeature) === null || _this$currentFeature === void 0 ? void 0 : (_this$currentFeature$ = _this$currentFeature.properties) === null || _this$currentFeature$ === void 0 ? void 0 : _this$currentFeature$.pointFeatures));
|
6025 |
|
6026 | _this.drawVertexLayer.show();
|
6027 |
|
6028 | _this.drawVertexLayer.enableEdit();
|
6029 |
|
6030 | _this.showOtherLayer();
|
6031 |
|
6032 | _this.drawStatus = 'DrawEdit';
|
6033 | break;
|
6034 |
|
6035 | case DrawModes.SIMPLE_SELECT:
|
6036 | if (!_this.selectEnable) {
|
6037 | _this.drawLayer.hide();
|
6038 |
|
6039 | _this.drawVertexLayer.hide();
|
6040 |
|
6041 | _this.hideOtherLayer();
|
6042 |
|
6043 | _this.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
|
6044 |
|
6045 | return;
|
6046 | }
|
6047 |
|
6048 | _this.selectMode.setSelectedFeature(_this.currentFeature);
|
6049 |
|
6050 | _this.selectMode.enable();
|
6051 |
|
6052 | _this.drawLayer.updateData(
|
6053 | helpers_13([_this.currentFeature]));
|
6054 |
|
6055 | _this.drawLayer.enableSelect();
|
6056 |
|
6057 | _this.drawVertexLayer.updateData(helpers_13((_this$currentFeature2 = _this.currentFeature) === null || _this$currentFeature2 === void 0 ? void 0 : (_this$currentFeature3 = _this$currentFeature2.properties) === null || _this$currentFeature3 === void 0 ? void 0 : _this$currentFeature3.pointFeatures));
|
6058 |
|
6059 | _this.drawVertexLayer.disableEdit();
|
6060 |
|
6061 | _this.drawVertexLayer.show();
|
6062 |
|
6063 | _this.drawLayer.show();
|
6064 |
|
6065 | _this.showOtherLayer();
|
6066 |
|
6067 | _this.drawStatus = 'DrawSelected';
|
6068 | break;
|
6069 |
|
6070 | case DrawModes.STATIC:
|
6071 | _this.source.updateFeature(_this.currentFeature);
|
6072 |
|
6073 | _this.selectMode.disable();
|
6074 |
|
6075 | _this.editMode.disable();
|
6076 |
|
6077 | _this.source.clearFeatureActive();
|
6078 |
|
6079 | _this.drawVertexLayer.hide();
|
6080 |
|
6081 | _this.drawVertexLayer.disableEdit();
|
6082 |
|
6083 | _this.hideOtherLayer();
|
6084 |
|
6085 | _this.normalLayer.update(_this.source.data);
|
6086 |
|
6087 | _this.normalLayer.enableSelect();
|
6088 |
|
6089 | _this.drawStatus = 'DrawFinish';
|
6090 | break;
|
6091 | }
|
6092 | };
|
6093 |
|
6094 | _this.onDrawCreate = function (feature) {
|
6095 | _this.source.addFeature(feature);
|
6096 | };
|
6097 |
|
6098 | _this.onDrawUpdate = function (feature) {
|
6099 | _this.source.updateFeature(_this.currentFeature);
|
6100 |
|
6101 | _this.emit(DrawEvent.UPDATE, _this.currentFeature);
|
6102 | };
|
6103 |
|
6104 | _this.onDrawMove = function (delta) {
|
6105 | if (_this.drawStatus === 'DrawSelected') {
|
6106 | _this.moveFeature(delta);
|
6107 | }
|
6108 | };
|
6109 |
|
6110 | _this.onDrawEdit = function (endpoint) {
|
6111 | _this.editFeature(endpoint);
|
6112 | };
|
6113 |
|
6114 | _this.onDrawDelete = function () {
|
6115 | if (_this.drawStatus === 'DrawSelected') {
|
6116 | _this.clear();
|
6117 |
|
6118 | _this.source.removeFeature(_this.currentFeature);
|
6119 |
|
6120 | _this.normalLayer.update(_this.source.data);
|
6121 |
|
6122 | _this.drawLayer.disableSelect();
|
6123 |
|
6124 | _this.selectMode.disable();
|
6125 |
|
6126 | _this.currentFeature = null;
|
6127 | }
|
6128 | };
|
6129 |
|
6130 | _this.addKeyDownEvent = function (event) {
|
6131 |
|
6132 | var e = event || window.event;
|
6133 |
|
6134 | if (e && e.keyCode === 8) {
|
6135 | _this.deleteMode.enable();
|
6136 | }
|
6137 | };
|
6138 |
|
6139 | _this.drawLayer = new DrawLayer(_assertThisInitialized(_this));
|
6140 | _this.drawVertexLayer = new DrawVertexLayer(_assertThisInitialized(_this));
|
6141 | _this.normalLayer = new DrawResultLayer(_assertThisInitialized(_this));
|
6142 | _this.selectEnable = _this.getOption('selectEnable');
|
6143 | _this.editEnable = _this.getOption('editEnable');
|
6144 |
|
6145 | _this.selectMode = new DrawSelect(_this.scene, {});
|
6146 | _this.editMode = new DrawEdit(_this.scene, {});
|
6147 | _this.deleteMode = new DrawDelete(_this.scene, {});
|
6148 |
|
6149 | _this.selectMode.on(DrawEvent.UPDATE, _this.onDrawUpdate);
|
6150 |
|
6151 | _this.selectMode.on(DrawEvent.Move, _this.onDrawMove);
|
6152 |
|
6153 | _this.editMode.on(DrawEvent.MODE_CHANGE, _this.onModeChange);
|
6154 |
|
6155 | _this.editMode.on(DrawEvent.UPDATE, _this.onDrawUpdate);
|
6156 |
|
6157 | _this.editMode.on(DrawEvent.Edit, _this.onDrawEdit);
|
6158 |
|
6159 | _this.selectMode.on(DrawEvent.MODE_CHANGE, _this.onModeChange);
|
6160 |
|
6161 | _this.deleteMode.on(DrawEvent.DELETE, _this.onDrawDelete);
|
6162 |
|
6163 | _this.on(DrawEvent.CREATE, _this.onDrawCreate);
|
6164 |
|
6165 | _this.on(DrawEvent.MODE_CHANGE, _this.onModeChange);
|
6166 |
|
6167 | document.addEventListener('keydown', _this.addKeyDownEvent);
|
6168 |
|
6169 | if (_this.options.data && _this.initData()) {
|
6170 | _this.normalLayer.update(_this.source.data);
|
6171 |
|
6172 | _this.normalLayer.enableSelect();
|
6173 | }
|
6174 |
|
6175 | return _this;
|
6176 | }
|
6177 |
|
6178 | _createClass(DrawFeature, [{
|
6179 | key: "setCurrentFeature",
|
6180 | value: function setCurrentFeature(feature) {
|
6181 | this.currentFeature = feature;
|
6182 |
|
6183 | this.pointFeatures = feature.properties.pointFeatures;
|
6184 | this.source.setFeatureActive(feature);
|
6185 | }
|
6186 | }, {
|
6187 | key: "deleteCurrentFeature",
|
6188 | value: function deleteCurrentFeature() {
|
6189 | this.deleteMode.enable();
|
6190 | }
|
6191 | }, {
|
6192 | key: "disableLayer",
|
6193 | value: function disableLayer() {
|
6194 |
|
6195 | this.drawLayer.disableSelect();
|
6196 | }
|
6197 | }, {
|
6198 | key: "enableLayer",
|
6199 | value: function enableLayer() {
|
6200 | this.drawLayer.enableSelect();
|
6201 | }
|
6202 | }, {
|
6203 | key: "getData",
|
6204 | value: function getData() {
|
6205 | return this.source.getData();
|
6206 | }
|
6207 | }, {
|
6208 | key: "removeAllData",
|
6209 | value: function removeAllData() {
|
6210 | this.source.removeAllFeatures();
|
6211 | this.currentFeature = null;
|
6212 | this.drawLayer.hide();
|
6213 | this.drawVertexLayer.hide();
|
6214 | this.normalLayer.hide();
|
6215 | this.hideOtherLayer();
|
6216 | }
|
6217 | }, {
|
6218 | key: "clear",
|
6219 | value: function clear() {
|
6220 | this.drawLayer.disableSelect();
|
6221 | this.drawLayer.disableEdit();
|
6222 | this.drawLayer.hide();
|
6223 | this.drawVertexLayer.hide();
|
6224 | this.hideOtherLayer();
|
6225 | this.emit(DrawEvent.MODE_CHANGE, DrawModes.STATIC);
|
6226 | }
|
6227 | }, {
|
6228 | key: "reset",
|
6229 | value: function reset() {
|
6230 | this.drawLayer.show();
|
6231 | this.drawVertexLayer.show();
|
6232 | this.showOtherLayer();
|
6233 | }
|
6234 | }, {
|
6235 | key: "addVertex",
|
6236 | value: function addVertex(feature) {
|
6237 | throw new Error('子类未实现该方法');
|
6238 | }
|
6239 | }, {
|
6240 | key: "onRemove",
|
6241 | value: function onRemove() {
|
6242 | this.destroy();
|
6243 | this.selectMode.destroy();
|
6244 | this.editMode.destroy();
|
6245 | this.source.destroy();
|
6246 | this.drawLayer.destroy();
|
6247 | this.drawVertexLayer.destroy();
|
6248 | this.normalLayer.destroy();
|
6249 | document.removeEventListener('keydown', this.addKeyDownEvent);
|
6250 | }
|
6251 | }, {
|
6252 | key: "getDefaultOptions",
|
6253 | value: function getDefaultOptions() {
|
6254 | return {
|
6255 | steps: 64,
|
6256 | units: 'kilometers',
|
6257 | cursor: 'crosshair',
|
6258 | editEnable: true,
|
6259 | selectEnable: true
|
6260 | };
|
6261 | }
|
6262 | }, {
|
6263 | key: "initData",
|
6264 | value: function initData() {
|
6265 | return false;
|
6266 | }
|
6267 | }, {
|
6268 | key: "addDrawPopup",
|
6269 | value: function addDrawPopup(lnglat, dis) {
|
6270 | var popup = new l7.Popup({
|
6271 | anchor: 'left',
|
6272 | closeButton: false
|
6273 | }).setLnglat(lnglat).setText("\u534A\u5F84:".concat(dis.toFixed(2), "\u5343\u7C73"));
|
6274 | this.scene.addPopup(popup);
|
6275 | this.popup = popup;
|
6276 | }
|
6277 | }]);
|
6278 |
|
6279 | return DrawFeature;
|
6280 | }(DrawMode);
|
6281 |
|
6282 | var DrawCircle = function (_DrawFeature) {
|
6283 | _inherits(DrawCircle, _DrawFeature);
|
6284 |
|
6285 | var _super = _createSuper(DrawCircle);
|
6286 |
|
6287 | function DrawCircle(scene) {
|
6288 | var _this;
|
6289 |
|
6290 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
6291 |
|
6292 | _classCallCheck(this, DrawCircle);
|
6293 |
|
6294 | _this = _super.call(this, scene, options);
|
6295 |
|
6296 | _this.onDragStart = function (e) {
|
6297 | if (_this.drawStatus !== 'Drawing') {
|
6298 | _this.drawLayer.emit('unclick', null);
|
6299 | }
|
6300 |
|
6301 | _this.startPoint = e.lngLat;
|
6302 |
|
6303 | _this.setCursor('grabbing');
|
6304 |
|
6305 | _this.initCenterLayer();
|
6306 |
|
6307 | _this.centerLayer.setData([_this.startPoint]);
|
6308 | };
|
6309 |
|
6310 | _this.onDragging = function (e) {
|
6311 | _this.endPoint = e.lngLat;
|
6312 |
|
6313 | var feature = _this.createFeature();
|
6314 |
|
6315 | var properties = feature.properties;
|
6316 |
|
6317 | _this.drawLayer.update(helpers_13([feature]));
|
6318 |
|
6319 | _this.drawVertexLayer.update(helpers_13(properties.pointFeatures));
|
6320 | };
|
6321 |
|
6322 | _this.onDragEnd = function () {
|
6323 | var feature = _this.createFeature("".concat(_this.getUniqId()));
|
6324 |
|
6325 | var properties = feature.properties;
|
6326 |
|
6327 | _this.drawLayer.update(helpers_13([feature]));
|
6328 |
|
6329 | _this.drawVertexLayer.update(helpers_13(properties.pointFeatures));
|
6330 |
|
6331 | _this.emit(DrawEvent.CREATE, _this.currentFeature);
|
6332 |
|
6333 | _this.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
|
6334 |
|
6335 | _this.disable();
|
6336 | };
|
6337 |
|
6338 | _this.type = 'circle';
|
6339 | return _this;
|
6340 | }
|
6341 |
|
6342 | _createClass(DrawCircle, [{
|
6343 | key: "drawFinish",
|
6344 | value: function drawFinish() {
|
6345 | return null;
|
6346 | }
|
6347 | }, {
|
6348 | key: "setCurrentFeature",
|
6349 | value: function setCurrentFeature(feature) {
|
6350 | this.currentFeature = feature;
|
6351 |
|
6352 | this.pointFeatures = feature.properties.pointFeatures;
|
6353 |
|
6354 | this.startPoint = feature.properties.startPoint;
|
6355 |
|
6356 | this.endPoint = feature.properties.endPoint;
|
6357 | this.source.setFeatureActive(feature);
|
6358 | }
|
6359 | }, {
|
6360 | key: "getDefaultOptions",
|
6361 | value: function getDefaultOptions() {
|
6362 | return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawCircle.prototype), "getDefaultOptions", this).call(this)), {}, {
|
6363 | title: '绘制圆'
|
6364 | });
|
6365 | }
|
6366 | }, {
|
6367 | key: "moveFeature",
|
6368 | value: function moveFeature(delta) {
|
6369 | var newFeature = moveFeatures([this.currentFeature], delta);
|
6370 | this.drawLayer.updateData(helpers_13(newFeature));
|
6371 | var newPointFeture = moveFeatures(this.pointFeatures, delta);
|
6372 | this.drawVertexLayer.updateData(helpers_13(newPointFeture));
|
6373 | var newStartPoint = movePoint([this.startPoint.lng, this.startPoint.lat], delta);
|
6374 | this.startPoint = {
|
6375 | lat: newStartPoint[1],
|
6376 | lng: newStartPoint[0]
|
6377 | };
|
6378 | var newEndPoint = movePoint([this.endPoint.lng, this.endPoint.lat], delta);
|
6379 | var endPointObj = {
|
6380 | lat: newEndPoint[1],
|
6381 | lng: newEndPoint[0]
|
6382 | };
|
6383 | newFeature[0].properties = _objectSpread2(_objectSpread2({}, newFeature[0].properties), {}, {
|
6384 | startPoint: this.startPoint,
|
6385 | endPoint: endPointObj,
|
6386 | pointFeatures: newPointFeture
|
6387 | });
|
6388 | this.centerLayer.setData([this.startPoint]);
|
6389 | this.setCurrentFeature(newFeature[0]);
|
6390 |
|
6391 | var changeFeature = _objectSpread2({}, newFeature[0]);
|
6392 |
|
6393 | this.emit(DrawEvent.CHANGE, changeFeature);
|
6394 | }
|
6395 | }, {
|
6396 | key: "createFeature",
|
6397 | value: function createFeature() {
|
6398 | var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0';
|
6399 | var points = createPoint([this.endPoint]);
|
6400 | var feature = createCircle([this.startPoint.lng, this.startPoint.lat], [this.endPoint.lng, this.endPoint.lat], {
|
6401 | pointFeatures: points.features,
|
6402 | units: this.getOption('units'),
|
6403 | steps: this.getOption('steps'),
|
6404 | id: id
|
6405 | });
|
6406 | this.setCurrentFeature(feature);
|
6407 | return feature;
|
6408 | }
|
6409 | }, {
|
6410 | key: "editFeature",
|
6411 | value: function editFeature(endPoint) {
|
6412 | this.endPoint = endPoint;
|
6413 | var newFeature = this.createFeature();
|
6414 | var properties = newFeature.properties;
|
6415 | this.drawLayer.updateData(helpers_13([newFeature]));
|
6416 | this.drawVertexLayer.updateData(helpers_13(properties.pointFeatures));
|
6417 | this.emit(DrawEvent.CHANGE, helpers_13([newFeature]).features[0]);
|
6418 | }
|
6419 | }, {
|
6420 | key: "showOtherLayer",
|
6421 | value: function showOtherLayer() {
|
6422 | var _this$currentFeature, _this$currentFeature$;
|
6423 |
|
6424 | this.centerLayer.setData([(_this$currentFeature = this.currentFeature) === null || _this$currentFeature === void 0 ? void 0 : (_this$currentFeature$ = _this$currentFeature.properties) === null || _this$currentFeature$ === void 0 ? void 0 : _this$currentFeature$.startPoint]);
|
6425 | this.centerLayer.show();
|
6426 | }
|
6427 | }, {
|
6428 | key: "hideOtherLayer",
|
6429 | value: function hideOtherLayer() {
|
6430 | if (this.currentFeature) {
|
6431 | this.centerLayer.hide();
|
6432 | }
|
6433 | }
|
6434 | }, {
|
6435 | key: "initCenterLayer",
|
6436 | value: function initCenterLayer() {
|
6437 | var centerStyle = this.getStyle('active').point;
|
6438 | var layer = new l7.PointLayer().source([this.startPoint], {
|
6439 | parser: {
|
6440 | type: 'json',
|
6441 | x: 'lng',
|
6442 | y: 'lat'
|
6443 | }
|
6444 | }).shape('circle').color(centerStyle.color).size(centerStyle.size).style(centerStyle.style);
|
6445 | this.scene.addLayer(layer);
|
6446 | this.centerLayer = layer;
|
6447 | }
|
6448 | }]);
|
6449 |
|
6450 | return DrawCircle;
|
6451 | }(DrawFeature);
|
6452 |
|
6453 | |
6454 |
|
6455 |
|
6456 |
|
6457 | |
6458 |
|
6459 |
|
6460 |
|
6461 |
|
6462 |
|
6463 |
|
6464 | function radiansToDegrees(radians) {
|
6465 | if (radians === null || radians === undefined) throw new Error('radians is required');
|
6466 |
|
6467 | var degrees = radians % (2 * Math.PI);
|
6468 | return degrees * 180 / Math.PI;
|
6469 | }
|
6470 |
|
6471 | |
6472 |
|
6473 |
|
6474 |
|
6475 |
|
6476 |
|
6477 |
|
6478 | function degreesToRadians(degrees) {
|
6479 | if (degrees === null || degrees === undefined) throw new Error('degrees is required');
|
6480 |
|
6481 | var radians = degrees % 360;
|
6482 | return radians * Math.PI / 180;
|
6483 | }
|
6484 |
|
6485 | |
6486 |
|
6487 |
|
6488 |
|
6489 |
|
6490 |
|
6491 |
|
6492 |
|
6493 |
|
6494 |
|
6495 |
|
6496 | function isObject$1(input) {
|
6497 | return (!!input) && (input.constructor === Object);
|
6498 | }
|
6499 |
|
6500 | |
6501 |
|
6502 |
|
6503 |
|
6504 |
|
6505 |
|
6506 |
|
6507 |
|
6508 |
|
6509 |
|
6510 |
|
6511 |
|
6512 | function getCoord(coord) {
|
6513 | if (!coord) throw new Error('coord is required');
|
6514 | if (coord.type === 'Feature' && coord.geometry !== null && coord.geometry.type === 'Point') return coord.geometry.coordinates;
|
6515 | if (coord.type === 'Point') return coord.coordinates;
|
6516 | if (Array.isArray(coord) && coord.length >= 2 && coord[0].length === undefined && coord[1].length === undefined) return coord;
|
6517 |
|
6518 | throw new Error('coord must be GeoJSON Point or an Array of numbers');
|
6519 | }
|
6520 |
|
6521 |
|
6522 |
|
6523 |
|
6524 | |
6525 |
|
6526 |
|
6527 |
|
6528 |
|
6529 |
|
6530 |
|
6531 |
|
6532 |
|
6533 |
|
6534 |
|
6535 |
|
6536 |
|
6537 |
|
6538 |
|
6539 |
|
6540 |
|
6541 |
|
6542 |
|
6543 |
|
6544 |
|
6545 |
|
6546 | function bearing(start, end, options) {
|
6547 |
|
6548 | options = options || {};
|
6549 | if (!isObject$1(options)) throw new Error('options is invalid');
|
6550 | var final = options.final;
|
6551 |
|
6552 |
|
6553 | if (final === true) return calculateFinalBearing(start, end);
|
6554 |
|
6555 | var coordinates1 = getCoord(start);
|
6556 | var coordinates2 = getCoord(end);
|
6557 |
|
6558 | var lon1 = degreesToRadians(coordinates1[0]);
|
6559 | var lon2 = degreesToRadians(coordinates2[0]);
|
6560 | var lat1 = degreesToRadians(coordinates1[1]);
|
6561 | var lat2 = degreesToRadians(coordinates2[1]);
|
6562 | var a = Math.sin(lon2 - lon1) * Math.cos(lat2);
|
6563 | var b = Math.cos(lat1) * Math.sin(lat2) -
|
6564 | Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
|
6565 |
|
6566 | return radiansToDegrees(Math.atan2(a, b));
|
6567 | }
|
6568 |
|
6569 | |
6570 |
|
6571 |
|
6572 |
|
6573 |
|
6574 |
|
6575 |
|
6576 |
|
6577 | function calculateFinalBearing(start, end) {
|
6578 |
|
6579 | var bear = bearing(end, start);
|
6580 | bear = (bear + 180) % 360;
|
6581 | return bear;
|
6582 | }
|
6583 |
|
6584 | |
6585 |
|
6586 |
|
6587 | var earthRadius = 6371008.8;
|
6588 |
|
6589 | |
6590 |
|
6591 |
|
6592 | var factors = {
|
6593 | meters: earthRadius,
|
6594 | metres: earthRadius,
|
6595 | millimeters: earthRadius * 1000,
|
6596 | millimetres: earthRadius * 1000,
|
6597 | centimeters: earthRadius * 100,
|
6598 | centimetres: earthRadius * 100,
|
6599 | kilometers: earthRadius / 1000,
|
6600 | kilometres: earthRadius / 1000,
|
6601 | miles: earthRadius / 1609.344,
|
6602 | nauticalmiles: earthRadius / 1852,
|
6603 | inches: earthRadius * 39.370,
|
6604 | yards: earthRadius / 1.0936,
|
6605 | feet: earthRadius * 3.28084,
|
6606 | radians: 1,
|
6607 | degrees: earthRadius / 111325,
|
6608 | };
|
6609 |
|
6610 | |
6611 |
|
6612 |
|
6613 |
|
6614 |
|
6615 |
|
6616 |
|
6617 |
|
6618 |
|
6619 |
|
6620 |
|
6621 |
|
6622 |
|
6623 |
|
6624 |
|
6625 |
|
6626 |
|
6627 |
|
6628 |
|
6629 |
|
6630 | function feature(geometry, properties, options) {
|
6631 |
|
6632 | options = options || {};
|
6633 | if (!isObject$2(options)) throw new Error('options is invalid');
|
6634 | var bbox = options.bbox;
|
6635 | var id = options.id;
|
6636 |
|
6637 |
|
6638 | if (geometry === undefined) throw new Error('geometry is required');
|
6639 | if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
|
6640 | if (bbox) validateBBox(bbox);
|
6641 | if (id) validateId(id);
|
6642 |
|
6643 |
|
6644 | var feat = {type: 'Feature'};
|
6645 | if (id) feat.id = id;
|
6646 | if (bbox) feat.bbox = bbox;
|
6647 | feat.properties = properties || {};
|
6648 | feat.geometry = geometry;
|
6649 | return feat;
|
6650 | }
|
6651 |
|
6652 | |
6653 |
|
6654 |
|
6655 |
|
6656 |
|
6657 |
|
6658 |
|
6659 |
|
6660 |
|
6661 |
|
6662 |
|
6663 |
|
6664 |
|
6665 |
|
6666 |
|
6667 | function point(coordinates, properties, options) {
|
6668 | if (!coordinates) throw new Error('coordinates is required');
|
6669 | if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array');
|
6670 | if (coordinates.length < 2) throw new Error('coordinates must be at least 2 numbers long');
|
6671 | if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('coordinates must contain numbers');
|
6672 |
|
6673 | return feature({
|
6674 | type: 'Point',
|
6675 | coordinates: coordinates
|
6676 | }, properties, options);
|
6677 | }
|
6678 |
|
6679 | |
6680 |
|
6681 |
|
6682 |
|
6683 |
|
6684 |
|
6685 |
|
6686 |
|
6687 |
|
6688 | function radiansToLength(radians, units) {
|
6689 | if (radians === undefined || radians === null) throw new Error('radians is required');
|
6690 |
|
6691 | if (units && typeof units !== 'string') throw new Error('units must be a string');
|
6692 | var factor = factors[units || 'kilometers'];
|
6693 | if (!factor) throw new Error(units + ' units is invalid');
|
6694 | return radians * factor;
|
6695 | }
|
6696 |
|
6697 | |
6698 |
|
6699 |
|
6700 |
|
6701 |
|
6702 |
|
6703 |
|
6704 |
|
6705 |
|
6706 | function lengthToRadians(distance, units) {
|
6707 | if (distance === undefined || distance === null) throw new Error('distance is required');
|
6708 |
|
6709 | if (units && typeof units !== 'string') throw new Error('units must be a string');
|
6710 | var factor = factors[units || 'kilometers'];
|
6711 | if (!factor) throw new Error(units + ' units is invalid');
|
6712 | return distance / factor;
|
6713 | }
|
6714 |
|
6715 | |
6716 |
|
6717 |
|
6718 |
|
6719 |
|
6720 |
|
6721 |
|
6722 | function radiansToDegrees$1(radians) {
|
6723 | if (radians === null || radians === undefined) throw new Error('radians is required');
|
6724 |
|
6725 | var degrees = radians % (2 * Math.PI);
|
6726 | return degrees * 180 / Math.PI;
|
6727 | }
|
6728 |
|
6729 | |
6730 |
|
6731 |
|
6732 |
|
6733 |
|
6734 |
|
6735 |
|
6736 | function degreesToRadians$1(degrees) {
|
6737 | if (degrees === null || degrees === undefined) throw new Error('degrees is required');
|
6738 |
|
6739 | var radians = degrees % 360;
|
6740 | return radians * Math.PI / 180;
|
6741 | }
|
6742 |
|
6743 | |
6744 |
|
6745 |
|
6746 |
|
6747 |
|
6748 |
|
6749 |
|
6750 |
|
6751 |
|
6752 |
|
6753 |
|
6754 | function isNumber(num) {
|
6755 | return !isNaN(num) && num !== null && !Array.isArray(num);
|
6756 | }
|
6757 |
|
6758 | |
6759 |
|
6760 |
|
6761 |
|
6762 |
|
6763 |
|
6764 |
|
6765 |
|
6766 |
|
6767 |
|
6768 |
|
6769 | function isObject$2(input) {
|
6770 | return (!!input) && (input.constructor === Object);
|
6771 | }
|
6772 |
|
6773 | |
6774 |
|
6775 |
|
6776 |
|
6777 |
|
6778 |
|
6779 |
|
6780 |
|
6781 |
|
6782 |
|
6783 |
|
6784 |
|
6785 |
|
6786 |
|
6787 |
|
6788 |
|
6789 |
|
6790 |
|
6791 |
|
6792 |
|
6793 |
|
6794 | function validateBBox(bbox) {
|
6795 | if (!bbox) throw new Error('bbox is required');
|
6796 | if (!Array.isArray(bbox)) throw new Error('bbox must be an Array');
|
6797 | if (bbox.length !== 4 && bbox.length !== 6) throw new Error('bbox must be an Array of 4 or 6 numbers');
|
6798 | bbox.forEach(function (num) {
|
6799 | if (!isNumber(num)) throw new Error('bbox must only contain numbers');
|
6800 | });
|
6801 | }
|
6802 |
|
6803 | |
6804 |
|
6805 |
|
6806 |
|
6807 |
|
6808 |
|
6809 |
|
6810 |
|
6811 |
|
6812 |
|
6813 |
|
6814 |
|
6815 |
|
6816 |
|
6817 |
|
6818 |
|
6819 |
|
6820 |
|
6821 |
|
6822 |
|
6823 |
|
6824 | function validateId(id) {
|
6825 | if (!id) throw new Error('id is required');
|
6826 | if (['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');
|
6827 | }
|
6828 |
|
6829 | |
6830 |
|
6831 |
|
6832 |
|
6833 |
|
6834 |
|
6835 |
|
6836 |
|
6837 |
|
6838 |
|
6839 |
|
6840 |
|
6841 | function getCoord$1(coord) {
|
6842 | if (!coord) throw new Error('coord is required');
|
6843 | if (coord.type === 'Feature' && coord.geometry !== null && coord.geometry.type === 'Point') return coord.geometry.coordinates;
|
6844 | if (coord.type === 'Point') return coord.coordinates;
|
6845 | if (Array.isArray(coord) && coord.length >= 2 && coord[0].length === undefined && coord[1].length === undefined) return coord;
|
6846 |
|
6847 | throw new Error('coord must be GeoJSON Point or an Array of numbers');
|
6848 | }
|
6849 |
|
6850 |
|
6851 |
|
6852 | |
6853 |
|
6854 |
|
6855 |
|
6856 |
|
6857 |
|
6858 |
|
6859 |
|
6860 |
|
6861 |
|
6862 |
|
6863 |
|
6864 |
|
6865 |
|
6866 |
|
6867 |
|
6868 |
|
6869 |
|
6870 |
|
6871 |
|
6872 |
|
6873 |
|
6874 |
|
6875 |
|
6876 | function destination(origin, distance, bearing, options) {
|
6877 |
|
6878 | options = options || {};
|
6879 | if (!isObject$2(options)) throw new Error('options is invalid');
|
6880 | var units = options.units;
|
6881 | var properties = options.properties;
|
6882 |
|
6883 |
|
6884 | var coordinates1 = getCoord$1(origin);
|
6885 | var longitude1 = degreesToRadians$1(coordinates1[0]);
|
6886 | var latitude1 = degreesToRadians$1(coordinates1[1]);
|
6887 | var bearing_rad = degreesToRadians$1(bearing);
|
6888 | var radians = lengthToRadians(distance, units);
|
6889 |
|
6890 |
|
6891 | var latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
|
6892 | Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearing_rad));
|
6893 | var longitude2 = longitude1 + Math.atan2(Math.sin(bearing_rad) * Math.sin(radians) * Math.cos(latitude1),
|
6894 | Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
|
6895 | var lng = radiansToDegrees$1(longitude2);
|
6896 | var lat = radiansToDegrees$1(latitude2);
|
6897 |
|
6898 | return point([lng, lat], properties);
|
6899 | }
|
6900 |
|
6901 |
|
6902 |
|
6903 |
|
6904 | |
6905 |
|
6906 |
|
6907 |
|
6908 |
|
6909 |
|
6910 |
|
6911 |
|
6912 |
|
6913 |
|
6914 |
|
6915 |
|
6916 |
|
6917 |
|
6918 |
|
6919 |
|
6920 |
|
6921 |
|
6922 |
|
6923 |
|
6924 |
|
6925 |
|
6926 |
|
6927 |
|
6928 | function distance(from, to, options) {
|
6929 |
|
6930 | options = options || {};
|
6931 | if (!isObject$2(options)) throw new Error('options is invalid');
|
6932 | var units = options.units;
|
6933 |
|
6934 | var coordinates1 = getCoord$1(from);
|
6935 | var coordinates2 = getCoord$1(to);
|
6936 | var dLat = degreesToRadians$1((coordinates2[1] - coordinates1[1]));
|
6937 | var dLon = degreesToRadians$1((coordinates2[0] - coordinates1[0]));
|
6938 | var lat1 = degreesToRadians$1(coordinates1[1]);
|
6939 | var lat2 = degreesToRadians$1(coordinates2[1]);
|
6940 |
|
6941 | var a = Math.pow(Math.sin(dLat / 2), 2) +
|
6942 | Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
|
6943 |
|
6944 | return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units);
|
6945 | }
|
6946 |
|
6947 | |
6948 |
|
6949 |
|
6950 |
|
6951 |
|
6952 |
|
6953 |
|
6954 |
|
6955 |
|
6956 |
|
6957 |
|
6958 |
|
6959 |
|
6960 |
|
6961 |
|
6962 |
|
6963 |
|
6964 |
|
6965 | function midpoint(point1, point2) {
|
6966 | var dist = distance(point1, point2);
|
6967 | var heading = bearing(point1, point2);
|
6968 | var midpoint = destination(point1, dist / 2, heading);
|
6969 |
|
6970 | return midpoint;
|
6971 | }
|
6972 |
|
6973 | var DrawVertexLayer$1 = function (_BaseRender) {
|
6974 | _inherits(DrawVertexLayer, _BaseRender);
|
6975 |
|
6976 | var _super = _createSuper(DrawVertexLayer);
|
6977 |
|
6978 | function DrawVertexLayer() {
|
6979 | var _this;
|
6980 |
|
6981 | _classCallCheck(this, DrawVertexLayer);
|
6982 |
|
6983 | _this = _super.apply(this, arguments);
|
6984 |
|
6985 | _this.onMouseEnter = function (e) {
|
6986 | _this.draw.setCursor('pointer');
|
6987 | };
|
6988 |
|
6989 | _this.onMouseOut = function (e) {
|
6990 | _this.draw.resetCursor();
|
6991 | };
|
6992 |
|
6993 | _this.onClick = function (e) {
|
6994 | _this.draw.addVertex(e.feature);
|
6995 |
|
6996 | };
|
6997 |
|
6998 | return _this;
|
6999 | }
|
7000 |
|
7001 | _createClass(DrawVertexLayer, [{
|
7002 | key: "update",
|
7003 | value: function update(pointFeatures) {
|
7004 | this.removeLayers();
|
7005 | var midFeatures = this.calcMidPointData(pointFeatures);
|
7006 | var style = this.draw.getStyle('mid_point');
|
7007 | this.drawLayers = renderFeature(midFeatures, style);
|
7008 | this.addLayers();
|
7009 | this.enableEdit();
|
7010 | }
|
7011 | }, {
|
7012 | key: "updateData",
|
7013 | value: function updateData(data) {
|
7014 | var midFeatures = this.calcMidPointData(data);
|
7015 | this.drawLayers.forEach(function (layer) {
|
7016 | return layer.setData(midFeatures);
|
7017 | });
|
7018 | }
|
7019 | }, {
|
7020 | key: "enableEdit",
|
7021 | value: function enableEdit() {
|
7022 | var layer = this.drawLayers[0];
|
7023 | layer.on('mouseenter', this.onMouseEnter);
|
7024 | layer.on('mouseout', this.onMouseOut);
|
7025 | layer.on('click', this.onClick);
|
7026 | }
|
7027 | }, {
|
7028 | key: "disableEdit",
|
7029 | value: function disableEdit() {
|
7030 | var layer = this.drawLayers[0];
|
7031 | layer.off('mouseenter', this.onMouseEnter);
|
7032 | layer.off('mouseout', this.onMouseOut);
|
7033 | layer.off('click', this.onClick);
|
7034 | }
|
7035 | }, {
|
7036 | key: "calcMidPointData",
|
7037 | value: function calcMidPointData(fe) {
|
7038 | var _this2 = this;
|
7039 |
|
7040 | var midFeatures = [];
|
7041 | fe.features.forEach(function (item, index) {
|
7042 | var preFeature = item;
|
7043 |
|
7044 | if (_this2.draw.type === 'line' && index === fe.features.length - 1) {
|
7045 | return;
|
7046 | }
|
7047 |
|
7048 | var nextFeature = index !== fe.features.length - 1 ? fe.features[index + 1] : fe.features[0];
|
7049 |
|
7050 | var point = midpoint(preFeature, nextFeature);
|
7051 |
|
7052 | point.properties.id = index;
|
7053 | midFeatures.push(point);
|
7054 | });
|
7055 | return helpers_13(midFeatures);
|
7056 | }
|
7057 | }]);
|
7058 |
|
7059 | return DrawVertexLayer;
|
7060 | }(BaseRenderLayer);
|
7061 |
|
7062 | var DrawPolygon = function (_DrawFeature) {
|
7063 | _inherits(DrawPolygon, _DrawFeature);
|
7064 |
|
7065 | var _super = _createSuper(DrawPolygon);
|
7066 |
|
7067 | function DrawPolygon(scene) {
|
7068 | var _this;
|
7069 |
|
7070 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7071 |
|
7072 | _classCallCheck(this, DrawPolygon);
|
7073 |
|
7074 | _this = _super.call(this, scene, options);
|
7075 | _this.points = [];
|
7076 |
|
7077 | _this.onDragStart = function (e) {
|
7078 | return null;
|
7079 | };
|
7080 |
|
7081 | _this.onDragging = function (e) {
|
7082 | return null;
|
7083 | };
|
7084 |
|
7085 | _this.onDragEnd = function () {
|
7086 | return null;
|
7087 | };
|
7088 |
|
7089 | _this.onClick = function (e) {
|
7090 | if (_this.drawStatus !== 'Drawing') {
|
7091 | _this.drawLayer.emit('unclick', null);
|
7092 | }
|
7093 |
|
7094 | var lngLat = e.lngLat || e.lnglat;
|
7095 | _this.endPoint = lngLat;
|
7096 |
|
7097 | _this.points.push(lngLat);
|
7098 |
|
7099 | var feature = _this.createFeature(_this.points);
|
7100 |
|
7101 | var pointfeatures = createPoint([_this.points[0], _this.endPoint]);
|
7102 |
|
7103 | _this.drawLayer.update(helpers_13([feature]));
|
7104 |
|
7105 | _this.drawVertexLayer.update(helpers_13(pointfeatures.features));
|
7106 |
|
7107 | _this.onDraw();
|
7108 | };
|
7109 |
|
7110 | _this.onMouseMove = function (e) {
|
7111 | var lngLat = e.lngLat || e.lnglat;
|
7112 |
|
7113 | if (_this.points.length === 0) {
|
7114 | return;
|
7115 | }
|
7116 |
|
7117 | var tmpPoints = _this.points.slice();
|
7118 |
|
7119 | tmpPoints.push(lngLat);
|
7120 |
|
7121 | var feature = _this.createFeature(tmpPoints);
|
7122 |
|
7123 | _this.drawLayer.update(helpers_13([feature]));
|
7124 | };
|
7125 |
|
7126 | _this.onDblClick = function (e) {
|
7127 | var lngLat = e.lngLat || e.lnglat;
|
7128 |
|
7129 | if (_this.points.length < 2) {
|
7130 | return;
|
7131 | }
|
7132 |
|
7133 | _this.points.push(lngLat);
|
7134 |
|
7135 | _this.drawFinish();
|
7136 | };
|
7137 |
|
7138 | _this.onDraw = function () {
|
7139 | _this.drawVertexLayer.on('mousemove', function (e) {
|
7140 | _this.setCursor('pointer');
|
7141 | });
|
7142 |
|
7143 | _this.drawVertexLayer.on('mouseout', function () {
|
7144 | _this.setCursor('crosshair');
|
7145 | });
|
7146 |
|
7147 | _this.drawVertexLayer.on('click', function () {
|
7148 | _this.resetCursor();
|
7149 |
|
7150 | _this.drawFinish();
|
7151 | });
|
7152 | };
|
7153 |
|
7154 | _this.type = 'polygon';
|
7155 | _this.drawMidVertexLayer = new DrawVertexLayer$1(_assertThisInitialized(_this));
|
7156 |
|
7157 | _this.on(DrawEvent.MODE_CHANGE, _this.addMidLayerEvent);
|
7158 |
|
7159 | return _this;
|
7160 | }
|
7161 |
|
7162 | _createClass(DrawPolygon, [{
|
7163 | key: "enable",
|
7164 | value: function enable() {
|
7165 | _get(_getPrototypeOf(DrawPolygon.prototype), "enable", this).call(this);
|
7166 |
|
7167 | this.scene.on('mousemove', this.onMouseMove);
|
7168 | this.scene.on('dblclick', this.onDblClick);
|
7169 | }
|
7170 | }, {
|
7171 | key: "disable",
|
7172 | value: function disable() {
|
7173 | _get(_getPrototypeOf(DrawPolygon.prototype), "disable", this).call(this);
|
7174 |
|
7175 | this.scene.off('mousemove', this.onMouseMove);
|
7176 | this.scene.off('dblclick', this.onDblClick);
|
7177 | }
|
7178 | }, {
|
7179 | key: "drawFinish",
|
7180 | value: function drawFinish() {
|
7181 | this.points = this.points.reverse();
|
7182 | var feature = this.createFeature(this.points);
|
7183 | var properties = feature.properties;
|
7184 | this.drawLayer.update(helpers_13([feature]));
|
7185 | this.drawVertexLayer.update(helpers_13(properties.pointFeatures));
|
7186 |
|
7187 | this.emit(DrawEvent.CREATE, this.currentFeature);
|
7188 | this.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
|
7189 | this.points = [];
|
7190 | this.disable();
|
7191 | }
|
7192 | }, {
|
7193 | key: "addVertex",
|
7194 | value: function addVertex(vertex) {
|
7195 | var _vertex$geometry, _feature$geometry;
|
7196 |
|
7197 |
|
7198 | var id = vertex.properties.id;
|
7199 | var coord = vertex === null || vertex === void 0 ? void 0 : (_vertex$geometry = vertex.geometry) === null || _vertex$geometry === void 0 ? void 0 : _vertex$geometry.coordinates;
|
7200 | var feature = this.currentFeature;
|
7201 | var type = feature === null || feature === void 0 ? void 0 : (_feature$geometry = feature.geometry) === null || _feature$geometry === void 0 ? void 0 : _feature$geometry.type;
|
7202 | var points = [];
|
7203 |
|
7204 | if (type === 'Polygon') {
|
7205 | var _feature$geometry2;
|
7206 |
|
7207 | var coords = feature === null || feature === void 0 ? void 0 : (_feature$geometry2 = feature.geometry) === null || _feature$geometry2 === void 0 ? void 0 : _feature$geometry2.coordinates;
|
7208 | coords[0].splice(id + 1, 0, coord);
|
7209 |
|
7210 | for (var i = 0; i < coords[0].length - 1; i++) {
|
7211 | points.push({
|
7212 | lng: coords[0][i][0],
|
7213 | lat: coords[0][i][1]
|
7214 | });
|
7215 | }
|
7216 | } else {
|
7217 | var _feature$geometry3;
|
7218 |
|
7219 | var _coords = feature === null || feature === void 0 ? void 0 : (_feature$geometry3 = feature.geometry) === null || _feature$geometry3 === void 0 ? void 0 : _feature$geometry3.coordinates;
|
7220 |
|
7221 | _coords.splice(id + 1, 0, coord);
|
7222 |
|
7223 | var _iterator = _createForOfIteratorHelper(_coords),
|
7224 | _step;
|
7225 |
|
7226 | try {
|
7227 | for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
7228 | var coor = _step.value;
|
7229 | points.push({
|
7230 | lng: coor[0],
|
7231 | lat: coor[1]
|
7232 | });
|
7233 | }
|
7234 | } catch (err) {
|
7235 | _iterator.e(err);
|
7236 | } finally {
|
7237 | _iterator.f();
|
7238 | }
|
7239 | }
|
7240 |
|
7241 | var pointfeatures = createPoint(points);
|
7242 | this.pointFeatures = pointfeatures.features;
|
7243 | this.drawLayer.updateData(helpers_13([feature]));
|
7244 | this.drawVertexLayer.updateData(pointfeatures);
|
7245 | this.drawMidVertexLayer.updateData(helpers_13(this.pointFeatures));
|
7246 |
|
7247 | feature.properties.pointFeatures = pointfeatures.features;
|
7248 | this.setCurrentFeature(feature);
|
7249 | }
|
7250 | }, {
|
7251 | key: "getDefaultOptions",
|
7252 | value: function getDefaultOptions() {
|
7253 | return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawPolygon.prototype), "getDefaultOptions", this).call(this)), {}, {
|
7254 | title: '绘制多边形'
|
7255 | });
|
7256 | }
|
7257 | }, {
|
7258 | key: "moveFeature",
|
7259 | value: function moveFeature(delta) {
|
7260 | var newFeature = moveFeatures([this.currentFeature], delta);
|
7261 | var newPointFeture = moveFeatures(this.pointFeatures, delta);
|
7262 | this.drawLayer.updateData(helpers_13(newFeature));
|
7263 | this.drawVertexLayer.updateData(helpers_13(newPointFeture));
|
7264 | newFeature[0].properties = _objectSpread2(_objectSpread2({}, newFeature[0].properties), {}, {
|
7265 | pointFeatures: newPointFeture
|
7266 | });
|
7267 | this.setCurrentFeature(newFeature[0]);
|
7268 | }
|
7269 | }, {
|
7270 | key: "createFeature",
|
7271 | value: function createFeature(points, id) {
|
7272 | var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
7273 | var pointfeatures = createPoint(points);
|
7274 | this.pointFeatures = pointfeatures.features;
|
7275 | var feature = createPolygon(points, {
|
7276 | id: id || this.getUniqId(),
|
7277 | type: 'polygon',
|
7278 | active: active,
|
7279 | pointFeatures: this.pointFeatures
|
7280 | });
|
7281 | this.setCurrentFeature(feature);
|
7282 | return feature;
|
7283 | }
|
7284 | }, {
|
7285 | key: "editFeature",
|
7286 | value: function editFeature(vertex) {
|
7287 | var selectVertexed = this.currentVertex;
|
7288 |
|
7289 | if (selectVertexed === null) {
|
7290 | return;
|
7291 | } else {
|
7292 | var _this$currentFeature;
|
7293 |
|
7294 |
|
7295 | var id = selectVertexed.properties.id * 1;
|
7296 |
|
7297 | selectVertexed.geometry.coordinates = [vertex.lng, vertex.lat];
|
7298 |
|
7299 | this.pointFeatures[id].geometry.coordinates = [vertex.lng, vertex.lat];
|
7300 | this.drawVertexLayer.updateData(helpers_13(this.pointFeatures));
|
7301 | this.drawMidVertexLayer.updateData(helpers_13(this.pointFeatures));
|
7302 | this.editPolygonVertex(id, vertex);
|
7303 | this.drawLayer.updateData(helpers_13([this.currentFeature]));
|
7304 | var feature = this.currentFeature;
|
7305 | feature.properties = _objectSpread2(_objectSpread2({}, (_this$currentFeature = this.currentFeature) === null || _this$currentFeature === void 0 ? void 0 : _this$currentFeature.properties), {}, {
|
7306 | pointFeatures: this.pointFeatures
|
7307 | });
|
7308 | this.setCurrentFeature(feature);
|
7309 | }
|
7310 | }
|
7311 | }, {
|
7312 | key: "showOtherLayer",
|
7313 | value: function showOtherLayer() {
|
7314 |
|
7315 |
|
7316 |
|
7317 |
|
7318 | return null;
|
7319 | }
|
7320 | }, {
|
7321 | key: "hideOtherLayer",
|
7322 | value: function hideOtherLayer() {
|
7323 | return null;
|
7324 | }
|
7325 | }, {
|
7326 | key: "addMidLayerEvent",
|
7327 | value: function addMidLayerEvent(mode) {
|
7328 | switch (mode) {
|
7329 | case DrawModes.DIRECT_SELECT:
|
7330 | this.drawMidVertexLayer.update(helpers_13(this.pointFeatures));
|
7331 | this.drawMidVertexLayer.show();
|
7332 | break;
|
7333 |
|
7334 | case DrawModes.STATIC:
|
7335 | this.drawMidVertexLayer.hide();
|
7336 | break;
|
7337 | }
|
7338 | }
|
7339 | }, {
|
7340 | key: "initData",
|
7341 | value: function initData() {
|
7342 | var _this2 = this;
|
7343 |
|
7344 | var features = [];
|
7345 | this.source.data.features.forEach(function (feature) {
|
7346 | if (feature.geometry.type === 'Polygon') {
|
7347 | var _feature$properties;
|
7348 |
|
7349 | var points = feature.geometry.coordinates[0].map(function (coord) {
|
7350 | return {
|
7351 | lng: coord[0],
|
7352 | lat: coord[1]
|
7353 | };
|
7354 | });
|
7355 | features.push(_this2.createFeature(points.slice(1), feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id, false));
|
7356 | }
|
7357 | });
|
7358 | this.source.data.features = features;
|
7359 | return true;
|
7360 | }
|
7361 | }, {
|
7362 | key: "editPolygonVertex",
|
7363 | value: function editPolygonVertex(id, vertex) {
|
7364 | var _feature$geometry4;
|
7365 |
|
7366 | var feature = this.currentFeature;
|
7367 | var type = feature === null || feature === void 0 ? void 0 : (_feature$geometry4 = feature.geometry) === null || _feature$geometry4 === void 0 ? void 0 : _feature$geometry4.type;
|
7368 |
|
7369 | if (type === 'Polygon') {
|
7370 | var _feature$geometry5;
|
7371 |
|
7372 | var coords = feature === null || feature === void 0 ? void 0 : (_feature$geometry5 = feature.geometry) === null || _feature$geometry5 === void 0 ? void 0 : _feature$geometry5.coordinates;
|
7373 | coords[0][id] = [vertex.lng, vertex.lat];
|
7374 |
|
7375 | if (-id === 0) {
|
7376 | coords[0][coords[0].length - 1] = [vertex.lng, vertex.lat];
|
7377 | }
|
7378 | } else {
|
7379 | var _feature$geometry6;
|
7380 |
|
7381 | var _coords2 = feature === null || feature === void 0 ? void 0 : (_feature$geometry6 = feature.geometry) === null || _feature$geometry6 === void 0 ? void 0 : _feature$geometry6.coordinates;
|
7382 |
|
7383 | _coords2[id] = [vertex.lng, vertex.lat];
|
7384 | }
|
7385 |
|
7386 | this.setCurrentFeature(feature);
|
7387 | this.drawLayer.updateData(helpers_13([this.currentFeature]));
|
7388 | }
|
7389 | }]);
|
7390 |
|
7391 | return DrawPolygon;
|
7392 | }(DrawFeature);
|
7393 |
|
7394 | var DrawLine = function (_DrawPolygon) {
|
7395 | _inherits(DrawLine, _DrawPolygon);
|
7396 |
|
7397 | var _super = _createSuper(DrawLine);
|
7398 |
|
7399 | function DrawLine(scene) {
|
7400 | var _this;
|
7401 |
|
7402 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7403 |
|
7404 | _classCallCheck(this, DrawLine);
|
7405 |
|
7406 | _this = _super.call(this, scene, options);
|
7407 | _this.type = 'line';
|
7408 | return _this;
|
7409 | }
|
7410 |
|
7411 | _createClass(DrawLine, [{
|
7412 | key: "getDefaultOptions",
|
7413 | value: function getDefaultOptions() {
|
7414 | return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawLine.prototype), "getDefaultOptions", this).call(this)), {}, {
|
7415 | title: '绘制线'
|
7416 | });
|
7417 | }
|
7418 | }, {
|
7419 | key: "moveFeature",
|
7420 | value: function moveFeature(delta) {
|
7421 | var newFeature = moveFeatures([this.currentFeature], delta);
|
7422 | var newPointFeture = moveFeatures(this.pointFeatures, delta);
|
7423 | this.drawLayer.updateData(helpers_13(newFeature));
|
7424 | this.drawVertexLayer.updateData(helpers_13(newPointFeture));
|
7425 | this.currentFeature = newFeature[0];
|
7426 | this.pointFeatures = newPointFeture;
|
7427 | return this.currentFeature;
|
7428 | }
|
7429 | }, {
|
7430 | key: "createFeature",
|
7431 | value: function createFeature(points, id) {
|
7432 | var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
7433 | var pointfeatures = createPoint(points);
|
7434 | this.pointFeatures = pointfeatures.features;
|
7435 | var feature = createLine(points, {
|
7436 | id: id || this.getUniqId(),
|
7437 | type: 'line',
|
7438 | active: active,
|
7439 | pointFeatures: this.pointFeatures
|
7440 | });
|
7441 | this.setCurrentFeature(feature);
|
7442 | return feature;
|
7443 | }
|
7444 | }, {
|
7445 | key: "initData",
|
7446 | value: function initData() {
|
7447 | var _this2 = this;
|
7448 |
|
7449 | var features = [];
|
7450 | this.source.data.features.forEach(function (feature) {
|
7451 | if (feature.geometry.type === 'LineString') {
|
7452 | var _feature$properties;
|
7453 |
|
7454 |
|
7455 | var points = feature.geometry.coordinates.map(function (coord) {
|
7456 | return {
|
7457 | lng: coord[0],
|
7458 | lat: coord[1]
|
7459 | };
|
7460 | });
|
7461 | features.push(_this2.createFeature(points, feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id, false));
|
7462 | }
|
7463 | });
|
7464 | this.source.data.features = features;
|
7465 | return true;
|
7466 | }
|
7467 | }]);
|
7468 |
|
7469 | return DrawLine;
|
7470 | }(DrawPolygon);
|
7471 |
|
7472 | var DrawPoint = function (_DrawFeature) {
|
7473 | _inherits(DrawPoint, _DrawFeature);
|
7474 |
|
7475 | var _super = _createSuper(DrawPoint);
|
7476 |
|
7477 | function DrawPoint(scene) {
|
7478 | var _this;
|
7479 |
|
7480 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7481 |
|
7482 | _classCallCheck(this, DrawPoint);
|
7483 |
|
7484 | _this = _super.call(this, scene, options);
|
7485 |
|
7486 | _this.onDragStart = function (e) {
|
7487 | return null;
|
7488 | };
|
7489 |
|
7490 | _this.onDragging = function (e) {
|
7491 | return null;
|
7492 | };
|
7493 |
|
7494 | _this.onDragEnd = function () {
|
7495 | return null;
|
7496 | };
|
7497 |
|
7498 | _this.onClick = function (e) {
|
7499 | if (_this.drawStatus !== 'Drawing') {
|
7500 | _this.drawLayer.emit('unclick', null);
|
7501 | }
|
7502 |
|
7503 | var lngLat = e.lngLat || e.lnglat;
|
7504 |
|
7505 | var feature = _this.createFeature(lngLat);
|
7506 |
|
7507 | _this.drawLayer.update(helpers_13([feature]));
|
7508 |
|
7509 | _this.drawVertexLayer.update(helpers_13([feature]));
|
7510 |
|
7511 | _this.drawFinish();
|
7512 | };
|
7513 |
|
7514 | _this.type = 'point';
|
7515 | return _this;
|
7516 | }
|
7517 |
|
7518 | _createClass(DrawPoint, [{
|
7519 | key: "drawFinish",
|
7520 | value: function drawFinish() {
|
7521 | this.emit(DrawEvent.CREATE, this.currentFeature);
|
7522 | this.emit(DrawEvent.MODE_CHANGE, DrawModes.SIMPLE_SELECT);
|
7523 | this.disable();
|
7524 | }
|
7525 | }, {
|
7526 | key: "getDefaultOptions",
|
7527 | value: function getDefaultOptions() {
|
7528 | return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawPoint.prototype), "getDefaultOptions", this).call(this)), {}, {
|
7529 | title: '绘制点'
|
7530 | });
|
7531 | }
|
7532 | }, {
|
7533 | key: "moveFeature",
|
7534 | value: function moveFeature(delta) {
|
7535 | var newFeature = moveFeatures([this.currentFeature], delta);
|
7536 | this.drawLayer.updateData(helpers_13(newFeature));
|
7537 | this.drawVertexLayer.updateData(helpers_13(newFeature));
|
7538 | this.currentFeature = newFeature[0];
|
7539 | this.pointFeatures = newFeature;
|
7540 | this.currentFeature.properties = _objectSpread2(_objectSpread2({}, this.currentFeature.properties), {}, {
|
7541 | pointFeatures: newFeature
|
7542 | });
|
7543 | return this.currentFeature;
|
7544 | }
|
7545 | }, {
|
7546 | key: "createFeature",
|
7547 | value: function createFeature(p, id) {
|
7548 | var active = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
7549 | var feature = helpers_7([p.lng, p.lat], {
|
7550 | id: id || this.getUniqId(),
|
7551 | type: 'point',
|
7552 | active: active,
|
7553 | pointFeatures: [helpers_7([p.lng, p.lat])]
|
7554 | });
|
7555 | this.setCurrentFeature(feature);
|
7556 | return feature;
|
7557 | }
|
7558 | }, {
|
7559 | key: "initData",
|
7560 | value: function initData() {
|
7561 | var _this2 = this;
|
7562 |
|
7563 | var features = [];
|
7564 | this.source.data.features.forEach(function (feature) {
|
7565 | if (feature.geometry.type === 'Point') {
|
7566 | var _feature$properties;
|
7567 |
|
7568 | var p = {
|
7569 | lng: feature.geometry.coordinates[0],
|
7570 | lat: feature.geometry.coordinates[1]
|
7571 | };
|
7572 | features.push(_this2.createFeature(p, feature === null || feature === void 0 ? void 0 : (_feature$properties = feature.properties) === null || _feature$properties === void 0 ? void 0 : _feature$properties.id, false));
|
7573 | }
|
7574 | });
|
7575 | this.source.data.features = features;
|
7576 | return true;
|
7577 | }
|
7578 | }, {
|
7579 | key: "editFeature",
|
7580 | value: function editFeature(endPoint) {
|
7581 | this.createFeature(endPoint);
|
7582 | }
|
7583 | }, {
|
7584 | key: "showOtherLayer",
|
7585 | value: function showOtherLayer() {
|
7586 | return null;
|
7587 | }
|
7588 | }, {
|
7589 | key: "hideOtherLayer",
|
7590 | value: function hideOtherLayer() {
|
7591 | return null;
|
7592 | }
|
7593 | }]);
|
7594 |
|
7595 | return DrawPoint;
|
7596 | }(DrawFeature);
|
7597 |
|
7598 | var DrawRect = function (_DrawCircle) {
|
7599 | _inherits(DrawRect, _DrawCircle);
|
7600 |
|
7601 | var _super = _createSuper(DrawRect);
|
7602 |
|
7603 | function DrawRect(scene) {
|
7604 | var _this;
|
7605 |
|
7606 | var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
7607 |
|
7608 | _classCallCheck(this, DrawRect);
|
7609 |
|
7610 | _this = _super.call(this, scene, options);
|
7611 | _this.type = 'rect';
|
7612 | return _this;
|
7613 | }
|
7614 |
|
7615 | _createClass(DrawRect, [{
|
7616 | key: "drawFinish",
|
7617 | value: function drawFinish() {
|
7618 | return null;
|
7619 | }
|
7620 | }, {
|
7621 | key: "getDefaultOptions",
|
7622 | value: function getDefaultOptions() {
|
7623 | return _objectSpread2(_objectSpread2({}, _get(_getPrototypeOf(DrawRect.prototype), "getDefaultOptions", this).call(this)), {}, {
|
7624 | title: '绘制矩形'
|
7625 | });
|
7626 | }
|
7627 | }, {
|
7628 | key: "createFeature",
|
7629 | value: function createFeature() {
|
7630 | var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0';
|
7631 | var points = createPoint([this.endPoint]);
|
7632 | var feature = createRect([this.startPoint.lng, this.startPoint.lat], [this.endPoint.lng, this.endPoint.lat], {
|
7633 | id: id,
|
7634 | pointFeatures: points.features
|
7635 | });
|
7636 | this.setCurrentFeature(feature);
|
7637 | return feature;
|
7638 | }
|
7639 | }]);
|
7640 |
|
7641 | return DrawRect;
|
7642 | }(DrawCircle);
|
7643 |
|
7644 | function styleInject(css, ref) {
|
7645 | if ( ref === void 0 ) ref = {};
|
7646 | var insertAt = ref.insertAt;
|
7647 |
|
7648 | if (!css || typeof document === 'undefined') { return; }
|
7649 |
|
7650 | var head = document.head || document.getElementsByTagName('head')[0];
|
7651 | var style = document.createElement('style');
|
7652 | style.type = 'text/css';
|
7653 |
|
7654 | if (insertAt === 'top') {
|
7655 | if (head.firstChild) {
|
7656 | head.insertBefore(style, head.firstChild);
|
7657 | } else {
|
7658 | head.appendChild(style);
|
7659 | }
|
7660 | } else {
|
7661 | head.appendChild(style);
|
7662 | }
|
7663 |
|
7664 | if (style.styleSheet) {
|
7665 | style.styleSheet.cssText = css;
|
7666 | } else {
|
7667 | style.appendChild(document.createTextNode(css));
|
7668 | }
|
7669 | }
|
7670 |
|
7671 | var css = ".l7-control-draw {\n border-radius: 4px;\n background: #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);\n display: flex;\n}\n.l7-control-draw button {\n background-repeat: no-repeat;\n background-position: center;\n background-size: 20px 20px;\n background-color: #fff;\n width: 30px;\n height: 30px;\n display: block;\n padding: 0;\n outline: none;\n border: 0;\n margin: 1px;\n box-sizing: border-box;\n cursor: pointer;\n}\n.l7-control-draw button:not(:disabled):hover {\n background-color: rgba(0, 0, 0, 0.05);\n}\n.l7-control-draw button:focus {\n box-shadow: 0 0 2px 2px #0096ff;\n}\n.l7-control-draw .draw-point {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjYxMTY0NjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDExOTQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI5MzUiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTQ5LjI1IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNjA5LjUzNiA3MDcuMDcyYTE5NS4wNzIgMTk1LjA3MiAwIDEgMSAwLTM5MC4xNDQgMTk1LjA3MiAxOTUuMDcyIDAgMCAxIDAgMzkwLjE0NHoiIGZpbGw9IiMyYzJjMmMiIHAtaWQ9IjI5MzYiPjwvcGF0aD48cGF0aCBkPSJNMTA0OC40MDUzMzMgNDE0LjQ2NGExNDYuMjYxMzMzIDE0Ni4yNjEzMzMgMCAxIDEgMC0yOTIuNTIyNjY3IDE0Ni4yNjEzMzMgMTQ2LjI2MTMzMyAwIDAgMSAwIDI5Mi41MjI2Njd6TTE3MC42NjY2NjcgOTk5LjU5NDY2N2ExNDYuMjYxMzMzIDE0Ni4yNjEzMzMgMCAxIDEgMC0yOTIuNTIyNjY3IDE0Ni4yNjEzMzMgMTQ2LjI2MTMzMyAwIDAgMSAwIDI5Mi41MjI2Njd6IG0wLTY4Mi42NjY2NjdBMTQ2LjI2MTMzMyAxNDYuMjYxMzMzIDAgMSAxIDE3MC42NjY2NjcgMjQuNDA1MzMzYTE0Ni4yNjEzMzMgMTQ2LjI2MTMzMyAwIDAgMSAwIDI5Mi41MjI2Njd6IiBmaWxsPSIjMmMyYzJjIiBwLWlkPSIyOTM3Ij48L3BhdGg+PC9zdmc+');\n}\n.l7-control-draw .draw-line {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjYxMDY5NTk0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjIxOTMiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNOTAwLjkzIDMwMC4yOThjLTQxLjA2NyAwLTc0LjQ3IDMzLjQyOS03NC40NyA3NC40OTEgMCAxMCAxLjk5MiAxOS41MzMgNS41ODEgMjguMjU3bC0yMjAuMjYyIDIwNS4xOGE3My45OSA3My45OSAwIDAgMC00MS4yMzItMTIuNTA0IDc0LjE3IDc0LjE3IDAgMCAwLTIyLjQ1MSAzLjQ1MWwtNzAuMTEzLTEzOS42MzhhNzQuMTM4IDc0LjEzOCAwIDAgMCA4LjE0Ni0zMy45MmMwLTQxLjA2Mi0zMy4zODMtNzQuNDktNzQuNDQ1LTc0LjQ5cy03NC40NDUgMzMuNDI4LTc0LjQ0NSA3NC40OWMwIDMuODI1IDAuMjkyIDcuNjA0IDAuODU1IDExLjMxNkwxNjAuODYgNjI3LjIyYTczLjg4NyA3My44ODcgMCAwIDAtMzkuNzk4LTExLjU5N2MtNDEuMDYyIDAtNzQuNDcgMzMuNDIzLTc0LjQ3IDc0LjQ5IDAgNDEuMDgzIDMzLjQwOCA3NC41MTcgNzQuNDcgNzQuNTE3IDQxLjA0MiAwIDc0LjQyLTMzLjQyOCA3NC40Mi03NC41MTZhNzQuMjMgNzQuMjMgMCAwIDAtMy4yOTMtMjEuODk5bDE3MS40MzMtMTg1LjcxMmE3NC40NTUgNzQuNDU1IDAgMCAwIDc2LjMzNCAxMi4wNzhsNjcuMzkgMTM2LjE5MmE3NC4xNjggNzQuMTY4IDAgMCAwLTExLjIzOCAzOS40NWMwIDQxLjA4MiAzMy4zODIgNzQuNTE2IDc0LjQ0NCA3NC41MTYgNDEuMDY4IDAgNzQuNDQ1LTMzLjQyOSA3NC40NDUtNzQuNTE3YTc0LjM0MiA3NC4zNDIgMCAwIDAtMi43MjQtMTkuOTE2bDIyNC42NzEtMjA5LjI2NWE3My45NjQgNzMuOTY0IDAgMCAwIDMzLjk5MiA4LjI0OGM0MS4wNDIgMCA3NC40MTktMzMuNDI4IDc0LjQxOS03NC40OS0wLjAxLTQxLjA2OC0zMy4zODgtNzQuNTAyLTc0LjQyNC03NC41MDJ6TTEyMS4wNjkgNzEzLjA0MmEyMi45MTcgMjIuOTE3IDAgMCAxIDAtNDUuODMgMjIuOTMyIDIyLjkzMiAwIDAgMSAyMi44NzYgMjIuOTAzYy0wLjAwNSAxMi42NDYtMTAuMjg2IDIyLjkyNy0yMi44NzYgMjIuOTI3eiBtMjc2LjMxLTI2OS41MzdhMjIuODYgMjIuODYgMCAwIDEtOC41OS0xNy44OSAyMi45MzggMjIuOTM4IDAgMCAxIDIyLjkwMS0yMi45MDEgMjIuOTEyIDIyLjkxMiAwIDAgMSAyMi44NzYgMjIuOTAxYzAgNi4wNDctMi4zMiAxMS43MjUtNi41MDcgMTYuMDFsLTAuMiAwLjE4NWMtOS4wNjggOS4wNTItMjUuMDQyIDYuMDc3LTMwLjQ4IDEuNjk1ek01NzAuNTUzIDY5My4xNGEyMi45MjIgMjIuOTIyIDAgMCAxLTIyLjg3Ni0yMi45MjcgMjIuNzMzIDIyLjczMyAwIDAgMSA4LjI4LTE3LjYyM2MwLjMzNy0wLjI0IDAuNjg1LTAuNDgxIDEuMDEzLTAuNzQyIDAuMi0wLjE1OSAwLjM5LTAuMzIzIDAuNTg0LTAuNDkyYTIyLjY0IDIyLjY0IDAgMCAxIDEyLjk5NC00LjA0NSAyMi45MjcgMjIuOTI3IDAgMCAxIDIyLjg4MSAyMi45MDIgMjIuOTM4IDIyLjkzOCAwIDAgMS0yMi44NzYgMjIuOTI3eiBtMzMwLjM3OS0yOTUuNDVjLTEyLjY1MiAwLTIyLjkwMi0xMC4yOC0yMi45MDItMjIuOXMxMC4yNS0yMi45MDMgMjIuOTAyLTIyLjkwM2EyMi45MjcgMjIuOTI3IDAgMCAxIDIyLjg3IDIyLjkwMiAyMi45MjcgMjIuOTI3IDAgMCAxLTIyLjg3IDIyLjkwMnoiIHAtaWQ9IjIxOTQiPjwvcGF0aD48L3N2Zz4=');\n}\n.l7-control-draw .draw-polygon {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjI5MzI3Nzc1IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE3MzkiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNDIxLjE0OSA5OTAuNDA0bC0xNDMuMzE4LTEzNy4xNS00My42NzktNDEuNzY0TDMxLjg0OSA2MTcuODUzbDIzNC4wNzQtNDg1LjQ4OCAxMjUuMTQxIDE3LjAyNiAxMDMuNjE0IDE0LjA0MS04LjA1NyA1OS40NTYtMTAzLjYzLTE0LjA0My04MS45Ni0xMS4xNTEtOTguMTAzIDIwMy40MzItOTguMTA1IDIwMy41MTkgMTcwLjgwNiAxNjMuNDkgNDMuNjgxIDQxLjc2NiAzNi4xNTcgMzQuNjE2IDc1LjY5OCA3Mi40IDM2LjUyOS0xOS42MjEgNTUuNzE4LTI5Ljk3MSA1MS43MDctMjcuNzM2IDUxLjgzNC0yNy45NjcgMTcuMTEtOS4xMTQgMTcuMTg4LTkuMyAzNC40NzYtMTguNDggMTcuMjM5LTkuMyAzNC41NDItMTguNTA1IDE3LjMxNS05LjM4NyAxNy4yNTYtOS4yMDEgNDYuOTgtMjUuMjkzLTQuOTk1LTI3LjM3NS04LjgzNi00OC45NjYtMTUuMzQxLTg0Ljg5MSA1OS4wNDQtMTAuNjcgMTUuMzQyIDg0Ljg5OCA4LjgyNyA0OC45MTggMTIuODMxIDcwLjMyOC0zMy43MTcgMTguMDQ5LTUxLjgyNyAyNy45MDQtMTcuMjM2IDkuMTktMTcuMjcyIDkuMzY1LTM0LjQ5MyAxOC40NzgtMzQuNTMxIDE4LjU3Ni0xNy4yMTMgOS4yMi0xNy4yOTIgOS4zNTYtMTcuMDk3IDkuMTA2LTE3LjIxOCA5LjMzNXoiIGZpbGw9IiMzRTNBMzkiIHAtaWQ9IjE3NDAiPjwvcGF0aD48cGF0aCBkPSJNNzUyLjUyNCA1NS40MzRoNjB2MzcwLjMyM2gtNjB6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxNzQxIj48L3BhdGg+PHBhdGggZD0iTTU5Ny4zODUgMjA1LjY5N2gzNzAuMjc5djYwSDU5Ny4zODV6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxNzQyIj48L3BhdGg+PC9zdmc+');\n}\n.l7-control-draw .draw-rect {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjI5Mjk5NTYxIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjEwMDEiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNzY1LjIzNCA2OS40MTdoNjB2MzcwLjYwNWgtNjB6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxMDAyIj48L3BhdGg+PHBhdGggZD0iTTYxNC4xOTMgMjE5LjgwN2gzNjIuMTI4djYwSDYxNC4xOTN6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxMDAzIj48L3BhdGg+PHBhdGggZD0iTTgyNS4yMzQgOTc1LjkzNkg4OS44MTlWMjI0LjcwN2gzNjcuNzA4djYwSDE0OS44MTl2NjMxLjIyOWg2MTUuNDE1VjYwMC4yOTloNjB6IiBmaWxsPSIjM0UzQTM5IiBwLWlkPSIxMDA0Ij48L3BhdGg+PC9zdmc+');\n}\n.l7-control-draw .draw-circle {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NjI5MjYwMDI2IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjI3NzYiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNNTEyIDg4MS4wNjY2NjdBMzY5LjA2NjY2NyAzNjkuMDY2NjY3IDAgMSAxIDg4MS4wNjY2NjcgNTEyIDM2OS40OTMzMzMgMzY5LjQ5MzMzMyAwIDAgMSA1MTIgODgxLjA2NjY2N3ogbTAtNjgyLjY2NjY2N0EzMTMuNiAzMTMuNiAwIDEgMCA4MjUuNiA1MTIgMzE0LjAyNjY2NyAzMTQuMDI2NjY3IDAgMCAwIDUxMiAxOTguNHoiIGZpbGw9IiIgcC1pZD0iMjc3NyI+PC9wYXRoPjwvc3ZnPg==');\n}\n.l7-control-draw .draw-delete {\n background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/PjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+PHN2ZyB0PSIxNTg1NzMwNDEyNjU0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQ4MDQiIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PGRlZnM+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48L3N0eWxlPjwvZGVmcz48cGF0aCBkPSJNMjEzLjMzMzMzMyAyODIuODM3MzMzYzAtMjAuNjkzMzMzIDE2LjE3MDY2Ny0zNy40MTg2NjcgMzYuMDk2LTM3LjQxODY2NmgxODAuNDh2LTM3LjM3NmMwLTIwLjY1MDY2NyAxNi4yMTMzMzMtMzcuMzc2IDM2LjEzODY2Ny0zNy4zNzZoNzIuMTkyYzE5Ljk2OCAwIDM2LjEzODY2NyAxNi43MjUzMzMgMzYuMTM4NjY3IDM3LjM3NnYzNy4zNzZoMTgwLjQ4YzE5Ljk2OCAwIDM2LjA5NiAxNi43MjUzMzMgMzYuMDk2IDM3LjQxODY2NnYzNy4zNzZIMjEzLjMzMzMzM3YtMzcuMzc2eiBtNTQxLjUyNTMzNCAxMTIuMTI4djQyMC45OTJjMCAyMC42MDgtMTYuMTI4IDM3LjM3Ni0zNi4wOTYgMzcuMzc2SDI4NS41MjUzMzNjLTE5LjkyNTMzMyAwLTM2LjA5Ni0xNi43NjgtMzYuMDk2LTM3LjM3NlYzNTcuNTQ2NjY3aDUwNS40MjkzMzR2MzcuMzc2ek0zOTMuODU2IDQ2OS43NmMwLTIwLjY1MDY2Ny0xNi4xNzA2NjctMzcuNDE4NjY3LTM2LjA5Ni0zNy40MTg2NjctMTkuOTY4IDAtMzYuMTM4NjY3IDE2Ljc2OC0zNi4xMzg2NjcgMzcuNDE4NjY3djI3MS40MDI2NjdjMCAyMC42NTA2NjcgMTYuMjEzMzMzIDM3LjQxODY2NyAzNi4xMzg2NjcgMzcuNDE4NjY2IDE5LjkyNTMzMyAwIDM2LjA5Ni0xNi43NjggMzYuMDk2LTM3LjQxODY2NlY0NjkuNzZ6IG0xNDQuMzg0IDBjMC0yMC42NTA2NjctMTYuMTI4LTM3LjQxODY2Ny0zNi4wOTYtMzcuNDE4NjY3LTE5LjkyNTMzMyAwLTM2LjA5NiAxNi43NjgtMzYuMDk2IDM3LjQxODY2N3YyNzEuNDAyNjY3YzAgMjAuNjUwNjY3IDE2LjE3MDY2NyAzNy40MTg2NjcgMzYuMDk2IDM3LjQxODY2NiAxOS45NjggMCAzNi4wOTYtMTYuNzY4IDM2LjA5Ni0zNy40MTg2NjZWNDY5Ljc2eiBtMTQ0LjQyNjY2NyAwYzAtMjAuNjUwNjY3LTE2LjE3MDY2Ny0zNy40MTg2NjctMzYuMDk2LTM3LjQxODY2Ny0xOS45NjggMC0zNi4wOTYgMTYuNzY4LTM2LjA5NiAzNy40MTg2Njd2MjcxLjQwMjY2N2MwIDIwLjY1MDY2NyAxNi4xMjggMzcuNDE4NjY3IDM2LjA5NiAzNy40MTg2NjYgMTkuOTI1MzMzIDAgMzYuMDk2LTE2Ljc2OCAzNi4wOTYtMzcuNDE4NjY2VjQ2OS43NnoiIHAtaWQ9IjQ4MDUiPjwvcGF0aD48L3N2Zz4=');\n}\n.horizontal {\n flex-direction: row;\n}\n.horizontal button:focus:first-child {\n border-radius: 4px 0px 0px 4px;\n}\n.horizontal button:focus:last-child {\n border-radius: 0px 4px 4px 4px;\n}\n.horizontal button + button {\n border-left: 1px solid #eee;\n}\n.vertical {\n flex-direction: column;\n}\n.vertical button:focus:first-child {\n border-radius: 4px 4px 0 0;\n}\n.vertical button:focus:last-child {\n border-radius: 0px 0px 4px 4px;\n}\n.vertical button + button {\n border-top: 1px solid #eee;\n}\n";
|
7672 | styleInject(css);
|
7673 |
|
7674 | var DrawType = {
|
7675 | point: DrawPoint,
|
7676 | line: DrawLine,
|
7677 | polygon: DrawPolygon,
|
7678 | circle: DrawCircle,
|
7679 | rect: DrawRect
|
7680 | };
|
7681 | var DrawControl = function (_Control) {
|
7682 | _inherits(DrawControl, _Control);
|
7683 |
|
7684 | var _super = _createSuper(DrawControl);
|
7685 |
|
7686 | function DrawControl(scene, options) {
|
7687 | var _this;
|
7688 |
|
7689 | _classCallCheck(this, DrawControl);
|
7690 |
|
7691 | _this = _super.call(this, options);
|
7692 | _this.draw = {};
|
7693 |
|
7694 | _this.onButtonClick = function (type, e) {
|
7695 | for (var draw in _this.draw) {
|
7696 | if (draw === type) {
|
7697 | _this.draw[draw].enable();
|
7698 | } else {
|
7699 | _this.draw[draw].disable();
|
7700 | }
|
7701 | }
|
7702 | };
|
7703 |
|
7704 | _this.onDeleteMode = function (type, e) {
|
7705 | e.stopPropagation();
|
7706 |
|
7707 | if (!_this.currentDraw) {
|
7708 | return;
|
7709 | }
|
7710 |
|
7711 | _this.currentDraw.deleteMode.enable();
|
7712 |
|
7713 | return false;
|
7714 | };
|
7715 |
|
7716 | _this.onModeChange = function (type, mode) {
|
7717 | if (mode === DrawModes.SIMPLE_SELECT) {
|
7718 | _this.currentDraw = _this.draw[type];
|
7719 | }
|
7720 | };
|
7721 |
|
7722 | _this.scene = scene;
|
7723 | return _this;
|
7724 | }
|
7725 |
|
7726 | _createClass(DrawControl, [{
|
7727 | key: "getDefault",
|
7728 | value: function getDefault() {
|
7729 | return {
|
7730 | position: l7.PositionType.TOPLEFT,
|
7731 | controls: {
|
7732 | point: true,
|
7733 | line: true,
|
7734 | polygon: true,
|
7735 | rect: true,
|
7736 | circle: true,
|
7737 | delete: true
|
7738 | },
|
7739 | name: 'draw'
|
7740 | };
|
7741 | }
|
7742 | }, {
|
7743 | key: "onAdd",
|
7744 | value: function onAdd() {
|
7745 | var layout = this.controlOption.layout;
|
7746 | var controlClass = 'l7-control-draw' + ' ' + layout;
|
7747 | var controls = this.controlOption.controls;
|
7748 | var container = l7.DOM.create('div', controlClass);
|
7749 | this.addControls(controls, container);
|
7750 |
|
7751 | this.addControlEvent();
|
7752 |
|
7753 | return container;
|
7754 | }
|
7755 | }, {
|
7756 | key: "onRemove",
|
7757 | value: function onRemove() {
|
7758 | for (var draw in this.draw) {
|
7759 | if (this.draw[draw]) {
|
7760 | this.draw[draw].destroy();
|
7761 | }
|
7762 | }
|
7763 | }
|
7764 | }, {
|
7765 | key: "getDraw",
|
7766 | value: function getDraw(type) {
|
7767 | var controls = this.controlOption.controls;
|
7768 |
|
7769 | if (controls[type]) {
|
7770 | return this.draw[type];
|
7771 | }
|
7772 |
|
7773 | return null;
|
7774 | }
|
7775 | }, {
|
7776 | key: "getAllData",
|
7777 | value: function getAllData() {
|
7778 | var res = {};
|
7779 |
|
7780 | for (var draw in this.draw) {
|
7781 | if (this.draw[draw]) {
|
7782 | res[draw] = this.draw[draw].getData();
|
7783 | }
|
7784 | }
|
7785 |
|
7786 | return res;
|
7787 | }
|
7788 | }, {
|
7789 | key: "removeAllData",
|
7790 | value: function removeAllData() {
|
7791 | for (var draw in this.draw) {
|
7792 | if (this.draw[draw]) {
|
7793 | this.draw[draw].removeAllData();
|
7794 | }
|
7795 | }
|
7796 | }
|
7797 | }, {
|
7798 | key: "addControls",
|
7799 | value: function addControls(controls, container) {
|
7800 | var style = this.controlOption.style;
|
7801 |
|
7802 | for (var type in controls) {
|
7803 | if (DrawType[type] && controls[type] !== false) {
|
7804 | var drawOption = helpers_28(controls[type]) ? controls[type] : {};
|
7805 |
|
7806 | if (style) {
|
7807 | drawOption.style = style;
|
7808 | }
|
7809 |
|
7810 | var draw = new DrawType[type](this.scene, drawOption);
|
7811 | draw.on(DrawEvent.MODE_CHANGE, this.onModeChange.bind(null, type));
|
7812 | this.draw[type] = draw;
|
7813 | this.createButton(draw.title, 'draw-' + type, container, 'click', this.onButtonClick.bind(null, type));
|
7814 | } else if (type === 'delete' && controls[type] !== false) {
|
7815 | var _draw = new DrawDelete(this.scene);
|
7816 |
|
7817 | _draw.on(DrawEvent.MODE_CHANGE, this.onModeChange.bind(null, type));
|
7818 |
|
7819 | this.createButton(_draw.title, 'draw-' + type, container, 'mousedown', this.onDeleteMode.bind(null, type));
|
7820 | }
|
7821 | }
|
7822 | }
|
7823 | }, {
|
7824 | key: "addControlEvent",
|
7825 | value: function addControlEvent() {
|
7826 | var _this2 = this;
|
7827 |
|
7828 | var _loop = function _loop(draw) {
|
7829 | if (_this2.draw[draw]) {
|
7830 | ['draw.create', 'draw.update', 'draw.delete'].forEach(function (type) {
|
7831 | _this2.draw[draw].on(type, function (feature) {
|
7832 | _this2.emit(type, {
|
7833 | drawType: draw,
|
7834 | feature: feature
|
7835 | });
|
7836 | });
|
7837 | });
|
7838 | }
|
7839 | };
|
7840 |
|
7841 | for (var draw in this.draw) {
|
7842 | _loop(draw);
|
7843 | }
|
7844 | }
|
7845 | }, {
|
7846 | key: "createButton",
|
7847 | value: function createButton(tile, className, container, eventType, fn) {
|
7848 | var link = l7.DOM.create('button', className, container);
|
7849 | link.title = tile;
|
7850 | link.addEventListener(eventType, fn, false);
|
7851 | return link;
|
7852 | }
|
7853 | }]);
|
7854 |
|
7855 | return DrawControl;
|
7856 | }(l7.Control);
|
7857 |
|
7858 | exports.DrawCircle = DrawCircle;
|
7859 | exports.DrawControl = DrawControl;
|
7860 | exports.DrawDelete = DrawDelete;
|
7861 | exports.DrawFeature = DrawFeature;
|
7862 | exports.DrawLine = DrawLine;
|
7863 | exports.DrawMode = DrawMode;
|
7864 | exports.DrawPoint = DrawPoint;
|
7865 | exports.DrawPolygon = DrawPolygon;
|
7866 | exports.DrawRect = DrawRect;
|
7867 |
|
7868 | Object.defineProperty(exports, '__esModule', { value: true });
|
7869 |
|
7870 | })));
|
7871 |
|