@mapgis/mapbox-gl-draw-radius 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +0 -0
- package/CONTRIBUTING.md +1 -0
- package/dist/radius-mode.js +109 -59
- package/dist/radius-mode.min.js +2 -2
- package/package.json +1 -1
- package/src/radius-mode.js +82 -53
package/dist/radius-mode.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var turf = require('@turf/turf');
|
|
4
|
+
|
|
5
|
+
function _interopNamespace(e) {
|
|
6
|
+
if (e && e.__esModule) return e;
|
|
7
|
+
var n = Object.create(null);
|
|
8
|
+
if (e) {
|
|
9
|
+
Object.keys(e).forEach(function (k) {
|
|
10
|
+
if (k !== 'default') {
|
|
11
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return e[k]; }
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n["default"] = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var turf__namespace = /*#__PURE__*/_interopNamespace(turf);
|
|
24
|
+
|
|
3
25
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
26
|
|
|
5
27
|
function createCommonjsModule(fn) {
|
|
@@ -8,8 +30,8 @@ function createCommonjsModule(fn) {
|
|
|
8
30
|
}
|
|
9
31
|
|
|
10
32
|
var mapboxGlDraw = createCommonjsModule(function (module, exports) {
|
|
11
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=function(t,e){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},r={on:function(t,e,r){if(void 0===n[t])throw new Error("Invalid event type: "+t);n[t].push({selector:e,fn:r});},render:function(t){e.store.featureChanged(t);}},o=function(t,o){for(var i=n[t],a=i.length;a--;){var s=i[a];if(s.selector(o)){s.fn.call(r,o)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(r),{render:t.render,stop:function(){t.stop&&t.stop();},trash:function(){t.trash&&(t.trash(),e.store.render());},combineFeatures:function(){t.combineFeatures&&t.combineFeatures();},uncombineFeatures:function(){t.uncombineFeatures&&t.uncombineFeatures();},drag:function(t){o("drag",t);},click:function(t){o("click",t);},mousemove:function(t){o("mousemove",t);},mousedown:function(t){o("mousedown",t);},mouseup:function(t){o("mouseup",t);},mouseout:function(t){o("mouseout",t);},keydown:function(t){o("keydown",t);},keyup:function(t){o("keyup",t);},touchstart:function(t){o("touchstart",t);},touchmove:function(t){o("touchmove",t);},touchend:function(t){o("touchend",t);},tap:function(t){o("tap",t);}}},e={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142};function n(t){var e=0;if(t&&t.length>0){e+=Math.abs(r(t[0]));for(var n=1;n<t.length;n++)e-=Math.abs(r(t[n]));}return e}function r(t){var n,r,i,a,s,u,c=0,l=t.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,a=l-1,s=0):u===l-1?(i=l-1,a=0,s=1):(i=u,a=u+1,s=u+2),n=t[i],r=t[a],c+=(o(t[s][0])-o(n[0]))*Math.sin(o(r[1]));c=c*e.RADIUS*e.RADIUS/2;}return c}function o(t){return t*Math.PI/180}var i={geometry:function t(e){var r,o=0;switch(e.type){case"Polygon":return n(e.coordinates);case"MultiPolygon":for(r=0;r<e.coordinates.length;r++)o+=n(e.coordinates[r]);return o;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(r=0;r<e.geometries.length;r++)o+=t(e.geometries[r]);return o}},ring:r},a={CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},s={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},u={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},c={POLYGON:"polygon",LINE:"line_string",POINT:"point"},l={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},h={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"},p={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},d="move",f="change_coordinates",g={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},y={ACTIVE:"true",INACTIVE:"false"},m=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],v=-85,_=85,b={Point:0,LineString:1,Polygon:2};function E(t,e){var n=b[t.geometry.type]-b[e.geometry.type];return 0===n&&t.geometry.type===l.POLYGON?t.area-e.area:n}function S(t){if(this._items={},this._nums={},this._length=t?t.length:0,t)for(var e=0,n=t.length;e<n;e++)this.add(t[e]),void 0!==t[e]&&("string"==typeof t[e]?this._items[t[e]]=e:this._nums[t[e]]=e);}S.prototype.add=function(t){return this.has(t)?this:(this._length++,"string"==typeof t?this._items[t]=this._length:this._nums[t]=this._length,this)},S.prototype.delete=function(t){return !1===this.has(t)?this:(this._length--,delete this._items[t],delete this._nums[t],this)},S.prototype.has=function(t){return ("string"==typeof t||"number"==typeof t)&&(void 0!==this._items[t]||void 0!==this._nums[t])},S.prototype.values=function(){var t=this,e=[];return Object.keys(this._items).forEach((function(n){e.push({k:n,v:t._items[n]});})),Object.keys(this._nums).forEach((function(n){e.push({k:JSON.parse(n),v:t._nums[n]});})),e.sort((function(t,e){return t.v-e.v})).map((function(t){return t.k}))},S.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};var T=[g.FEATURE,g.MIDPOINT,g.VERTEX],C={click:function(t,e,n){return O(t,e,n,n.options.clickBuffer)},touch:function(t,e,n){return O(t,e,n,n.options.touchBuffer)}};function O(t,e,n,r){if(null===n.map)return [];var o=t?function(t,e){return void 0===e&&(e=0),[[t.point.x-e,t.point.y-e],[t.point.x+e,t.point.y+e]]}(t,r):e,a={};n.options.styles&&(a.layers=n.options.styles.map((function(t){return t.id})));var s=n.map.queryRenderedFeatures(o,a).filter((function(t){return -1!==T.indexOf(t.properties.meta)})),u=new S,c=[];return s.forEach((function(t){var e=t.properties.id;u.has(e)||(u.add(e),c.push(t));})),function(t){return t.map((function(t){return t.geometry.type===l.POLYGON&&(t.area=i.geometry({type:l.FEATURE,property:{},geometry:t.geometry})),t})).sort(E).map((function(t){return delete t.area,t}))}(c)}function I(t,e){var n=C.click(t,null,e),r={mouse:u.NONE};return n[0]&&(r.mouse=n[0].properties.active===y.ACTIVE?u.MOVE:u.POINTER,r.feature=n[0].properties.meta),-1!==e.events.currentModeName().indexOf("draw")&&(r.mouse=u.ADD),e.ui.queueMapClasses(r),e.ui.updateMapClasses(),n[0]}function x(t,e){var n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}var L=4,M=12,N=500;function P(t,e,n){void 0===n&&(n={});var r=null!=n.fineTolerance?n.fineTolerance:L,o=null!=n.grossTolerance?n.grossTolerance:M,i=null!=n.interval?n.interval:N;t.point=t.point||e.point,t.time=t.time||e.time;var a=x(t.point,e.point);return a<r||a<o&&e.time-t.time<i}var w=25,A=250;function F(t,e,n){void 0===n&&(n={});var r=null!=n.tolerance?n.tolerance:w,o=null!=n.interval?n.interval:A;return t.point=t.point||e.point,t.time=t.time||e.time,x(t.point,e.point)<r&&e.time-t.time<o}function k(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function R(t,e){return t(e={exports:{}},e.exports),e.exports}var U=R((function(t){var e=t.exports=function(t,n){if(n||(n=16),void 0===t&&(t=128),t<=0)return "0";for(var r=Math.log(Math.pow(2,t))/Math.log(n),o=2;r===1/0;o*=2)r=Math.log(Math.pow(2,t/o))/Math.log(n)*o;var i=r-Math.floor(r),a="";for(o=0;o<Math.floor(r);o++){a=Math.floor(Math.random()*n).toString(n)+a;}if(i){var s=Math.pow(n,i);a=Math.floor(Math.random()*s).toString(n)+a;}var u=parseInt(a,n);return u!==1/0&&u>=Math.pow(2,t)?e(t,n):a};e.rack=function(t,n,r){var o=function(o){var a=0;do{if(a++>10){if(!r)throw new Error("too many ID collisions, use more bits");t+=r;}var s=e(t,n);}while(Object.hasOwnProperty.call(i,s));return i[s]=o,s},i=o.hats={};return o.get=function(t){return o.hats[t]},o.set=function(t,e){return o.hats[t]=e,o},o.bits=t||128,o.base=n||16,o};})),j=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||U(),this.type=e.geometry.type;};j.prototype.changed=function(){this.ctx.store.featureChanged(this.id);},j.prototype.incomingCoords=function(t){this.setCoordinates(t);},j.prototype.setCoordinates=function(t){this.coordinates=t,this.changed();},j.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},j.prototype.setProperty=function(t,e){this.properties[t]=e;},j.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:l.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},j.prototype.internal=function(t){var e={id:this.id,meta:g.FEATURE,"meta:type":this.type,active:y.INACTIVE,mode:t};if(this.ctx.options.userProperties)for(var n in this.properties)e["user_"+n]=this.properties[n];return {type:l.FEATURE,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var D=function(t,e){j.call(this,t,e);};(D.prototype=Object.create(j.prototype)).isValid=function(){return "number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},D.prototype.updateCoordinate=function(t,e,n){3===arguments.length?this.coordinates=[e,n]:this.coordinates=[t,e],this.changed();},D.prototype.getCoordinate=function(){return this.getCoordinates()};var V=function(t,e){j.call(this,t,e);};(V.prototype=Object.create(j.prototype)).isValid=function(){return this.coordinates.length>1},V.prototype.addCoordinate=function(t,e,n){this.changed();var r=parseInt(t,10);this.coordinates.splice(r,0,[e,n]);},V.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},V.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1);},V.prototype.updateCoordinate=function(t,e,n){var r=parseInt(t,10);this.coordinates[r]=[e,n],this.changed();};var B=function(t,e){j.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}));};(B.prototype=Object.create(j.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},B.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed();},B.prototype.setCoordinates=function(t){this.coordinates=t,this.changed();},B.prototype.addCoordinate=function(t,e,n){this.changed();var r=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[r[0]].splice(r[1],0,[e,n]);},B.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];n&&(n.splice(e[1],1),n.length<3&&this.coordinates.splice(e[0],1));},B.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];return JSON.parse(JSON.stringify(n[e[1]]))},B.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},B.prototype.updateCoordinate=function(t,e,n){this.changed();var r=t.split("."),o=parseInt(r[0],10),i=parseInt(r[1],10);void 0===this.coordinates[o]&&(this.coordinates[o]=[]),this.coordinates[o][i]=[e,n];};var G={MultiPoint:D,MultiLineString:V,MultiPolygon:B},$=function(t,e,n,r,o){var i=n.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return t[a][e](s,r,o)},J=function(t,e){if(j.call(this,t,e),delete this.coordinates,this.model=G[e.geometry.type],void 0===this.model)throw new TypeError(e.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(e.geometry.coordinates);};function z(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t;}(J.prototype=Object.create(j.prototype))._coordinatesToFeatures=function(t){var e=this,n=this.model.bind(this);return t.map((function(t){return new n(e.ctx,{id:U(),type:l.FEATURE,properties:{},geometry:{coordinates:t,type:e.type.replace("Multi","")}})}))},J.prototype.isValid=function(){return this.features.every((function(t){return t.isValid()}))},J.prototype.setCoordinates=function(t){this.features=this._coordinatesToFeatures(t),this.changed();},J.prototype.getCoordinate=function(t){return $(this.features,"getCoordinate",t)},J.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===l.POLYGON?t.getCoordinates():t.coordinates}))))},J.prototype.updateCoordinate=function(t,e,n){$(this.features,"updateCoordinate",t,e,n),this.changed();},J.prototype.addCoordinate=function(t,e,n){$(this.features,"addCoordinate",t,e,n),this.changed();},J.prototype.removeCoordinate=function(t){$(this.features,"removeCoordinate",t),this.changed();},J.prototype.getFeatures=function(){return this.features},z.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},z.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,n){return void 0===t[n.feature_id]&&(t[n.feature_id]=!0,e._ctx.store.get(n.feature_id).changed()),t}),{});},z.prototype.getSelected=function(){return this._ctx.store.getSelected()},z.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},z.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},z.prototype.getFeature=function(t){return this._ctx.store.get(t)},z.prototype.select=function(t){return this._ctx.store.select(t)},z.prototype.deselect=function(t){return this._ctx.store.deselect(t)},z.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},z.prototype.addFeature=function(t){return this._ctx.store.add(t)},z.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},z.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},z.prototype.setActionableState=function(t){void 0===t&&(t={});var e={trash:t.trash||!1,combineFeatures:t.combineFeatures||!1,uncombineFeatures:t.uncombineFeatures||!1};return this._ctx.events.actionable(e)},z.prototype.changeMode=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),this._ctx.events.changeMode(t,e,n)},z.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},z.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},z.prototype.featuresAt=function(t,e,n){if(void 0===n&&(n="click"),"click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return C[n](t,e,this._ctx)},z.prototype.newFeature=function(t){var e=t.geometry.type;return e===l.POINT?new D(this._ctx,t):e===l.LINE_STRING?new V(this._ctx,t):e===l.POLYGON?new B(this._ctx,t):new J(this._ctx,t)},z.prototype.isInstanceOf=function(t,e){if(t===l.POINT)return e instanceof D;if(t===l.LINE_STRING)return e instanceof V;if(t===l.POLYGON)return e instanceof B;if("MultiFeature"===t)return e instanceof J;throw new Error("Unknown feature class: "+t)},z.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},z.prototype.onSetup=function(){},z.prototype.onDrag=function(){},z.prototype.onClick=function(){},z.prototype.onMouseMove=function(){},z.prototype.onMouseDown=function(){},z.prototype.onMouseUp=function(){},z.prototype.onMouseOut=function(){},z.prototype.onKeyUp=function(){},z.prototype.onKeyDown=function(){},z.prototype.onTouchStart=function(){},z.prototype.onTouchMove=function(){},z.prototype.onTouchEnd=function(){},z.prototype.onTap=function(){},z.prototype.onStop=function(){},z.prototype.onTrash=function(){},z.prototype.onCombineFeature=function(){},z.prototype.onUncombineFeature=function(){},z.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Y={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},q=Object.keys(Y);function W(t){var e=Object.keys(t);return function(n,r){void 0===r&&(r={});var o={},i=e.reduce((function(e,n){return e[n]=t[n],e}),new z(n));return {start:function(){var e=this;o=i.onSetup(r),q.forEach((function(n){var r,a=Y[n],s=function(){return !1};t[a]&&(s=function(){return !0}),e.on(n,s,(r=a,function(t){return i[r](o,t)}));}));},stop:function(){i.onStop(o);},trash:function(){i.onTrash(o);},combineFeatures:function(){i.onCombineFeatures(o);},uncombineFeatures:function(){i.onUncombineFeatures(o);},render:function(t,e){i.toDisplayFeatures(o,t,e);}}}}function H(t){return [].concat(t).filter((function(t){return void 0!==t}))}function X(){var t=this;if(!(t.ctx.map&&void 0!==t.ctx.map.getSource(s.HOT)))return c();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var n=[],r=[];t.isDirty?r=t.getAllIds():(n=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),r=t.sources.hot.filter((function(e){return e.properties.id&&-1===n.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var o=t.sources.cold.length;t.sources.cold=t.isDirty?[]:t.sources.cold.filter((function(t){var e=t.properties.id||t.properties.parent;return -1===n.indexOf(e)}));var i=o!==t.sources.cold.length||r.length>0;function a(n,r){var o=t.get(n).internal(e);t.ctx.events.currentModeRender(o,(function(e){t.sources[r].push(e);}));}if(n.forEach((function(t){return a(t,"hot")})),r.forEach((function(t){return a(t,"cold")})),i&&t.ctx.map.getSource(s.COLD).setData({type:l.FEATURE_COLLECTION,features:t.sources.cold}),t.ctx.map.getSource(s.HOT).setData({type:l.FEATURE_COLLECTION,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(p.SELECTION_CHANGE,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return {type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var u=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(p.DELETE,{features:u});}function c(){t.isDirty=!1,t.clearChangedIds();}c(),t.ctx.map.fire(p.RENDER,{});}function Z(t){var e,n=this;this._features={},this._featureIds=new S,this._selectedFeatureIds=new S,this._selectedCoordinates=[],this._changedFeatureIds=new S,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,X.call(n);})));},this.isDirty=!1;}function K(t,e){var n=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===n.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=n;}Z.prototype.createRenderBatch=function(){var t=this,e=this.render,n=0;return this.render=function(){n++;},function(){t.render=e,n>0&&t.render();}},Z.prototype.setDirty=function(){return this.isDirty=!0,this},Z.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},Z.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Z.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Z.prototype.getAllIds=function(){return this._featureIds.values()},Z.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},Z.prototype.delete=function(t,e){var n=this;return void 0===e&&(e={}),H(t).forEach((function(t){n._featureIds.has(t)&&(n._featureIds.delete(t),n._selectedFeatureIds.delete(t),e.silent||-1===n._deletedFeaturesToEmit.indexOf(n._features[t])&&n._deletedFeaturesToEmit.push(n._features[t]),delete n._features[t],n.isDirty=!0);})),K(this,e),this},Z.prototype.get=function(t){return this._features[t]},Z.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},Z.prototype.select=function(t,e){var n=this;return void 0===e&&(e={}),H(t).forEach((function(t){n._selectedFeatureIds.has(t)||(n._selectedFeatureIds.add(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0));})),this},Z.prototype.deselect=function(t,e){var n=this;return void 0===e&&(e={}),H(t).forEach((function(t){n._selectedFeatureIds.has(t)&&(n._selectedFeatureIds.delete(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0));})),K(this,e),this},Z.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},Z.prototype.setSelected=function(t,e){var n=this;return void 0===e&&(e={}),t=H(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return -1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return !n._selectedFeatureIds.has(t)})),{silent:e.silent}),this},Z.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},Z.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Z.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Z.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},Z.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return {coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},Z.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},Z.prototype.setFeatureProperty=function(t,e,n){this.get(t).setProperty(e,n),this.featureChanged(t);},Z.prototype.storeMapConfig=function(){var t=this;m.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled());}));},Z.prototype.restoreMapConfig=function(){var t=this;Object.keys(this._mapInitialConfig).forEach((function(e){t._mapInitialConfig[e]?t.ctx.map[e].enable():t.ctx.map[e].disable();}));},Z.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var Q=function(){for(var t=arguments,e={},n=0;n<arguments.length;n++){var r=t[n];for(var o in r)tt.call(r,o)&&(e[o]=r[o]);}return e},tt=Object.prototype.hasOwnProperty;var et=["mode","feature","mouse"];function nt(e){var n=null,r=null,o={onRemove:function(){return e.map.off("load",o.connect),clearInterval(r),o.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.map=null,e.container=null,e.store=null,n&&n.parentNode&&n.parentNode.removeChild(n),n=null,this},connect:function(){e.map.off("load",o.connect),clearInterval(r),o.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners();},onAdd:function(i){var s=i.fire;return i.fire=function(t,e){var n=arguments;return 1===s.length&&1!==arguments.length&&(n=[Q({},{type:t},e)]),s.apply(i,n)},e.map=i,e.events=function(e){var n=Object.keys(e.options.modes).reduce((function(t,n){return t[n]=W(e.options.modes[n]),t}),{}),r={},o={},i={},a=null,s=null;i.drag=function(t,n){n({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:u.DRAG}),s.drag(t)):t.originalEvent.stopPropagation();},i.mousedrag=function(t){i.drag(t,(function(t){return !P(r,t)}));},i.touchdrag=function(t){i.drag(t,(function(t){return !F(o,t)}));},i.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return i.mousedrag(t);var n=I(t,e);t.featureTarget=n,s.mousemove(t);},i.mousedown=function(t){r={time:(new Date).getTime(),point:t.point};var n=I(t,e);t.featureTarget=n,s.mousedown(t);},i.mouseup=function(t){var n=I(t,e);t.featureTarget=n,P(r,{point:t.point,time:(new Date).getTime()})?s.click(t):s.mouseup(t);},i.mouseout=function(t){s.mouseout(t);},i.touchstart=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){o={time:(new Date).getTime(),point:t.point};var n=C.touch(t,null,e)[0];t.featureTarget=n,s.touchstart(t);}},i.touchmove=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled)return s.touchmove(t),i.touchdrag(t)},i.touchend=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){var n=C.touch(t,null,e)[0];t.featureTarget=n,F(o,{time:(new Date).getTime(),point:t.point})?s.tap(t):s.touchend(t);}};var c=function(t){return !(8===t||46===t||t>=48&&t<=57)};function l(r,o,i){void 0===i&&(i={}),s.stop();var u=n[r];if(void 0===u)throw new Error(r+" is not valid");a=r;var c=u(e,o);s=t(c,e),i.silent||e.map.fire(p.MODE_CHANGE,{mode:r}),e.store.setDirty(),e.store.render();}i.keydown=function(t){"mapboxgl-canvas"===(t.srcElement||t.target).classList[0]&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?c(t.keyCode)?s.keydown(t):49===t.keyCode&&e.options.controls.point?l(h.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?l(h.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&l(h.DRAW_POLYGON):(t.preventDefault(),s.trash()));},i.keyup=function(t){c(t.keyCode)&&s.keyup(t);},i.zoomend=function(){e.store.changeZoom();},i.data=function(t){if("style"===t.dataType){var n=e.setup,r=e.map,o=e.options,i=e.store;o.styles.some((function(t){return r.getLayer(t.id)}))||(n.addLayers(),i.setDirty(),i.render());}};var d={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return {start:function(){a=e.options.defaultMode,s=t(n[a](e),e);},changeMode:l,actionable:function(t){var n=!1;Object.keys(t).forEach((function(e){if(void 0===d[e])throw new Error("Invalid action type");d[e]!==t[e]&&(n=!0),d[e]=t[e];})),n&&e.map.fire(p.ACTIONABLE,{actions:d});},currentModeName:function(){return a},currentModeRender:function(t,e){return s.render(t,e)},fire:function(t,e){i[t]&&i[t](e);},addEventListeners:function(){e.map.on("mousemove",i.mousemove),e.map.on("mousedown",i.mousedown),e.map.on("mouseup",i.mouseup),e.map.on("data",i.data),e.map.on("touchmove",i.touchmove),e.map.on("touchstart",i.touchstart),e.map.on("touchend",i.touchend),e.container.addEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",i.keydown),e.container.addEventListener("keyup",i.keyup));},removeEventListeners:function(){e.map.off("mousemove",i.mousemove),e.map.off("mousedown",i.mousedown),e.map.off("mouseup",i.mouseup),e.map.off("data",i.data),e.map.off("touchmove",i.touchmove),e.map.off("touchstart",i.touchstart),e.map.off("touchend",i.touchend),e.container.removeEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",i.keydown),e.container.removeEventListener("keyup",i.keyup));},trash:function(t){s.trash(t);},combineFeatures:function(){s.combineFeatures();},uncombineFeatures:function(){s.uncombineFeatures();},getMode:function(){return a}}}(e),e.ui=function(t){var e={},n=null,r={mode:null,feature:null,mouse:null},o={mode:null,feature:null,mouse:null};function i(t){o=Q(o,t);}function s(){var e,n;if(t.container){var i=[],a=[];et.forEach((function(t){o[t]!==r[t]&&(i.push(t+"-"+r[t]),null!==o[t]&&a.push(t+"-"+o[t]));})),i.length>0&&(e=t.container.classList).remove.apply(e,i),a.length>0&&(n=t.container.classList).add.apply(n,a),r=Q(r,o);}}function u(t,e){void 0===e&&(e={});var r=document.createElement("button");return r.className=a.CONTROL_BUTTON+" "+e.className,r.setAttribute("title",e.title),e.container.appendChild(r),r.addEventListener("click",(function(r){if(r.preventDefault(),r.stopPropagation(),r.target===n)return l(),void e.onDeactivate();p(t),e.onActivate();}),!0),r}function l(){n&&(n.classList.remove(a.ACTIVE_BUTTON),n=null);}function p(t){l();var r=e[t];r&&r&&"trash"!==t&&(r.classList.add(a.ACTIVE_BUTTON),n=r);}return {setActiveButton:p,queueMapClasses:i,updateMapClasses:s,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),s();},addButtons:function(){var n=t.options.controls,r=document.createElement("div");return r.className=a.CONTROL_GROUP+" "+a.CONTROL_BASE,n?(n[c.LINE]&&(e[c.LINE]=u(c.LINE,{container:r,className:a.CONTROL_BUTTON_LINE,title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(h.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),n[c.POLYGON]&&(e[c.POLYGON]=u(c.POLYGON,{container:r,className:a.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(h.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),n[c.POINT]&&(e[c.POINT]=u(c.POINT,{container:r,className:a.CONTROL_BUTTON_POINT,title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(h.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),n.trash&&(e.trash=u("trash",{container:r,className:a.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){t.events.trash();}})),n.combine_features&&(e.combine_features=u("combineFeatures",{container:r,className:a.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){t.events.combineFeatures();}})),n.uncombine_features&&(e.uncombine_features=u("uncombineFeatures",{container:r,className:a.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){t.events.uncombineFeatures();}})),r):r},removeButtons:function(){Object.keys(e).forEach((function(t){var n=e[t];n.parentNode&&n.parentNode.removeChild(n),delete e[t];}));}}}(e),e.container=i.getContainer(),e.store=new Z(e),n=e.ui.addButtons(),e.options.boxSelect&&(i.boxZoom.disable(),i.dragPan.disable(),i.dragPan.enable()),i.loaded()?o.connect():(i.on("load",o.connect),r=setInterval((function(){i.loaded()&&o.connect();}),16)),e.events.start(),n},addLayers:function(){e.map.addSource(s.COLD,{data:{type:l.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(s.HOT,{data:{type:l.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.options.styles.forEach((function(t){e.map.addLayer(t);})),e.store.setDirty(!0),e.store.render();},removeLayers:function(){e.options.styles.forEach((function(t){e.map.getLayer(t.id)&&e.map.removeLayer(t.id);})),e.map.getSource(s.COLD)&&e.map.removeSource(s.COLD),e.map.getSource(s.HOT)&&e.map.removeSource(s.HOT);}};return e.setup=o,o}function rt(t){return function(e){var n=e.featureTarget;return !!n&&(!!n.properties&&n.properties.meta===t)}}function ot(t){return !!t.featureTarget&&(!!t.featureTarget.properties&&(t.featureTarget.properties.active===y.ACTIVE&&t.featureTarget.properties.meta===g.FEATURE))}function it(t){return !!t.featureTarget&&(!!t.featureTarget.properties&&(t.featureTarget.properties.active===y.INACTIVE&&t.featureTarget.properties.meta===g.FEATURE))}function at(t){return void 0===t.featureTarget}function st(t){var e=t.featureTarget;return !!e&&(!!e.properties&&e.properties.meta===g.VERTEX)}function ut(t){return !!t.originalEvent&&!0===t.originalEvent.shiftKey}function ct(t){return 27===t.keyCode}function lt(t){return 13===t.keyCode}var ht=pt;function pt(t,e){this.x=t,this.y=e;}function dt(t,e){var n=e.getBoundingClientRect();return new ht(t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0))}function ft(t,e,n,r){return {type:l.FEATURE,properties:{meta:g.VERTEX,parent:t,coord_path:n,active:r?y.ACTIVE:y.INACTIVE},geometry:{type:l.POINT,coordinates:e}}}function gt(t,e,n){void 0===e&&(e={}),void 0===n&&(n=null);var r,o=t.geometry,i=o.type,a=o.coordinates,s=t.properties&&t.properties.id,u=[];function c(t,n){var r="",o=null;t.forEach((function(t,i){var a=null!=n?n+"."+i:String(i),c=ft(s,t,a,h(a));if(e.midpoints&&o){var p=function(t,e,n){var r=e.geometry.coordinates,o=n.geometry.coordinates;if(r[1]>_||r[1]<v||o[1]>_||o[1]<v)return null;var i={lng:(r[0]+o[0])/2,lat:(r[1]+o[1])/2};return {type:l.FEATURE,properties:{meta:g.MIDPOINT,parent:t,lng:i.lng,lat:i.lat,coord_path:n.properties.coord_path},geometry:{type:l.POINT,coordinates:[i.lng,i.lat]}}}(s,o,c);p&&u.push(p);}o=c;var d=JSON.stringify(t);r!==d&&u.push(c),0===i&&(r=d);}));}function h(t){return !!e.selectedPaths&&-1!==e.selectedPaths.indexOf(t)}return i===l.POINT?u.push(ft(s,a,n,h(n))):i===l.POLYGON?a.forEach((function(t,e){c(t,null!==n?n+"."+e:String(e));})):i===l.LINE_STRING?c(a,n):0===i.indexOf(l.MULTI_PREFIX)&&(r=i.replace(l.MULTI_PREFIX,""),a.forEach((function(n,o){var i={type:l.FEATURE,properties:t.properties,geometry:{type:r,coordinates:n}};u=u.concat(gt(i,e,o));}))),u}pt.prototype={clone:function(){return new pt(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,o=n*this.x+e*this.y;return this.x=r,this.y=o,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),o=e.x+n*(this.x-e.x)-r*(this.y-e.y),i=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=o,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},pt.convert=function(t){return t instanceof pt?t:Array.isArray(t)?new pt(t[0],t[1]):t};var yt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable();}),0);},mt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable();}),0);},vt=function(t){if(!t||!t.type)return null;var e=_t[t.type];if(!e)return null;if("geometry"===e)return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]};if("feature"===e)return {type:"FeatureCollection",features:[t]};if("featurecollection"===e)return t},_t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};var bt=function(t){if(!t)return [];var e=function t(e){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.reduce((function(e,n){return e.concat(t(n))}),[]),e;case"Feature":return e.geometry?t(e.geometry).map((function(t){var n={type:"Feature",properties:JSON.parse(JSON.stringify(e.properties)),geometry:t};return void 0!==e.id&&(n.id=e.id),n})):e;case"MultiPoint":return e.coordinates.map((function(t){return {type:"Point",coordinates:t}}));case"MultiPolygon":return e.coordinates.map((function(t){return {type:"Polygon",coordinates:t}}));case"MultiLineString":return e.coordinates.map((function(t){return {type:"LineString",coordinates:t}}));case"GeometryCollection":return e.geometries.map(t).reduce((function(t,e){return t.concat(e)}),[]);case"Point":case"Polygon":case"LineString":return [e]}}(vt(t)),n=[];return e.features.forEach((function(t){t.geometry&&(n=n.concat(function t(e){return Array.isArray(e)&&e.length&&"number"==typeof e[0]?[e]:e.reduce((function(e,n){return Array.isArray(n)&&Array.isArray(n[0])?e.concat(t(n)):(e.push(n),e)}),[])}(t.geometry.coordinates)));})),n},Et=R((function(t){var e=t.exports=function(t){return new n(t)};function n(t){this.value=t;}function r(t,e,n){var r=[],a=[],l=!0;return function t(h){var p=n?o(h):h,d={},f=!0,g={node:p,node_:h,path:[].concat(r),parent:a[a.length-1],parents:a,key:r.slice(-1)[0],isRoot:0===r.length,level:r.length,circular:null,update:function(t,e){g.isRoot||(g.parent.node[g.key]=t),g.node=t,e&&(f=!1);},delete:function(t){delete g.parent.node[g.key],t&&(f=!1);},remove:function(t){s(g.parent.node)?g.parent.node.splice(g.key,1):delete g.parent.node[g.key],t&&(f=!1);},keys:null,before:function(t){d.before=t;},after:function(t){d.after=t;},pre:function(t){d.pre=t;},post:function(t){d.post=t;},stop:function(){l=!1;},block:function(){f=!1;}};if(!l)return g;function y(){if("object"==typeof g.node&&null!==g.node){g.keys&&g.node_===g.node||(g.keys=i(g.node)),g.isLeaf=0==g.keys.length;for(var t=0;t<a.length;t++)if(a[t].node_===h){g.circular=a[t];break}}else g.isLeaf=!0,g.keys=null;g.notLeaf=!g.isLeaf,g.notRoot=!g.isRoot;}y();var m=e.call(g,g.node);return void 0!==m&&g.update&&g.update(m),d.before&&d.before.call(g,g.node),f?("object"!=typeof g.node||null===g.node||g.circular||(a.push(g),y(),u(g.keys,(function(e,o){r.push(e),d.pre&&d.pre.call(g,g.node[e],e);var i=t(g.node[e]);n&&c.call(g.node,e)&&(g.node[e]=i.node),i.isLast=o==g.keys.length-1,i.isFirst=0==o,d.post&&d.post.call(g,i),r.pop();})),a.pop()),d.after&&d.after.call(g,g.node),g):g}(t).node}function o(t){if("object"==typeof t&&null!==t){var e;if(s(t))e=[];else if("[object Date]"===a(t))e=new Date(t.getTime?t.getTime():t);else if(function(t){return "[object RegExp]"===a(t)}(t))e=new RegExp(t);else if(function(t){return "[object Error]"===a(t)}(t))e={message:t.message};else if(function(t){return "[object Boolean]"===a(t)}(t))e=new Boolean(t);else if(function(t){return "[object Number]"===a(t)}(t))e=new Number(t);else if(function(t){return "[object String]"===a(t)}(t))e=new String(t);else if(Object.create&&Object.getPrototypeOf)e=Object.create(Object.getPrototypeOf(t));else if(t.constructor===Object)e={};else {var n=t.constructor&&t.constructor.prototype||t.__proto__||{},r=function(){};r.prototype=n,e=new r;}return u(i(t),(function(n){e[n]=t[n];})),e}return t}n.prototype.get=function(t){for(var e=this.value,n=0;n<t.length;n++){var r=t[n];if(!e||!c.call(e,r)){e=void 0;break}e=e[r];}return e},n.prototype.has=function(t){for(var e=this.value,n=0;n<t.length;n++){var r=t[n];if(!e||!c.call(e,r))return !1;e=e[r];}return !0},n.prototype.set=function(t,e){for(var n=this.value,r=0;r<t.length-1;r++){var o=t[r];c.call(n,o)||(n[o]={}),n=n[o];}return n[t[r]]=e,e},n.prototype.map=function(t){return r(this.value,t,!0)},n.prototype.forEach=function(t){return this.value=r(this.value,t,!1),this.value},n.prototype.reduce=function(t,e){var n=1===arguments.length,r=n?this.value:e;return this.forEach((function(e){this.isRoot&&n||(r=t.call(this,r,e));})),r},n.prototype.paths=function(){var t=[];return this.forEach((function(e){t.push(this.path);})),t},n.prototype.nodes=function(){var t=[];return this.forEach((function(e){t.push(this.node);})),t},n.prototype.clone=function(){var t=[],e=[];return function n(r){for(var a=0;a<t.length;a++)if(t[a]===r)return e[a];if("object"==typeof r&&null!==r){var s=o(r);return t.push(r),e.push(s),u(i(r),(function(t){s[t]=n(r[t]);})),t.pop(),e.pop(),s}return r}(this.value)};var i=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};function a(t){return Object.prototype.toString.call(t)}var s=Array.isArray||function(t){return "[object Array]"===Object.prototype.toString.call(t)},u=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t);};u(i(n.prototype),(function(t){e[t]=function(e){var r=[].slice.call(arguments,1),o=new n(e);return o[t].apply(o,r)};}));var c=Object.hasOwnProperty||function(t,e){return e in t};})),St=Tt;function Tt(t){if(!(this instanceof Tt))return new Tt(t);this._bbox=t||[1/0,1/0,-1/0,-1/0],this._valid=!!t;}Tt.prototype.include=function(t){return this._valid=!0,this._bbox[0]=Math.min(this._bbox[0],t[0]),this._bbox[1]=Math.min(this._bbox[1],t[1]),this._bbox[2]=Math.max(this._bbox[2],t[0]),this._bbox[3]=Math.max(this._bbox[3],t[1]),this},Tt.prototype.equals=function(t){var e;return e=t instanceof Tt?t.bbox():t,this._bbox[0]==e[0]&&this._bbox[1]==e[1]&&this._bbox[2]==e[2]&&this._bbox[3]==e[3]},Tt.prototype.center=function(t){return this._valid?[(this._bbox[0]+this._bbox[2])/2,(this._bbox[1]+this._bbox[3])/2]:null},Tt.prototype.union=function(t){var e;return this._valid=!0,e=t instanceof Tt?t.bbox():t,this._bbox[0]=Math.min(this._bbox[0],e[0]),this._bbox[1]=Math.min(this._bbox[1],e[1]),this._bbox[2]=Math.max(this._bbox[2],e[2]),this._bbox[3]=Math.max(this._bbox[3],e[3]),this},Tt.prototype.bbox=function(){return this._valid?this._bbox:null},Tt.prototype.contains=function(t){if(!t)return this._fastContains();if(!this._valid)return null;var e=t[0],n=t[1];return this._bbox[0]<=e&&this._bbox[1]<=n&&this._bbox[2]>=e&&this._bbox[3]>=n},Tt.prototype.intersect=function(t){return this._valid?(e=t instanceof Tt?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]<e[0]||this._bbox[3]<e[1]||this._bbox[1]>e[3])):null;var e;},Tt.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var t="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",t)},Tt.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var Ct={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},Ot=Object.keys(Ct),It=function(t){return xt(t).bbox()};function xt(t){for(var e=St(),n=bt(t),r=0;r<n.length;r++)e.include(n[r]);return e}It.polygon=function(t){return xt(t).polygon()},It.bboxify=function(t){return Et(t).map((function(t){t&&(Ot.some((function(e){return !!t[e]&&-1!==Ct[e].indexOf(t.type)}))&&(t.bbox=xt(t).bbox(),this.update(t)));}))};var Lt=-90,Mt=90,Nt=v,Pt=_,wt=-270,At=270;function Ft(t,e){var n=Lt,r=Mt,o=Lt,i=Mt,a=At,s=wt;t.forEach((function(t){var e=It(t),u=e[1],c=e[3],l=e[0],h=e[2];u>n&&(n=u),c<r&&(r=c),c>o&&(o=c),u<i&&(i=u),l<a&&(a=l),h>s&&(s=h);}));var u=e;return n+u.lat>Pt&&(u.lat=Pt-n),o+u.lat>Mt&&(u.lat=Mt-o),r+u.lat<Nt&&(u.lat=Nt-r),i+u.lat<Lt&&(u.lat=Lt-i),a+u.lng<=wt&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=At&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function kt(t,e){var n=Ft(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,r=t.getCoordinates(),o=function(t){var e={lng:t[0]+n.lng,lat:t[1]+n.lat};return [e.lng,e.lat]},i=function(t){return t.map((function(t){return o(t)}))};t.type===l.POINT?e=o(r):t.type===l.LINE_STRING||t.type===l.MULTI_POINT?e=r.map(o):t.type===l.POLYGON||t.type===l.MULTI_LINE_STRING?e=r.map(i):t.type===l.MULTI_POLYGON&&(e=r.map((function(t){return t.map((function(t){return i(t)}))}))),t.incomingCoords(e);}));}var Rt={onSetup:function(t){var e=this,n={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireUpdate:function(){this.map.fire(p.UPDATE,{action:d,features:this.getSelected().map((function(t){return t.toGeoJSON()}))});},fireActionable:function(){var t=this,e=this.getSelected(),n=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),r=!1;if(e.length>1){r=!0;var o=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==o&&(r=!1);}));}var i=n.length>0,a=e.length>0;this.setActionableState({combineFeatures:r,uncombineFeatures:i,trash:a});},getUniqueIds:function(t){return t.length?t.map((function(t){return t.properties.id})).filter((function(t){return void 0!==t})).reduce((function(t,e){return t.add(e),t}),new S).values():[]},stopExtendedInteractions:function(t){t.boxSelectElement&&(t.boxSelectElement.parentNode&&t.boxSelectElement.parentNode.removeChild(t.boxSelectElement),t.boxSelectElement=null),this.map.dragPan.enable(),t.boxSelecting=!1,t.canBoxSelect=!1,t.dragMoving=!1,t.canDragMove=!1;},onStop:function(){yt(this);},onMouseMove:function(t){return this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return !t.dragMoving||this.fireUpdate()}};Rt.onTap=Rt.onClick=function(t,e){return at(e)?this.clickAnywhere(t,e):rt(g.VERTEX)(e)?this.clickOnVertex(t,e):function(t){return !!t.featureTarget&&(!!t.featureTarget.properties&&t.featureTarget.properties.meta===g.FEATURE)}(e)?this.clickOnFeature(t,e):void 0},Rt.clickAnywhere=function(t){var e=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(t){return e.doRender(t)}))),yt(this),this.stopExtendedInteractions(t);},Rt.clickOnVertex=function(t,e){this.changeMode(h.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:u.MOVE});},Rt.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat;},Rt.clickOnFeature=function(t,e){var n=this;mt(this),this.stopExtendedInteractions(t);var r=ut(e),o=this.getSelectedIds(),i=e.featureTarget.properties.id,a=this.isSelected(i);if(!r&&a&&this.getFeature(i).type!==l.POINT)return this.changeMode(h.DIRECT_SELECT,{featureId:i});a&&r?(this.deselect(i),this.updateUIClasses({mouse:u.POINTER}),1===o.length&&yt(this)):!a&&r?(this.select(i),this.updateUIClasses({mouse:u.MOVE})):a||r||(o.forEach((function(t){return n.doRender(t)})),this.setSelected(i),this.updateUIClasses({mouse:u.MOVE})),this.doRender(i);},Rt.onMouseDown=function(t,e){return ot(e)?this.startOnActiveFeature(t,e):this.drawConfig.boxSelect&&function(t){return !!t.originalEvent&&(!!t.originalEvent.shiftKey&&0===t.originalEvent.button)}(e)?this.startBoxSelect(t,e):void 0},Rt.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=dt(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0;},Rt.onTouchStart=function(t,e){if(ot(e))return this.startOnActiveFeature(t,e)},Rt.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},Rt.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:u.ADD}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add(a.BOX_SELECT),this.map.getContainer().appendChild(t.boxSelectElement));var n=dt(e.originalEvent,this.map.getContainer()),r=Math.min(t.boxSelectStartLocation.x,n.x),o=Math.max(t.boxSelectStartLocation.x,n.x),i=Math.min(t.boxSelectStartLocation.y,n.y),s=Math.max(t.boxSelectStartLocation.y,n.y),c="translate("+r+"px, "+i+"px)";t.boxSelectElement.style.transform=c,t.boxSelectElement.style.WebkitTransform=c,t.boxSelectElement.style.width=o-r+"px",t.boxSelectElement.style.height=s-i+"px";},Rt.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};kt(this.getSelected(),n),t.dragMoveLocation=e.lngLat;},Rt.onMouseUp=function(t,e){var n=this;if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){var r=[t.boxSelectStartLocation,dt(e.originalEvent,this.map.getContainer())],o=this.featuresAt(null,r,"click"),i=this.getUniqueIds(o).filter((function(t){return !n.isSelected(t)}));i.length&&(this.select(i),i.forEach((function(t){return n.doRender(t)})),this.updateUIClasses({mouse:u.MOVE}));}this.stopExtendedInteractions(t);},Rt.toDisplayFeatures=function(t,e,n){e.properties.active=this.isSelected(e.properties.id)?y.ACTIVE:y.INACTIVE,n(e),this.fireActionable(),e.properties.active===y.ACTIVE&&e.geometry.type!==l.POINT&>(e).forEach(n);},Rt.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable();},Rt.onCombineFeatures=function(){var t=this.getSelected();if(!(0===t.length||t.length<2)){for(var e=[],n=[],r=t[0].type.replace("Multi",""),o=0;o<t.length;o++){var i=t[o];if(i.type.replace("Multi","")!==r)return;i.type.includes("Multi")?i.getCoordinates().forEach((function(t){e.push(t);})):e.push(i.getCoordinates()),n.push(i.toGeoJSON());}if(n.length>1){var a=this.newFeature({type:l.FEATURE,properties:n[0].properties,geometry:{type:"Multi"+r,coordinates:e}});this.addFeature(a),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([a.id]),this.map.fire(p.COMBINE_FEATURES,{createdFeatures:[a.toGeoJSON()],deletedFeatures:n});}this.fireActionable();}},Rt.onUncombineFeatures=function(){var t=this,e=this.getSelected();if(0!==e.length){for(var n=[],r=[],o=function(o){var i=e[o];t.isInstanceOf("MultiFeature",i)&&(i.getFeatures().forEach((function(e){t.addFeature(e),e.properties=i.properties,n.push(e.toGeoJSON()),t.select([e.id]);})),t.deleteFeature(i.id,{silent:!0}),r.push(i.toGeoJSON()));},i=0;i<e.length;i++)o(i);n.length>1&&this.map.fire(p.UNCOMBINE_FEATURES,{createdFeatures:n,deletedFeatures:r}),this.fireActionable();}};var Ut=rt(g.VERTEX),jt=rt(g.MIDPOINT),Dt={fireUpdate:function(){this.map.fire(p.UPDATE,{action:f,features:this.getSelected().map((function(t){return t.toGeoJSON()}))});},fireActionable:function(t){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:t.selectedCoordPaths.length>0});},startDragging:function(t,e){this.map.dragPan.disable(),t.canDragMove=!0,t.dragMoveLocation=e.lngLat;},stopDragging:function(t){this.map.dragPan.enable(),t.dragMoving=!1,t.canDragMove=!1,t.dragMoveLocation=null;},onVertex:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties,r=t.selectedCoordPaths.indexOf(n.coord_path);ut(e)||-1!==r?ut(e)&&-1===r&&t.selectedCoordPaths.push(n.coord_path):t.selectedCoordPaths=[n.coord_path];var o=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(o);},onMidpoint:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties;t.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),t.selectedCoordPaths=[n.coord_path];},pathsToCoordinates:function(t,e){return e.map((function(e){return {feature_id:t,coord_path:e}}))},onFeature:function(t,e){0===t.selectedCoordPaths.length?this.startDragging(t,e):this.stopDragging(t);},dragFeature:function(t,e,n){kt(this.getSelected(),n),t.dragMoveLocation=e.lngLat;},dragVertex:function(t,e,n){for(var r=t.selectedCoordPaths.map((function(e){return t.feature.getCoordinate(e)})),o=Ft(r.map((function(t){return {type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:t}}})),n),i=0;i<r.length;i++){var a=r[i];t.feature.updateCoordinate(t.selectedCoordPaths[i],a[0]+o.lng,a[1]+o.lat);}},clickNoTarget:function(){this.changeMode(h.SIMPLE_SELECT);},clickInactive:function(){this.changeMode(h.SIMPLE_SELECT);},clickActiveFeature:function(t){t.selectedCoordPaths=[],this.clearSelectedCoordinates(),t.feature.changed();},onSetup:function(t){var e=t.featureId,n=this.getFeature(e);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===l.POINT)throw new TypeError("direct_select mode doesn't handle point features");var r={featureId:e,feature:n,dragMoveLocation:t.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:t.coordPath?[t.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(e,r.selectedCoordPaths)),this.setSelected(e),mt(this),this.setActionableState({trash:!0}),r},onStop:function(){yt(this),this.clearSelectedCoordinates();},toDisplayFeatures:function(t,e,n){t.featureId===e.properties.id?(e.properties.active=y.ACTIVE,n(e),gt(e,{map:this.map,midpoints:!0,selectedPaths:t.selectedCoordPaths}).forEach(n)):(e.properties.active=y.INACTIVE,n(e)),this.fireActionable(t);},onTrash:function(t){t.selectedCoordPaths.sort((function(t,e){return e.localeCompare(t,"en",{numeric:!0})})).forEach((function(e){return t.feature.removeCoordinate(e)})),this.fireUpdate(),t.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(t),!1===t.feature.isValid()&&(this.deleteFeature([t.featureId]),this.changeMode(h.SIMPLE_SELECT,{}));},onMouseMove:function(t,e){var n=ot(e),r=Ut(e),o=0===t.selectedCoordPaths.length;return n&&o?this.updateUIClasses({mouse:u.MOVE}):r&&!o?this.updateUIClasses({mouse:u.MOVE}):this.updateUIClasses({mouse:u.NONE}),this.stopDragging(t),!0},onMouseOut:function(t){return t.dragMoving&&this.fireUpdate(),!0}};Dt.onTouchStart=Dt.onMouseDown=function(t,e){return Ut(e)?this.onVertex(t,e):ot(e)?this.onFeature(t,e):jt(e)?this.onMidpoint(t,e):void 0},Dt.onDrag=function(t,e){if(!0===t.canDragMove){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};t.selectedCoordPaths.length>0?this.dragVertex(t,e,n):this.dragFeature(t,e,n),t.dragMoveLocation=e.lngLat;}},Dt.onClick=function(t,e){return at(e)?this.clickNoTarget(t,e):ot(e)?this.clickActiveFeature(t,e):it(e)?this.clickInactive(t,e):void this.stopDragging(t)},Dt.onTap=function(t,e){return at(e)?this.clickNoTarget(t,e):ot(e)?this.clickActiveFeature(t,e):it(e)?this.clickInactive(t,e):void 0},Dt.onTouchEnd=Dt.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t);};var Vt={};function Bt(t,e){return !!t.lngLat&&(t.lngLat.lng===e[0]&&t.lngLat.lat===e[1])}Vt.onSetup=function(){var t=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:[]}});return this.addFeature(t),this.clearSelectedFeatures(),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.POINT),this.setActionableState({trash:!0}),{point:t}},Vt.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT);},Vt.onTap=Vt.onClick=function(t,e){this.updateUIClasses({mouse:u.MOVE}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(p.CREATE,{features:[t.point.toGeoJSON()]}),this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.point.id]});},Vt.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0});},Vt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.point.id;if(e.properties.active=r?y.ACTIVE:y.INACTIVE,!r)return n(e)},Vt.onTrash=Vt.stopDrawingAndRemove,Vt.onKeyUp=function(t,e){if(ct(e)||lt(e))return this.stopDrawingAndRemove(t,e)};var Gt={onSetup:function(){var t=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.POLYGON,coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),mt(this),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.POLYGON),this.setActionableState({trash:!0}),{polygon:t,currentVertexPosition:0}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Bt(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:u.ADD}),t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),t.currentVertexPosition++,t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat);},clickOnVertex:function(t){return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),st(e)&&this.updateUIClasses({mouse:u.POINTER});}};Gt.onTap=Gt.onClick=function(t,e){return st(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},Gt.onKeyUp=function(t,e){ct(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT)):lt(e)&&this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.polygon.id]});},Gt.onStop=function(t){this.updateUIClasses({mouse:u.NONE}),yt(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate("0."+t.currentVertexPosition),t.polygon.isValid()?this.map.fire(p.CREATE,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT,{},{silent:!0})));},Gt.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.polygon.id;if(e.properties.active=r?y.ACTIVE:y.INACTIVE,!r)return n(e);if(0!==e.geometry.coordinates.length){var o=e.geometry.coordinates[0].length;if(!(o<3)){if(e.properties.meta=g.FEATURE,n(ft(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1)),o>3){var i=e.geometry.coordinates[0].length-3;n(ft(t.polygon.id,e.geometry.coordinates[0][i],"0."+i,!1));}if(o<=4){var a=[[e.geometry.coordinates[0][0][0],e.geometry.coordinates[0][0][1]],[e.geometry.coordinates[0][1][0],e.geometry.coordinates[0][1][1]]];if(n({type:l.FEATURE,properties:e.properties,geometry:{coordinates:a,type:l.LINE_STRING}}),3===o)return}return n(e)}}},Gt.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT);};var $t={onSetup:function(t){var e,n,r=(t=t||{}).featureId,o="forward";if(r){if(!(e=this.getFeature(r)))throw new Error("Could not find a feature with the provided featureId");var i=t.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");var a=e.coordinates.length-1;if(e.coordinates[a][0]===i[0]&&e.coordinates[a][1]===i[1])n=a+1,e.addCoordinate.apply(e,[n].concat(e.coordinates[a]));else {if(e.coordinates[0][0]!==i[0]||e.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");o="backwards",n=0,e.addCoordinate.apply(e,[n].concat(e.coordinates[0]));}}else e=this.newFeature({type:l.FEATURE,properties:{},geometry:{type:l.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(e);return this.clearSelectedFeatures(),mt(this),this.updateUIClasses({mouse:u.ADD}),this.activateUIButton(c.LINE),this.setActionableState({trash:!0}),{line:e,currentVertexPosition:n,direction:o}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Bt(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&Bt(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:u.ADD}),t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),"forward"===t.direction?(t.currentVertexPosition++,t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)):t.line.addCoordinate(0,e.lngLat.lng,e.lngLat.lat);},clickOnVertex:function(t){return this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),st(e)&&this.updateUIClasses({mouse:u.POINTER});}};$t.onTap=$t.onClick=function(t,e){if(st(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e);},$t.onKeyUp=function(t,e){lt(e)?this.changeMode(h.SIMPLE_SELECT,{featureIds:[t.line.id]}):ct(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT));},$t.onStop=function(t){yt(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(""+t.currentVertexPosition),t.line.isValid()?this.map.fire(p.CREATE,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT,{},{silent:!0})));},$t.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(h.SIMPLE_SELECT);},$t.toDisplayFeatures=function(t,e,n){var r=e.properties.id===t.line.id;if(e.properties.active=r?y.ACTIVE:y.INACTIVE,!r)return n(e);e.geometry.coordinates.length<2||(e.properties.meta=g.FEATURE,n(ft(t.line.id,e.geometry.coordinates["forward"===t.direction?e.geometry.coordinates.length-2:1],""+("forward"===t.direction?e.geometry.coordinates.length-2:1),!1)),n(e));};var Jt={simple_select:Rt,direct_select:Dt,draw_point:Vt,draw_polygon:Gt,draw_line_string:$t},zt={defaultMode:h.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}],modes:Jt,controls:{},userProperties:!1},Yt={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},qt={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function Wt(t,e){return t.map((function(t){return t.source?t:Q(t,{id:t.id+"."+e,source:"hot"===e?s.HOT:s.COLD})}))}var Ht=R((function(t,e){var n=200,r="__lodash_hash_undefined__",o=1,i=2,a=9007199254740991,s="[object Arguments]",u="[object Array]",c="[object AsyncFunction]",l="[object Boolean]",h="[object Date]",p="[object Error]",d="[object Function]",f="[object GeneratorFunction]",g="[object Map]",y="[object Number]",m="[object Null]",v="[object Object]",_="[object Proxy]",b="[object RegExp]",E="[object Set]",S="[object String]",T="[object Symbol]",C="[object Undefined]",O="[object ArrayBuffer]",I="[object DataView]",x=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,M={};M["[object Float32Array]"]=M["[object Float64Array]"]=M["[object Int8Array]"]=M["[object Int16Array]"]=M["[object Int32Array]"]=M["[object Uint8Array]"]=M["[object Uint8ClampedArray]"]=M["[object Uint16Array]"]=M["[object Uint32Array]"]=!0,M[s]=M[u]=M[O]=M[l]=M[I]=M[h]=M[p]=M[d]=M[g]=M[y]=M[v]=M[b]=M[E]=M[S]=M["[object WeakMap]"]=!1;var N="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,P="object"==typeof self&&self&&self.Object===Object&&self,w=N||P||Function("return this")(),A=e&&!e.nodeType&&e,F=A&&t&&!t.nodeType&&t,k=F&&F.exports===A,R=k&&N.process,U=function(){try{return R&&R.binding&&R.binding("util")}catch(t){}}(),j=U&&U.isTypedArray;function D(t,e){for(var n=-1,r=null==t?0:t.length;++n<r;)if(e(t[n],n,t))return !0;return !1}function V(t){var e=-1,n=Array(t.size);return t.forEach((function(t,r){n[++e]=[r,t];})),n}function B(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t;})),n}var G,$,J,z=Array.prototype,Y=Function.prototype,q=Object.prototype,W=w["__core-js_shared__"],H=Y.toString,X=q.hasOwnProperty,Z=(G=/[^.]+$/.exec(W&&W.keys&&W.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"",K=q.toString,Q=RegExp("^"+H.call(X).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),tt=k?w.Buffer:void 0,et=w.Symbol,nt=w.Uint8Array,rt=q.propertyIsEnumerable,ot=z.splice,it=et?et.toStringTag:void 0,at=Object.getOwnPropertySymbols,st=tt?tt.isBuffer:void 0,ut=($=Object.keys,J=Object,function(t){return $(J(t))}),ct=Ut(w,"DataView"),lt=Ut(w,"Map"),ht=Ut(w,"Promise"),pt=Ut(w,"Set"),dt=Ut(w,"WeakMap"),ft=Ut(Object,"create"),gt=Bt(ct),yt=Bt(lt),mt=Bt(ht),vt=Bt(pt),_t=Bt(dt),bt=et?et.prototype:void 0,Et=bt?bt.valueOf:void 0;function St(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]);}}function Tt(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]);}}function Ct(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]);}}function Ot(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new Ct;++e<n;)this.add(t[e]);}function It(t){var e=this.__data__=new Tt(t);this.size=e.size;}function xt(t,e){var n=Jt(t),r=!n&&$t(t),o=!n&&!r&&zt(t),i=!n&&!r&&!o&&Xt(t),a=n||r||o||i,s=a?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],u=s.length;for(var c in t)!e&&!X.call(t,c)||a&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Vt(c,u))||s.push(c);return s}function Lt(t,e){for(var n=t.length;n--;)if(Gt(t[n][0],e))return n;return -1}function Mt(t){return null==t?void 0===t?C:m:it&&it in Object(t)?function(t){var e=X.call(t,it),n=t[it];try{t[it]=void 0;var r=!0;}catch(t){}var o=K.call(t);r&&(e?t[it]=n:delete t[it]);return o}(t):function(t){return K.call(t)}(t)}function Nt(t){return Ht(t)&&Mt(t)==s}function Pt(t,e,n,r,a){return t===e||(null==t||null==e||!Ht(t)&&!Ht(e)?t!=t&&e!=e:function(t,e,n,r,a,c){var d=Jt(t),f=Jt(e),m=d?u:Dt(t),_=f?u:Dt(e),C=(m=m==s?v:m)==v,x=(_=_==s?v:_)==v,L=m==_;if(L&&zt(t)){if(!zt(e))return !1;d=!0,C=!1;}if(L&&!C)return c||(c=new It),d||Xt(t)?Ft(t,e,n,r,a,c):function(t,e,n,r,a,s,u){switch(n){case I:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return !1;t=t.buffer,e=e.buffer;case O:return !(t.byteLength!=e.byteLength||!s(new nt(t),new nt(e)));case l:case h:case y:return Gt(+t,+e);case p:return t.name==e.name&&t.message==e.message;case b:case S:return t==e+"";case g:var c=V;case E:var d=r&o;if(c||(c=B),t.size!=e.size&&!d)return !1;var f=u.get(t);if(f)return f==e;r|=i,u.set(t,e);var m=Ft(c(t),c(e),r,a,s,u);return u.delete(t),m;case T:if(Et)return Et.call(t)==Et.call(e)}return !1}(t,e,m,n,r,a,c);if(!(n&o)){var M=C&&X.call(t,"__wrapped__"),N=x&&X.call(e,"__wrapped__");if(M||N){var P=M?t.value():t,w=N?e.value():e;return c||(c=new It),a(P,w,n,r,c)}}if(!L)return !1;return c||(c=new It),function(t,e,n,r,i,a){var s=n&o,u=kt(t),c=u.length,l=kt(e).length;if(c!=l&&!s)return !1;var h=c;for(;h--;){var p=u[h];if(!(s?p in e:X.call(e,p)))return !1}var d=a.get(t);if(d&&a.get(e))return d==e;var f=!0;a.set(t,e),a.set(e,t);var g=s;for(;++h<c;){p=u[h];var y=t[p],m=e[p];if(r)var v=s?r(m,y,p,e,t,a):r(y,m,p,t,e,a);if(!(void 0===v?y===m||i(y,m,n,r,a):v)){f=!1;break}g||(g="constructor"==p);}if(f&&!g){var _=t.constructor,b=e.constructor;_!=b&&"constructor"in t&&"constructor"in e&&!("function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b)&&(f=!1);}return a.delete(t),a.delete(e),f}(t,e,n,r,a,c)}(t,e,n,r,Pt,a))}function wt(t){return !(!Wt(t)||function(t){return !!Z&&Z in t}(t))&&(Yt(t)?Q:x).test(Bt(t))}function At(t){if(n=(e=t)&&e.constructor,r="function"==typeof n&&n.prototype||q,e!==r)return ut(t);var e,n,r,o=[];for(var i in Object(t))X.call(t,i)&&"constructor"!=i&&o.push(i);return o}function Ft(t,e,n,r,a,s){var u=n&o,c=t.length,l=e.length;if(c!=l&&!(u&&l>c))return !1;var h=s.get(t);if(h&&s.get(e))return h==e;var p=-1,d=!0,f=n&i?new Ot:void 0;for(s.set(t,e),s.set(e,t);++p<c;){var g=t[p],y=e[p];if(r)var m=u?r(y,g,p,e,t,s):r(g,y,p,t,e,s);if(void 0!==m){if(m)continue;d=!1;break}if(f){if(!D(e,(function(t,e){if(o=e,!f.has(o)&&(g===t||a(g,t,n,r,s)))return f.push(e);var o;}))){d=!1;break}}else if(g!==y&&!a(g,y,n,r,s)){d=!1;break}}return s.delete(t),s.delete(e),d}function kt(t){return function(t,e,n){var r=e(t);return Jt(t)?r:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(r,n(t))}(t,Zt,jt)}function Rt(t,e){var n,r,o=t.__data__;return ("string"==(r=typeof(n=e))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function Ut(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return wt(n)?n:void 0}St.prototype.clear=function(){this.__data__=ft?ft(null):{},this.size=0;},St.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},St.prototype.get=function(t){var e=this.__data__;if(ft){var n=e[t];return n===r?void 0:n}return X.call(e,t)?e[t]:void 0},St.prototype.has=function(t){var e=this.__data__;return ft?void 0!==e[t]:X.call(e,t)},St.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=ft&&void 0===e?r:e,this},Tt.prototype.clear=function(){this.__data__=[],this.size=0;},Tt.prototype.delete=function(t){var e=this.__data__,n=Lt(e,t);return !(n<0)&&(n==e.length-1?e.pop():ot.call(e,n,1),--this.size,!0)},Tt.prototype.get=function(t){var e=this.__data__,n=Lt(e,t);return n<0?void 0:e[n][1]},Tt.prototype.has=function(t){return Lt(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var n=this.__data__,r=Lt(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this},Ct.prototype.clear=function(){this.size=0,this.__data__={hash:new St,map:new(lt||Tt),string:new St};},Ct.prototype.delete=function(t){var e=Rt(this,t).delete(t);return this.size-=e?1:0,e},Ct.prototype.get=function(t){return Rt(this,t).get(t)},Ct.prototype.has=function(t){return Rt(this,t).has(t)},Ct.prototype.set=function(t,e){var n=Rt(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this},Ot.prototype.add=Ot.prototype.push=function(t){return this.__data__.set(t,r),this},Ot.prototype.has=function(t){return this.__data__.has(t)},It.prototype.clear=function(){this.__data__=new Tt,this.size=0;},It.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},It.prototype.get=function(t){return this.__data__.get(t)},It.prototype.has=function(t){return this.__data__.has(t)},It.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Tt){var o=r.__data__;if(!lt||o.length<n-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new Ct(o);}return r.set(t,e),this.size=r.size,this};var jt=at?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,r=null==t?0:t.length,o=0,i=[];++n<r;){var a=t[n];e(a,n,t)&&(i[o++]=a);}return i}(at(t),(function(e){return rt.call(t,e)})))}:function(){return []},Dt=Mt;function Vt(t,e){return !!(e=null==e?a:e)&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t<e}function Bt(t){if(null!=t){try{return H.call(t)}catch(t){}try{return t+""}catch(t){}}return ""}function Gt(t,e){return t===e||t!=t&&e!=e}(ct&&Dt(new ct(new ArrayBuffer(1)))!=I||lt&&Dt(new lt)!=g||ht&&"[object Promise]"!=Dt(ht.resolve())||pt&&Dt(new pt)!=E||dt&&"[object WeakMap]"!=Dt(new dt))&&(Dt=function(t){var e=Mt(t),n=e==v?t.constructor:void 0,r=n?Bt(n):"";if(r)switch(r){case gt:return I;case yt:return g;case mt:return "[object Promise]";case vt:return E;case _t:return "[object WeakMap]"}return e});var $t=Nt(function(){return arguments}())?Nt:function(t){return Ht(t)&&X.call(t,"callee")&&!rt.call(t,"callee")},Jt=Array.isArray;var zt=st||function(){return !1};function Yt(t){if(!Wt(t))return !1;var e=Mt(t);return e==d||e==f||e==c||e==_}function qt(t){return "number"==typeof t&&t>-1&&t%1==0&&t<=a}function Wt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ht(t){return null!=t&&"object"==typeof t}var Xt=j?function(t){return function(e){return t(e)}}(j):function(t){return Ht(t)&&qt(t.length)&&!!M[Mt(t)]};function Zt(t){return null!=(e=t)&&qt(e.length)&&!Yt(e)?xt(t):At(t);var e;}t.exports=function(t,e){return Pt(t,e)};}));var Xt={};function Zt(t,e){for(var n=0,r=t.length-1;r>=0;r--){var o=t[r];"."===o?t.splice(r,1):".."===o?(t.splice(r,1),n++):n&&(t.splice(r,1),n--);}if(e)for(;n--;n)t.unshift("..");return t}var Kt=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Qt=function(t){return Kt.exec(t).slice(1)};function te(){for(var t=arguments,e="",n=!1,r=arguments.length-1;r>=-1&&!n;r--){var o=r>=0?t[r]:"/";if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(e=o+"/"+e,n="/"===o.charAt(0));}return (n?"/":"")+(e=Zt(oe(e.split("/"),(function(t){return !!t})),!n).join("/"))||"."}function ee(t){var e=ne(t),n="/"===ie(t,-1);return (t=Zt(oe(t.split("/"),(function(t){return !!t})),!e).join("/"))||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t}function ne(t){return "/"===t.charAt(0)}var re={extname:function(t){return Qt(t)[3]},basename:function(t,e){var n=Qt(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),n},dirname:function(t){var e=Qt(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},sep:"/",delimiter:":",relative:function(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=te(t).substr(1),e=te(e).substr(1);for(var r=n(t.split("/")),o=n(e.split("/")),i=Math.min(r.length,o.length),a=i,s=0;s<i;s++)if(r[s]!==o[s]){a=s;break}var u=[];for(s=a;s<r.length;s++)u.push("..");return (u=u.concat(o.slice(a))).join("/")},join:function(){return ee(oe(Array.prototype.slice.call(arguments,0),(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))},isAbsolute:ne,normalize:ee,resolve:te};function oe(t,e){if(t.filter)return t.filter(e);for(var n=[],r=0;r<t.length;r++)e(t[r],r,t)&&n.push(t[r]);return n}var ie="b"==="ab".substr(-1)?function(t,e,n){return t.substr(e,n)}:function(t,e,n){return e<0&&(e=t.length+e),t.substr(e,n)},ae=R((function(t,e){var n=function(){var t=function(t,e,n,r){for(n=n||{},r=t.length;r--;n[t[r]]=e);return n},e=[1,12],n=[1,13],r=[1,9],o=[1,10],i=[1,11],a=[1,14],s=[1,15],u=[14,18,22,24],c=[18,22],l=[22,24],h={trace:function(){},yy:{},symbols_:{error:2,JSONString:3,STRING:4,JSONNumber:5,NUMBER:6,JSONNullLiteral:7,NULL:8,JSONBooleanLiteral:9,TRUE:10,FALSE:11,JSONText:12,JSONValue:13,EOF:14,JSONObject:15,JSONArray:16,"{":17,"}":18,JSONMemberList:19,JSONMember:20,":":21,",":22,"[":23,"]":24,JSONElementList:25,$accept:0,$end:1},terminals_:{2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"},productions_:[0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]],performAction:function(t,e,n,r,o,i,a){var s=i.length-1;switch(o){case 1:this.$=t.replace(/\\(\\|")/g,"$1").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\v/g,"\v").replace(/\\f/g,"\f").replace(/\\b/g,"\b");break;case 2:this.$=Number(t);break;case 3:this.$=null;break;case 4:this.$=!0;break;case 5:this.$=!1;break;case 6:return this.$=i[s-1];case 13:this.$={},Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 14:case 19:this.$=i[s-1],Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 15:this.$=[i[s-2],i[s]];break;case 16:this.$={},this.$[i[s][0]]=i[s][1];break;case 17:this.$=i[s-2],void 0!==i[s-2][i[s][0]]&&(this.$.__duplicateProperties__||Object.defineProperty(this.$,"__duplicateProperties__",{value:[],enumerable:!1}),this.$.__duplicateProperties__.push(i[s][0])),i[s-2][i[s][0]]=i[s][1];break;case 18:this.$=[],Object.defineProperty(this.$,"__line__",{value:this._$.first_line,enumerable:!1});break;case 20:this.$=[i[s]];break;case 21:this.$=i[s-2],i[s-2].push(i[s]);}},table:[{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:o,11:i,12:1,13:2,15:7,16:8,17:a,23:s},{1:[3]},{14:[1,16]},t(u,[2,7]),t(u,[2,8]),t(u,[2,9]),t(u,[2,10]),t(u,[2,11]),t(u,[2,12]),t(u,[2,3]),t(u,[2,4]),t(u,[2,5]),t([14,18,21,22,24],[2,1]),t(u,[2,2]),{3:20,4:e,18:[1,17],19:18,20:19},{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:o,11:i,13:23,15:7,16:8,17:a,23:s,24:[1,21],25:22},{1:[2,6]},t(u,[2,13]),{18:[1,24],22:[1,25]},t(c,[2,16]),{21:[1,26]},t(u,[2,18]),{22:[1,28],24:[1,27]},t(l,[2,20]),t(u,[2,14]),{3:20,4:e,20:29},{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:o,11:i,13:30,15:7,16:8,17:a,23:s},t(u,[2,19]),{3:5,4:e,5:6,6:n,7:3,8:r,9:4,10:o,11:i,13:31,15:7,16:8,17:a,23:s},t(c,[2,17]),t(c,[2,15]),t(l,[2,21])],defaultActions:{16:[2,6]},parseError:function(t,e){if(!e.recoverable){function n(t,e){this.message=t,this.hash=e;}throw n.prototype=Error,new n(t,e)}this.trace(t);},parse:function(t){var e=this,n=[0],r=[null],o=[],i=this.table,a="",s=0,u=0,c=2,l=1,h=o.slice.call(arguments,1),p=Object.create(this.lexer),d={yy:{}};for(var f in this.yy)Object.prototype.hasOwnProperty.call(this.yy,f)&&(d.yy[f]=this.yy[f]);p.setInput(t,d.yy),d.yy.lexer=p,d.yy.parser=this,void 0===p.yylloc&&(p.yylloc={});var g=p.yylloc;o.push(g);var y=p.options&&p.options.ranges;"function"==typeof d.yy.parseError?this.parseError=d.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;for(var m,v,_,b,E,S,T,C,O,I=function(){var t;return "number"!=typeof(t=p.lex()||l)&&(t=e.symbols_[t]||t),t},x={};;){if(_=n[n.length-1],this.defaultActions[_]?b=this.defaultActions[_]:(null==m&&(m=I()),b=i[_]&&i[_][m]),void 0===b||!b.length||!b[0]){var L="";for(S in O=[],i[_])this.terminals_[S]&&S>c&&O.push("'"+this.terminals_[S]+"'");L=p.showPosition?"Parse error on line "+(s+1)+":\n"+p.showPosition()+"\nExpecting "+O.join(", ")+", got '"+(this.terminals_[m]||m)+"'":"Parse error on line "+(s+1)+": Unexpected "+(m==l?"end of input":"'"+(this.terminals_[m]||m)+"'"),this.parseError(L,{text:p.match,token:this.terminals_[m]||m,line:p.yylineno,loc:g,expected:O});}if(b[0]instanceof Array&&b.length>1)throw new Error("Parse Error: multiple actions possible at state: "+_+", token: "+m);switch(b[0]){case 1:n.push(m),r.push(p.yytext),o.push(p.yylloc),n.push(b[1]),m=null,v?(m=v,v=null):(u=p.yyleng,a=p.yytext,s=p.yylineno,g=p.yylloc);break;case 2:if(T=this.productions_[b[1]][1],x.$=r[r.length-T],x._$={first_line:o[o.length-(T||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(T||1)].first_column,last_column:o[o.length-1].last_column},y&&(x._$.range=[o[o.length-(T||1)].range[0],o[o.length-1].range[1]]),void 0!==(E=this.performAction.apply(x,[a,u,s,d.yy,b[1],r,o].concat(h))))return E;T&&(n=n.slice(0,-1*T*2),r=r.slice(0,-1*T),o=o.slice(0,-1*T)),n.push(this.productions_[b[1]][0]),r.push(x.$),o.push(x._$),C=i[n[n.length-2]][n[n.length-1]],n.push(C);break;case 3:return !0}}return !0}},p={EOF:1,parseError:function(t,e){if(!this.yy.parser)throw new Error(t);this.yy.parser.parseError(t,e);},setInput:function(t,e){return this.yy=e||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},input:function(){var t=this._input[0];return this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t,t.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},unput:function(t){var e=t.length,n=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-e),this.offset-=e;var r=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),n.length-1&&(this.yylineno-=n.length-1);var o=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:n?(n.length===r.length?this.yylloc.first_column:0)+r[r.length-n.length].length-n[0].length:this.yylloc.first_column-e},this.options.ranges&&(this.yylloc.range=[o[0],o[0]+this.yyleng-e]),this.yyleng=this.yytext.length,this},more:function(){return this._more=!0,this},reject:function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},less:function(t){this.unput(this.match.slice(t));},pastInput:function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return (t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},upcomingInput:function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},showPosition:function(){var t=this.pastInput(),e=new Array(t.length+1).join("-");return t+this.upcomingInput()+"\n"+e+"^"},test_match:function(t,e){var n,r,o;if(this.options.backtrack_lexer&&(o={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(o.yylloc.range=this.yylloc.range.slice(0))),(r=t[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=r.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:r?r[r.length-1].length-r[r.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+t[0].length},this.yytext+=t[0],this.match+=t[0],this.matches=t,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(t[0].length),this.matched+=t[0],n=this.performAction.call(this,this.yy,this,e,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),n)return n;if(this._backtrack){for(var i in o)this[i]=o[i];return !1}return !1},next:function(){if(this.done)return this.EOF;var t,e,n,r;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var o=this._currentRules(),i=0;i<o.length;i++)if((n=this._input.match(this.rules[o[i]]))&&(!e||n[0].length>e[0].length)){if(e=n,r=i,this.options.backtrack_lexer){if(!1!==(t=this.test_match(n,o[i])))return t;if(this._backtrack){e=!1;continue}return !1}if(!this.options.flex)break}return e?!1!==(t=this.test_match(e,o[r]))&&t:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},lex:function(){var t=this.next();return t||this.lex()},begin:function(t){this.conditionStack.push(t);},popState:function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},_currentRules:function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},topState:function(t){return (t=this.conditionStack.length-1-Math.abs(t||0))>=0?this.conditionStack[t]:"INITIAL"},pushState:function(t){this.begin(t);},stateStackSize:function(){return this.conditionStack.length},options:{},performAction:function(t,e,n,r){switch(n){case 0:break;case 1:return 6;case 2:return e.yytext=e.yytext.substr(1,e.yyleng-2),4;case 3:return 17;case 4:return 18;case 5:return 23;case 6:return 24;case 7:return 22;case 8:return 21;case 9:return 10;case 10:return 11;case 11:return 8;case 12:return 14;case 13:return "INVALID"}},rules:[/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt\/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/],conditions:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};function d(){this.yy={};}return h.lexer=p,d.prototype=h,h.Parser=d,new d}();e.parser=n,e.Parser=n.Parser,e.parse=function(){return n.parse.apply(n,arguments)},e.main=function(t){t[1]||(console.log("Usage: "+t[0]+" FILE"),process.exit(1));var n=Xt.readFileSync(re.normalize(t[1]),"utf8");return e.parser.parse(n)},k.main===t&&e.main(process.argv.slice(1));}));ae.parser,ae.Parser,ae.parse,ae.main;function se(t){return t*Math.PI/180}function ue(t){var e=0;if(t.length>2)for(var n,r,o=0;o<t.length-1;o++)n=t[o],e+=se((r=t[o+1])[0]-n[0])*(2+Math.sin(se(n[1]))+Math.sin(se(r[1])));return e>=0}function ce(t){if(t&&t.length>0){if(ue(t[0]))return !1;if(!t.slice(1,t.length).every(ue))return !1}return !0}var le=function(t,e){(function(t){return "Polygon"===t.type?ce(t.coordinates):"MultiPolygon"===t.type?t.coordinates.every(ce):void 0})(t)||e.push({message:"Polygons and MultiPolygons should follow the right-hand rule",level:"message",line:t.__line__});};var he={hint:function(t,e){var n=[],r=0,o=10,i=6;function a(t){if(e&&!1===e.noDuplicateMembers||!t.__duplicateProperties__||n.push({message:"An object contained duplicate members, making parsing ambigous: "+t.__duplicateProperties__.join(", "),line:t.__line__}),!u(t,"type","string"))if(f[t.type])t&&f[t.type](t);else {var r=g[t.type.toLowerCase()];void 0!==r?n.push({message:"Expected "+r+" but got "+t.type+" (case sensitive)",line:t.__line__}):n.push({message:"The type "+t.type+" is unknown",line:t.__line__});}}function s(t,e){return t.every((function(t){return null!==t&&typeof t===e}))}function u(t,e,r){if(void 0===t[e])return n.push({message:'"'+e+'" member required',line:t.__line__});if("array"===r){if(!Array.isArray(t[e]))return n.push({message:'"'+e+'" member should be an array, but is an '+typeof t[e]+" instead",line:t.__line__})}else {if("object"===r&&t[e]&&t[e].constructor!==Object)return n.push({message:'"'+e+'" member should be '+r+", but is an "+t[e].constructor.name+" instead",line:t.__line__});if(r&&typeof t[e]!==r)return n.push({message:'"'+e+'" member should be '+r+", but is an "+typeof t[e]+" instead",line:t.__line__})}}function c(t,a){if(!Array.isArray(t))return n.push({message:"position should be an array, is a "+typeof t+" instead",line:t.__line__||a});if(t.length<2)return n.push({message:"position must have 2 or more elements",line:t.__line__||a});if(t.length>3)return n.push({message:"position should not have more than 3 elements",level:"message",line:t.__line__||a});if(!s(t,"number"))return n.push({message:"each element in a position must be a number",line:t.__line__||a});if(e&&e.precisionWarning){if(r===o)return r+=1,n.push({message:"truncated warnings: we've encountered coordinate precision warning "+o+" times, no more warnings will be reported",level:"message",line:t.__line__||a});r<o&&t.forEach((function(e){var o=0,s=String(e).split(".")[1];if(void 0!==s&&(o=s.length),o>i)return r+=1,n.push({message:"precision of coordinates should be reduced",level:"message",line:t.__line__||a})}));}}function l(t,e,r,o){if(void 0===o&&void 0!==t.__line__&&(o=t.__line__),0===r)return c(t,o);if(1===r&&e)if("LinearRing"===e){if(!Array.isArray(t[t.length-1]))return n.push({message:"a number was found where a coordinate array should have been found: this needs to be nested more deeply",line:o}),!0;if(t.length<4&&n.push({message:"a LinearRing of coordinates needs to have four or more positions",line:o}),t.length&&(t[t.length-1].length!==t[0].length||!t[t.length-1].every((function(e,n){return t[0][n]===e}))))return n.push({message:"the first and last positions in a LinearRing of coordinates must be the same",line:o}),!0}else if("Line"===e&&t.length<2)return n.push({message:"a line needs to have two or more coordinates to be valid",line:o});if(Array.isArray(t))return t.map((function(t){return l(t,e,r-1,t.__line__||o)})).some((function(t){return t}));n.push({message:"a number was found where a coordinate array should have been found: this needs to be nested more deeply",line:o});}function h(t){if(t.crs){"object"==typeof t.crs&&t.crs.properties&&"urn:ogc:def:crs:OGC:1.3:CRS84"===t.crs.properties.name?n.push({message:"old-style crs member is not recommended, this object is equivalent to the default and should be removed",line:t.__line__}):n.push({message:"old-style crs member is not recommended",line:t.__line__});}}function p(t){if(t.bbox)return Array.isArray(t.bbox)?(s(t.bbox,"number")||n.push({message:"each element in a bbox member must be a number",line:t.bbox.__line__}),4!==t.bbox.length&&6!==t.bbox.length&&n.push({message:"bbox must contain 4 elements (for 2D) or 6 elements (for 3D)",line:t.bbox.__line__}),n.length):void n.push({message:"bbox member must be an array of numbers, but is a "+typeof t.bbox,line:t.__line__})}function d(t){h(t),p(t),void 0!==t.id&&"string"!=typeof t.id&&"number"!=typeof t.id&&n.push({message:'Feature "id" member must have a string or number value',line:t.__line__}),void 0!==t.features&&n.push({message:'Feature object cannot contain a "features" member',line:t.__line__}),void 0!==t.coordinates&&n.push({message:'Feature object cannot contain a "coordinates" member',line:t.__line__}),"Feature"!==t.type&&n.push({message:"GeoJSON features must have a type=feature member",line:t.__line__}),u(t,"properties","object"),u(t,"geometry","object")||t.geometry&&a(t.geometry);}var f={Point:function(t){var e;h(t),p(t),void 0!==(e=t).properties&&n.push({message:'geometry object cannot contain a "properties" member',line:e.__line__}),void 0!==e.geometry&&n.push({message:'geometry object cannot contain a "geometry" member',line:e.__line__}),void 0!==e.features&&n.push({message:'geometry object cannot contain a "features" member',line:e.__line__}),u(t,"coordinates","array")||c(t.coordinates);},Feature:d,MultiPoint:function(t){h(t),p(t),u(t,"coordinates","array")||l(t.coordinates,"",1);},LineString:function(t){h(t),p(t),u(t,"coordinates","array")||l(t.coordinates,"Line",1);},MultiLineString:function(t){h(t),p(t),u(t,"coordinates","array")||l(t.coordinates,"Line",2);},FeatureCollection:function(t){if(h(t),p(t),void 0!==t.properties&&n.push({message:'FeatureCollection object cannot contain a "properties" member',line:t.__line__}),void 0!==t.coordinates&&n.push({message:'FeatureCollection object cannot contain a "coordinates" member',line:t.__line__}),!u(t,"features","array")){if(!s(t.features,"object"))return n.push({message:"Every feature must be an object",line:t.__line__});t.features.forEach(d);}},GeometryCollection:function(t){h(t),p(t),u(t,"geometries","array")||(s(t.geometries,"object")||n.push({message:"The geometries array in a GeometryCollection must contain only geometry objects",line:t.__line__}),1===t.geometries.length&&n.push({message:"GeometryCollection with a single geometry should be avoided in favor of single part or a single object of multi-part type",line:t.geometries.__line__}),t.geometries.forEach((function(e){e&&("GeometryCollection"===e.type&&n.push({message:"GeometryCollection should avoid nested geometry collections",line:t.geometries.__line__}),a(e));})));},Polygon:function(t){h(t),p(t),u(t,"coordinates","array")||l(t.coordinates,"LinearRing",2)||le(t,n);},MultiPolygon:function(t){h(t),p(t),u(t,"coordinates","array")||l(t.coordinates,"LinearRing",3)||le(t,n);}},g=Object.keys(f).reduce((function(t,e){return t[e.toLowerCase()]=e,t}),{});return "object"!=typeof t||null==t?(n.push({message:"The root of a GeoJSON object must be an object.",line:0}),n):(a(t),n.forEach((function(t){({}).hasOwnProperty.call(t,"line")&&void 0===t.line&&delete t.line;})),n)}};var pe={hint:function(t,e){var n,r=[];if("object"==typeof t)n=t;else {if("string"!=typeof t)return [{message:"Expected string or object as input",line:0}];try{n=ae.parse(t);}catch(t){var o=t.message.match(/line (\d+)/);return [{line:parseInt(o[1],10)-1,message:t.message,error:t}]}}return r=r.concat(he.hint(n,e))}},de={Polygon:B,LineString:V,Point:D,MultiPolygon:J,MultiLineString:J,MultiPoint:J};function fe(t,e){return e.modes=h,e.getFeatureIdsAt=function(e){return C.click({point:e},null,t).map((function(t){return t.properties.id}))},e.getSelectedIds=function(){return t.store.getSelectedIds()},e.getSelected=function(){return {type:l.FEATURE_COLLECTION,features:t.store.getSelectedIds().map((function(e){return t.store.get(e)})).map((function(t){return t.toGeoJSON()}))}},e.getSelectedPoints=function(){return {type:l.FEATURE_COLLECTION,features:t.store.getSelectedCoordinates().map((function(t){return {type:l.FEATURE,properties:{},geometry:{type:l.POINT,coordinates:t.coordinates}}}))}},e.set=function(n){if(void 0===n.type||n.type!==l.FEATURE_COLLECTION||!Array.isArray(n.features))throw new Error("Invalid FeatureCollection");var r=t.store.createRenderBatch(),o=t.store.getAllIds().slice(),i=e.add(n),a=new S(i);return (o=o.filter((function(t){return !a.has(t)}))).length&&e.delete(o),r(),i},e.add=function(e){var n=pe.hint(e,{precisionWarning:!1}).filter((function(t){return "message"!==t.level}));if(n.length)throw new Error(n[0].message);var r=JSON.parse(JSON.stringify(vt(e))).features.map((function(e){if(e.id=e.id||U(),null===e.geometry)throw new Error("Invalid geometry: null");if(void 0===t.store.get(e.id)||t.store.get(e.id).type!==e.geometry.type){var n=de[e.geometry.type];if(void 0===n)throw new Error("Invalid geometry type: "+e.geometry.type+".");var r=new n(t,e);t.store.add(r);}else {var o=t.store.get(e.id);o.properties=e.properties,Ht(o.getCoordinates(),e.geometry.coordinates)||o.incomingCoords(e.geometry.coordinates);}return e.id}));return t.store.render(),r},e.get=function(e){var n=t.store.get(e);if(n)return n.toGeoJSON()},e.getAll=function(){return {type:l.FEATURE_COLLECTION,features:t.store.getAll().map((function(t){return t.toGeoJSON()}))}},e.delete=function(n){return t.store.delete(n,{silent:!0}),e.getMode()!==h.DIRECT_SELECT||t.store.getSelectedIds().length?t.store.render():t.events.changeMode(h.SIMPLE_SELECT,void 0,{silent:!0}),e},e.deleteAll=function(){return t.store.delete(t.store.getAllIds(),{silent:!0}),e.getMode()===h.DIRECT_SELECT?t.events.changeMode(h.SIMPLE_SELECT,void 0,{silent:!0}):t.store.render(),e},e.changeMode=function(n,r){return void 0===r&&(r={}),n===h.SIMPLE_SELECT&&e.getMode()===h.SIMPLE_SELECT?(o=r.featureIds||[],i=t.store.getSelectedIds(),o.length===i.length&&JSON.stringify(o.map((function(t){return t})).sort())===JSON.stringify(i.map((function(t){return t})).sort())?e:(t.store.setSelected(r.featureIds,{silent:!0}),t.store.render(),e)):n===h.DIRECT_SELECT&&e.getMode()===h.DIRECT_SELECT&&r.featureId===t.store.getSelectedIds()[0]?e:(t.events.changeMode(n,r,{silent:!0}),e);var o,i;},e.getMode=function(){return t.events.getMode()},e.trash=function(){return t.events.trash({silent:!0}),e},e.combineFeatures=function(){return t.events.combineFeatures({silent:!0}),e},e.uncombineFeatures=function(){return t.events.uncombineFeatures({silent:!0}),e},e.setFeatureProperty=function(n,r,o){return t.store.setFeatureProperty(n,r,o),e},e}var ge=function(t,e){var n={options:t=function(t){void 0===t&&(t={});var e=Q(t);return t.controls||(e.controls={}),!1===t.displayControlsDefault?e.controls=Q(qt,t.controls):e.controls=Q(Yt,t.controls),(e=Q(zt,e)).styles=Wt(e.styles,"cold").concat(Wt(e.styles,"hot")),e}(t)};e=fe(n,e),n.api=e;var r=nt(n);return e.onAdd=r.onAdd,e.onRemove=r.onRemove,e.types=c,e.options=t,e};function ye(t){ge(t,this);}return ye.modes=Jt,ye}));
|
|
12
|
-
|
|
33
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=function(t,e){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on:function(t,e,o){if(void 0===n[t])throw new Error("Invalid event type: "+t);n[t].push({selector:e,fn:o});},render:function(t){e.store.featureChanged(t);}},r=function(t,r){for(var i=n[t],a=i.length;a--;){var s=i[a];if(s.selector(r)){s.fn.call(o,r)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(o),{render:t.render,stop:function(){t.stop&&t.stop();},trash:function(){t.trash&&(t.trash(),e.store.render());},combineFeatures:function(){t.combineFeatures&&t.combineFeatures();},uncombineFeatures:function(){t.uncombineFeatures&&t.uncombineFeatures();},drag:function(t){r("drag",t);},click:function(t){r("click",t);},mousemove:function(t){r("mousemove",t);},mousedown:function(t){r("mousedown",t);},mouseup:function(t){r("mouseup",t);},mouseout:function(t){r("mouseout",t);},keydown:function(t){r("keydown",t);},keyup:function(t){r("keyup",t);},touchstart:function(t){r("touchstart",t);},touchmove:function(t){r("touchmove",t);},touchend:function(t){r("touchend",t);},tap:function(t){r("tap",t);}}},e=6378137;function n(t){var e=0;if(t&&t.length>0){e+=Math.abs(o(t[0]));for(var n=1;n<t.length;n++)e-=Math.abs(o(t[n]));}return e}function o(t){var n,o,i,a,s,u,c=0,l=t.length;if(l>2){for(u=0;u<l;u++)u===l-2?(i=l-2,a=l-1,s=0):u===l-1?(i=l-1,a=0,s=1):(i=u,a=u+1,s=u+2),n=t[i],o=t[a],c+=(r(t[s][0])-r(n[0]))*Math.sin(r(o[1]));c=c*e*e/2;}return c}function r(t){return t*Math.PI/180}var i={geometry:function t(e){var o,r=0;switch(e.type){case"Polygon":return n(e.coordinates);case"MultiPolygon":for(o=0;o<e.coordinates.length;o++)r+=n(e.coordinates[o]);return r;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(o=0;o<e.geometries.length;o++)r+=t(e.geometries[o]);return r}},ring:o},a="mapboxgl-ctrl",s="mapbox-gl-draw_ctrl-draw-btn",u="mapbox-gl-draw_line",c="mapbox-gl-draw_polygon",l="mapbox-gl-draw_point",d="mapbox-gl-draw_trash",p="mapbox-gl-draw_combine",f="mapbox-gl-draw_uncombine",h="mapboxgl-ctrl-group",g="active",y="mapbox-gl-draw_boxselect",v="mapbox-gl-draw-hot",m="mapbox-gl-draw-cold",b="add",_="move",S="drag",x="pointer",C="none",E={POLYGON:"polygon",LINE:"line_string",POINT:"point"},M="Feature",w="Polygon",I="LineString",L="Point",P="FeatureCollection",F="Multi",O="MultiPoint",k="MultiLineString",T="MultiPolygon",j={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"},A="draw.create",D="draw.delete",N="draw.update",U="draw.selectionchange",R="draw.modechange",B="draw.actionable",V="draw.render",J="draw.combine",G="draw.uncombine",z="move",$="change_coordinates",W="feature",q="midpoint",Y="vertex",Z="true",K="false",X=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],H={Point:0,LineString:1,Polygon:2};function Q(t,e){var n=H[t.geometry.type]-H[e.geometry.type];return 0===n&&t.geometry.type===w?t.area-e.area:n}function tt(t){if(this._items={},this._nums={},this._length=t?t.length:0,t)for(var e=0,n=t.length;e<n;e++)this.add(t[e]),void 0!==t[e]&&("string"==typeof t[e]?this._items[t[e]]=e:this._nums[t[e]]=e);}tt.prototype.add=function(t){return this.has(t)||(this._length++,"string"==typeof t?this._items[t]=this._length:this._nums[t]=this._length),this},tt.prototype.delete=function(t){return !1===this.has(t)||(this._length--,delete this._items[t],delete this._nums[t]),this},tt.prototype.has=function(t){return ("string"==typeof t||"number"==typeof t)&&(void 0!==this._items[t]||void 0!==this._nums[t])},tt.prototype.values=function(){var t=this,e=[];return Object.keys(this._items).forEach((function(n){e.push({k:n,v:t._items[n]});})),Object.keys(this._nums).forEach((function(n){e.push({k:JSON.parse(n),v:t._nums[n]});})),e.sort((function(t,e){return t.v-e.v})).map((function(t){return t.k}))},tt.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};var et=[W,q,Y],nt={click:function(t,e,n){return ot(t,e,n,n.options.clickBuffer)},touch:function(t,e,n){return ot(t,e,n,n.options.touchBuffer)}};function ot(t,e,n,o){if(null===n.map)return [];var r=t?function(t,e){return void 0===e&&(e=0),[[t.point.x-e,t.point.y-e],[t.point.x+e,t.point.y+e]]}(t,o):e,a={};n.options.styles&&(a.layers=n.options.styles.map((function(t){return t.id})));var s=n.map.queryRenderedFeatures(r,a).filter((function(t){return -1!==et.indexOf(t.properties.meta)})),u=new tt,c=[];return s.forEach((function(t){var e=t.properties.id;u.has(e)||(u.add(e),c.push(t));})),function(t){return t.map((function(t){return t.geometry.type===w&&(t.area=i.geometry({type:M,property:{},geometry:t.geometry})),t})).sort(Q).map((function(t){return delete t.area,t}))}(c)}function rt(t,e){var n=nt.click(t,null,e),o={mouse:C};return n[0]&&(o.mouse=n[0].properties.active===Z?_:x,o.feature=n[0].properties.meta),-1!==e.events.currentModeName().indexOf("draw")&&(o.mouse=b),e.ui.queueMapClasses(o),e.ui.updateMapClasses(),n[0]}function it(t,e){var n=t.x-e.x,o=t.y-e.y;return Math.sqrt(n*n+o*o)}function at(t,e,n){void 0===n&&(n={});var o=null!=n.fineTolerance?n.fineTolerance:4,r=null!=n.grossTolerance?n.grossTolerance:12,i=null!=n.interval?n.interval:500;t.point=t.point||e.point,t.time=t.time||e.time;var a=it(t.point,e.point);return a<o||a<r&&e.time-t.time<i}function st(t,e,n){void 0===n&&(n={});var o=null!=n.tolerance?n.tolerance:25,r=null!=n.interval?n.interval:250;return t.point=t.point||e.point,t.time=t.time||e.time,it(t.point,e.point)<o&&e.time-t.time<r}function ut(t,e){return t(e={exports:{}},e.exports),e.exports}var ct=ut((function(t){var e=t.exports=function(t,n){if(n||(n=16),void 0===t&&(t=128),t<=0)return "0";for(var o=Math.log(Math.pow(2,t))/Math.log(n),r=2;o===1/0;r*=2)o=Math.log(Math.pow(2,t/r))/Math.log(n)*r;var i=o-Math.floor(o),a="";for(r=0;r<Math.floor(o);r++){a=Math.floor(Math.random()*n).toString(n)+a;}if(i){var s=Math.pow(n,i);a=Math.floor(Math.random()*s).toString(n)+a;}var u=parseInt(a,n);return u!==1/0&&u>=Math.pow(2,t)?e(t,n):a};e.rack=function(t,n,o){var r=function(r){var a=0;do{if(a++>10){if(!o)throw new Error("too many ID collisions, use more bits");t+=o;}var s=e(t,n);}while(Object.hasOwnProperty.call(i,s));return i[s]=r,s},i=r.hats={};return r.get=function(t){return r.hats[t]},r.set=function(t,e){return r.hats[t]=e,r},r.bits=t||128,r.base=n||16,r};})),lt=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||ct(),this.type=e.geometry.type;};lt.prototype.changed=function(){this.ctx.store.featureChanged(this.id);},lt.prototype.incomingCoords=function(t){this.setCoordinates(t);},lt.prototype.setCoordinates=function(t){this.coordinates=t,this.changed();},lt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},lt.prototype.setProperty=function(t,e){this.properties[t]=e;},lt.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:M,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},lt.prototype.internal=function(t){var e={id:this.id,meta:W,"meta:type":this.type,active:K,mode:t};if(this.ctx.options.userProperties)for(var n in this.properties)e["user_"+n]=this.properties[n];return {type:M,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var dt=function(t,e){lt.call(this,t,e);};(dt.prototype=Object.create(lt.prototype)).isValid=function(){return "number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},dt.prototype.updateCoordinate=function(t,e,n){this.coordinates=3===arguments.length?[e,n]:[t,e],this.changed();},dt.prototype.getCoordinate=function(){return this.getCoordinates()};var pt=function(t,e){lt.call(this,t,e);};(pt.prototype=Object.create(lt.prototype)).isValid=function(){return this.coordinates.length>1},pt.prototype.addCoordinate=function(t,e,n){this.changed();var o=parseInt(t,10);this.coordinates.splice(o,0,[e,n]);},pt.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},pt.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1);},pt.prototype.updateCoordinate=function(t,e,n){var o=parseInt(t,10);this.coordinates[o]=[e,n],this.changed();};var ft=function(t,e){lt.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}));};(ft.prototype=Object.create(lt.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},ft.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed();},ft.prototype.setCoordinates=function(t){this.coordinates=t,this.changed();},ft.prototype.addCoordinate=function(t,e,n){this.changed();var o=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[o[0]].splice(o[1],0,[e,n]);},ft.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];n&&(n.splice(e[1],1),n.length<3&&this.coordinates.splice(e[0],1));},ft.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),n=this.coordinates[e[0]];return JSON.parse(JSON.stringify(n[e[1]]))},ft.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},ft.prototype.updateCoordinate=function(t,e,n){this.changed();var o=t.split("."),r=parseInt(o[0],10),i=parseInt(o[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][i]=[e,n];};var ht={MultiPoint:dt,MultiLineString:pt,MultiPolygon:ft},gt=function(t,e,n,o,r){var i=n.split("."),a=parseInt(i[0],10),s=i[1]?i.slice(1).join("."):null;return t[a][e](s,o,r)},yt=function(t,e){if(lt.call(this,t,e),delete this.coordinates,this.model=ht[e.geometry.type],void 0===this.model)throw new TypeError(e.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(e.geometry.coordinates);};function vt(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t;}(yt.prototype=Object.create(lt.prototype))._coordinatesToFeatures=function(t){var e=this,n=this.model.bind(this);return t.map((function(t){return new n(e.ctx,{id:ct(),type:M,properties:{},geometry:{coordinates:t,type:e.type.replace("Multi","")}})}))},yt.prototype.isValid=function(){return this.features.every((function(t){return t.isValid()}))},yt.prototype.setCoordinates=function(t){this.features=this._coordinatesToFeatures(t),this.changed();},yt.prototype.getCoordinate=function(t){return gt(this.features,"getCoordinate",t)},yt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===w?t.getCoordinates():t.coordinates}))))},yt.prototype.updateCoordinate=function(t,e,n){gt(this.features,"updateCoordinate",t,e,n),this.changed();},yt.prototype.addCoordinate=function(t,e,n){gt(this.features,"addCoordinate",t,e,n),this.changed();},yt.prototype.removeCoordinate=function(t){gt(this.features,"removeCoordinate",t),this.changed();},yt.prototype.getFeatures=function(){return this.features},vt.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},vt.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,n){return void 0===t[n.feature_id]&&(t[n.feature_id]=!0,e._ctx.store.get(n.feature_id).changed()),t}),{});},vt.prototype.getSelected=function(){return this._ctx.store.getSelected()},vt.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},vt.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},vt.prototype.getFeature=function(t){return this._ctx.store.get(t)},vt.prototype.select=function(t){return this._ctx.store.select(t)},vt.prototype.deselect=function(t){return this._ctx.store.deselect(t)},vt.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},vt.prototype.addFeature=function(t){return this._ctx.store.add(t)},vt.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},vt.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},vt.prototype.setActionableState=function(t){void 0===t&&(t={});var e={trash:t.trash||!1,combineFeatures:t.combineFeatures||!1,uncombineFeatures:t.uncombineFeatures||!1};return this._ctx.events.actionable(e)},vt.prototype.changeMode=function(t,e,n){return void 0===e&&(e={}),void 0===n&&(n={}),this._ctx.events.changeMode(t,e,n)},vt.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},vt.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},vt.prototype.featuresAt=function(t,e,n){if(void 0===n&&(n="click"),"click"!==n&&"touch"!==n)throw new Error("invalid buffer type");return nt[n](t,e,this._ctx)},vt.prototype.newFeature=function(t){var e=t.geometry.type;return e===L?new dt(this._ctx,t):e===I?new pt(this._ctx,t):e===w?new ft(this._ctx,t):new yt(this._ctx,t)},vt.prototype.isInstanceOf=function(t,e){if(t===L)return e instanceof dt;if(t===I)return e instanceof pt;if(t===w)return e instanceof ft;if("MultiFeature"===t)return e instanceof yt;throw new Error("Unknown feature class: "+t)},vt.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},vt.prototype.onSetup=function(){},vt.prototype.onDrag=function(){},vt.prototype.onClick=function(){},vt.prototype.onMouseMove=function(){},vt.prototype.onMouseDown=function(){},vt.prototype.onMouseUp=function(){},vt.prototype.onMouseOut=function(){},vt.prototype.onKeyUp=function(){},vt.prototype.onKeyDown=function(){},vt.prototype.onTouchStart=function(){},vt.prototype.onTouchMove=function(){},vt.prototype.onTouchEnd=function(){},vt.prototype.onTap=function(){},vt.prototype.onStop=function(){},vt.prototype.onTrash=function(){},vt.prototype.onCombineFeature=function(){},vt.prototype.onUncombineFeature=function(){},vt.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var mt={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},bt=Object.keys(mt);function _t(t){var e=Object.keys(t);return function(n,o){void 0===o&&(o={});var r={},i=e.reduce((function(e,n){return e[n]=t[n],e}),new vt(n));return {start:function(){var e=this;r=i.onSetup(o),bt.forEach((function(n){var o,a=mt[n],s=function(){return !1};t[a]&&(s=function(){return !0}),e.on(n,s,(o=a,function(t){return i[o](r,t)}));}));},stop:function(){i.onStop(r);},trash:function(){i.onTrash(r);},combineFeatures:function(){i.onCombineFeatures(r);},uncombineFeatures:function(){i.onUncombineFeatures(r);},render:function(t,e){i.toDisplayFeatures(r,t,e);}}}}function St(t){return [].concat(t).filter((function(t){return void 0!==t}))}function xt(){var t=this;if(!(t.ctx.map&&void 0!==t.ctx.map.getSource(v)))return u();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var n=[],o=[];t.isDirty?o=t.getAllIds():(n=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),o=t.sources.hot.filter((function(e){return e.properties.id&&-1===n.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var r=t.sources.cold.length;t.sources.cold=t.isDirty?[]:t.sources.cold.filter((function(t){var e=t.properties.id||t.properties.parent;return -1===n.indexOf(e)}));var i=r!==t.sources.cold.length||o.length>0;function a(n,o){var r=t.get(n).internal(e);t.ctx.events.currentModeRender(r,(function(e){t.sources[o].push(e);}));}if(n.forEach((function(t){return a(t,"hot")})),o.forEach((function(t){return a(t,"cold")})),i&&t.ctx.map.getSource(m).setData({type:P,features:t.sources.cold}),t.ctx.map.getSource(v).setData({type:P,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(U,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return {type:M,properties:{},geometry:{type:L,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var s=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(D,{features:s});}function u(){t.isDirty=!1,t.clearChangedIds();}u(),t.ctx.map.fire(V,{});}function Ct(t){var e,n=this;this._features={},this._featureIds=new tt,this._selectedFeatureIds=new tt,this._selectedCoordinates=[],this._changedFeatureIds=new tt,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,xt.call(n);})));},this.isDirty=!1;}function Et(t,e){var n=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===n.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=n;}Ct.prototype.createRenderBatch=function(){var t=this,e=this.render,n=0;return this.render=function(){n++;},function(){t.render=e,n>0&&t.render();}},Ct.prototype.setDirty=function(){return this.isDirty=!0,this},Ct.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},Ct.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Ct.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Ct.prototype.getAllIds=function(){return this._featureIds.values()},Ct.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},Ct.prototype.delete=function(t,e){var n=this;return void 0===e&&(e={}),St(t).forEach((function(t){n._featureIds.has(t)&&(n._featureIds.delete(t),n._selectedFeatureIds.delete(t),e.silent||-1===n._deletedFeaturesToEmit.indexOf(n._features[t])&&n._deletedFeaturesToEmit.push(n._features[t]),delete n._features[t],n.isDirty=!0);})),Et(this,e),this},Ct.prototype.get=function(t){return this._features[t]},Ct.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},Ct.prototype.select=function(t,e){var n=this;return void 0===e&&(e={}),St(t).forEach((function(t){n._selectedFeatureIds.has(t)||(n._selectedFeatureIds.add(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0));})),this},Ct.prototype.deselect=function(t,e){var n=this;return void 0===e&&(e={}),St(t).forEach((function(t){n._selectedFeatureIds.has(t)&&(n._selectedFeatureIds.delete(t),n._changedFeatureIds.add(t),e.silent||(n._emitSelectionChange=!0));})),Et(this,e),this},Ct.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},Ct.prototype.setSelected=function(t,e){var n=this;return void 0===e&&(e={}),t=St(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return -1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return !n._selectedFeatureIds.has(t)})),{silent:e.silent}),this},Ct.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},Ct.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Ct.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Ct.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},Ct.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return {coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},Ct.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},Ct.prototype.setFeatureProperty=function(t,e,n){this.get(t).setProperty(e,n),this.featureChanged(t);},Ct.prototype.storeMapConfig=function(){var t=this;X.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled());}));},Ct.prototype.restoreMapConfig=function(){var t=this;Object.keys(this._mapInitialConfig).forEach((function(e){t._mapInitialConfig[e]?t.ctx.map[e].enable():t.ctx.map[e].disable();}));},Ct.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var Mt=function(){for(var t=arguments,e={},n=0;n<arguments.length;n++){var o=t[n];for(var r in o)wt.call(o,r)&&(e[r]=o[r]);}return e},wt=Object.prototype.hasOwnProperty;var It=["mode","feature","mouse"];function Lt(e){var n=null,o=null,r={onRemove:function(){return e.map.off("load",r.connect),clearInterval(o),r.removeLayers(),e.store.restoreMapConfig(),e.ui.removeButtons(),e.events.removeEventListeners(),e.ui.clearMapClasses(),e.map=null,e.container=null,e.store=null,n&&n.parentNode&&n.parentNode.removeChild(n),n=null,this},connect:function(){e.map.off("load",r.connect),clearInterval(o),r.addLayers(),e.store.storeMapConfig(),e.events.addEventListeners();},onAdd:function(i){var y=i.fire;return i.fire=function(t,e){var n=arguments;return 1===y.length&&1!==arguments.length&&(n=[Mt({},{type:t},e)]),y.apply(i,n)},e.map=i,e.events=function(e){var n=Object.keys(e.options.modes).reduce((function(t,n){return t[n]=_t(e.options.modes[n]),t}),{}),o={},r={},i={},a=null,s=null;i.drag=function(t,n){n({point:t.point,time:(new Date).getTime()})?(e.ui.queueMapClasses({mouse:S}),s.drag(t)):t.originalEvent.stopPropagation();},i.mousedrag=function(t){i.drag(t,(function(t){return !at(o,t)}));},i.touchdrag=function(t){i.drag(t,(function(t){return !st(r,t)}));},i.mousemove=function(t){if(1===(void 0!==t.originalEvent.buttons?t.originalEvent.buttons:t.originalEvent.which))return i.mousedrag(t);var n=rt(t,e);t.featureTarget=n,s.mousemove(t);},i.mousedown=function(t){o={time:(new Date).getTime(),point:t.point};var n=rt(t,e);t.featureTarget=n,s.mousedown(t);},i.mouseup=function(t){var n=rt(t,e);t.featureTarget=n,at(o,{point:t.point,time:(new Date).getTime()})?s.click(t):s.mouseup(t);},i.mouseout=function(t){s.mouseout(t);},i.touchstart=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){r={time:(new Date).getTime(),point:t.point};var n=nt.touch(t,null,e)[0];t.featureTarget=n,s.touchstart(t);}},i.touchmove=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled)return s.touchmove(t),i.touchdrag(t)},i.touchend=function(t){if(t.originalEvent.preventDefault(),e.options.touchEnabled){var n=nt.touch(t,null,e)[0];t.featureTarget=n,st(r,{time:(new Date).getTime(),point:t.point})?s.tap(t):s.touchend(t);}};var u=function(t){return !(8===t||46===t||t>=48&&t<=57)};function c(o,r,i){void 0===i&&(i={}),s.stop();var u=n[o];if(void 0===u)throw new Error(o+" is not valid");a=o;var c=u(e,r);s=t(c,e),i.silent||e.map.fire(R,{mode:o}),e.store.setDirty(),e.store.render();}i.keydown=function(t){"mapboxgl-canvas"===(t.srcElement||t.target).classList[0]&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?u(t.keyCode)?s.keydown(t):49===t.keyCode&&e.options.controls.point?c(j.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?c(j.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&c(j.DRAW_POLYGON):(t.preventDefault(),s.trash()));},i.keyup=function(t){u(t.keyCode)&&s.keyup(t);},i.zoomend=function(){e.store.changeZoom();},i.data=function(t){if("style"===t.dataType){var n=e.setup,o=e.map,r=e.options,i=e.store;r.styles.some((function(t){return o.getLayer(t.id)}))||(n.addLayers(),i.setDirty(),i.render());}};var l={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return {start:function(){a=e.options.defaultMode,s=t(n[a](e),e);},changeMode:c,actionable:function(t){var n=!1;Object.keys(t).forEach((function(e){if(void 0===l[e])throw new Error("Invalid action type");l[e]!==t[e]&&(n=!0),l[e]=t[e];})),n&&e.map.fire(B,{actions:l});},currentModeName:function(){return a},currentModeRender:function(t,e){return s.render(t,e)},fire:function(t,e){i[t]&&i[t](e);},addEventListeners:function(){e.map.on("mousemove",i.mousemove),e.map.on("mousedown",i.mousedown),e.map.on("mouseup",i.mouseup),e.map.on("data",i.data),e.map.on("touchmove",i.touchmove),e.map.on("touchstart",i.touchstart),e.map.on("touchend",i.touchend),e.container.addEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.addEventListener("keydown",i.keydown),e.container.addEventListener("keyup",i.keyup));},removeEventListeners:function(){e.map.off("mousemove",i.mousemove),e.map.off("mousedown",i.mousedown),e.map.off("mouseup",i.mouseup),e.map.off("data",i.data),e.map.off("touchmove",i.touchmove),e.map.off("touchstart",i.touchstart),e.map.off("touchend",i.touchend),e.container.removeEventListener("mouseout",i.mouseout),e.options.keybindings&&(e.container.removeEventListener("keydown",i.keydown),e.container.removeEventListener("keyup",i.keyup));},trash:function(t){s.trash(t);},combineFeatures:function(){s.combineFeatures();},uncombineFeatures:function(){s.uncombineFeatures();},getMode:function(){return a}}}(e),e.ui=function(t){var e={},n=null,o={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function i(t){r=Mt(r,t);}function y(){var e,n;if(t.container){var i=[],a=[];It.forEach((function(t){r[t]!==o[t]&&(i.push(t+"-"+o[t]),null!==r[t]&&a.push(t+"-"+r[t]));})),i.length>0&&(e=t.container.classList).remove.apply(e,i),a.length>0&&(n=t.container.classList).add.apply(n,a),o=Mt(o,r);}}function v(t,e){void 0===e&&(e={});var o=document.createElement("button");return o.className=s+" "+e.className,o.setAttribute("title",e.title),e.container.appendChild(o),o.addEventListener("click",(function(o){if(o.preventDefault(),o.stopPropagation(),o.target===n)return m(),void e.onDeactivate();b(t),e.onActivate();}),!0),o}function m(){n&&(n.classList.remove(g),n=null);}function b(t){m();var o=e[t];o&&o&&"trash"!==t&&(o.classList.add(g),n=o);}return {setActiveButton:b,queueMapClasses:i,updateMapClasses:y,clearMapClasses:function(){i({mode:null,feature:null,mouse:null}),y();},addButtons:function(){var n=t.options.controls,o=document.createElement("div");return o.className=h+" "+a,n?(n[E.LINE]&&(e[E.LINE]=v(E.LINE,{container:o,className:u,title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(j.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),n[E.POLYGON]&&(e[E.POLYGON]=v(E.POLYGON,{container:o,className:c,title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(j.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),n[E.POINT]&&(e[E.POINT]=v(E.POINT,{container:o,className:l,title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(j.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),n.trash&&(e.trash=v("trash",{container:o,className:d,title:"Delete",onActivate:function(){t.events.trash();}})),n.combine_features&&(e.combine_features=v("combineFeatures",{container:o,className:p,title:"Combine",onActivate:function(){t.events.combineFeatures();}})),n.uncombine_features&&(e.uncombine_features=v("uncombineFeatures",{container:o,className:f,title:"Uncombine",onActivate:function(){t.events.uncombineFeatures();}})),o):o},removeButtons:function(){Object.keys(e).forEach((function(t){var n=e[t];n.parentNode&&n.parentNode.removeChild(n),delete e[t];}));}}}(e),e.container=i.getContainer(),e.store=new Ct(e),n=e.ui.addButtons(),e.options.boxSelect&&(i.boxZoom.disable(),i.dragPan.disable(),i.dragPan.enable()),i.loaded()?r.connect():(i.on("load",r.connect),o=setInterval((function(){i.loaded()&&r.connect();}),16)),e.events.start(),n},addLayers:function(){e.map.addSource(m,{data:{type:P,features:[]},type:"geojson"}),e.map.addSource(v,{data:{type:P,features:[]},type:"geojson"}),e.options.styles.forEach((function(t){e.map.addLayer(t);})),e.store.setDirty(!0),e.store.render();},removeLayers:function(){e.options.styles.forEach((function(t){e.map.getLayer(t.id)&&e.map.removeLayer(t.id);})),e.map.getSource(m)&&e.map.removeSource(m),e.map.getSource(v)&&e.map.removeSource(v);}};return e.setup=r,r}function Pt(t){return function(e){var n=e.featureTarget;return !!n&&(!!n.properties&&n.properties.meta===t)}}function Ft(t){return !!t.featureTarget&&(!!t.featureTarget.properties&&(t.featureTarget.properties.active===Z&&t.featureTarget.properties.meta===W))}function Ot(t){return !!t.featureTarget&&(!!t.featureTarget.properties&&(t.featureTarget.properties.active===K&&t.featureTarget.properties.meta===W))}function kt(t){return void 0===t.featureTarget}function Tt(t){var e=t.featureTarget;return !!e&&(!!e.properties&&e.properties.meta===Y)}function jt(t){return !!t.originalEvent&&!0===t.originalEvent.shiftKey}function At(t){return 27===t.keyCode}function Dt(t){return 13===t.keyCode}var Nt=Ut;function Ut(t,e){this.x=t,this.y=e;}function Rt(t,e){var n=e.getBoundingClientRect();return new Nt(t.clientX-n.left-(e.clientLeft||0),t.clientY-n.top-(e.clientTop||0))}function Bt(t,e,n,o){return {type:M,properties:{meta:Y,parent:t,coord_path:n,active:o?Z:K},geometry:{type:L,coordinates:e}}}function Vt(t,e,n){void 0===e&&(e={}),void 0===n&&(n=null);var o,r=t.geometry,i=r.type,a=r.coordinates,s=t.properties&&t.properties.id,u=[];function c(t,n){var o="",r=null;t.forEach((function(t,i){var a=null!=n?n+"."+i:String(i),c=Bt(s,t,a,l(a));if(e.midpoints&&r){var d=function(t,e,n){var o=e.geometry.coordinates,r=n.geometry.coordinates;if(o[1]>85||o[1]<-85||r[1]>85||r[1]<-85)return null;var i={lng:(o[0]+r[0])/2,lat:(o[1]+r[1])/2};return {type:M,properties:{meta:q,parent:t,lng:i.lng,lat:i.lat,coord_path:n.properties.coord_path},geometry:{type:L,coordinates:[i.lng,i.lat]}}}(s,r,c);d&&u.push(d);}r=c;var p=JSON.stringify(t);o!==p&&u.push(c),0===i&&(o=p);}));}function l(t){return !!e.selectedPaths&&-1!==e.selectedPaths.indexOf(t)}return i===L?u.push(Bt(s,a,n,l(n))):i===w?a.forEach((function(t,e){c(t,null!==n?n+"."+e:String(e));})):i===I?c(a,n):0===i.indexOf(F)&&(o=i.replace(F,""),a.forEach((function(n,r){var i={type:M,properties:t.properties,geometry:{type:o,coordinates:n}};u=u.concat(Vt(i,e,r));}))),u}Ut.prototype={clone:function(){return new Ut(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),o=e*this.x-n*this.y,r=n*this.x+e*this.y;return this.x=o,this.y=r,this},_rotateAround:function(t,e){var n=Math.cos(t),o=Math.sin(t),r=e.x+n*(this.x-e.x)-o*(this.y-e.y),i=e.y+o*(this.x-e.x)+n*(this.y-e.y);return this.x=r,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Ut.convert=function(t){return t instanceof Ut?t:Array.isArray(t)?new Ut(t[0],t[1]):t};var Jt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable();}),0);},Gt=function(t){setTimeout((function(){t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable();}),0);},zt=function(t){if(!t||!t.type)return null;var e=$t[t.type];if(!e)return null;if("geometry"===e)return {type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]};if("feature"===e)return {type:"FeatureCollection",features:[t]};if("featurecollection"===e)return t},$t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};function Wt(t){switch(t&&t.type||null){case"FeatureCollection":return t.features=t.features.reduce((function(t,e){return t.concat(Wt(e))}),[]),t;case"Feature":return t.geometry?Wt(t.geometry).map((function(e){var n={type:"Feature",properties:JSON.parse(JSON.stringify(t.properties)),geometry:e};return void 0!==t.id&&(n.id=t.id),n})):[t];case"MultiPoint":return t.coordinates.map((function(t){return {type:"Point",coordinates:t}}));case"MultiPolygon":return t.coordinates.map((function(t){return {type:"Polygon",coordinates:t}}));case"MultiLineString":return t.coordinates.map((function(t){return {type:"LineString",coordinates:t}}));case"GeometryCollection":return t.geometries.map(Wt).reduce((function(t,e){return t.concat(e)}),[]);case"Point":case"Polygon":case"LineString":return [t]}}var qt=function(t){if(!t)return [];var e=Wt(zt(t)),n=[];return e.features.forEach((function(t){t.geometry&&(n=n.concat(function t(e){return Array.isArray(e)&&e.length&&"number"==typeof e[0]?[e]:e.reduce((function(e,n){return Array.isArray(n)&&Array.isArray(n[0])?e.concat(t(n)):(e.push(n),e)}),[])}(t.geometry.coordinates)));})),n},Yt=ut((function(t){var e=t.exports=function(t){return new n(t)};function n(t){this.value=t;}function o(t,e,n){var o=[],a=[],l=!0;return function t(d){var p=n?r(d):d,f={},h=!0,g={node:p,node_:d,path:[].concat(o),parent:a[a.length-1],parents:a,key:o.slice(-1)[0],isRoot:0===o.length,level:o.length,circular:null,update:function(t,e){g.isRoot||(g.parent.node[g.key]=t),g.node=t,e&&(h=!1);},delete:function(t){delete g.parent.node[g.key],t&&(h=!1);},remove:function(t){s(g.parent.node)?g.parent.node.splice(g.key,1):delete g.parent.node[g.key],t&&(h=!1);},keys:null,before:function(t){f.before=t;},after:function(t){f.after=t;},pre:function(t){f.pre=t;},post:function(t){f.post=t;},stop:function(){l=!1;},block:function(){h=!1;}};if(!l)return g;function y(){if("object"==typeof g.node&&null!==g.node){g.keys&&g.node_===g.node||(g.keys=i(g.node)),g.isLeaf=0==g.keys.length;for(var t=0;t<a.length;t++)if(a[t].node_===d){g.circular=a[t];break}}else g.isLeaf=!0,g.keys=null;g.notLeaf=!g.isLeaf,g.notRoot=!g.isRoot;}y();var v=e.call(g,g.node);return void 0!==v&&g.update&&g.update(v),f.before&&f.before.call(g,g.node),h?("object"!=typeof g.node||null===g.node||g.circular||(a.push(g),y(),u(g.keys,(function(e,r){o.push(e),f.pre&&f.pre.call(g,g.node[e],e);var i=t(g.node[e]);n&&c.call(g.node,e)&&(g.node[e]=i.node),i.isLast=r==g.keys.length-1,i.isFirst=0==r,f.post&&f.post.call(g,i),o.pop();})),a.pop()),f.after&&f.after.call(g,g.node),g):g}(t).node}function r(t){if("object"==typeof t&&null!==t){var e;if(s(t))e=[];else if("[object Date]"===a(t))e=new Date(t.getTime?t.getTime():t);else if(function(t){return "[object RegExp]"===a(t)}(t))e=new RegExp(t);else if(function(t){return "[object Error]"===a(t)}(t))e={message:t.message};else if(function(t){return "[object Boolean]"===a(t)}(t))e=new Boolean(t);else if(function(t){return "[object Number]"===a(t)}(t))e=new Number(t);else if(function(t){return "[object String]"===a(t)}(t))e=new String(t);else if(Object.create&&Object.getPrototypeOf)e=Object.create(Object.getPrototypeOf(t));else if(t.constructor===Object)e={};else {var n=t.constructor&&t.constructor.prototype||t.__proto__||{},o=function(){};o.prototype=n,e=new o;}return u(i(t),(function(n){e[n]=t[n];})),e}return t}n.prototype.get=function(t){for(var e=this.value,n=0;n<t.length;n++){var o=t[n];if(!e||!c.call(e,o)){e=void 0;break}e=e[o];}return e},n.prototype.has=function(t){for(var e=this.value,n=0;n<t.length;n++){var o=t[n];if(!e||!c.call(e,o))return !1;e=e[o];}return !0},n.prototype.set=function(t,e){for(var n=this.value,o=0;o<t.length-1;o++){var r=t[o];c.call(n,r)||(n[r]={}),n=n[r];}return n[t[o]]=e,e},n.prototype.map=function(t){return o(this.value,t,!0)},n.prototype.forEach=function(t){return this.value=o(this.value,t,!1),this.value},n.prototype.reduce=function(t,e){var n=1===arguments.length,o=n?this.value:e;return this.forEach((function(e){this.isRoot&&n||(o=t.call(this,o,e));})),o},n.prototype.paths=function(){var t=[];return this.forEach((function(e){t.push(this.path);})),t},n.prototype.nodes=function(){var t=[];return this.forEach((function(e){t.push(this.node);})),t},n.prototype.clone=function(){var t=[],e=[];return function n(o){for(var a=0;a<t.length;a++)if(t[a]===o)return e[a];if("object"==typeof o&&null!==o){var s=r(o);return t.push(o),e.push(s),u(i(o),(function(t){s[t]=n(o[t]);})),t.pop(),e.pop(),s}return o}(this.value)};var i=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};function a(t){return Object.prototype.toString.call(t)}var s=Array.isArray||function(t){return "[object Array]"===Object.prototype.toString.call(t)},u=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n<t.length;n++)e(t[n],n,t);};u(i(n.prototype),(function(t){e[t]=function(e){var o=[].slice.call(arguments,1),r=new n(e);return r[t].apply(r,o)};}));var c=Object.hasOwnProperty||function(t,e){return e in t};})),Zt=Kt;function Kt(t){if(!(this instanceof Kt))return new Kt(t);this._bbox=t||[1/0,1/0,-1/0,-1/0],this._valid=!!t;}Kt.prototype.include=function(t){return this._valid=!0,this._bbox[0]=Math.min(this._bbox[0],t[0]),this._bbox[1]=Math.min(this._bbox[1],t[1]),this._bbox[2]=Math.max(this._bbox[2],t[0]),this._bbox[3]=Math.max(this._bbox[3],t[1]),this},Kt.prototype.equals=function(t){var e;return e=t instanceof Kt?t.bbox():t,this._bbox[0]==e[0]&&this._bbox[1]==e[1]&&this._bbox[2]==e[2]&&this._bbox[3]==e[3]},Kt.prototype.center=function(t){return this._valid?[(this._bbox[0]+this._bbox[2])/2,(this._bbox[1]+this._bbox[3])/2]:null},Kt.prototype.union=function(t){var e;return this._valid=!0,e=t instanceof Kt?t.bbox():t,this._bbox[0]=Math.min(this._bbox[0],e[0]),this._bbox[1]=Math.min(this._bbox[1],e[1]),this._bbox[2]=Math.max(this._bbox[2],e[2]),this._bbox[3]=Math.max(this._bbox[3],e[3]),this},Kt.prototype.bbox=function(){return this._valid?this._bbox:null},Kt.prototype.contains=function(t){if(!t)return this._fastContains();if(!this._valid)return null;var e=t[0],n=t[1];return this._bbox[0]<=e&&this._bbox[1]<=n&&this._bbox[2]>=e&&this._bbox[3]>=n},Kt.prototype.intersect=function(t){return this._valid?(e=t instanceof Kt?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]<e[0]||this._bbox[3]<e[1]||this._bbox[1]>e[3])):null;var e;},Kt.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var t="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",t)},Kt.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var Xt={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},Ht=Object.keys(Xt),Qt=function(t){return te(t).bbox()};function te(t){for(var e=Zt(),n=qt(t),o=0;o<n.length;o++)e.include(n[o]);return e}Qt.polygon=function(t){return te(t).polygon()},Qt.bboxify=function(t){return Yt(t).map((function(t){t&&(Ht.some((function(e){return !!t[e]&&-1!==Xt[e].indexOf(t.type)}))&&(t.bbox=te(t).bbox(),this.update(t)));}))};function ee(t,e){var n=-90,o=90,r=-90,i=90,a=270,s=-270;t.forEach((function(t){var e=Qt(t),u=e[1],c=e[3],l=e[0],d=e[2];u>n&&(n=u),c<o&&(o=c),c>r&&(r=c),u<i&&(i=u),l<a&&(a=l),d>s&&(s=d);}));var u=e;return n+u.lat>85&&(u.lat=85-n),r+u.lat>90&&(u.lat=90-r),o+u.lat<-85&&(u.lat=-85-o),i+u.lat<-90&&(u.lat=-90-i),a+u.lng<=-270&&(u.lng+=360*Math.ceil(Math.abs(u.lng)/360)),s+u.lng>=270&&(u.lng-=360*Math.ceil(Math.abs(u.lng)/360)),u}function ne(t,e){var n=ee(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,o=t.getCoordinates(),r=function(t){var e={lng:t[0]+n.lng,lat:t[1]+n.lat};return [e.lng,e.lat]},i=function(t){return t.map((function(t){return r(t)}))};t.type===L?e=r(o):t.type===I||t.type===O?e=o.map(r):t.type===w||t.type===k?e=o.map(i):t.type===T&&(e=o.map((function(t){return t.map((function(t){return i(t)}))}))),t.incomingCoords(e);}));}var oe={onSetup:function(t){var e=this,n={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(n.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),n},fireUpdate:function(){this.map.fire(N,{action:z,features:this.getSelected().map((function(t){return t.toGeoJSON()}))});},fireActionable:function(){var t=this,e=this.getSelected(),n=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),o=!1;if(e.length>1){o=!0;var r=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==r&&(o=!1);}));}var i=n.length>0,a=e.length>0;this.setActionableState({combineFeatures:o,uncombineFeatures:i,trash:a});},getUniqueIds:function(t){return t.length?t.map((function(t){return t.properties.id})).filter((function(t){return void 0!==t})).reduce((function(t,e){return t.add(e),t}),new tt).values():[]},stopExtendedInteractions:function(t){t.boxSelectElement&&(t.boxSelectElement.parentNode&&t.boxSelectElement.parentNode.removeChild(t.boxSelectElement),t.boxSelectElement=null),this.map.dragPan.enable(),t.boxSelecting=!1,t.canBoxSelect=!1,t.dragMoving=!1,t.canDragMove=!1;},onStop:function(){Jt(this);},onMouseMove:function(t){return this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return !t.dragMoving||this.fireUpdate()}};oe.onTap=oe.onClick=function(t,e){return kt(e)?this.clickAnywhere(t,e):Pt(Y)(e)?this.clickOnVertex(t,e):function(t){return !!t.featureTarget&&(!!t.featureTarget.properties&&t.featureTarget.properties.meta===W)}(e)?this.clickOnFeature(t,e):void 0},oe.clickAnywhere=function(t){var e=this,n=this.getSelectedIds();n.length&&(this.clearSelectedFeatures(),n.forEach((function(t){return e.doRender(t)}))),Jt(this),this.stopExtendedInteractions(t);},oe.clickOnVertex=function(t,e){this.changeMode(j.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:_});},oe.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat;},oe.clickOnFeature=function(t,e){var n=this;Gt(this),this.stopExtendedInteractions(t);var o=jt(e),r=this.getSelectedIds(),i=e.featureTarget.properties.id,a=this.isSelected(i);if(!o&&a&&this.getFeature(i).type!==L)return this.changeMode(j.DIRECT_SELECT,{featureId:i});a&&o?(this.deselect(i),this.updateUIClasses({mouse:x}),1===r.length&&Jt(this)):!a&&o?(this.select(i),this.updateUIClasses({mouse:_})):a||o||(r.forEach((function(t){return n.doRender(t)})),this.setSelected(i),this.updateUIClasses({mouse:_})),this.doRender(i);},oe.onMouseDown=function(t,e){return Ft(e)?this.startOnActiveFeature(t,e):this.drawConfig.boxSelect&&function(t){return !!t.originalEvent&&(!!t.originalEvent.shiftKey&&0===t.originalEvent.button)}(e)?this.startBoxSelect(t,e):void 0},oe.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=Rt(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0;},oe.onTouchStart=function(t,e){if(Ft(e))return this.startOnActiveFeature(t,e)},oe.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},oe.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:b}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add(y),this.map.getContainer().appendChild(t.boxSelectElement));var n=Rt(e.originalEvent,this.map.getContainer()),o=Math.min(t.boxSelectStartLocation.x,n.x),r=Math.max(t.boxSelectStartLocation.x,n.x),i=Math.min(t.boxSelectStartLocation.y,n.y),a=Math.max(t.boxSelectStartLocation.y,n.y),s="translate("+o+"px, "+i+"px)";t.boxSelectElement.style.transform=s,t.boxSelectElement.style.WebkitTransform=s,t.boxSelectElement.style.width=r-o+"px",t.boxSelectElement.style.height=a-i+"px";},oe.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};ne(this.getSelected(),n),t.dragMoveLocation=e.lngLat;},oe.onMouseUp=function(t,e){var n=this;if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){var o=[t.boxSelectStartLocation,Rt(e.originalEvent,this.map.getContainer())],r=this.featuresAt(null,o,"click"),i=this.getUniqueIds(r).filter((function(t){return !n.isSelected(t)}));i.length&&(this.select(i),i.forEach((function(t){return n.doRender(t)})),this.updateUIClasses({mouse:_}));}this.stopExtendedInteractions(t);},oe.toDisplayFeatures=function(t,e,n){e.properties.active=this.isSelected(e.properties.id)?Z:K,n(e),this.fireActionable(),e.properties.active===Z&&e.geometry.type!==L&&Vt(e).forEach(n);},oe.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable();},oe.onCombineFeatures=function(){var t=this.getSelected();if(!(0===t.length||t.length<2)){for(var e=[],n=[],o=t[0].type.replace("Multi",""),r=0;r<t.length;r++){var i=t[r];if(i.type.replace("Multi","")!==o)return;i.type.includes("Multi")?i.getCoordinates().forEach((function(t){e.push(t);})):e.push(i.getCoordinates()),n.push(i.toGeoJSON());}if(n.length>1){var a=this.newFeature({type:M,properties:n[0].properties,geometry:{type:"Multi"+o,coordinates:e}});this.addFeature(a),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([a.id]),this.map.fire(J,{createdFeatures:[a.toGeoJSON()],deletedFeatures:n});}this.fireActionable();}},oe.onUncombineFeatures=function(){var t=this,e=this.getSelected();if(0!==e.length){for(var n=[],o=[],r=function(r){var i=e[r];t.isInstanceOf("MultiFeature",i)&&(i.getFeatures().forEach((function(e){t.addFeature(e),e.properties=i.properties,n.push(e.toGeoJSON()),t.select([e.id]);})),t.deleteFeature(i.id,{silent:!0}),o.push(i.toGeoJSON()));},i=0;i<e.length;i++)r(i);n.length>1&&this.map.fire(G,{createdFeatures:n,deletedFeatures:o}),this.fireActionable();}};var re=Pt(Y),ie=Pt(q),ae={fireUpdate:function(){this.map.fire(N,{action:$,features:this.getSelected().map((function(t){return t.toGeoJSON()}))});},fireActionable:function(t){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:t.selectedCoordPaths.length>0});},startDragging:function(t,e){this.map.dragPan.disable(),t.canDragMove=!0,t.dragMoveLocation=e.lngLat;},stopDragging:function(t){this.map.dragPan.enable(),t.dragMoving=!1,t.canDragMove=!1,t.dragMoveLocation=null;},onVertex:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties,o=t.selectedCoordPaths.indexOf(n.coord_path);jt(e)||-1!==o?jt(e)&&-1===o&&t.selectedCoordPaths.push(n.coord_path):t.selectedCoordPaths=[n.coord_path];var r=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(r);},onMidpoint:function(t,e){this.startDragging(t,e);var n=e.featureTarget.properties;t.feature.addCoordinate(n.coord_path,n.lng,n.lat),this.fireUpdate(),t.selectedCoordPaths=[n.coord_path];},pathsToCoordinates:function(t,e){return e.map((function(e){return {feature_id:t,coord_path:e}}))},onFeature:function(t,e){0===t.selectedCoordPaths.length?this.startDragging(t,e):this.stopDragging(t);},dragFeature:function(t,e,n){ne(this.getSelected(),n),t.dragMoveLocation=e.lngLat;},dragVertex:function(t,e,n){for(var o=t.selectedCoordPaths.map((function(e){return t.feature.getCoordinate(e)})),r=ee(o.map((function(t){return {type:M,properties:{},geometry:{type:L,coordinates:t}}})),n),i=0;i<o.length;i++){var a=o[i];t.feature.updateCoordinate(t.selectedCoordPaths[i],a[0]+r.lng,a[1]+r.lat);}},clickNoTarget:function(){this.changeMode(j.SIMPLE_SELECT);},clickInactive:function(){this.changeMode(j.SIMPLE_SELECT);},clickActiveFeature:function(t){t.selectedCoordPaths=[],this.clearSelectedCoordinates(),t.feature.changed();},onSetup:function(t){var e=t.featureId,n=this.getFeature(e);if(!n)throw new Error("You must provide a featureId to enter direct_select mode");if(n.type===L)throw new TypeError("direct_select mode doesn't handle point features");var o={featureId:e,feature:n,dragMoveLocation:t.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:t.coordPath?[t.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(e,o.selectedCoordPaths)),this.setSelected(e),Gt(this),this.setActionableState({trash:!0}),o},onStop:function(){Jt(this),this.clearSelectedCoordinates();},toDisplayFeatures:function(t,e,n){t.featureId===e.properties.id?(e.properties.active=Z,n(e),Vt(e,{map:this.map,midpoints:!0,selectedPaths:t.selectedCoordPaths}).forEach(n)):(e.properties.active=K,n(e)),this.fireActionable(t);},onTrash:function(t){t.selectedCoordPaths.sort((function(t,e){return e.localeCompare(t,"en",{numeric:!0})})).forEach((function(e){return t.feature.removeCoordinate(e)})),this.fireUpdate(),t.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(t),!1===t.feature.isValid()&&(this.deleteFeature([t.featureId]),this.changeMode(j.SIMPLE_SELECT,{}));},onMouseMove:function(t,e){var n=Ft(e),o=re(e),r=0===t.selectedCoordPaths.length;return n&&r||o&&!r?this.updateUIClasses({mouse:_}):this.updateUIClasses({mouse:C}),this.stopDragging(t),!0},onMouseOut:function(t){return t.dragMoving&&this.fireUpdate(),!0}};ae.onTouchStart=ae.onMouseDown=function(t,e){return re(e)?this.onVertex(t,e):Ft(e)?this.onFeature(t,e):ie(e)?this.onMidpoint(t,e):void 0},ae.onDrag=function(t,e){if(!0===t.canDragMove){t.dragMoving=!0,e.originalEvent.stopPropagation();var n={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};t.selectedCoordPaths.length>0?this.dragVertex(t,e,n):this.dragFeature(t,e,n),t.dragMoveLocation=e.lngLat;}},ae.onClick=function(t,e){return kt(e)?this.clickNoTarget(t,e):Ft(e)?this.clickActiveFeature(t,e):Ot(e)?this.clickInactive(t,e):void this.stopDragging(t)},ae.onTap=function(t,e){return kt(e)?this.clickNoTarget(t,e):Ft(e)?this.clickActiveFeature(t,e):Ot(e)?this.clickInactive(t,e):void 0},ae.onTouchEnd=ae.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t);};var se={};function ue(t,e){return !!t.lngLat&&(t.lngLat.lng===e[0]&&t.lngLat.lat===e[1])}se.onSetup=function(){var t=this.newFeature({type:M,properties:{},geometry:{type:L,coordinates:[]}});return this.addFeature(t),this.clearSelectedFeatures(),this.updateUIClasses({mouse:b}),this.activateUIButton(E.POINT),this.setActionableState({trash:!0}),{point:t}},se.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT);},se.onTap=se.onClick=function(t,e){this.updateUIClasses({mouse:_}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(A,{features:[t.point.toGeoJSON()]}),this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.point.id]});},se.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0});},se.toDisplayFeatures=function(t,e,n){var o=e.properties.id===t.point.id;if(e.properties.active=o?Z:K,!o)return n(e)},se.onTrash=se.stopDrawingAndRemove,se.onKeyUp=function(t,e){if(At(e)||Dt(e))return this.stopDrawingAndRemove(t,e)};var ce={onSetup:function(){var t=this.newFeature({type:M,properties:{},geometry:{type:w,coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),Gt(this),this.updateUIClasses({mouse:b}),this.activateUIButton(E.POLYGON),this.setActionableState({trash:!0}),{polygon:t,currentVertexPosition:0}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&ue(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:b}),t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),t.currentVertexPosition++,t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat);},clickOnVertex:function(t){return this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),Tt(e)&&this.updateUIClasses({mouse:x});}};ce.onTap=ce.onClick=function(t,e){return Tt(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},ce.onKeyUp=function(t,e){At(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT)):Dt(e)&&this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.polygon.id]});},ce.onStop=function(t){this.updateUIClasses({mouse:C}),Jt(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate("0."+t.currentVertexPosition),t.polygon.isValid()?this.map.fire(A,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT,{},{silent:!0})));},ce.toDisplayFeatures=function(t,e,n){var o=e.properties.id===t.polygon.id;if(e.properties.active=o?Z:K,!o)return n(e);if(0!==e.geometry.coordinates.length){var r=e.geometry.coordinates[0].length;if(!(r<3)){if(e.properties.meta=W,n(Bt(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1)),r>3){var i=e.geometry.coordinates[0].length-3;n(Bt(t.polygon.id,e.geometry.coordinates[0][i],"0."+i,!1));}if(r<=4){var a=[[e.geometry.coordinates[0][0][0],e.geometry.coordinates[0][0][1]],[e.geometry.coordinates[0][1][0],e.geometry.coordinates[0][1][1]]];if(n({type:M,properties:e.properties,geometry:{coordinates:a,type:I}}),3===r)return}return n(e)}}},ce.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT);};var le={onSetup:function(t){var e,n,o=(t=t||{}).featureId,r="forward";if(o){if(!(e=this.getFeature(o)))throw new Error("Could not find a feature with the provided featureId");var i=t.from;if(i&&"Feature"===i.type&&i.geometry&&"Point"===i.geometry.type&&(i=i.geometry),i&&"Point"===i.type&&i.coordinates&&2===i.coordinates.length&&(i=i.coordinates),!i||!Array.isArray(i))throw new Error("Please use the `from` property to indicate which point to continue the line from");var a=e.coordinates.length-1;if(e.coordinates[a][0]===i[0]&&e.coordinates[a][1]===i[1])n=a+1,e.addCoordinate.apply(e,[n].concat(e.coordinates[a]));else {if(e.coordinates[0][0]!==i[0]||e.coordinates[0][1]!==i[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",n=0,e.addCoordinate.apply(e,[n].concat(e.coordinates[0]));}}else e=this.newFeature({type:M,properties:{},geometry:{type:I,coordinates:[]}}),n=0,this.addFeature(e);return this.clearSelectedFeatures(),Gt(this),this.updateUIClasses({mouse:b}),this.activateUIButton(E.LINE),this.setActionableState({trash:!0}),{line:e,currentVertexPosition:n,direction:r}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&ue(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&ue(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:b}),t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),"forward"===t.direction?(t.currentVertexPosition++,t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat)):t.line.addCoordinate(0,e.lngLat.lng,e.lngLat.lat);},clickOnVertex:function(t){return this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),Tt(e)&&this.updateUIClasses({mouse:x});}};le.onTap=le.onClick=function(t,e){if(Tt(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e);},le.onKeyUp=function(t,e){Dt(e)?this.changeMode(j.SIMPLE_SELECT,{featureIds:[t.line.id]}):At(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT));},le.onStop=function(t){Jt(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(""+t.currentVertexPosition),t.line.isValid()?this.map.fire(A,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT,{},{silent:!0})));},le.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(j.SIMPLE_SELECT);},le.toDisplayFeatures=function(t,e,n){var o=e.properties.id===t.line.id;if(e.properties.active=o?Z:K,!o)return n(e);e.geometry.coordinates.length<2||(e.properties.meta=W,n(Bt(t.line.id,e.geometry.coordinates["forward"===t.direction?e.geometry.coordinates.length-2:1],""+("forward"===t.direction?e.geometry.coordinates.length-2:1),!1)),n(e));};var de={simple_select:oe,direct_select:ae,draw_point:se,draw_polygon:ce,draw_line_string:le},pe={defaultMode:j.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}],modes:de,controls:{},userProperties:!1},fe={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},he={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function ge(t,e){return t.map((function(t){return t.source?t:Mt(t,{id:t.id+"."+e,source:"hot"===e?v:m})}))}var ye=ut((function(t,e){var n="[object Arguments]",o="[object Map]",r="[object Object]",i="[object Set]",a=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,u={};u["[object Float32Array]"]=u["[object Float64Array]"]=u["[object Int8Array]"]=u["[object Int16Array]"]=u["[object Int32Array]"]=u["[object Uint8Array]"]=u["[object Uint8ClampedArray]"]=u["[object Uint16Array]"]=u["[object Uint32Array]"]=!0,u[n]=u["[object Array]"]=u["[object ArrayBuffer]"]=u["[object Boolean]"]=u["[object DataView]"]=u["[object Date]"]=u["[object Error]"]=u["[object Function]"]=u[o]=u["[object Number]"]=u[r]=u["[object RegExp]"]=u[i]=u["[object String]"]=u["[object WeakMap]"]=!1;var c="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,l="object"==typeof self&&self&&self.Object===Object&&self,d=c||l||Function("return this")(),p=e&&!e.nodeType&&e,f=p&&t&&!t.nodeType&&t,h=f&&f.exports===p,g=h&&c.process,y=function(){try{return g&&g.binding&&g.binding("util")}catch(t){}}(),v=y&&y.isTypedArray;function m(t,e){for(var n=-1,o=null==t?0:t.length;++n<o;)if(e(t[n],n,t))return !0;return !1}function b(t){var e=-1,n=Array(t.size);return t.forEach((function(t,o){n[++e]=[o,t];})),n}function _(t){var e=-1,n=Array(t.size);return t.forEach((function(t){n[++e]=t;})),n}var S,x,C,E=Array.prototype,M=Function.prototype,w=Object.prototype,I=d["__core-js_shared__"],L=M.toString,P=w.hasOwnProperty,F=(S=/[^.]+$/.exec(I&&I.keys&&I.keys.IE_PROTO||""))?"Symbol(src)_1."+S:"",O=w.toString,k=RegExp("^"+L.call(P).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=h?d.Buffer:void 0,j=d.Symbol,A=d.Uint8Array,D=w.propertyIsEnumerable,N=E.splice,U=j?j.toStringTag:void 0,R=Object.getOwnPropertySymbols,B=T?T.isBuffer:void 0,V=(x=Object.keys,C=Object,function(t){return x(C(t))}),J=yt(d,"DataView"),G=yt(d,"Map"),z=yt(d,"Promise"),$=yt(d,"Set"),W=yt(d,"WeakMap"),q=yt(Object,"create"),Y=_t(J),Z=_t(G),K=_t(z),X=_t($),H=_t(W),Q=j?j.prototype:void 0,tt=Q?Q.valueOf:void 0;function et(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1]);}}function nt(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1]);}}function ot(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e<n;){var o=t[e];this.set(o[0],o[1]);}}function rt(t){var e=-1,n=null==t?0:t.length;for(this.__data__=new ot;++e<n;)this.add(t[e]);}function it(t){var e=this.__data__=new nt(t);this.size=e.size;}function at(t,e){var n=Ct(t),o=!n&&xt(t),r=!n&&!o&&Et(t),i=!n&&!o&&!r&&Pt(t),a=n||o||r||i,s=a?function(t,e){for(var n=-1,o=Array(t);++n<t;)o[n]=e(n);return o}(t.length,String):[],u=s.length;for(var c in t)!e&&!P.call(t,c)||a&&("length"==c||r&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||bt(c,u))||s.push(c);return s}function st(t,e){for(var n=t.length;n--;)if(St(t[n][0],e))return n;return -1}function ut(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":U&&U in Object(t)?function(t){var e=P.call(t,U),n=t[U];try{t[U]=void 0;var o=!0;}catch(t){}var r=O.call(t);o&&(e?t[U]=n:delete t[U]);return r}(t):function(t){return O.call(t)}(t)}function ct(t){return Lt(t)&&ut(t)==n}function lt(t,e,a,s,u){return t===e||(null==t||null==e||!Lt(t)&&!Lt(e)?t!=t&&e!=e:function(t,e,a,s,u,c){var l=Ct(t),d=Ct(e),p=l?"[object Array]":mt(t),f=d?"[object Array]":mt(e),h=(p=p==n?r:p)==r,g=(f=f==n?r:f)==r,y=p==f;if(y&&Et(t)){if(!Et(e))return !1;l=!0,h=!1;}if(y&&!h)return c||(c=new it),l||Pt(t)?ft(t,e,a,s,u,c):function(t,e,n,r,a,s,u){switch(n){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return !1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return !(t.byteLength!=e.byteLength||!s(new A(t),new A(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return St(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case o:var c=b;case i:var l=1&r;if(c||(c=_),t.size!=e.size&&!l)return !1;var d=u.get(t);if(d)return d==e;r|=2,u.set(t,e);var p=ft(c(t),c(e),r,a,s,u);return u.delete(t),p;case"[object Symbol]":if(tt)return tt.call(t)==tt.call(e)}return !1}(t,e,p,a,s,u,c);if(!(1&a)){var v=h&&P.call(t,"__wrapped__"),m=g&&P.call(e,"__wrapped__");if(v||m){var S=v?t.value():t,x=m?e.value():e;return c||(c=new it),u(S,x,a,s,c)}}if(!y)return !1;return c||(c=new it),function(t,e,n,o,r,i){var a=1&n,s=ht(t),u=s.length,c=ht(e).length;if(u!=c&&!a)return !1;var l=u;for(;l--;){var d=s[l];if(!(a?d in e:P.call(e,d)))return !1}var p=i.get(t);if(p&&i.get(e))return p==e;var f=!0;i.set(t,e),i.set(e,t);var h=a;for(;++l<u;){d=s[l];var g=t[d],y=e[d];if(o)var v=a?o(y,g,d,e,t,i):o(g,y,d,t,e,i);if(!(void 0===v?g===y||r(g,y,n,o,i):v)){f=!1;break}h||(h="constructor"==d);}if(f&&!h){var m=t.constructor,b=e.constructor;m==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof m&&m instanceof m&&"function"==typeof b&&b instanceof b||(f=!1);}return i.delete(t),i.delete(e),f}(t,e,a,s,u,c)}(t,e,a,s,lt,u))}function dt(t){return !(!It(t)||function(t){return !!F&&F in t}(t))&&(Mt(t)?k:a).test(_t(t))}function pt(t){if(n=(e=t)&&e.constructor,o="function"==typeof n&&n.prototype||w,e!==o)return V(t);var e,n,o,r=[];for(var i in Object(t))P.call(t,i)&&"constructor"!=i&&r.push(i);return r}function ft(t,e,n,o,r,i){var a=1&n,s=t.length,u=e.length;if(s!=u&&!(a&&u>s))return !1;var c=i.get(t);if(c&&i.get(e))return c==e;var l=-1,d=!0,p=2&n?new rt:void 0;for(i.set(t,e),i.set(e,t);++l<s;){var f=t[l],h=e[l];if(o)var g=a?o(h,f,l,e,t,i):o(f,h,l,t,e,i);if(void 0!==g){if(g)continue;d=!1;break}if(p){if(!m(e,(function(t,e){if(a=e,!p.has(a)&&(f===t||r(f,t,n,o,i)))return p.push(e);var a;}))){d=!1;break}}else if(f!==h&&!r(f,h,n,o,i)){d=!1;break}}return i.delete(t),i.delete(e),d}function ht(t){return function(t,e,n){var o=e(t);return Ct(t)?o:function(t,e){for(var n=-1,o=e.length,r=t.length;++n<o;)t[r+n]=e[n];return t}(o,n(t))}(t,Ft,vt)}function gt(t,e){var n,o,r=t.__data__;return ("string"==(o=typeof(n=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==n:null===n)?r["string"==typeof e?"string":"hash"]:r.map}function yt(t,e){var n=function(t,e){return null==t?void 0:t[e]}(t,e);return dt(n)?n:void 0}et.prototype.clear=function(){this.__data__=q?q(null):{},this.size=0;},et.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},et.prototype.get=function(t){var e=this.__data__;if(q){var n=e[t];return "__lodash_hash_undefined__"===n?void 0:n}return P.call(e,t)?e[t]:void 0},et.prototype.has=function(t){var e=this.__data__;return q?void 0!==e[t]:P.call(e,t)},et.prototype.set=function(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=q&&void 0===e?"__lodash_hash_undefined__":e,this},nt.prototype.clear=function(){this.__data__=[],this.size=0;},nt.prototype.delete=function(t){var e=this.__data__,n=st(e,t);return !(n<0)&&(n==e.length-1?e.pop():N.call(e,n,1),--this.size,!0)},nt.prototype.get=function(t){var e=this.__data__,n=st(e,t);return n<0?void 0:e[n][1]},nt.prototype.has=function(t){return st(this.__data__,t)>-1},nt.prototype.set=function(t,e){var n=this.__data__,o=st(n,t);return o<0?(++this.size,n.push([t,e])):n[o][1]=e,this},ot.prototype.clear=function(){this.size=0,this.__data__={hash:new et,map:new(G||nt),string:new et};},ot.prototype.delete=function(t){var e=gt(this,t).delete(t);return this.size-=e?1:0,e},ot.prototype.get=function(t){return gt(this,t).get(t)},ot.prototype.has=function(t){return gt(this,t).has(t)},ot.prototype.set=function(t,e){var n=gt(this,t),o=n.size;return n.set(t,e),this.size+=n.size==o?0:1,this},rt.prototype.add=rt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},rt.prototype.has=function(t){return this.__data__.has(t)},it.prototype.clear=function(){this.__data__=new nt,this.size=0;},it.prototype.delete=function(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n},it.prototype.get=function(t){return this.__data__.get(t)},it.prototype.has=function(t){return this.__data__.has(t)},it.prototype.set=function(t,e){var n=this.__data__;if(n instanceof nt){var o=n.__data__;if(!G||o.length<199)return o.push([t,e]),this.size=++n.size,this;n=this.__data__=new ot(o);}return n.set(t,e),this.size=n.size,this};var vt=R?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var n=-1,o=null==t?0:t.length,r=0,i=[];++n<o;){var a=t[n];e(a,n,t)&&(i[r++]=a);}return i}(R(t),(function(e){return D.call(t,e)})))}:function(){return []},mt=ut;function bt(t,e){return !!(e=null==e?9007199254740991:e)&&("number"==typeof t||s.test(t))&&t>-1&&t%1==0&&t<e}function _t(t){if(null!=t){try{return L.call(t)}catch(t){}try{return t+""}catch(t){}}return ""}function St(t,e){return t===e||t!=t&&e!=e}(J&&"[object DataView]"!=mt(new J(new ArrayBuffer(1)))||G&&mt(new G)!=o||z&&"[object Promise]"!=mt(z.resolve())||$&&mt(new $)!=i||W&&"[object WeakMap]"!=mt(new W))&&(mt=function(t){var e=ut(t),n=e==r?t.constructor:void 0,a=n?_t(n):"";if(a)switch(a){case Y:return "[object DataView]";case Z:return o;case K:return "[object Promise]";case X:return i;case H:return "[object WeakMap]"}return e});var xt=ct(function(){return arguments}())?ct:function(t){return Lt(t)&&P.call(t,"callee")&&!D.call(t,"callee")},Ct=Array.isArray;var Et=B||function(){return !1};function Mt(t){if(!It(t))return !1;var e=ut(t);return "[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function wt(t){return "number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function It(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Lt(t){return null!=t&&"object"==typeof t}var Pt=v?function(t){return function(e){return t(e)}}(v):function(t){return Lt(t)&&wt(t.length)&&!!u[ut(t)]};function Ft(t){return null!=(e=t)&&wt(e.length)&&!Mt(e)?at(t):pt(t);var e;}t.exports=function(t,e){return lt(t,e)};}));var ve={Polygon:ft,LineString:pt,Point:dt,MultiPolygon:yt,MultiLineString:yt,MultiPoint:yt};function me(t,e){return e.modes=j,e.getFeatureIdsAt=function(e){return nt.click({point:e},null,t).map((function(t){return t.properties.id}))},e.getSelectedIds=function(){return t.store.getSelectedIds()},e.getSelected=function(){return {type:P,features:t.store.getSelectedIds().map((function(e){return t.store.get(e)})).map((function(t){return t.toGeoJSON()}))}},e.getSelectedPoints=function(){return {type:P,features:t.store.getSelectedCoordinates().map((function(t){return {type:M,properties:{},geometry:{type:L,coordinates:t.coordinates}}}))}},e.set=function(n){if(void 0===n.type||n.type!==P||!Array.isArray(n.features))throw new Error("Invalid FeatureCollection");var o=t.store.createRenderBatch(),r=t.store.getAllIds().slice(),i=e.add(n),a=new tt(i);return (r=r.filter((function(t){return !a.has(t)}))).length&&e.delete(r),o(),i},e.add=function(e){var n=JSON.parse(JSON.stringify(zt(e))).features.map((function(e){if(e.id=e.id||ct(),null===e.geometry)throw new Error("Invalid geometry: null");if(void 0===t.store.get(e.id)||t.store.get(e.id).type!==e.geometry.type){var n=ve[e.geometry.type];if(void 0===n)throw new Error("Invalid geometry type: "+e.geometry.type+".");var o=new n(t,e);t.store.add(o);}else {var r=t.store.get(e.id);r.properties=e.properties,ye(r.getCoordinates(),e.geometry.coordinates)||r.incomingCoords(e.geometry.coordinates);}return e.id}));return t.store.render(),n},e.get=function(e){var n=t.store.get(e);if(n)return n.toGeoJSON()},e.getAll=function(){return {type:P,features:t.store.getAll().map((function(t){return t.toGeoJSON()}))}},e.delete=function(n){return t.store.delete(n,{silent:!0}),e.getMode()!==j.DIRECT_SELECT||t.store.getSelectedIds().length?t.store.render():t.events.changeMode(j.SIMPLE_SELECT,void 0,{silent:!0}),e},e.deleteAll=function(){return t.store.delete(t.store.getAllIds(),{silent:!0}),e.getMode()===j.DIRECT_SELECT?t.events.changeMode(j.SIMPLE_SELECT,void 0,{silent:!0}):t.store.render(),e},e.changeMode=function(n,o){return void 0===o&&(o={}),n===j.SIMPLE_SELECT&&e.getMode()===j.SIMPLE_SELECT?(r=o.featureIds||[],i=t.store.getSelectedIds(),r.length===i.length&&JSON.stringify(r.map((function(t){return t})).sort())===JSON.stringify(i.map((function(t){return t})).sort())||(t.store.setSelected(o.featureIds,{silent:!0}),t.store.render()),e):(n===j.DIRECT_SELECT&&e.getMode()===j.DIRECT_SELECT&&o.featureId===t.store.getSelectedIds()[0]||t.events.changeMode(n,o,{silent:!0}),e);var r,i;},e.getMode=function(){return t.events.getMode()},e.trash=function(){return t.events.trash({silent:!0}),e},e.combineFeatures=function(){return t.events.combineFeatures({silent:!0}),e},e.uncombineFeatures=function(){return t.events.uncombineFeatures({silent:!0}),e},e.setFeatureProperty=function(n,o,r){return t.store.setFeatureProperty(n,o,r),e},e}var be=function(t,e){var n={options:t=function(t){void 0===t&&(t={});var e=Mt(t);return t.controls||(e.controls={}),!1===t.displayControlsDefault?e.controls=Mt(he,t.controls):e.controls=Mt(fe,t.controls),(e=Mt(pe,e)).styles=ge(e.styles,"cold").concat(ge(e.styles,"hot")),e}(t)};e=me(n,e),n.api=e;var o=Lt(n);return e.onAdd=o.onAdd,e.onRemove=o.onRemove,e.types=E,e.options=t,e};function _e(t){be(t,this);}return _e.modes=de,_e}));
|
|
34
|
+
|
|
13
35
|
});
|
|
14
36
|
|
|
15
37
|
/*! @preserve
|
|
@@ -18252,7 +18274,7 @@ var factors = {
|
|
|
18252
18274
|
millimetres: earthRadius * 1000,
|
|
18253
18275
|
nauticalmiles: earthRadius / 1852,
|
|
18254
18276
|
radians: 1,
|
|
18255
|
-
yards: earthRadius
|
|
18277
|
+
yards: earthRadius * 1.0936,
|
|
18256
18278
|
};
|
|
18257
18279
|
/**
|
|
18258
18280
|
* Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
|
|
@@ -18387,8 +18409,8 @@ function getCoord(coord) {
|
|
|
18387
18409
|
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
|
|
18388
18410
|
*
|
|
18389
18411
|
* @name distance
|
|
18390
|
-
* @param {Coord} from origin point
|
|
18391
|
-
* @param {Coord} to destination point
|
|
18412
|
+
* @param {Coord | Point} from origin point or coordinate
|
|
18413
|
+
* @param {Coord | Point} to destination point or coordinate
|
|
18392
18414
|
* @param {Object} [options={}] Optional parameters
|
|
18393
18415
|
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
|
|
18394
18416
|
* @returns {number} distance between the two points
|
|
@@ -18874,13 +18896,13 @@ function flattenEach(geojson, callback) {
|
|
|
18874
18896
|
* });
|
|
18875
18897
|
*/
|
|
18876
18898
|
function segmentEach(geojson, callback) {
|
|
18877
|
-
flattenEach(geojson, function (feature
|
|
18899
|
+
flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {
|
|
18878
18900
|
var segmentIndex = 0;
|
|
18879
18901
|
|
|
18880
18902
|
// Exclude null Geometries
|
|
18881
|
-
if (!feature
|
|
18903
|
+
if (!feature.geometry) return;
|
|
18882
18904
|
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
|
|
18883
|
-
var type = feature
|
|
18905
|
+
var type = feature.geometry.type;
|
|
18884
18906
|
if (type === "Point" || type === "MultiPoint") return;
|
|
18885
18907
|
|
|
18886
18908
|
// Generate 2-vertex line segments
|
|
@@ -18890,7 +18912,7 @@ function segmentEach(geojson, callback) {
|
|
|
18890
18912
|
var prevGeomIndex = 0;
|
|
18891
18913
|
if (
|
|
18892
18914
|
coordEach(
|
|
18893
|
-
feature
|
|
18915
|
+
feature,
|
|
18894
18916
|
function (
|
|
18895
18917
|
currentCoord,
|
|
18896
18918
|
coordIndex,
|
|
@@ -18914,7 +18936,7 @@ function segmentEach(geojson, callback) {
|
|
|
18914
18936
|
}
|
|
18915
18937
|
var currentSegment = lineString(
|
|
18916
18938
|
[previousCoords, currentCoord],
|
|
18917
|
-
feature
|
|
18939
|
+
feature.properties
|
|
18918
18940
|
);
|
|
18919
18941
|
if (
|
|
18920
18942
|
callback(
|
|
@@ -19053,51 +19075,72 @@ function createVertex(parentId, coordinates, path, selected) {
|
|
|
19053
19075
|
meta: "vertex",
|
|
19054
19076
|
parent: parentId,
|
|
19055
19077
|
coord_path: path,
|
|
19056
|
-
active: selected ? "true" : "false"
|
|
19078
|
+
active: selected ? "true" : "false",
|
|
19057
19079
|
},
|
|
19058
19080
|
geometry: {
|
|
19059
19081
|
type: "Point",
|
|
19060
|
-
coordinates
|
|
19061
|
-
}
|
|
19082
|
+
coordinates,
|
|
19083
|
+
},
|
|
19062
19084
|
};
|
|
19063
19085
|
}
|
|
19064
19086
|
|
|
19065
19087
|
// create a circle-like polygon given a center point and radius
|
|
19066
19088
|
// https://stackoverflow.com/questions/37599561/drawing-a-circle-with-the-radius-in-miles-meters-with-mapbox-gl-js/39006388#39006388
|
|
19067
|
-
function createGeoJSONCircle(
|
|
19068
|
-
|
|
19069
|
-
|
|
19070
|
-
|
|
19071
|
-
|
|
19089
|
+
function createGeoJSONCircle(
|
|
19090
|
+
center,
|
|
19091
|
+
radiusInKm,
|
|
19092
|
+
parentId,
|
|
19093
|
+
epsgCode,
|
|
19094
|
+
points = 64
|
|
19095
|
+
) {
|
|
19096
|
+
if (epsgCode.includes("4326")) {
|
|
19097
|
+
// 经纬度坐标系下绘制圆
|
|
19098
|
+
const coords = {
|
|
19099
|
+
latitude: center[1],
|
|
19100
|
+
longitude: center[0],
|
|
19101
|
+
};
|
|
19072
19102
|
|
|
19073
|
-
|
|
19103
|
+
const km = radiusInKm;
|
|
19074
19104
|
|
|
19075
|
-
|
|
19076
|
-
|
|
19077
|
-
|
|
19105
|
+
const ret = [];
|
|
19106
|
+
// const distanceX = km / 111.32;
|
|
19107
|
+
// const distanceY = km / 110.574;
|
|
19108
|
+
const distanceX =
|
|
19109
|
+
km / (111.32 * Math.cos((coords.latitude * Math.PI) / 180));
|
|
19110
|
+
const distanceY = km / 110.574;
|
|
19078
19111
|
|
|
19079
|
-
|
|
19080
|
-
|
|
19081
|
-
|
|
19082
|
-
|
|
19083
|
-
|
|
19084
|
-
|
|
19085
|
-
|
|
19112
|
+
let theta;
|
|
19113
|
+
let x;
|
|
19114
|
+
let y;
|
|
19115
|
+
for (let i = 0; i < points; i += 1) {
|
|
19116
|
+
theta = (i / points) * (2 * Math.PI);
|
|
19117
|
+
x = distanceX * Math.cos(theta);
|
|
19118
|
+
y = distanceY * Math.sin(theta);
|
|
19086
19119
|
|
|
19087
|
-
|
|
19088
|
-
}
|
|
19089
|
-
ret.push(ret[0]);
|
|
19090
|
-
|
|
19091
|
-
return {
|
|
19092
|
-
type: "Feature",
|
|
19093
|
-
geometry: {
|
|
19094
|
-
type: "Polygon",
|
|
19095
|
-
coordinates: [ret]
|
|
19096
|
-
},
|
|
19097
|
-
properties: {
|
|
19098
|
-
parent: parentId
|
|
19120
|
+
ret.push([coords.longitude + x, coords.latitude + y]);
|
|
19099
19121
|
}
|
|
19100
|
-
|
|
19122
|
+
ret.push(ret[0]);
|
|
19123
|
+
return {
|
|
19124
|
+
type: "Feature",
|
|
19125
|
+
geometry: {
|
|
19126
|
+
type: "Polygon",
|
|
19127
|
+
coordinates: [ret],
|
|
19128
|
+
},
|
|
19129
|
+
properties: {
|
|
19130
|
+
parent: parentId,
|
|
19131
|
+
},
|
|
19132
|
+
};
|
|
19133
|
+
} else {
|
|
19134
|
+
// 墨卡托坐标系下绘制圆
|
|
19135
|
+
const options = {
|
|
19136
|
+
steps: 64,
|
|
19137
|
+
units: "kilometers",
|
|
19138
|
+
properties: { parent: parentId },
|
|
19139
|
+
};
|
|
19140
|
+
const circle = turf__namespace.circle(center, radiusInKm, options);
|
|
19141
|
+
|
|
19142
|
+
return circle;
|
|
19143
|
+
}
|
|
19101
19144
|
}
|
|
19102
19145
|
|
|
19103
19146
|
function getDisplayMeasurements(feature) {
|
|
@@ -19134,14 +19177,14 @@ function getDisplayMeasurements(feature) {
|
|
|
19134
19177
|
metric: `${numeral(metricMeasurement).format(metricFormat)} ${metricUnits}`,
|
|
19135
19178
|
standard: `${numeral(standardMeasurement).format(
|
|
19136
19179
|
standardFormat
|
|
19137
|
-
)} ${standardUnits}
|
|
19180
|
+
)} ${standardUnits}`,
|
|
19138
19181
|
};
|
|
19139
19182
|
|
|
19140
19183
|
return displayMeasurements;
|
|
19141
19184
|
}
|
|
19142
19185
|
|
|
19143
19186
|
const doubleClickZoom = {
|
|
19144
|
-
enable: ctx => {
|
|
19187
|
+
enable: (ctx) => {
|
|
19145
19188
|
setTimeout(() => {
|
|
19146
19189
|
// First check we've got a map and some context.
|
|
19147
19190
|
if (
|
|
@@ -19156,29 +19199,29 @@ const doubleClickZoom = {
|
|
|
19156
19199
|
if (!ctx._ctx.store.getInitialConfigValue("doubleClickZoom")) return;
|
|
19157
19200
|
ctx.map.doubleClickZoom.enable();
|
|
19158
19201
|
}, 0);
|
|
19159
|
-
}
|
|
19202
|
+
},
|
|
19160
19203
|
};
|
|
19161
|
-
RadiusMode.onSetup = function(opts) {
|
|
19204
|
+
RadiusMode.onSetup = function (opts) {
|
|
19162
19205
|
const props = mapboxGlDraw.modes.draw_line_string.onSetup.call(this, opts);
|
|
19163
19206
|
const circle = this.newFeature({
|
|
19164
19207
|
type: "Feature",
|
|
19165
19208
|
properties: {
|
|
19166
|
-
meta: "radius"
|
|
19209
|
+
meta: "radius",
|
|
19167
19210
|
},
|
|
19168
19211
|
geometry: {
|
|
19169
19212
|
type: "Polygon",
|
|
19170
|
-
coordinates: [[]]
|
|
19171
|
-
}
|
|
19213
|
+
coordinates: [[]],
|
|
19214
|
+
},
|
|
19172
19215
|
});
|
|
19173
19216
|
this.addFeature(circle);
|
|
19174
19217
|
|
|
19175
19218
|
return {
|
|
19176
19219
|
...props,
|
|
19177
|
-
circle
|
|
19220
|
+
circle,
|
|
19178
19221
|
};
|
|
19179
19222
|
};
|
|
19180
19223
|
|
|
19181
|
-
RadiusMode.clickAnywhere = function(state, e) {
|
|
19224
|
+
RadiusMode.clickAnywhere = function (state, e) {
|
|
19182
19225
|
// this ends the drawing after the user creates a second point, triggering this.onStop
|
|
19183
19226
|
if (state.currentVertexPosition === 1) {
|
|
19184
19227
|
state.line.addCoordinate(0, e.lngLat.lng, e.lngLat.lat);
|
|
@@ -19204,19 +19247,26 @@ RadiusMode.clickAnywhere = function(state, e) {
|
|
|
19204
19247
|
return null;
|
|
19205
19248
|
};
|
|
19206
19249
|
|
|
19207
|
-
RadiusMode.onMouseMove = function(state, e) {
|
|
19250
|
+
RadiusMode.onMouseMove = function (state, e) {
|
|
19208
19251
|
mapboxGlDraw.modes.draw_line_string.onMouseMove.call(this, state, e);
|
|
19209
19252
|
const geojson = state.line.toGeoJSON();
|
|
19210
19253
|
const center = geojson.geometry.coordinates[0];
|
|
19211
19254
|
const radiusInKm = length(geojson, "kilometers");
|
|
19212
|
-
const
|
|
19255
|
+
const epsgCode =
|
|
19256
|
+
this.map && this.map.crs ? this.map.crs.epsgCode : "EPSG:4326";
|
|
19257
|
+
const circleFeature = createGeoJSONCircle(
|
|
19258
|
+
center,
|
|
19259
|
+
radiusInKm,
|
|
19260
|
+
state.line.id,
|
|
19261
|
+
epsgCode
|
|
19262
|
+
);
|
|
19213
19263
|
circleFeature.properties.meta = "radius";
|
|
19214
19264
|
state.circle.setCoordinates(circleFeature.geometry.coordinates);
|
|
19215
19265
|
};
|
|
19216
19266
|
|
|
19217
19267
|
// creates the final geojson point feature with a radius property
|
|
19218
19268
|
// triggers draw.create
|
|
19219
|
-
RadiusMode.onStop = function(state) {
|
|
19269
|
+
RadiusMode.onStop = function (state) {
|
|
19220
19270
|
doubleClickZoom.enable(this);
|
|
19221
19271
|
|
|
19222
19272
|
this.activateUIButton();
|
|
@@ -19231,7 +19281,7 @@ RadiusMode.onStop = function(state) {
|
|
|
19231
19281
|
this.deleteFeature([state.line.id], { silent: true });
|
|
19232
19282
|
|
|
19233
19283
|
this.map.fire("draw.create", {
|
|
19234
|
-
features: [state.circle.toGeoJSON()]
|
|
19284
|
+
features: [state.circle.toGeoJSON()],
|
|
19235
19285
|
});
|
|
19236
19286
|
} else {
|
|
19237
19287
|
this.deleteFeature([state.line.id], { silent: true });
|
|
@@ -19239,7 +19289,7 @@ RadiusMode.onStop = function(state) {
|
|
|
19239
19289
|
}
|
|
19240
19290
|
};
|
|
19241
19291
|
|
|
19242
|
-
RadiusMode.toDisplayFeatures = function(state, geojson, display) {
|
|
19292
|
+
RadiusMode.toDisplayFeatures = function (state, geojson, display) {
|
|
19243
19293
|
const isActiveLine = geojson.properties.id === state.line.id;
|
|
19244
19294
|
geojson.properties.active = isActiveLine ? "true" : "false";
|
|
19245
19295
|
if (!isActiveLine) return display(geojson);
|
|
@@ -19278,12 +19328,12 @@ RadiusMode.toDisplayFeatures = function(state, geojson, display) {
|
|
|
19278
19328
|
meta: "currentPosition",
|
|
19279
19329
|
radiusMetric: displayMeasurements.metric,
|
|
19280
19330
|
radiusStandard: displayMeasurements.standard,
|
|
19281
|
-
parent: state.line.id
|
|
19331
|
+
parent: state.line.id,
|
|
19282
19332
|
},
|
|
19283
19333
|
geometry: {
|
|
19284
19334
|
type: "Point",
|
|
19285
|
-
coordinates: geojson.geometry.coordinates[1]
|
|
19286
|
-
}
|
|
19335
|
+
coordinates: geojson.geometry.coordinates[1],
|
|
19336
|
+
},
|
|
19287
19337
|
};
|
|
19288
19338
|
display(currentVertex);
|
|
19289
19339
|
|