2 lines
77 KiB
JavaScript
2 lines
77 KiB
JavaScript
|
/* 2020-9-22 15:23:19 | 版权所有 军懋国兴 */
|
||
|
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.mapv=t.mapv||{})}(this,function(t){"use strict";function n(){this._subscribers={}}function O(t,e){n.bind(this)(),this._options=e||{},this._data=[],t&&this.add(t)}function g(t,e,n,i){for(var o,r,a,s,l=0;l<6;l++){var u=(o={x:e,y:n},r=i,s=a=void 0,a=60*l+30,s=Math.PI/180*a,[o.x+r*Math.cos(s),o.y+r*Math.sin(s)]);t.lineTo(u[0],u[1])}}function x(t,e){var n;return"undefined"==typeof document||(n=document.createElement("canvas"),t&&(n.width=t),e&&(n.height=e)),n}function I(t){t=t||{},this.gradient=t.gradient||{.25:"rgba(0, 0, 255, 1)",.55:"rgba(0, 255, 0, 1)",.85:"rgba(255, 255, 0, 1)",1:"rgba(255, 0, 0, 1)"},this.maxSize=t.maxSize||35,this.minSize=t.minSize||0,this.max=t.max||100,this.min=t.min||0,this.initPalette()}function l(r,t,a){var s=a.max||100,e=a.min||0,n=a._size;null!=n||null==(n=a.size)&&(n=13);var i,o,l,u,h,c,g,p=new I({gradient:a.gradient,max:s,min:e}),f=(u=new x(2*(l=(i=n)+(o=i/2)),2*l),(h=u.getContext("2d")).shadowBlur=o,h.shadowColor="black",h.shadowOffsetX=h.shadowOffsetY=1e4,h.beginPath(),h.arc(l-1e4,l-1e4,i,0,2*Math.PI,!0),h.closePath(),h.fill(),u),d=f.width/2,v=f.height/2,y=t,m={};for(c in y.forEach(function(t,e){var n=void 0===t.count?1:t.count,i=Math.min(1,n/s).toFixed(2);m[i]=m[i]||[],m[i].push(t)}),m){isNaN(c)||(g=m[c],r.beginPath(),a.withoutAlpha||(r.globalAlpha=c),r.strokeStyle=p.getColor(c*s),g.forEach(function(t,e){var n,i,o;t.geometry&&(n=t.geometry._coordinates||t.geometry.coordinates,"Point"===(i=t.geometry.type)?(o=void 0===t.count?1:t.count,r.globalAlpha=o/s,r.drawImage(f,n[0]-d,n[1]-v)):"LineString"===i&&(o=void 0===t.count?1:t.count,r.globalAlpha=o/s,r.beginPath(),F.draw(r,t,a),r.stroke()))}))}}function a(t,e,n){var i=t.createShader(n);return t.shaderSource(i,e),t.compileShader(i),i}function w(t,e,n){var i=a(t,e,t.VERTEX_SHADER),o=a(t,n,t.FRAGMENT_SHADER),r=t.createProgram();return t.attachShader(r,i),t.attachShader(r,o),t.linkProgram(r),t.useProgram(r),r}function _(t){var e=document.createElement("canvas"),n=e.getContext("2d");return e.width=1,e.height=1,n.fillStyle=t,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1).data}function m(t,e,n){n=n||2;var i,o,r,a,s,l,u,h=e&&e.length,c=h?e[0]*n:t.length,g=d(t,0,c,n,!0),p=[];if(!g)return p;if(h&&(g=function(t,e,n,i){var o,r,a,s,l,u=[];for(o=0,r=e.length;o<r;o++)a=e[o]*i,s=o<r-1?e[o+1]*i:t.length,(l=d(t,a,s,i,!1))===l.next&&(l.steiner=!0),u.push(function(t){var e=t,n=t;for(;e.x<n.x&&(n=e),e=e.next,e!==t;);return n}(l));for(u.sort(b),o=0;o<u.length;o++)(function(t,e){{var n;(e=function(t,e){var n,i=e,o=t.x,r=t.y,a=-1/0;do{if(r<=i.y&&r>=i.next.y){var s=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=o&&a<s){if((a=s)===o){if(r===i.y)return i;if(r===i.next.y)return i.next}n=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!n)return null;if(o===a)return n.prev;var l,u=n,h=n.x,c=n.y,g=1/0;for(i=n.next;i!==u;)o>=i.x&&i.x>=h&&S(r<c?o:a,r,h,c,r<c?a:o,r,i.x,i.y)&&(((l=Math.abs(r-i.y)/(o-i.x))<g||l===g&&i.x>n.x)&&C(i,t)&&(n=i,g=l)),i=i.next;return n}(t,e))&&v(n=A(e,t),n.next)}})(u[o],n),n=v(n,n.next);return n}(t,e,g,n)),t.length>80*n){i=r=t[0],o=a=t[1];for(var f=n;f<c;f+=n)(s=t[f])<i&&(i=s),(l=t[f+1])<o&&(o=l),r<s&&(r=s),a<l&&(a=l);u=Math.max(r-i,a-o)}return y(g,p,n,i,o,u),p}function d(t,e,n,i,o){var r,a;if(o===0<L(t,e,n,i))for(r=e;r<n;r+=i)a=s(r,t[r],t[r+1],a);else for(r=n-i;e<=r;r-=i)a=s(r,t[r],t[r+1],a);return a&&h(a,a.next)&&(p(a),a=a.next),a}function v(t,e){if(!t)return t;e=e||t;var n,i=t;do{if(n=!1,i.steiner||!h(i,i.next)&&0!==M(i.prev,i,i.next))i=i.next;else{if(p(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function y(t,e,n,i,o,r,a){if(t){!a&&r&&function(t,e,n,i){var o=t;for(;null===o.z&&(o.z=f(o.x,o.y,e,n,i)),o.prevZ=
|