UNPKG

leaflet.pm-measure-path

Version:

This package combine leaflet.pm package with leaflet-measure-path package to enhance the drawing tool with measurements

1,614 lines (1,613 loc) 207 kB
!(function(t) { var e = {}; function n(r) { if (e[r]) return e[r].exports; var i = (e[r] = { i: r, l: !1, exports: {} }); return t[r].call(i.exports, i, i.exports, n), (i.l = !0), i.exports; } (n.m = t), (n.c = e), (n.d = function(t, e, r) { n.o(t, e) || Object.defineProperty(t, e, { configurable: !1, enumerable: !0, get: r }); }), (n.n = function(t) { var e = t && t.__esModule ? function() { return t["default"]; } : function() { return t; }; return n.d(e, "a", e), e; }), (n.o = function(t, e) { return Object.prototype.hasOwnProperty.call(t, e); }), (n.p = ""), n((n.s = 46)); })([ function(t, e, n) { "use strict"; (e.a = function(t) { var e = L.PM.activeLang; o()(s.a, e) || (e = "en"); return i()(s.a[e], t); }), (e.b = function(t) { return !(function e(t) { return t .filter(function(t) { return ![null, "", undefined].includes(t); }) .reduce(function(t, n) { return t.concat(Array.isArray(n) ? e(n) : n); }, []); })(t).length; }); var r = n(37), i = n.n(r), a = n(138), o = n.n(a), s = n(36); }, function(t, e, n) { "use strict"; var r = n(40), i = L.Class.extend({ includes: [r.a], options: { snappable: !0, snapDistance: 20, tooltips: !0, cursorMarker: !0, finishOnDoubleClick: !1, finishOn: null, allowSelfIntersection: !0, templineStyle: {}, hintlineStyle: { color: "#3388ff", dashArray: "5,5" }, markerStyle: { draggable: !0 } }, initialize: function(t) { var e = this; (this._map = t), (this.shapes = [ "Marker", "CircleMarker", "Line", "Polygon", "Rectangle", "Circle", "Cut" ]), this.shapes.forEach(function(t) { e[t] = new L.PM.Draw[t](e._map); }); }, setPathOptions: function(t) { this.options.pathOptions = t; }, getShapes: function() { return this.shapes; }, enable: function(t, e) { if (!t) throw new Error( "Error: Please pass a shape as a parameter. Possible shapes are: ".concat( this.getShapes().join(",") ) ); this.disable(), this[t].enable(e); }, disable: function() { var t = this; this.shapes.forEach(function(e) { t[e].disable(); }); }, addControls: function() { var t = this; this.shapes.forEach(function(e) { t[e].addButton(); }); } }); e.a = i; }, function(t, e, n) { "use strict"; var r = n(40), i = n(151), a = L.Class.extend({ includes: [i.a, r.a], options: { snappable: !0, snapDistance: 20, allowSelfIntersection: !0, draggable: !0 }, isPolygon: function() { return this._layer instanceof L.Polygon; } }); e.a = a; }, function(t, e) { t.exports = function(t) { var e = typeof t; return null != t && ("object" == e || "function" == e); }; }, function(t, e, n) { var r = n(25), i = "object" == typeof self && self && self.Object === Object && self, a = r || i || Function("return this")(); t.exports = a; }, function(t, e) { t.exports = function(t) { return null != t && "object" == typeof t; }; }, function(t, e) { var n = Array.isArray; t.exports = n; }, function(t, e, n) { var r = n(16), i = n(66), a = n(67), o = "[object Null]", s = "[object Undefined]", l = r ? r.toStringTag : undefined; t.exports = function(t) { return null == t ? t === undefined ? s : o : l && l in Object(t) ? i(t) : a(t); }; }, function(t, e, n) { "use strict"; function r(t, e, n) { void 0 === n && (n = {}); var r = { type: "Feature" }; return ( (0 === n.id || n.id) && (r.id = n.id), n.bbox && (r.bbox = n.bbox), (r.properties = e || {}), (r.geometry = t), r ); } function i(t, e, n) { return ( void 0 === n && (n = {}), r({ type: "Point", coordinates: t }, e, n) ); } function a(t, e, n) { void 0 === n && (n = {}); for (var i = 0, a = t; i < a.length; i++) { var o = a[i]; if (o.length < 4) throw new Error( "Each LinearRing of a Polygon must have 4 or more Positions." ); for (var s = 0; s < o[o.length - 1].length; s++) if (o[o.length - 1][s] !== o[0][s]) throw new Error("First and last Position are not equivalent."); } return r({ type: "Polygon", coordinates: t }, e, n); } function o(t, e, n) { if ((void 0 === n && (n = {}), t.length < 2)) throw new Error( "coordinates must be an array of two or more positions" ); return r({ type: "LineString", coordinates: t }, e, n); } function s(t, e) { void 0 === e && (e = {}); var n = { type: "FeatureCollection" }; return ( e.id && (n.id = e.id), e.bbox && (n.bbox = e.bbox), (n.features = t), n ); } function l(t, e, n) { return ( void 0 === n && (n = {}), r({ type: "MultiLineString", coordinates: t }, e, n) ); } function u(t, e, n) { return ( void 0 === n && (n = {}), r({ type: "MultiPoint", coordinates: t }, e, n) ); } function c(t, e, n) { return ( void 0 === n && (n = {}), r({ type: "MultiPolygon", coordinates: t }, e, n) ); } function h(t, n) { void 0 === n && (n = "kilometers"); var r = e.factors[n]; if (!r) throw new Error(n + " units is invalid"); return t * r; } function p(t, n) { void 0 === n && (n = "kilometers"); var r = e.factors[n]; if (!r) throw new Error(n + " units is invalid"); return t / r; } function f(t) { return (180 * (t % (2 * Math.PI))) / Math.PI; } function d(t) { return !isNaN(t) && null !== t && !Array.isArray(t) && !/^\s*$/.test(t); } Object.defineProperty(e, "__esModule", { value: !0 }), (e.earthRadius = 6371008.8), (e.factors = { centimeters: 100 * e.earthRadius, centimetres: 100 * e.earthRadius, degrees: e.earthRadius / 111325, feet: 3.28084 * e.earthRadius, inches: 39.37 * e.earthRadius, kilometers: e.earthRadius / 1e3, kilometres: e.earthRadius / 1e3, meters: e.earthRadius, metres: e.earthRadius, miles: e.earthRadius / 1609.344, millimeters: 1e3 * e.earthRadius, millimetres: 1e3 * e.earthRadius, nauticalmiles: e.earthRadius / 1852, radians: 1, yards: e.earthRadius / 1.0936 }), (e.unitsFactors = { centimeters: 100, centimetres: 100, degrees: 1 / 111325, feet: 3.28084, inches: 39.37, kilometers: 0.001, kilometres: 0.001, meters: 1, metres: 1, miles: 1 / 1609.344, millimeters: 1e3, millimetres: 1e3, nauticalmiles: 1 / 1852, radians: 1 / e.earthRadius, yards: 1 / 1.0936 }), (e.areaFactors = { acres: 247105e-9, centimeters: 1e4, centimetres: 1e4, feet: 10.763910417, inches: 1550.003100006, kilometers: 1e-6, kilometres: 1e-6, meters: 1, metres: 1, miles: 3.86e-7, millimeters: 1e6, millimetres: 1e6, yards: 1.195990046 }), (e.feature = r), (e.geometry = function(t, e, n) { switch ((void 0 === n && (n = {}), t)) { case "Point": return i(e).geometry; case "LineString": return o(e).geometry; case "Polygon": return a(e).geometry; case "MultiPoint": return u(e).geometry; case "MultiLineString": return l(e).geometry; case "MultiPolygon": return c(e).geometry; default: throw new Error(t + " is invalid"); } }), (e.point = i), (e.points = function(t, e, n) { return ( void 0 === n && (n = {}), s( t.map(function(t) { return i(t, e); }), n ) ); }), (e.polygon = a), (e.polygons = function(t, e, n) { return ( void 0 === n && (n = {}), s( t.map(function(t) { return a(t, e); }), n ) ); }), (e.lineString = o), (e.lineStrings = function(t, e, n) { return ( void 0 === n && (n = {}), s( t.map(function(t) { return o(t, e); }), n ) ); }), (e.featureCollection = s), (e.multiLineString = l), (e.multiPoint = u), (e.multiPolygon = c), (e.geometryCollection = function(t, e, n) { return ( void 0 === n && (n = {}), r({ type: "GeometryCollection", geometries: t }, e, n) ); }), (e.round = function(t, e) { if ((void 0 === e && (e = 0), e && !(e >= 0))) throw new Error("precision must be a positive number"); var n = Math.pow(10, e || 0); return Math.round(t * n) / n; }), (e.radiansToLength = h), (e.lengthToRadians = p), (e.lengthToDegrees = function(t, e) { return f(p(t, e)); }), (e.bearingToAzimuth = function(t) { var e = t % 360; return e < 0 && (e += 360), e; }), (e.radiansToDegrees = f), (e.degreesToRadians = function(t) { return ((t % 360) * Math.PI) / 180; }), (e.convertLength = function(t, e, n) { if ( (void 0 === e && (e = "kilometers"), void 0 === n && (n = "kilometers"), !(t >= 0)) ) throw new Error("length must be a positive number"); return h(p(t, e), n); }), (e.convertArea = function(t, n, r) { if ( (void 0 === n && (n = "meters"), void 0 === r && (r = "kilometers"), !(t >= 0)) ) throw new Error("area must be a positive number"); var i = e.areaFactors[n]; if (!i) throw new Error("invalid original units"); var a = e.areaFactors[r]; if (!a) throw new Error("invalid final units"); return (t / i) * a; }), (e.isNumber = d), (e.isObject = function(t) { return !!t && t.constructor === Object; }), (e.validateBBox = function(t) { if (!t) throw new Error("bbox is required"); if (!Array.isArray(t)) throw new Error("bbox must be an Array"); if (4 !== t.length && 6 !== t.length) throw new Error("bbox must be an Array of 4 or 6 numbers"); t.forEach(function(t) { if (!d(t)) throw new Error("bbox must only contain numbers"); }); }), (e.validateId = function(t) { if (!t) throw new Error("id is required"); if (-1 === ["string", "number"].indexOf(typeof t)) throw new Error("id must be a number or a string"); }), (e.radians2degrees = function() { throw new Error("method has been renamed to `radiansToDegrees`"); }), (e.degrees2radians = function() { throw new Error("method has been renamed to `degreesToRadians`"); }), (e.distanceToDegrees = function() { throw new Error("method has been renamed to `lengthToDegrees`"); }), (e.distanceToRadians = function() { throw new Error("method has been renamed to `lengthToRadians`"); }), (e.radiansToDistance = function() { throw new Error("method has been renamed to `radiansToLength`"); }), (e.bearingToAngle = function() { throw new Error("method has been renamed to `bearingToAzimuth`"); }), (e.convertDistance = function() { throw new Error("method has been renamed to `convertLength`"); }); }, function(t, e, n) { var r = n(54), i = n(55), a = n(56), o = n(57), s = n(58); function l(t) { var e = -1, n = null == t ? 0 : t.length; for (this.clear(); ++e < n; ) { var r = t[e]; this.set(r[0], r[1]); } } (l.prototype.clear = r), (l.prototype["delete"] = i), (l.prototype.get = a), (l.prototype.has = o), (l.prototype.set = s), (t.exports = l); }, function(t, e, n) { var r = n(11); t.exports = function(t, e) { for (var n = t.length; n--; ) if (r(t[n][0], e)) return n; return -1; }; }, function(t, e) { t.exports = function(t, e) { return t === e || (t != t && e != e); }; }, function(t, e, n) { var r = n(14)(Object, "create"); t.exports = r; }, function(t, e, n) { var r = n(80); t.exports = function(t, e) { var n = t.__data__; return r(e) ? n["string" == typeof e ? "string" : "hash"] : n.map; }; }, function(t, e, n) { var r = n(64), i = n(71); t.exports = function(t, e) { var n = i(t, e); return r(n) ? n : undefined; }; }, function(t, e, n) { var r = n(7), i = n(3), a = "[object AsyncFunction]", o = "[object Function]", s = "[object GeneratorFunction]", l = "[object Proxy]"; t.exports = function(t) { if (!i(t)) return !1; var e = r(t); return e == o || e == s || e == a || e == l; }; }, function(t, e, n) { var r = n(4).Symbol; t.exports = r; }, function(t, e, n) { var r = n(28); t.exports = function(t, e, n) { "__proto__" == e && r ? r(t, e, { configurable: !0, enumerable: !0, value: n, writable: !0 }) : (t[e] = n); }; }, function(t, e) { t.exports = function(t) { return ( t.webpackPolyfill || ((t.deprecate = function() {}), (t.paths = []), t.children || (t.children = []), Object.defineProperty(t, "loaded", { enumerable: !0, get: function() { return t.l; } }), Object.defineProperty(t, "id", { enumerable: !0, get: function() { return t.i; } }), (t.webpackPolyfill = 1)), t ); }; }, function(t, e, n) { var r = n(95), i = n(5), a = Object.prototype, o = a.hasOwnProperty, s = a.propertyIsEnumerable, l = r( (function() { return arguments; })() ) ? r : function(t) { return i(t) && o.call(t, "callee") && !s.call(t, "callee"); }; t.exports = l; }, function(t, e, n) { var r = n(15), i = n(21); t.exports = function(t) { return null != t && i(t.length) && !r(t); }; }, function(t, e) { var n = 9007199254740991; t.exports = function(t) { return "number" == typeof t && t > -1 && t % 1 == 0 && t <= n; }; }, function(t, e) { var n = 9007199254740991, r = /^(?:0|[1-9]\d*)$/; t.exports = function(t, e) { var i = typeof t; return ( !!(e = null == e ? n : e) && ("number" == i || ("symbol" != i && r.test(t))) && t > -1 && t % 1 == 0 && t < e ); }; }, function(t, e, n) { var r = n(7), i = n(5), a = "[object Symbol]"; t.exports = function(t) { return "symbol" == typeof t || (i(t) && r(t) == a); }; }, function(t, e, n) { var r = n(14)(n(4), "Map"); t.exports = r; }, function(t, e, n) { (function(e) { var n = "object" == typeof e && e && e.Object === Object && e; t.exports = n; }.call(e, n(65))); }, function(t, e, n) { var r = n(72), i = n(79), a = n(81), o = n(82), s = n(83); function l(t) { var e = -1, n = null == t ? 0 : t.length; for (this.clear(); ++e < n; ) { var r = t[e]; this.set(r[0], r[1]); } } (l.prototype.clear = r), (l.prototype["delete"] = i), (l.prototype.get = a), (l.prototype.has = o), (l.prototype.set = s), (t.exports = l); }, function(t, e, n) { var r = n(17), i = n(11); t.exports = function(t, e, n) { ((n === undefined || i(t[e], n)) && (n !== undefined || e in t)) || r(t, e, n); }; }, function(t, e, n) { var r = n(14), i = (function() { try { var t = r(Object, "defineProperty"); return t({}, "", {}), t; } catch (e) {} })(); t.exports = i; }, function(t, e, n) { var r = n(94)(Object.getPrototypeOf, Object); t.exports = r; }, function(t, e) { var n = Object.prototype; t.exports = function(t) { var e = t && t.constructor; return t === (("function" == typeof e && e.prototype) || n); }; }, function(t, e, n) { (function(t) { var r = n(4), i = n(97), a = "object" == typeof e && e && !e.nodeType && e, o = a && "object" == typeof t && t && !t.nodeType && t, s = o && o.exports === a ? r.Buffer : undefined, l = (s ? s.isBuffer : undefined) || i; t.exports = l; }.call(e, n(18)(t))); }, function(t, e, n) { var r = n(99), i = n(100), a = n(101), o = a && a.isTypedArray, s = o ? i(o) : r; t.exports = s; }, function(t, e) { t.exports = function(t, e) { if ( ("constructor" !== e || "function" != typeof t[e]) && "__proto__" != e ) return t[e]; }; }, function(t, e, n) { var r = n(105), i = n(107), a = n(20); t.exports = function(t) { return a(t) ? r(t, !0) : i(t); }; }, function(t, e) { t.exports = function(t) { return t; }; }, function(t, e, n) { "use strict"; var r = n(118), i = n.n(r), a = n(119), o = n.n(a), s = n(120), l = n.n(s), u = n(121), c = n.n(u), h = n(122), p = n.n(h), f = n(123), d = n.n(f), g = n(124), _ = n.n(g), m = n(125), y = n.n(m), v = n(126), b = n.n(v), L = n(127), k = n.n(L); e.a = { en: i.a, de: o.a, it: l.a, ro: c.a, ru: p.a, es: d.a, nl: _.a, fr: y.a, pt_br: k.a, zh: b.a }; }, function(t, e, n) { var r = n(130); t.exports = function(t, e, n) { var i = null == t ? undefined : r(t, e); return i === undefined ? n : i; }; }, function(t, e, n) { var r = n(6), i = n(131), a = n(132), o = n(135); t.exports = function(t, e) { return r(t) ? t : i(t, e) ? [t] : a(o(t)); }; }, function(t, e, n) { var r = n(23), i = 1 / 0; t.exports = function(t) { if ("string" == typeof t || r(t)) return t; var e = t + ""; return "0" == e && 1 / t == -i ? "-0" : e; }; }, function(t, e, n) { "use strict"; var r = n(41), i = { _initSnappableMarkers: function() { (this.options.snapDistance = this.options.snapDistance || 30), this._assignEvents(this._markers), this._layer.off("pm:dragstart", this._unsnap, this), this._layer.on("pm:dragstart", this._unsnap, this); }, _assignEvents: function(t) { var e = this; t.forEach(function(t) { Array.isArray(t) ? e._assignEvents(t) : (t.off("drag", e._handleSnapping, e), t.on("drag", e._handleSnapping, e), t.off("dragend", e._cleanupSnapping, e), t.on("dragend", e._cleanupSnapping, e)); }); }, _unsnap: function() { delete this._snapLatLng; }, _cleanupSnapping: function() { delete this._snapList, this._map.off("pm:remove", this._handleSnapLayerRemoval, this), this.debugIndicatorLines && this.debugIndicatorLines.forEach(function(t) { t.remove(); }); }, _handleSnapLayerRemoval: function(t) { var e = t.layer, n = this._snapList.findIndex(function(t) { return t._leaflet_id === e._leaflet_id; }); this._snapList.splice(n, 1); }, _handleSnapping: function(t) { var e = this; if (t.originalEvent.altKey) return !1; if ( (this._snapList === undefined && this._createSnapList(t), this._snapList.length <= 0) ) return !1; var n, r = t.target, i = this._calcClosestLayer(r.getLatLng(), this._snapList), a = i.layer instanceof L.Marker || i.layer instanceof L.CircleMarker; n = a ? i.latlng : this._checkPrioritiySnapping(i); var o = this.options.snapDistance, s = { marker: r, snapLatLng: n, segment: i.segment, layer: this._layer, layerInteractedWith: i.layer, distance: i.distance }; if ( (s.marker.fire("pm:snapdrag", s), this._layer.fire("pm:snapdrag", s), i.distance < o) ) { r.setLatLng(n), (r._snapped = !0); var l = this._snapLatLng || {}, u = n || {}; (l.lat === u.lat && l.lng === u.lng) || ((e._snapLatLng = n), r.fire("pm:snap", s), e._layer.fire("pm:snap", s)); } else this._snapLatLng && (this._unsnap(s), (r._snapped = !1), s.marker.fire("pm:unsnap", s), this._layer.fire("pm:unsnap", s)); return !0; }, _checkPrioritiySnapping: function(t) { var e, n = this._map, i = t.segment[0], a = t.segment[1], o = t.latlng, s = this._getDistance(n, i, o), l = this._getDistance(n, a, o), u = s < l ? i : a, c = s < l ? s : l; if (this.options.snapMiddle) { var h = r.a.calcMiddleLatLng(n, i, a), p = this._getDistance(n, h, o); p < s && p < l && ((u = h), (c = p)); } return ( (e = c < this.options.snapDistance ? u : o), Object.assign({}, e) ); }, _createSnapList: function() { var t = this, e = [], n = [], r = this._map; r.off("pm:remove", this._handleSnapLayerRemoval, this), r.on("pm:remove", this._handleSnapLayerRemoval, this), r.eachLayer(function(t) { if ( (t instanceof L.Polyline || t instanceof L.Marker || t instanceof L.CircleMarker) && !0 !== t.options.snapIgnore ) { e.push(t); var r = L.polyline([], { color: "red", pmIgnore: !0 }); (r._pmTempLayer = !0), n.push(r); } }), (e = (e = (e = e.filter(function(e) { return t._layer !== e; })).filter(function(t) { return t._latlng || (t._latlngs && t._latlngs.length > 0); })).filter(function(t) { return !t._pmTempLayer; })), this._otherSnapLayers ? (this._snapList = e.concat(this._otherSnapLayers)) : (this._snapList = e), (this.debugIndicatorLines = n); }, _calcClosestLayer: function(t, e) { var n = this, r = {}; return ( e.forEach(function(e, i) { var a = n._calcLayerDistances(t, e); n.debugIndicatorLines[i].setLatLngs([t, a.latlng]), (r.distance === undefined || a.distance < r.distance) && ((r = a).layer = e); }), r ); }, _calcLayerDistances: function(t, e) { var n, r, i = this, a = this._map, o = e instanceof L.Marker || e instanceof L.CircleMarker, s = e instanceof L.Polygon, l = t, u = o ? e.getLatLng() : e.getLatLngs(); if (o) return { latlng: Object.assign({}, u), distance: this._getDistance(a, u, l) }; !(function h(t) { t.forEach(function(e, o) { if (Array.isArray(e)) h(e); else { var u, c = e; u = s ? o + 1 === t.length ? 0 : o + 1 : o + 1 === t.length ? undefined : o + 1; var p = t[u]; if (p) { var f = i._getDistanceToSegment(a, l, c, p); (r === undefined || f < r) && ((r = f), (n = [c, p])); } } }); })(u); var c = this._getClosestPointOnSegment(a, t, n[0], n[1]); return { latlng: Object.assign({}, c), segment: n, distance: r }; }, _getClosestPointOnSegment: function(t, e, n, r) { var i = t.getMaxZoom(); i === Infinity && (i = t.getZoom()); var a = t.project(e, i), o = t.project(n, i), s = t.project(r, i), l = L.LineUtil.closestPointOnSegment(a, o, s); return t.unproject(l, i); }, _getDistanceToSegment: function(t, e, n, r) { var i = t.latLngToLayerPoint(e), a = t.latLngToLayerPoint(n), o = t.latLngToLayerPoint(r); return L.LineUtil.pointToSegmentDistance(i, a, o); }, _getDistance: function(t, e, n) { return t.latLngToLayerPoint(e).distanceTo(t.latLngToLayerPoint(n)); } }; e.a = i; }, function(t, e, n) { "use strict"; e.a = { calcMiddleLatLng: function(t, e, n) { var r = t.project(e), i = t.project(n); return t.unproject(r._add(i)._divideBy(2)); } }; }, function(t, e, n) { "use strict"; Object.defineProperty(e, "__esModule", { value: !0 }); var r = n(8); function i(t, e, n, r, i, a, o, s) { var l, u, c, h, p = { x: null, y: null, onLine1: !1, onLine2: !1 }; return 0 === (l = (s - a) * (n - t) - (o - i) * (r - e)) ? null !== p.x && null !== p.y && p : ((h = (n - t) * (u = e - a) - (r - e) * (c = t - i)), (u = ((o - i) * u - (s - a) * c) / l), (c = h / l), (p.x = t + u * (n - t)), (p.y = e + u * (r - e)), u >= 0 && u <= 1 && (p.onLine1 = !0), c >= 0 && c <= 1 && (p.onLine2 = !0), !(!p.onLine1 || !p.onLine2) && [p.x, p.y]); } e["default"] = function(t) { var e, n, a = { type: "FeatureCollection", features: [] }; if ("LineString" === (n = "Feature" === t.type ? t.geometry : t).type) e = [n.coordinates]; else if ("MultiLineString" === n.type) e = n.coordinates; else if ("MultiPolygon" === n.type) e = [].concat.apply([], n.coordinates); else { if ("Polygon" !== n.type) throw new Error( "Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry" ); e = n.coordinates; } return ( e.forEach(function(t) { e.forEach(function(e) { for (var n = 0; n < t.length - 1; n++) for (var o = n; o < e.length - 1; o++) { if (t === e) { if (1 === Math.abs(n - o)) continue; if ( 0 === n && o === t.length - 2 && t[n][0] === t[t.length - 1][0] && t[n][1] === t[t.length - 1][1] ) continue; } var s = i( t[n][0], t[n][1], t[n + 1][0], t[n + 1][1], e[o][0], e[o][1], e[o + 1][0], e[o + 1][1] ); s && a.features.push(r.point([s[0], s[1]])); } }); }), a ); }; }, function(t, e, n) { "use strict"; Object.defineProperty(e, "__esModule", { value: !0 }); var r = n(8); (e.getCoord = function(t) { if (!t) throw new Error("coord is required"); if (!Array.isArray(t)) { if ( "Feature" === t.type && null !== t.geometry && "Point" === t.geometry.type ) return t.geometry.coordinates; if ("Point" === t.type) return t.coordinates; } if ( Array.isArray(t) && t.length >= 2 && !Array.isArray(t[0]) && !Array.isArray(t[1]) ) return t; throw new Error("coord must be GeoJSON Point or an Array of numbers"); }), (e.getCoords = function(t) { if (Array.isArray(t)) return t; if ("Feature" === t.type) { if (null !== t.geometry) return t.geometry.coordinates; } else if (t.coordinates) return t.coordinates; throw new Error( "coords must be GeoJSON Feature, Geometry Object or an Array" ); }), (e.containsNumber = function i(t) { if (t.length > 1 && r.isNumber(t[0]) && r.isNumber(t[1])) return !0; if (Array.isArray(t[0]) && t[0].length) return i(t[0]); throw new Error("coordinates must only contain numbers"); }), (e.geojsonType = function(t, e, n) { if (!e || !n) throw new Error("type and name required"); if (!t || t.type !== e) throw new Error( "Invalid input to " + n + ": must be a " + e + ", given " + t.type ); }), (e.featureOf = function(t, e, n) { if (!t) throw new Error("No feature passed"); if (!n) throw new Error(".featureOf() requires a name"); if (!t || "Feature" !== t.type || !t.geometry) throw new Error( "Invalid input to " + n + ", Feature with geometry required" ); if (!t.geometry || t.geometry.type !== e) throw new Error( "Invalid input to " + n + ": must be a " + e + ", given " + t.geometry.type ); }), (e.collectionOf = function(t, e, n) { if (!t) throw new Error("No featureCollection passed"); if (!n) throw new Error(".collectionOf() requires a name"); if (!t || "FeatureCollection" !== t.type) throw new Error( "Invalid input to " + n + ", FeatureCollection required" ); for (var r = 0, i = t.features; r < i.length; r++) { var a = i[r]; if (!a || "Feature" !== a.type || !a.geometry) throw new Error( "Invalid input to " + n + ", Feature with geometry required" ); if (!a.geometry || a.geometry.type !== e) throw new Error( "Invalid input to " + n + ": must be a " + e + ", given " + a.geometry.type ); } }), (e.getGeom = function(t) { return "Feature" === t.type ? t.geometry : t; }), (e.getType = function(t, e) { return "FeatureCollection" === t.type ? "FeatureCollection" : "GeometryCollection" === t.type ? "GeometryCollection" : "Feature" === t.type && null !== t.geometry ? t.geometry.type : t.type; }); }, function(t, e, n) { !(function(t, n) { n(e); })(0, function(t) { "use strict"; function e(t, e) { return t > e ? 1 : t < e ? -1 : 0; } var n = function(t, n) { void 0 === t && (t = e), void 0 === n && (n = !1), (this._compare = t), (this._root = null), (this._size = 0), (this._noDuplicates = !!n); }, r = { size: { configurable: !0 } }; (n.prototype.rotateLeft = function(t) { var e = t.right; e && ((t.right = e.left), e.left && (e.left.parent = t), (e.parent = t.parent)), t.parent ? t === t.parent.left ? (t.parent.left = e) : (t.parent.right = e) : (this._root = e), e && (e.left = t), (t.parent = e); }), (n.prototype.rotateRight = function(t) { var e = t.left; e && ((t.left = e.right), e.right && (e.right.parent = t), (e.parent = t.parent)), t.parent ? t === t.parent.left ? (t.parent.left = e) : (t.parent.right = e) : (this._root = e), e && (e.right = t), (t.parent = e); }), (n.prototype._splay = function(t) { for (; t.parent; ) { var e = t.parent; e.parent ? e.left === t && e.parent.left === e ? (this.rotateRight(e.parent), this.rotateRight(e)) : e.right === t && e.parent.right === e ? (this.rotateLeft(e.parent), this.rotateLeft(e)) : e.left === t && e.parent.right === e ? (this.rotateRight(e), this.rotateLeft(e)) : (this.rotateLeft(e), this.rotateRight(e)) : e.left === t ? this.rotateRight(e) : this.rotateLeft(e); } }), (n.prototype.splay = function(t) { for (var e, n, r, i, a; t.parent; ) (n = (e = t.parent).parent) && n.parent ? ((r = n.parent).left === n ? (r.left = t) : (r.right = t), (t.parent = r)) : ((t.parent = null), (this._root = t)), (i = t.left), (a = t.right), t === e.left ? (n && (n.left === e ? (e.right ? ((n.left = e.right), (n.left.parent = n)) : (n.left = null), (e.right = n), (n.parent = e)) : (i ? ((n.right = i), (i.parent = n)) : (n.right = null), (t.left = n), (n.parent = t))), a ? ((e.left = a), (a.parent = e)) : (e.left = null), (t.right = e), (e.parent = t)) : (n && (n.right === e ? (e.left ? ((n.right = e.left), (n.right.parent = n)) : (n.right = null), (e.left = n), (n.parent = e)) : (a ? ((n.left = a), (a.parent = n)) : (n.left = null), (t.right = n), (n.parent = t))), i ? ((e.right = i), (i.parent = e)) : (e.right = null), (t.left = e), (e.parent = t)); }), (n.prototype.replace = function(t, e) { t.parent ? t === t.parent.left ? (t.parent.left = e) : (t.parent.right = e) : (this._root = e), e && (e.parent = t.parent); }), (n.prototype.minNode = function(t) { if ((void 0 === t && (t = this._root), t)) for (; t.left; ) t = t.left; return t; }), (n.prototype.maxNode = function(t) { if ((void 0 === t && (t = this._root), t)) for (; t.right; ) t = t.right; return t; }), (n.prototype.insert = function(t, e) { var n = this._root, r = null, i = this._compare; if (this._noDuplicates) for (; n; ) { if (((r = n), 0 === i(n.key, t))) return; n = i(n.key, t) < 0 ? n.right : n.left; } else for (; n; ) (r = n), (n = i(n.key, t) < 0 ? n.right : n.left); return ( (n = { key: t, data: e, left: null, right: null, parent: r }), r ? i(r.key, n.key) < 0 ? (r.right = n) : (r.left = n) : (this._root = n), this.splay(n), this._size++, n ); }), (n.prototype.find = function(t) { for (var e = this._root, n = this._compare; e; ) { var r = n(e.key, t); if (r < 0) e = e.right; else { if (!(r > 0)) return e; e = e.left; } } return null; }), (n.prototype.contains = function(t) { for (var e = this._root, n = this._compare; e; ) { var r = n(t, e.key); if (0 === r) return !0; e = r < 0 ? e.left : e.right; } return !1; }), (n.prototype.remove = function(t) { var e = this.find(t); if (!e) return !1; if ((this.splay(e), e.left)) if (e.right) { var n = this.minNode(e.right); n.parent !== e && (this.replace(n, n.right), (n.right = e.right), (n.right.parent = n)), this.replace(e, n), (n.left = e.left), (n.left.parent = n); } else this.replace(e, e.left); else this.replace(e, e.right); return this._size--, !0; }), (n.prototype.removeNode = function(t) { if (!t) return !1; if ((this.splay(t), t.left)) if (t.right) { var e = this.minNode(t.right); e.parent !== t && (this.replace(e, e.right), (e.right = t.right), (e.right.parent = e)), this.replace(t, e), (e.left = t.left), (e.left.parent = e); } else this.replace(t, t.left); else this.replace(t, t.right); return this._size--, !0; }), (n.prototype.erase = function(t) { var e = this.find(t); if (e) { this.splay(e); var n = e.left, r = e.right, i = null; n && ((n.parent = null), (i = this.maxNode(n)), this.splay(i), (this._root = i)), r && (n ? (i.right = r) : (this._root = r), (r.parent = i)), this._size--; } }), (n.prototype.pop = function() { var t = this._root, e = null; if (t) { for (; t.left; ) t = t.left; (e = { key: t.key, data: t.data }), this.remove(t.key); } return e; }), (n.prototype.next = function(t) { var e = t; if (e) if (e.right) for (e = e.right; e && e.left; ) e = e.left; else for (e = t.parent; e && e.right === t; ) (t = e), (e = e.parent); return e; }), (n.prototype.prev = function(t) { var e = t; if (e) if (e.left) for (e = e.left; e && e.right; ) e = e.right; else for (e = t.parent; e && e.left === t; ) (t = e), (e = e.parent); return e; }), (n.prototype.forEach = function(t) { for (var e = this._root, n = [], r = !1, i = 0; !r; ) e ? (n.push(e), (e = e.left)) : n.length > 0 ? (t((e = n.pop()), i++), (e = e.right)) : (r = !0); return this; }), (n.prototype.range = function(t, e, n, r) { for ( var i = [], a = this._compare, o = this._root; 0 !== i.length || o; ) if (o) i.push(o), (o = o.left); else { if (a((o = i.pop()).key, e) > 0) break; if (a(o.key, t) >= 0 && n.call(r, o)) return this; o = o.right; } return this; }), (n.prototype.keys = function() { for (var t = this._root, e = [], n = [], r = !1; !r; ) t ? (e.push(t), (t = t.left)) : e.length > 0 ? ((t = e.pop()), n.push(t.key), (t = t.right)) : (r = !0); return n; }), (n.prototype.values = function() { for (var t = this._root, e = [], n = [], r = !1; !r; ) t ? (e.push(t), (t = t.left)) : e.length > 0 ? ((t = e.pop()), n.push(t.data), (t = t.right)) : (r = !0); return n; }), (n.prototype.at = function(t) { for (var e = this._root, n = [], r = !1, i = 0; !r; ) if (e) n.push(e), (e = e.left); else if (n.length > 0) { if (((e = n.pop()), i === t)) return e; i++, (e = e.right); } else r = !0; return null; }), (n.prototype.load = function(t, e, n) { if ( (void 0 === t && (t = []), void 0 === e && (e = []), void 0 === n && (n = !1), 0 !== this._size) ) throw new Error("bulk-load: tree is not empty"); var r = t.length; return ( n && (function i(t, e, n, r, a) { if (n >= r) return; var o = t[(n + r) >> 1]; var s = n - 1; var l = r + 1; for (;;) { do { s++; } while (a(t[s], o) < 0); do { l--; } while (a(t[l], o) > 0); if (s >= l) break; var u = t[s]; (t[s] = t[l]), (t[l] = u), (u = e[s]), (e[s] = e[l]), (e[l] = u); } i(t, e, n, l, a); i(t, e, l + 1, r, a); })(t, e, 0, r - 1, this._compare), (this._root = (function a(t, e, n, r, i) { var o = i - r; if (o > 0) { var s = r + Math.floor(o / 2), l = e[s], u = n[s], c = { key: l, data: u, parent: t }; return ( (c.left = a(c, e, n, r, s)), (c.right = a(c, e, n, s + 1, i)), c ); } return null; })(null, t, e, 0, r)), (this._size = r), this ); }), (n.prototype.min = function() { var t = this.minNode(this._root); return t ? t.key : null; }), (n.prototype.max = function() { var t = this.maxNode(this._root); return t ? t.key : null; }), (n.prototype.isEmpty = function() { return null === this._root; }), (r.size.get = function() { return this._size; }), (n.createTree = function(t, e, r, i, a) { return new n(r, a).load(t, e, i); }), Object.defineProperties(n.prototype, r); var i = 0, a = 1, o = 2, s = 3, l = 0, u = 1, c = 2, h = 3; function p(t, e, n) { null === e ? ((t.inOut = !1), (t.otherInOut = !0)) : (t.isSubject === e.isSubject ? ((t.inOut = !e.inOut), (t.otherInOut = e.otherInOut)) : ((t.inOut = !e.otherInOut), (t.otherInOut = e.isVertical() ? !e.inOut : e.inOut)), e && (t.prevInResult = !f(e, n) || e.isVertical() ? e.prevInResult : e)), (t.inResult = f(t, n)); } function f(t, e) { switch (t.type) { case i: switch (e) { case l: return !t.otherInOut; case u: return t.otherInOut; case c: return ( (t.isSubject && t.otherInOut) || (!t.isSubject && !t.otherInOut) ); case h: return !0; } break; case o: return e === l || e === u; case s: return e === c; case a: return !1; } return !1; } var d = function(t, e, n, r, a) { (this.left = e), (this.point = t), (this.otherEvent = n), (this.isSubject = r), (this.type = a || i), (this.inOut = !1), (this.otherInOut = !1), (this.prevInResult = null), (this.inResult = !1), (this.resultInOut = !1), (this.isExteriorRing = !0); }; function g(t, e) { return t[0] === e[0] && t[1] === e[1]; } function _(t, e, n) { return (t[0] - n[0]) * (e[1] - n[1]) - (e[0] - n[0]) * (t[1] - n[1]); } function m(t, e) { var n = t.point, r = e.point; return n[0] > r[0] ? 1 : n[0] < r[0] ? -1 : n[1] !== r[1] ? n[1] > r[1] ? 1 : -1 : (function(t, e, n, r) { if (t.left !== e.left) return t.left ? 1 : -1; if (0 !== _(n, t.otherEvent.point, e.otherEvent.point)) return t.isBelow(e.otherEvent.point) ? -1 : 1; return !t.isSubject && e.isSubject ? 1 : -1; })(t, e, n); } function y(t, e, n) { var r = new d(e, !1, t, t.isSubject), i = new d(e, !0, t.otherEvent, t.isSubject); return ( g(t.point, t.otherEvent.point) && console.warn("what is that, a collapsed segment?", t), (r.contourId = i.contourId = t.contourId), m(i, t.otherEvent) > 0 && ((t.otherEvent.left = !0), (i.left = !1)), (t.otherEvent.otherEvent = i), (t.otherEvent = r), n.push(i), n.push(r), n ); } function v(t, e) { return t[0] * e[1] - t[1] * e[0]; } function b(t, e) { return t[0] * e[0] + t[1] * e[1]; } function L(t, e, n) { var r = (function(t, e, n, r, i) { var a = [e[0] - t[0], e[1] - t[1]], o = [r[0] - n[0], r[1] - n[1]]; function s(t, e, n) { return [t[0] + e * n[0], t[1] +