New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ldmap

Package Overview
Dependencies
Maintainers
3
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldmap - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

2

layer/flow.js

@@ -1,1 +0,1 @@

function b(a,b){this.u=a,this.v=b,this.m=Math.sqrt(a*a+b*b)}function i(a,b,c,d){this.grid=a,this.extent=b,this.dx=c,this.dy=d}function c(a,b,c){this.x=a,this.y=b,this.oldX=-1,this.oldY=-1,this.life=c}var d=require('./webgl_heatmap/CanvasLayerBase.js'),e=require('chroma-js'),f=d.extend({options:{start_color:'rgba(0, 255, 255, 0.5)',end_color:'rgba(255, 30, 219, 0.5)',fade:1,maxIntensity:17,velocityScale:1,lineWidth:2,fadeFillStyle:'rgba(0, 0, 0, 0.97)',life:80,strokeStyle:'rgb(227, 238, 238)',particles_factor:1},initialize:function(a){L.setOptions(this,a)},updateOptions:function(a){L.setOptions(this,a),this._reset()},setData:function(a){this.data=a,this._initVectorField(),this._reset()},_initVectorField:function(){var a=this.data;if(!(a&&a.data&&a.data.length>0))return;var s=a.lo1||0,t=a.la1||90,m=a.lo2||359,n=a.la2||-90,f=a.dx||1,r=a.dy||1,g=a.nx||360,l=a.ny||181,h=[],j=0,o=a.data,p=Math.floor(g*f)>=360;for(var d=0;d<l;d++){var c=[];for(var e=0;e<g;e++,j++){var k=o[j];c[e]=new b(k[0],k[1])}p&&c.push(c[0]),h[d]=c}var q={lng_min:s,lat_min:n,lng_max:m,lat_max:t};this.vectorField=new i(h,q,f,r)},interpolateLngLat:function(t,s){if(Math.abs(s)>=85.0511287798)return new b(NaN,NaN);var c=this.vectorField,q=c.extent,h=g(t-q.lng_min,360)/c.dx,i=(q.lat_max-s)/c.dy,d=Math.floor(h),f=d+1,e=Math.floor(i),r=e+1,o=c.grid,a;if(a=o[e]){var n=a[d],l=a[f];if(j(n)&&j(l)&&(a=o[r])){var k=a[d],m=a[f];if(j(k)&&j(m))return p(h-d,i-e,n,l,k,m)}}return new b(NaN,NaN)},columns:[],_initColumns:function(){var d=this.getMapBounds(),h=this.columns,o=(d.south-d.north)*(d.west-d.east),j=this._map.getBounds(),m=this.width*180/(20037508.34*(j.getEast()-j.getWest())),n=this.options.velocityScale*1e-6/m;for(var a=0;a<=this.width;a+=2){var f=[];for(var b=0;b<=this.height;b+=2){var l=this._map.containerPointToLatLng(L.point(a,b)),g=[l.lng,l.lat];if(g){var e=g[0],i=g[1];if(isFinite(e)){var c=this.interpolateLngLat(e,i);c&&!Array.isArray(c)&&(c=k(e,i,a,b,n,c,d)),f[b+1]=f[b]=c}}}h[a+1]=h[a]=f}},getVectorAtXY:function(b,c){var a=this._map.containerPointToLatLng(L.point(b,c));return this.interpolateLngLat(a.lng,a.lat)},getField:function(c,d){var a=this.columns[Math.round(c)];return a&&a[Math.round(d)]||new b(NaN,NaN)},particles:[],generateParticles:function(){var a=this.getMapBounds(),c=(a.south-a.north)*(a.west-a.east),d=Math.round(this._canvas.width*this._canvas.height*this.options.particles_factor*Math.pow(c,.24)/200);for(var b=0;b<d;b++)this.particles.push(this.randomParticle())},randomParticle:function(){var a,b,d=0;do a=Math.round(Math.floor(Math.random()*this._canvas.width)),b=Math.round(Math.floor(Math.random()*this._canvas.height));while(isNaN(this.getField(a,b).m)&&d++<30);return new c(a,b,1+this.options.life*Math.random())},_reset:function(){var b=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,b);var a=this.data;a&&a.data&&a.data.length>0&&(this._clear(),this._initColumns(),this.generateParticles(),this.initColorStyles(),this.start())},_resize:function(a){this._setCanvasSize(a.newSize),this._reset()},_clear:function(){this.particles=[],this.columns=[],this.frame&&L.Util.cancelAnimFrame(this.frame),this._canvas.getContext('2d').clearRect(0,0,this.width,this.height)},getMapBounds:function(){var a=this._map.getBounds(),b=[[a._southWest.lng,a._southWest.lat],[a._northEast.lng,a._northEast.lat]];return{south:h(b[0][1]),north:h(b[1][1]),east:h(b[1][0]),west:h(b[0][0]),height:this.height,width:this.width}},initColorStyles:function(){var a=e.scale([this.options.start_color,this.options.end_color]).colors(8),b=this;a.indexFor=function(c){return Math.floor(Math.min(c,b.options.maxIntensity)/b.options.maxIntensity*(a.length-1))},this.colorStyles=a},updateParticles:function(){var d=1,e=this.particles,f=this.colorStyles;for(var b=0;b<e.length;b++){var a=e[b];if(a.color='#eee',a.life>0){var c=this.getField(a.x,a.y);isNaN(c.m)?this.particles[b]=this.randomParticle():(a.x+=d*c.u,a.y+=d*c.v,isNaN(this.getField(a.x,a.y).m)?this.particles[b]=this.randomParticle():a.color=this.colorStyles[this.colorStyles.indexFor(c.m)]),a.life--}else this.particles[b]=this.randomParticle()}},draw:function(a){var d=this._canvas.width,f=this._canvas.height,g=a.globalCompositeOperation;a.globalCompositeOperation='destination-in',a.fillStyle=e('#000').alpha(1-this.options.fade/10).css(),a.fillRect(0,0,d,f),a.globalCompositeOperation=g;for(var c=0;c<this.particles.length;c++){var b=this.particles[c];b.oldX!=-1&&(a.beginPath(),a.lineWidth=this.options.lineWidth,a.strokeStyle=b.color,a.moveTo(b.oldX,b.oldY),a.lineTo(b.x,b.y),a.stroke()),b.oldX=b.x,b.oldY=b.y}},start:function(){this.updateParticles(),this._redraw(),this.frame=L.Util.requestAnimFrame(this.start,this)},destory:function(){this._clear(),this.onRemove(this._map),this._map.off('resize',this.onResize,this),this.data=[]}}),g=function(a,b){return a-b*Math.floor(a/b)},h=function(a){return a/180*Math.PI},a=function(a){return a/(Math.PI/180)},j=function(a){return a!==null&&a!==undefined},k=function(f,j,i,g,e,b,h){var d=b.u*e,c=b.v*e,a=l(f,j,i,g,h);return b.u=a[0]*d+a[2]*c,b.v=a[1]*d+a[3]*c,b},l=function(f,b,l,i,j){var k=2*Math.PI,a=Math.pow(10,-5.2),c=f<0?a:-a,d=b<0?a:-a,g=n(b,f+c,j),h=n(b+d,f,j),e=Math.cos(b/360*k);return[(g[0]-l)/c/e,(g[1]-i)/c/e,(h[0]-l)/d,(h[1]-i)/d]},m=function(a){return Math.log(Math.tan(a/2+Math.PI/4))},n=function(i,j,a){var d=m(a.south),c=m(a.north),e=a.width/(a.east-a.west),f=a.height/(c-d),b=m(h(i)),g=(h(j)-a.west)*e,b=(c-b)*f;return[g,b]},o=function(j,k,b){var d=b.east-b.west,c=b.width/a(d)*360/(2*Math.PI),h=c/2*Math.log((1+Math.sin(b.south))/(1-Math.sin(b.south))),i=b.height+h,g=(i-k)/c,f=180/Math.PI*(2*Math.atan(Math.exp(g))-Math.PI/2),e=a(b.west)+j/b.width*a(d);return[e,f]},p=function(d,c,j,k,l,m){var a=1-d,e=1-c,f=a*e,g=d*e,h=a*c,i=d*c,o=j.u*f+k.u*g+l.u*h+m.u*i,n=j.v*f+k.v*g+l.v*h+m.v*i;return new b(o,n)},q=L.dmap=L.dmap||{};q.Flow=f,q.flow=function(a){return new f(a)},module.exports=f
function b(a,b){this.u=a,this.v=b,this.m=Math.sqrt(a*a+b*b)}function i(a,b,c,d){this.grid=a,this.extent=b,this.dx=c,this.dy=d}function c(a,b,c){this.x=a,this.y=b,this.oldX=-1,this.oldY=-1,this.life=c}var d=require('./webgl_heatmap/CanvasLayerBase.js'),e=require('chroma-js'),f=d.extend({options:{start_color:'rgba(0, 255, 255, 0.5)',end_color:'rgba(255, 30, 219, 0.5)',fade:1,maxIntensity:17,velocityScale:1,lineWidth:2,fadeFillStyle:'rgba(0, 0, 0, 0.97)',life:80,strokeStyle:'rgb(227, 238, 238)',particles_factor:1},initialize:function(a){L.setOptions(this,a)},updateOptions:function(a){L.setOptions(this,a),this._reset()},setData:function(a){this.data=a,this._initVectorField(),this._reset()},_initVectorField:function(){var a=this.data;if(!(a&&a.data&&a.data.length>0))return;var s=a.lo1||0,t=a.la1||90,m=a.lo2||359,n=a.la2||-90,f=a.dx||1,r=a.dy||1,g=a.nx||360,l=a.ny||181,h=[],j=0,o=a.data,p=Math.floor(g*f)>=360;for(var d=0;d<l;d++){var c=[];for(var e=0;e<g;e++,j++){var k=o[j];c[e]=new b(k[0],k[1])}p&&c.push(c[0]),h[d]=c}var q={lng_min:s,lat_min:n,lng_max:m,lat_max:t};this.vectorField=new i(h,q,f,r)},interpolateLngLat:function(t,s){if(Math.abs(s)>=85.0511287798)return new b(NaN,NaN);var c=this.vectorField,q=c.extent,h=g(t-q.lng_min,360)/c.dx,i=(q.lat_max-s)/c.dy,d=Math.floor(h),f=d+1,e=Math.floor(i),r=e+1,o=c.grid,a;if(a=o[e]){var n=a[d],l=a[f];if(j(n)&&j(l)&&(a=o[r])){var k=a[d],m=a[f];if(j(k)&&j(m))return p(h-d,i-e,n,l,k,m)}}return new b(NaN,NaN)},columns:[],_initColumns:function(){var d=this.getMapBounds(),h=this.columns,o=(d.south-d.north)*(d.west-d.east),j=this._map.getBounds(),m=this.width*180/(20037508.34*(j.getEast()-j.getWest())),n=this.options.velocityScale*1e-6/m;for(var a=0;a<=this.width;a+=2){var f=[];for(var b=0;b<=this.height;b+=2){var l=this._map.containerPointToLatLng([a,b]),g=[l.lng,l.lat];if(g){var e=g[0],i=g[1];if(isFinite(e)){var c=this.interpolateLngLat(e,i);c&&!Array.isArray(c)&&(c=k(e,i,a,b,n,c,d)),f[b+1]=f[b]=c}}}h[a+1]=h[a]=f}},getVectorAtXY:function(b,c){var a=this._map.containerPointToLatLng(L.point(b,c));return this.interpolateLngLat(a.lng,a.lat)},getField:function(c,d){var a=this.columns[Math.round(c)];return a&&a[Math.round(d)]||new b(NaN,NaN)},particles:[],generateParticles:function(){var a=this.getMapBounds(),c=(a.south-a.north)*(a.west-a.east),d=Math.round(this._canvas.width*this._canvas.height*this.options.particles_factor*Math.pow(c,.24)/200);for(var b=0;b<d;b++)this.particles.push(this.randomParticle())},randomParticle:function(){var a,b,d=0;do a=Math.round(Math.floor(Math.random()*this._canvas.width)),b=Math.round(Math.floor(Math.random()*this._canvas.height));while(isNaN(this.getField(a,b).m)&&d++<30);return new c(a,b,1+this.options.life*Math.random())},_reset:function(){var b=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,b);var a=this.data;a&&a.data&&a.data.length>0&&(this._clear(),this._initColumns(),this.generateParticles(),this.initColorStyles(),this.start())},_resize:function(a){this._setCanvasSize(a.newSize),this._reset()},_clear:function(){this.particles=[],this.columns=[],this.frame&&L.Util.cancelAnimFrame(this.frame),this._canvas.getContext('2d').clearRect(0,0,this.width,this.height)},getMapBounds:function(){var a=this._map.getBounds(),b=[[a._southWest.lng,a._southWest.lat],[a._northEast.lng,a._northEast.lat]];return{south:h(b[0][1]),north:h(b[1][1]),east:h(b[1][0]),west:h(b[0][0]),height:this.height,width:this.width}},initColorStyles:function(){var a=e.scale([this.options.start_color,this.options.end_color]).colors(8),b=this;a.indexFor=function(c){return Math.floor(Math.min(c,b.options.maxIntensity)/b.options.maxIntensity*(a.length-1))},this.colorStyles=a},updateParticles:function(){var d=1,e=this.particles,f=this.colorStyles;for(var b=0;b<e.length;b++){var a=e[b];if(a.color='#eee',a.life>0){var c=this.getField(a.x,a.y);isNaN(c.m)?this.particles[b]=this.randomParticle():(a.x+=d*c.u,a.y+=d*c.v,isNaN(this.getField(a.x,a.y).m)?this.particles[b]=this.randomParticle():a.color=this.colorStyles[this.colorStyles.indexFor(c.m)]),a.life--}else this.particles[b]=this.randomParticle()}},draw:function(a){var d=this._canvas.width,f=this._canvas.height,g=a.globalCompositeOperation;a.globalCompositeOperation='destination-in',a.fillStyle=e('#000').alpha(1-this.options.fade/10).css(),a.fillRect(0,0,d,f),a.globalCompositeOperation=g;for(var c=0;c<this.particles.length;c++){var b=this.particles[c];b.oldX!=-1&&(a.beginPath(),a.lineWidth=this.options.lineWidth,a.strokeStyle=b.color,a.moveTo(b.oldX,b.oldY),a.lineTo(b.x,b.y),a.stroke()),b.oldX=b.x,b.oldY=b.y}},start:function(){this.updateParticles(),this._redraw(),this.frame=L.Util.requestAnimFrame(this.start,this)},destory:function(){this._clear(),this.onRemove(this._map),this._map.off('resize',this.onResize,this),this.data=[]}}),g=function(a,b){return a-b*Math.floor(a/b)},h=function(a){return a/180*Math.PI},a=function(a){return a/(Math.PI/180)},j=function(a){return a!==null&&a!==undefined},k=function(f,j,i,g,e,b,h){var d=b.u*e,c=b.v*e,a=l(f,j,i,g,h);return b.u=a[0]*d+a[2]*c,b.v=a[1]*d+a[3]*c,b},l=function(f,b,l,i,j){var k=2*Math.PI,a=Math.pow(10,-5.2),c=f<0?a:-a,d=b<0?a:-a,g=n(b,f+c,j),h=n(b+d,f,j),e=Math.cos(b/360*k);return[(g[0]-l)/c/e,(g[1]-i)/c/e,(h[0]-l)/d,(h[1]-i)/d]},m=function(a){return Math.log(Math.tan(a/2+Math.PI/4))},n=function(i,j,a){var d=m(a.south),c=m(a.north),e=a.width/(a.east-a.west),f=a.height/(c-d),b=m(h(i)),g=(h(j)-a.west)*e,b=(c-b)*f;return[g,b]},o=function(j,k,b){var d=b.east-b.west,c=b.width/a(d)*360/(2*Math.PI),h=c/2*Math.log((1+Math.sin(b.south))/(1-Math.sin(b.south))),i=b.height+h,g=(i-k)/c,f=180/Math.PI*(2*Math.atan(Math.exp(g))-Math.PI/2),e=a(b.west)+j/b.width*a(d);return[e,f]},p=function(d,c,j,k,l,m){var a=1-d,e=1-c,f=a*e,g=d*e,h=a*c,i=d*c,o=j.u*f+k.u*g+l.u*h+m.u*i,n=j.v*f+k.v*g+l.v*h+m.v*i;return new b(o,n)},q=L.dmap=L.dmap||{};q.Flow=f,q.flow=function(a){return new f(a)},module.exports=f

@@ -5,3 +5,3 @@ {

"description": "2d map visualization lib",
"version": "0.1.5",
"version": "0.1.6",
"scripts": {

@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc