Agriculture-front-end/public/libs/openlayers/ol3-echarts/2.0.6/ol3Echarts.min.js
2023-06-22 06:50:23 +08:00

2 lines
14 KiB
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("openlayers"),require("echarts")):"function"==typeof define&&define.amd?define(["openlayers","echarts"],e):(t=t||self).ol3Echarts=e(t.ol,t.echarts)}(this,function(t,r){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r;var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function s(t){var e=typeof t;return null!==t&&("object"==e||"function"==e)}function o(i,o){for(var t=arguments,r=[],e=2;e<arguments.length;e++)r[e-2]=t[e];return function(){for(var t=arguments,e=[],n=0;n<arguments.length;n++)e[n]=t[n];return i.apply(o,r.concat(Array.prototype.slice.call(e)))}}function i(t,e){for(var n,i=0,o=t.length;i<o;i++)if(t[i].index===e.index){n=i;break}return void 0===n?t.push(e):t[n]=e,t}function a(){return function t(e){return e?(e^16*Math.random()>>e/4).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}var h=function(e,n){return Object.keys(n).forEach(function(t){s(n[t])&&s(e[t])?h(e[t],n[t]):e[t]=n[t]}),e};function p(t,e){t.forEach(function(t){e[t]&&(e[t]=e[t].bind(e))})}function c(t){return t&&t.parentNode?t.parentNode.removeChild(t):null}function u(t,e){var n=new MouseEvent(t,{bubbles:!0,cancelable:!0,button:e.pointerEvent.button,buttons:e.pointerEvent.buttons,clientX:e.pointerEvent.clientX,clientY:e.pointerEvent.clientY,zrX:e.pointerEvent.offsetX,zrY:e.pointerEvent.offsetY,movementX:e.pointerEvent.movementX,movementY:e.pointerEvent.movementY,relatedTarget:e.pointerEvent.relatedTarget,screenX:e.pointerEvent.screenX,screenY:e.pointerEvent.screenY,view:window});return n.zrX=e.pointerEvent.offsetX,n.zrY=e.pointerEvent.offsetY,n.event=n}function d(t,e,n){for(var i=[],o=[e[0],e[1]],r=o[0],s=o[1],a=0;a<t.length;a+=2){var h=t.charCodeAt(a)-64,p=t.charCodeAt(a+1)-64;h=h>>1^-(1&h),p=p>>1^-(1&p),r=h+=r,s=p+=s,i.push([h/n,p/n])}return i}function e(t){var e=function(t){if(function(t){return!t.UTF8Encoding}(t))return t;var e=t.UTF8Scale;null==e&&(e=1024);for(var n=t.features,i=0;i<n.length;i++)for(var o=n[i].geometry,r=[o.coordinates,o.encodeOffsets],s=r[0],a=r[1],h=0;h<s.length;h++){var p=s[h];if("Polygon"===o.type)s[h]=d(p,a[h],e);else if("MultiPolygon"===o.type)for(var c=0;c<p.length;c++){var u=p[c];p[c]=d(u,a[h][c],e)}}return t.UTF8Encoding=!1,t}(t);return{type:"FeatureCollection",crs:{},features:r.util.map(r.util.filter(e.features,function(t){return t.geometry&&t.properties&&0<t.geometry.coordinates.length}),function(t){var e=t.properties,n=t.geometry,i=n.coordinates,o=[];return"Polygon"===n.type&&o.push(i[0]),"MultiPolygon"===n.type&&r.util.each(i,function(t){t[0]&&o.push(t[0])}),{properties:e,type:"Feature",geometry:{type:"Polygon",coordinates:o}}})}}var l=Object.freeze({pie:function(t,e,n){return e.center=n.dataToPoint(e.coordinates),e},bar:function(i,t,o){return s(i.grid)&&!Array.isArray(i.grid)?console.log(i):Array.isArray(i.grid)&&(i.grid=i.grid.map(function(t,e){var n=o.dataToPoint(i.series[e].coordinates);return t.left=n[0]-parseFloat(t.width)/2,t.top=n[1]-parseFloat(t.height)/2,t})),t},line:function(i,t,o){return s(i.grid)&&!Array.isArray(i.grid)?console.log(i):Array.isArray(i.grid)&&(i.grid=i.grid.map(function(t,e){var n=o.dataToPoint(i.series[e].coordinates);return t.left=n[0]-parseFloat(t.width)/2,t.top=n[1]-parseFloat(t.height)/2,t})),t}}),f=t.Map,y=t.Object,g=t.proj.transform;f.prototype.getOverlayContainer||(f.prototype.getOverlayContainer=function(t){t=t||"ol-overlaycontainer";var e=this.getViewport();if(e){var n=e.getElementsByClassName(t);return n&&0<n.length?n[0]:null}return null}),f.prototype.getOverlayContainerStopEvent||(f.prototype.getOverlayContainerStopEvent=function(t){t=t||"ol-overlaycontainer-stopevent";var e=this.getViewport();if(e){var n=e.getElementsByClassName(t);return n&&0<n.length?n[0]:null}return null});var v,m,w,E={forcedRerender:!1,forcedPrecomposeRerender:!1,hideOnZooming:!1,hideOnMoving:!1,hideOnRotating:!1,convertTypes:["pie","line","bar"],insertFirst:!1,stopEvent:!1,polyfillEvents:!1};function $(){this.constructor=v}function _(t,e,n){var i=this,o=Object.assign(E,e);return(i=w.call(this,o)||this)._options=o,i._chartOptions=t,i.set("chartOptions",t),i.$chart=null,i.$container=void 0,i._isRegistered=!1,i._initEvent=!1,i._incremental=[],i._coordinateSystem=null,i.coordinateSystemId="",i.prevVisibleState="",p(["redraw","onResize","onZoomEnd","onCenterChange","onDragRotateEnd","onMoveStart","onMoveEnd","mouseDown","mouseUp","onClick","mouseMove"],i),n&&i.setMap(n),i}return n(v=_,m=w=y),void(v.prototype=null===m?Object.create(m):($.prototype=m.prototype,new $)),_.prototype.appendTo=function(t,e){void 0===e&&(e=!1),this.setMap(t,e)},_.prototype.getMap=function(){return this._map},_.prototype.setMap=function(t,e){var n=this;if(void 0===e&&(e=!1),!t||!(e||t instanceof f))throw new Error("not ol map object");this._map=t,this._map.once("postrender",function(){n.handleMapChanged()}),this._map.renderSync()},_.prototype.getChartOptions=function(){return this.get("chartOptions")},_.prototype.setChartOptions=function(t){return void 0===t&&(t={}),this._chartOptions=t,this.set("chartOptions",t),this.clearAndRedraw(),this},_.prototype.appendData=function(t,e){return void 0===e&&(e=!0),t&&(e&&(this._incremental=i(this._incremental,{index:this._incremental.length,data:t.data,seriesIndex:t.seriesIndex})),this.$chart.appendData({data:t.data.copyWithin(),seriesIndex:t.seriesIndex})),this},_.prototype.clear=function(t){t||(this._incremental=[]),this.$chart&&this.$chart.clear()},_.prototype.remove=function(){this.clear(),this.$chart&&this.$chart.dispose(),this._initEvent&&this.$container&&(this.$container&&c(this.$container),this.unBindEvent()),delete this.$chart,delete this._map},_.prototype.show=function(){this.setVisible(!0)},_.prototype.innerShow=function(){this.$container&&(this.$container.style.display=this.prevVisibleState,this.prevVisibleState="")},_.prototype.hide=function(){this.setVisible(!1)},_.prototype.innerHide=function(){this.$container&&(this.prevVisibleState=this.$container.style.display,this.$container.style.display="none")},_.prototype.isVisible=function(){return this.$container&&"none"!==this.$container.style.display},_.prototype.showLoading=function(){this.$chart&&this.$chart.showLoading()},_.prototype.hideLoading=function(){this.$chart&&this.$chart.hideLoading()},_.prototype.setZIndex=function(t){this.$container&&("number"==typeof t&&(t=String(t)),this.$container.style.zIndex=t)},_.prototype.getZIndex=function(){return this.$container&&this.$container.style.zIndex},_.prototype.setVisible=function(t){t?(this.$container&&(this.$container.style.display=""),this._chartOptions=this.getChartOptions()):(this.$container&&(this.$container.style.display="none"),this.clear(!0),this._chartOptions={}),this.clearAndRedraw()},_.prototype.render=function(){!this.$chart&&this.$container?(this.$chart=r.init(this.$container),this._chartOptions&&(this.registerMap(),this.$chart.setOption(this.convertData(this._chartOptions),!1)),this.dispatchEvent({type:"load",source:this,value:this.$chart})):this.isVisible()&&this.redraw()},_.prototype.redraw=function(){this.clearAndRedraw()},_.prototype.updateViewSize=function(t){this.$container&&(this.$container.style.width=t[0]+"px",this.$container.style.height=t[1]+"px",this.$container.setAttribute("width",String(t[0])),this.$container.setAttribute("height",String(t[1])))},_.prototype.onResize=function(t){var e=this.getMap();if(e){var n=e.getSize();this.updateViewSize(n),this.clearAndRedraw(),t&&this.dispatchEvent({type:"change:size",source:this,value:n})}},_.prototype.onZoomEnd=function(){this._options.hideOnZooming&&this.innerShow();var t=this.getMap();t&&t.getView()&&(this.clearAndRedraw(),this.dispatchEvent({type:"zoomend",source:this,value:t.getView().getZoom()}))},_.prototype.onDragRotateEnd=function(){this._options.hideOnRotating&&this.innerShow();var t=this.getMap();t&&t.getView()&&(this.clearAndRedraw(),this.dispatchEvent({type:"change:rotation",source:this,value:t.getView().getRotation()}))},_.prototype.onMoveStart=function(){this._options.hideOnMoving&&this.innerHide();var t=this.getMap();t&&t.getView()&&this.dispatchEvent({type:"movestart",source:this,value:t.getView().getCenter()})},_.prototype.onMoveEnd=function(){this._options.hideOnMoving&&this.innerShow();var t=this.getMap();t&&t.getView()&&(this.clearAndRedraw(),this.dispatchEvent({type:"moveend",source:this,value:t.getView().getCenter()}))},_.prototype.onClick=function(t){this.$chart&&this.$chart.getZr().painter.getViewportRoot().dispatchEvent(u("click",t))},_.prototype.mouseDown=function(t){this.$chart&&this.$chart.getZr().painter.getViewportRoot().dispatchEvent(u("mousedown",t))},_.prototype.mouseUp=function(t){this.$chart&&this.$chart.getZr().painter.getViewportRoot().dispatchEvent(u("mouseup",t))},_.prototype.mouseMove=function(t){if(this.$chart)for(var e=t.originalEvent.target;e;){if("ol-overlaycontainer-stopevent"===e.className)return void this.$chart.getZr().painter.getViewportRoot().dispatchEvent(u("mousemove",t));e=e.parentElement}},_.prototype.onCenterChange=function(){var t=this.getMap();t&&t.getView()&&(this.clearAndRedraw(),this.dispatchEvent({type:"change:center",source:this,value:t.getView().getCenter()}))},_.prototype.handleMapChanged=function(){var t=this.getMap();if(this._initEvent&&this.$container&&(this.$container&&c(this.$container),this.unBindEvent()),this.$container||(this.createLayerContainer(),this.onResize(!1)),t){var e=this._options.stopEvent?t.getOverlayContainerStopEvent():t.getOverlayContainer();this._options.insertFirst?e.insertBefore(this.$container,e.childNodes[0]||null):e.appendChild(this.$container),this.render(),this.bindEvent(t)}},_.prototype.createLayerContainer=function(){this.$container=document.createElement("div"),this.$container.style.position="absolute",this.$container.style.top="0px",this.$container.style.left="0px",this.$container.style.right="0px",this.$container.style.bottom="0px"},_.prototype.bindEvent=function(t){var e=t.getView();this._options.forcedPrecomposeRerender&&t.on("precompose",this.redraw),t.on("change:size",this.onResize),e.on("change:resolution",this.onZoomEnd),e.on("change:center",this.onCenterChange),e.on("change:rotation",this.onDragRotateEnd),t.on("movestart",this.onMoveStart),t.on("moveend",this.onMoveEnd),this._options.polyfillEvents&&(t.on("pointerdown",this.mouseDown),t.on("pointerup",this.mouseUp),t.on("pointermove",this.mouseMove),t.on("click",this.onClick)),this._initEvent=!0},_.prototype.unBindEvent=function(){var t=this.getMap();if(t){var e=t.getView();e&&(t.un("precompose",this.redraw),t.un("change:size",this.onResize),e.un("change:resolution",this.onZoomEnd),e.un("change:center",this.onCenterChange),e.un("change:rotation",this.onDragRotateEnd),t.un("movestart",this.onMoveStart),t.un("moveend",this.onMoveEnd),this._options.polyfillEvents&&(t.un("pointerdown",this.mouseDown),t.un("pointerup",this.mouseUp),t.un("pointermove",this.mouseMove),t.un("click",this.onClick)),this._initEvent=!1)}},_.prototype.clearAndRedraw=function(){if(this.$chart&&this.isVisible()){if(this._options.forcedRerender&&this.$chart.clear(),this.$chart.resize(),this._chartOptions&&(this.registerMap(),this.$chart.setOption(this.convertData(this._chartOptions),!1),this._incremental&&0<this._incremental.length))for(var t=0;t<this._incremental.length;t++)this.appendData(this._incremental[t],!1);this.dispatchEvent({type:"redraw",source:this})}},_.prototype.registerMap=function(){if(this._isRegistered||(this.coordinateSystemId="openlayers_"+a(),r.registerCoordinateSystem(this.coordinateSystemId,this.getCoordinateSystem(this._options)),this._isRegistered=!0),this._chartOptions){var t=this._chartOptions.series;if(t&&s(t)){var e=this._options.convertTypes;if(e)for(var n=t.length-1;0<=n;n--)-1<e.indexOf(t[n].type)||(t[n].coordinateSystem=this.coordinateSystemId),t[n].animation=!1}}},_.prototype.convertData=function(t){var e=t.series;if(e&&0<e.length){if(!this._coordinateSystem){var n=this.getCoordinateSystem(this._options);this._coordinateSystem=new n(this.getMap())}if(e&&s(e)){var i=this._options.convertTypes;if(i)for(var o=e.length-1;0<=o;o--)-1<i.indexOf(e[o].type)&&e[o]&&e[o].hasOwnProperty("coordinates")&&(e[o]=l[e[o].type](t,e[o],this._coordinateSystem))}}return t},_.prototype.getCoordinateSystem=function(s){var e=this.getMap(),n=this.coordinateSystemId,i=function(t){this.map=t,this._mapOffset=[0,0],this.dimensions=["lng","lat"],this.projCode=i.getProjectionCode(this.map)};return i.dimensions=i.prototype.dimensions||["lng","lat"],i.prototype.getZoom=function(){return this.map.getView().getZoom()},i.prototype.setZoom=function(t){return this.map.getView().setZoom(t)},i.prototype.getViewRectAfterRoam=function(){return this.getViewRect().clone()},i.prototype.setMapOffset=function(t){this._mapOffset=t},i.prototype.dataToPoint=function(t){var e;if(t&&Array.isArray(t)&&0<t.length){e=t.map(function(t){return"string"==typeof t?Number(t):t});var n=s&&s.source||"EPSG:4326",i=s&&s.destination||this.projCode,o=this.map.getPixelFromCoordinate(g(e,n,i)),r=this._mapOffset;return[o[0]-r[0],o[1]-r[1]]}return[0,0]},i.prototype.pointToData=function(t){var e=this._mapOffset;return this.map.getCoordinateFromPixel([t[0]+e[0],t[1]+e[1]])},i.prototype.getViewRect=function(){var t=this.map.getSize();return new r.graphic.BoundingRect(0,0,t[0],t[1])},i.prototype.getRoamTransform=function(){return r.matrix.create()},i.prototype.prepareCustoms=function(){var t=this.getViewRect();return{coordSys:{type:n,x:t.x,y:t.y,width:t.width,height:t.height},api:{coord:o(this.dataToPoint,this),size:o(i.dataToCoordsSize,this)}}},i.create=function(t){t.eachSeries(function(t){t.get("coordinateSystem")===n&&(t.coordinateSystem=new i(e))})},i.getProjectionCode=function(t){return t?t.getView()&&t.getView().getProjection().getCode():"EPSG:3857"},i.dataToCoordsSize=function(s,a){var h=this;return void 0===a&&(a=[0,0]),[0,1].map(function(t){var e=a[t],n=[],i=[],o=s[t]/2;n[t]=e-o,i[t]=e+o,n[1-t]=a[1-t],i[1-t]=a[1-t];var r=h.dataToPoint(n)[t]-h.dataToPoint(i)[t];return Math.abs(r)},this)},i},_.prototype.dispatchEvent=function(t){return w.prototype.dispatchEvent.call(this,t)},_.prototype.set=function(t,e,n){return w.prototype.set.call(this,t,e,n)},_.prototype.get=function(t){return w.prototype.get.call(this,t)},_.prototype.unset=function(t,e){return w.prototype.unset.call(this,t,e)},_.prototype.on=function(t,e,n){return w.prototype.on.call(this,t,e,n)},_.prototype.un=function(t,e,n){return w.prototype.un.call(this,t,e,n)},_.formatGeoJSON=e,_.bind=o,_.merge=h,_.uuid=a,_.bindAll=p,_.arrayAdd=i,_.removeNode=c,_.isObject=s,_});