hi-ucs/front/public/leaflet/libs/mapbox-gl-js/plugins/mapbox-gl-draw/mapbox-gl-draw.js

12 lines
108 KiB
Vue
Raw Normal View History

2022-06-14 09:32:49 +08:00
/*!
* Copyright (c) Mapbox
* mapbox-gl-draw.js v1.0.0 (https://github.com/mapbox/mapbox-gl-draw)
* github: https://github.com/mapbox/mapbox-gl-draw
* license: ISC
*
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.MapboxDraw=e()}}(function(){return function e(t,n,o){function r(s,a){if(!n[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return r(n||e)},l,l.exports,e,t,n,o)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<o.length;s++)r(o[s]);return r}({1:[function(e,t,n){"use strict";var o=e("./src/setup"),r=e("./src/options"),i=e("./src/api"),s=e("./src/constants"),a=function(e,t){e=r(e);var n={options:e};t=i(n,t),n.api=t;var a=o(n);return t.onAdd=a.onAdd,t.onRemove=a.onRemove,t.types=s.types,t.options=e,t};t.exports=function(e){a(e,this)},t.exports.modes=e("./src/modes")},{"./src/api":23,"./src/constants":24,"./src/modes":57,"./src/options":62,"./src/setup":64}],2:[function(e,t,n){function o(e){var t,n=0;switch(e.type){case"Polygon":return r(e.coordinates);case"MultiPolygon":for(t=0;t<e.coordinates.length;t++)n+=r(e.coordinates[t]);return n;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(t=0;t<e.geometries.length;t++)n+=o(e.geometries[t]);return n}}function r(e){var t=0;if(e&&e.length>0){t+=Math.abs(i(e[0]));for(var n=1;n<e.length;n++)t-=Math.abs(i(e[n]))}return t}function i(e){var t,n,o,r,i,c,u,l=0,p=e.length;if(p>2){for(u=0;u<p;u++)u===p-2?(r=p-2,i=p-1,c=0):u===p-1?(r=p-1,i=0,c=1):(r=u,i=u+1,c=u+2),t=e[r],n=e[i],o=e[c],l+=(s(o[0])-s(t[0]))*Math.sin(s(n[1]));l=l*a.RADIUS*a.RADIUS/2}return l}function s(e){return e*Math.PI/180}var a=e("wgs84");t.exports.geometry=o,t.exports.ring=i},{wgs84:21}],3:[function(e,t,n){function o(e){if(!e||!e.type)return null;var t=r[e.type];return t?"geometry"===t?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]}:"feature"===t?{type:"FeatureCollection",features:[e]}:"featurecollection"===t?e:void 0:null}t.exports=o;var r={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},{}],4:[function(e,t,n){function o(e,t){var n,o=[];if("object"==typeof e)n=e;else{if("string"!=typeof e)return[{message:"Expected string or object as input",line:0}];try{n=r.parse(e)}catch(e){var s=e.message.match(/line (\d+)/),a=parseInt(s[1],10);return[{line:a-1,message:e.message,error:e}]}}return o=o.concat(i.hint(n,t))}var r=e("jsonlint-lines"),i=e("./object");t.exports.hint=o},{"./object":5,"jsonlint-lines":15}],5:[function(e,t,n){function o(e,t){function n(e){if(t&&!1===t.noDuplicateMembers||!e.__duplicateProperties__||b.push({message:"An object contained duplicate members, making parsing ambigous: "+e.__duplicateProperties__.join(", "),line:e.__line__}),!i(e,"type","string"))if(S[e.type])e&&S[e.type](e);else{var n=O[e.type.toLowerCase()];void 0!==n?b.push({message:"Expected "+n+" but got "+e.type+" (case sensitive)",line:e.__line__}):b.push({message:"The type "+e.type+" is unknown",line:e.__line__})}}function o(e,t){return e.every(function(e){return null!==e&&typeof e===t})}function i(e,t,n){if(void 0===e[t])return b.push({message:'"'+t+'" member required',line:e.__line__});if("array"===n){if(!Array.isArray(e[t]))return b.push({message:'"'+t+'" member should be an array, but is an '+typeof e[t]+" instead",line:e.__line__})}else{if("object"===n&&e[t]&&"Object"!==e[t].constructor.name)return b.push({message:'"'+t+'" member should be '+n+", but is an "+e[t].constructor.name+" instead",line:e.__line__});if(n&&typeof e[t]!==n)return b.push({message:'"'+t+'" member should be '+n+", but is an "+typeof e[t]+" instead",line:e.__line__})}}function s(e){if(u(e),l(e),void 0!==e.properties&&b.push({messag
;Je["[object Float32Array]"]=Je["[object Float64Array]"]=Je["[object Int8Array]"]=Je["[object Int16Array]"]=Je["[object Int32Array]"]=Je["[object Uint8Array]"]=Je["[object Uint8ClampedArray]"]=Je["[object Uint16Array]"]=Je["[object Uint32Array]"]=!0,Je[Te]=Je[xe]=Je[Ve]=Je[Oe]=Je[Ge]=Je[Ie]=Je[Ce]=Je[Le]=Je[Ne]=Je[we]=Je[Pe]=Je[je]=Je[ke]=Je[Re]=Je["[object WeakMap]"]=!1;var ze="object"==typeof e&&e&&e.Object===Object&&e,Ye="object"==typeof self&&self&&self.Object===Object&&self,qe=ze||Ye||Function("return this")(),Xe="object"==typeof n&&n&&!n.nodeType&&n,We=Xe&&"object"==typeof t&&t&&!t.nodeType&&t,Ke=We&&We.exports===Xe,He=Ke&&ze.process,Ze=function(){try{return He&&He.binding&&He.binding("util")}catch(e){}}(),Qe=Ze&&Ze.isTypedArray,et=Array.prototype,tt=Function.prototype,nt=Object.prototype,ot=qe["__core-js_shared__"],rt=tt.toString,it=nt.hasOwnProperty,st=function(){var e=/[^.]+$/.exec(ot&&ot.keys&&ot.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),at=nt.toString,ct=RegExp("^"+rt.call(it).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ut=Ke?qe.Buffer:void 0,lt=qe.Symbol,pt=qe.Uint8Array,ft=nt.propertyIsEnumerable,ht=et.splice,dt=lt?lt.toStringTag:void 0,gt=Object.getOwnPropertySymbols,yt=ut?ut.isBuffer:void 0,mt=function(e,t){return function(n){return e(t(n))}}(Object.keys,Object),_t=Q(qe,"DataView"),vt=Q(qe,"Map"),bt=Q(qe,"Promise"),Et=Q(qe,"Set"),Tt=Q(qe,"WeakMap"),xt=Q(Object,"create"),St=se(_t),Ot=se(vt),It=se(bt),Ct=se(Et),Lt=se(Tt),Mt=lt?lt.prototype:void 0,Nt=Mt?Mt.valueOf:void 0;p.prototype.clear=f,p.prototype.delete=h,p.prototype.get=d,p.prototype.has=g,p.prototype.set=y,m.prototype.clear=_,m.prototype.delete=v,m.prototype.get=b,m.prototype.has=E,m.prototype.set=T,x.prototype.clear=S,x.prototype.delete=O,x.prototype.get=I,x.prototype.has=C,x.prototype.set=L,M.prototype.add=M.prototype.push=N,M.prototype.has=w,A.prototype.clear=P,A.prototype.delete=F,A.prototype.get=j,A.prototype.has=k,A.prototype.set=R;var wt=gt?function(e){return null==e?[]:(e=Object(e),o(gt(e),function(t){return ft.call(e,t)}))}:ge,At=G;(_t&&At(new _t(new ArrayBuffer(1)))!=Ge||vt&&At(new vt)!=Ne||bt&&"[object Promise]"!=At(bt.resolve())||Et&&At(new Et)!=ke||Tt&&"[object WeakMap]"!=At(new Tt))&&(At=function(e){var t=G(e),n=t==Pe?e.constructor:void 0,o=n?se(n):"";if(o)switch(o){case St:return Ge;case Ot:return Ne;case It:return"[object Promise]";case Ct:return ke;case Lt:return"[object WeakMap]"}return t});var Pt=B(function(){return arguments}())?B:function(e){return he(e)&&it.call(e,"callee")&&!ft.call(e,"callee")},Ft=Array.isArray,jt=yt||ye,kt=Qe?function(e){return function(t){return e(t)}}(Qe):Y;t.exports=ue}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],17:[function(e,t,n){(function(e){function t(e,t){for(var n=0,o=e.length-1;o>=0;o--){var r=e[o];"."===r?e.splice(o,1):".."===r?(e.splice(o,1),n++):n&&(e.splice(o,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function o(e,t){if(e.filter)return e.filter(t);for(var n=[],o=0;o<e.length;o++)t(e[o],o,e)&&n.push(e[o]);return n}var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){return r.exec(e).slice(1)};n.resolve=function(){for(var n="",r=!1,i=arguments.length-1;i>=-1&&!r;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,r="/"===s.charAt(0))}return n=t(o(n.split("/"),function(e){return!!e}),!r).join("/"),(r?"/":"")+n||"."},n.normalize=function(e){var r=n.isAbsolute(e),i="/"===s(e,-1);return e=t(o(e.split("/"),function(e){return!!e}),!r).join("/"),e||r||(e="."),e&&i&&(e+="/"),(r?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(o(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function o(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=
36:[function(e,t,n){"use strict";t.exports={enable:function(e){setTimeout(function(){e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.enable()},0)},disable:function(e){setTimeout(function(){e.map&&e.map.doubleClickZoom&&e.map.doubleClickZoom.disable()},0)}}},{}],37:[function(e,t,n){"use strict";t.exports=function(e,t){var n=e.x-t.x,o=e.y-t.y;return Math.sqrt(n*n+o*o)}},{}],38:[function(e,t,n){"use strict";function o(e,t,n){return i(e,t,n,n.options.clickBuffer)}function r(e,t,n){return i(e,t,n,n.options.touchBuffer)}function i(e,t,n,o){if(null===n.map)return[];var r=e?a(e,o):t,i={};n.options.styles&&(i.layers=n.options.styles.map(function(e){return e.id}));var c=n.map.queryRenderedFeatures(r,i).filter(function(e){return-1!==l.indexOf(e.properties.meta)}),p=new u,f=[];return c.forEach(function(e){var t=e.properties.id;p.has(t)||(p.add(t),f.push(e))}),s(f)}var s=e("./sort_features"),a=e("./map_event_to_bounding_box"),c=e("../constants"),u=e("./string_set"),l=[c.meta.FEATURE,c.meta.MIDPOINT,c.meta.VERTEX];t.exports={click:o,touch:r}},{"../constants":24,"./map_event_to_bounding_box":43,"./sort_features":47,"./string_set":48}],39:[function(e,t,n){"use strict";var o=e("./features_at"),r=e("../constants");t.exports=function(e,t){var n=o.click(e,null,t),i={mouse:r.cursors.NONE};return n[0]&&(i.mouse=n[0].properties.active===r.activeStates.ACTIVE?r.cursors.MOVE:r.cursors.POINTER,i.feature=n[0].properties.meta),-1!==t.events.currentModeName().indexOf("draw")&&(i.mouse=r.cursors.ADD),t.ui.queueMapClasses(i),t.ui.updateMapClasses(),n[0]}},{"../constants":24,"./features_at":38}],40:[function(e,t,n){"use strict";var o=e("./euclidean_distance");t.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=null!=n.fineTolerance?n.fineTolerance:4,i=null!=n.grossTolerance?n.grossTolerance:12,s=null!=n.interval?n.interval:500;e.point=e.point||t.point,e.time=e.time||t.time;var a=o(e.point,t.point);return a<r||a<i&&t.time-e.time<s}},{"./euclidean_distance":37}],41:[function(e,t,n){"use strict";function o(e,t){return!!e.lngLat&&(e.lngLat.lng===t[0]&&e.lngLat.lat===t[1])}t.exports=o},{}],42:[function(e,t,n){"use strict";var o=e("./euclidean_distance");t.exports=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=null!=n.tolerance?n.tolerance:25,i=null!=n.interval?n.interval:250;return e.point=e.point||t.point,e.time=e.time||t.time,o(e.point,t.point)<r&&t.time-e.time<i}},{"./euclidean_distance":37}],43:[function(e,t,n){"use strict";function o(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[[e.point.x-t,e.point.y-t],[e.point.x+t,e.point.y+t]]}t.exports=o},{}],44:[function(e,t,n){"use strict";var o=function(e,t){var n={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},o={on:function(e,t,o){if(void 0===n[e])throw new Error("Invalid event type: "+e);n[e].push({selector:t,fn:o})},render:function(e){t.store.featureChanged(e)}},r=function(e,r){for(var i=n[e],s=i.length;s--;){var a=i[s];if(a.selector(r)){a.fn.call(o,r),t.store.render(),t.ui.updateMapClasses();break}}};return e.start.call(o),{render:e.render,stop:function(){e.stop&&e.stop()},trash:function(){e.trash&&(e.trash(),t.store.render())},combineFeatures:function(){e.combineFeatures&&e.combineFeatures()},uncombineFeatures:function(){e.uncombineFeatures&&e.uncombineFeatures()},drag:function(e){r("drag",e)},click:function(e){r("click",e)},mousemove:function(e){r("mousemove",e)},mousedown:function(e){r("mousedown",e)},mouseup:function(e){r("mouseup",e)},mouseout:function(e){r("mouseout",e)},keydown:function(e){r("keydown",e)},keyup:function(e){r("keyup",e)},touchstart:function(e){r("touchstart",e)},touchmove:function(e){r("touchmove",e)},touchend:function(e){r("touchend",e)},tap:function(e){r("tap",e)}}};t.exports=o},{}],45:[function(e,t,n){"use strict";function o(e,t){var n=t.getBoundingClientRect();return new r(e.clientX-n.left-(t.clientLeft||0),e.clientY-n.top-(t.clientTop||0))}var r=e("point-geometry");t.exports=o},{"point-geometr
return o.isActiveFeature(t)?this.startOnActiveFeature(e,t):this.drawConfig.boxSelect&&o.isShiftMousedown(t)?this.startBoxSelect(e,t):void 0},l.startBoxSelect=function(e,t){this.stopExtendedInteractions(e),this.map.dragPan.disable(),e.boxSelectStartLocation=r(t.originalEvent,this.map.getContainer()),e.canBoxSelect=!0},l.onTouchStart=function(e,t){if(o.isActiveFeature(t))return this.startOnActiveFeature(e,t)},l.onDrag=function(e,t){return e.canDragMove?this.dragMove(e,t):this.drawConfig.boxSelect&&e.canBoxSelect?this.whileBoxSelect(e,t):void 0},l.whileBoxSelect=function(e,t){e.boxSelecting=!0,this.updateUIClasses({mouse:u.cursors.ADD}),e.boxSelectElement||(e.boxSelectElement=document.createElement("div"),e.boxSelectElement.classList.add(u.classes.BOX_SELECT),this.map.getContainer().appendChild(e.boxSelectElement));var n=r(t.originalEvent,this.map.getContainer()),o=Math.min(e.boxSelectStartLocation.x,n.x),i=Math.max(e.boxSelectStartLocation.x,n.x),s=Math.min(e.boxSelectStartLocation.y,n.y),a=Math.max(e.boxSelectStartLocation.y,n.y),c="translate("+o+"px, "+s+"px)";e.boxSelectElement.style.transform=c,e.boxSelectElement.style.WebkitTransform=c,e.boxSelectElement.style.width=i-o+"px",e.boxSelectElement.style.height=a-s+"px"},l.dragMove=function(e,t){e.dragMoving=!0,t.originalEvent.stopPropagation();var n={lng:t.lngLat.lng-e.dragMoveLocation.lng,lat:t.lngLat.lat-e.dragMoveLocation.lat};c(this.getSelected(),n),e.dragMoveLocation=t.lngLat},l.onMouseUp=function(e,t){var n=this;if(e.dragMoving)this.fireUpdate();else if(e.boxSelecting){var o=[e.boxSelectStartLocation,r(t.originalEvent,this.map.getContainer())],i=this.featuresAt(null,o,"click"),s=this.getUniqueIds(i).filter(function(e){return!n.isSelected(e)});s.length&&(this.select(s),s.forEach(function(e){return n.doRender(e)}),this.updateUIClasses({mouse:u.cursors.MOVE}))}this.stopExtendedInteractions(e)},l.toDisplayFeatures=function(e,t,n){t.properties.active=this.isSelected(t.properties.id)?u.activeStates.ACTIVE:u.activeStates.INACTIVE,n(t),this.fireActionable(),t.properties.active===u.activeStates.ACTIVE&&t.geometry.type!==u.geojsonTypes.POINT&&i(t).forEach(n)},l.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},l.onCombineFeatures=function(){var e=this.getSelected();if(!(0===e.length||e.length<2)){for(var t=[],n=[],o=e[0].type.replace("Multi",""),r=0;r<e.length;r++){var i=e[r];if(i.type.replace("Multi","")!==o)return;i.type.includes("Multi")?i.getCoordinates().forEach(function(e){t.push(e)}):t.push(i.getCoordinates()),n.push(i.toGeoJSON())}if(n.length>1){var s=this.newFeature({type:u.geojsonTypes.FEATURE,properties:n[0].properties,geometry:{type:"Multi"+o,coordinates:t}});this.addFeature(s),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([s.id]),this.map.fire(u.events.COMBINE_FEATURES,{createdFeatures:[s.toGeoJSON()],deletedFeatures:n})}this.fireActionable()}},l.onUncombineFeatures=function(){var e=this,t=this.getSelected();if(0!==t.length){for(var n=[],o=[],r=0;r<t.length;r++)!function(r){var i=t[r];e.isInstanceOf("MultiFeature",i)&&(i.getFeatures().forEach(function(t){e.addFeature(t),t.properties=i.properties,n.push(t.toGeoJSON()),e.select([t.id])}),e.deleteFeature(i.id,{silent:!0}),o.push(i.toGeoJSON()))}(r);n.length>1&&this.map.fire(u.events.UNCOMBINE_FEATURES,{createdFeatures:n,deletedFeatures:o}),this.fireActionable()}},t.exports=l},{"../constants":24,"../lib/common_selectors":31,"../lib/create_supplementary_points":34,"../lib/double_click_zoom":36,"../lib/mouse_event_point":45,"../lib/move_features":46,"../lib/string_set":48}],62:[function(e,t,n){"use strict";function o(e,t){return e.map(function(e){return e.source?e:r(e,{id:e.id+"."+t,source:"hot"===t?i.sources.HOT:i.sources.COLD})})}var r=e("xtend"),i=e("./constants"),s={defaultMode:i.modes.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:e("./lib/theme"),modes:e("./modes"),controls:{},userProperties:!1},a={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0