Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldmap

Package Overview
Dependencies
Maintainers
4
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.31 to 0.1.32

2

layer/isosurface_new.js

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

function a(a){this.options=c.deepMerge(this.options,a)}var b=require('bcore/event'),c=require('bcore/utils'),d=require('leaflet'),e=require('chroma-js'),f=require('geojson-bbox');module.exports=b.extend(a,{options:{zIndex:101,opacity:.8,classifyType:'linear',classes:[],defaultColor:'rgba(255,255,255,0.5)',startColor:'#58F613',middleColor:'#FC5300',endColor:'#ff0000',breakValue:.5,colors:25,dweight:2,delta:2,getLat:function(a){return+a.lat},getLng:function(a){return+a.lng},getValue:function(a){return+a.value}},initCanvas:function(){var a=this.map,b=a.getPanes().overlayPane;this._canvas=d.DomUtil.create('canvas','leaflet-zoom-hide'),this._canvas.style.position='absolute',this._canvas.style.zIndex=this.options.zIndex,this._canvas.style.pointerEvents='none',this.resize(),b.appendChild(this._canvas)},resize:function(){var g=this.map,b=1,c=g.getSize(),e=this.width=c.x,f=this.height=c.y;this._canvas.width=b*e,this._canvas.height=b*f,this._canvas.style.width=e+'px',this._canvas.style.height=f+'px';var a=d.DomUtil.getPosition(this.map.getPanes().mapPane);a&&d.DomUtil.setPosition(this._canvas,{x:-a.x,y:-a.y})},getExtent:function(e){var l,a=this,c=Infinity,b=-Infinity;if(this.clipGeo){var i=f(this.clipGeo),j=this.map.latLngToContainerPoint(d.latLng(i[1],i[0])),k=this.map.latLngToContainerPoint(d.latLng(i[3],i[2])),e=this.newdata=e.map(function(e){var f=a.map.latLngToContainerPoint(d.latLng(a.options.getLat(e),a.options.getLng(e)));return c=a.options.getValue(e)>c?c:a.options.getValue(e),b=a.options.getValue(e)>b?a.options.getValue(e):b,{x:f.x,y:f.y,value:a.options.getValue(e)}});l=[j.x,j.y,k.x,k.y]}else{var g=minY=Infinity,h=maxY=-Infinity,e=this.newdata=e.map(function(f){var e=a.map.latLngToContainerPoint(d.latLng(a.options.getLat(f),a.options.getLng(f)));return g=e.x>g?g:e.x,minY=e.y>minY?minY:e.y,h=e.x>h?e.x:h,maxY=e.y>maxY?e.y:maxY,c=a.options.getValue(f)>c?c:a.options.getValue(f),b=a.options.getValue(f)>b?a.options.getValue(f):b,{x:e.x,y:e.y,value:a.options.getValue(f)}});l=[g,maxY,h,minY]}return this.minZ=c,this.maxZ=b,l},rerender:function(){var a=this,b=this._canvas.getContext('2d'),c=1;if(b.save(),b.scale(c,c),!(this.data&&this.data.length)){b.clearRect(0,0,a.width,a.height),b.restore();return}b.clearRect(0,0,a.width,a.height),setTimeout(function(){var E=a.getExtent(a.data),f=a.options.delta/2,c=[0,a.height,a.width,0],d=E,w=[(c[0]+c[2])/2,(c[1]+c[3])/2],u=[(d[0]+d[2])/2,(d[1]+d[3])/2],B=Math.abs(c[2]-c[0]),C=Math.abs(c[1]-c[3]),D=Math.abs(d[2]-d[0]),H=Math.abs(d[1]-d[3]),I=Math.abs(w[0]-u[0])<=B/2+D/2&&Math.abs(w[1]-u[1])<=C/2+H/2;if(!I){b.clearRect(0,0,a.width,a.height),b.restore();return}var e=[Math.max(c[0],d[0]),Math.min(c[1],d[1]),Math.min(c[2],d[2]),Math.max(c[3],d[3])],K=Math.abs(e[2]-e[0]),A=Math.abs(e[1]-e[3]),s=e[0]-1,t=e[3]-1,l=s,J=0,F=a.getColor(),r=b.getImageData(0,0,a.width,a.height),k=r.data;while(l<s+K){var g=t;while(g<t+A){var x=[l+f,g+f],y,n=0,o=0;for(var m=a.newdata.length-1;m>=0;m--){var h=a.newdata[m],v=Math.sqrt(Math.pow(h.x-x[0],2)+Math.pow(h.y-x[1],2));if(v<=.01){n=h.value,o=1;break}y=1/Math.pow(v,a.options.dweight),o+=y,n+=y*h.value}var G=n/o,j=F(G).rgba();J++;for(var p=1;p<2*f+1;p++)for(var q=1;q<2*f+1;q++){var i=(a.width*(g+q)+p+l)*4;k[i+0]=j[0],k[i+1]=j[1],k[i+2]=j[2],k[i+3]=j[3]*255*a.options.opacity}g+=2*f}l+=2*f}b.putImageData(r,0,0),b.globalCompositeOperation='destination-in',b.fillStyle='rgba(0,0,0,1)';var z=a.clipGeo;b.beginPath(),z.features&&z.features.forEach(function(c){switch(c.geometry.type){case'Polygon':a.renderPolygon(b,c.geometry.coordinates[0]);break;case'MultiPolygon':c.geometry.coordinates.forEach(function(c){a.renderPolygon(b,c[0])});break}}),b.fill(),b.restore()},100)},getColor:function(){var a=this;return a.options.classifyType==='linear'?e.scale([a.options.startColor,a.options.middleColor,a.options.endColor]).domain([a.minZ,a.minZ+(a.maxZ-a.minZ)*a.options.breakValue,a.maxZ]).mode('hsl').classes(a.options.colors):function(c){for(var b=0;b<a.options.classes.length;b++)if(c<a.options.classes[b].value)return e(a.options.classes[b].color);return e(a.options.classes[a.options.classes.length-1].color)}},renderPolygon:function(f,a){var b=this.map,c=b.latLngToContainerPoint(d.latLng(a[0][1],a[0][0]));for(f.moveTo(~~(.5+c.x),~~(.5+c.y)),j=1;j<a.length;j++){var e=b.latLngToContainerPoint(d.latLng(a[j][1],a[j][0]));f.lineTo(~~(.5+e.x),~~(.5+e.y))}},setClipGeo:function(a){a&&a.features?this.clipGeo=a:this.clipGeo=null},setData:function(a){this.data=a,this.rerender()},onresize:function(a){this.resize()},updateOptions:function(a){this.options=c.deepMerge(this.options,a),this.options.classes=a.classes,this.options.classes.sort(function(a,b){return a.value-b.value}),this.rerender()},destory:function(){this.map.getPanes().overlayPane.removeChild(this._canvas),this.map.off('moveend',this.onmoveend,this)},onmoveend:function(b){var a=d.DomUtil.getPosition(this.map.getPanes().mapPane);a&&d.DomUtil.setPosition(this._canvas,{x:-a.x,y:-a.y}),this.rerender()},addTo:function(a){this.map=a,this.map.on('resize',this.onresize,this),this.map.on('moveend',this.onmoveend,this),this.initCanvas(),this.rerender()}})
function a(a){this.options=c.deepMerge(this.options,a)}var b=require('bcore/event'),c=require('bcore/utils'),d=require('leaflet'),e=require('chroma-js'),f=require('geojson-bbox');module.exports=b.extend(a,{options:{zIndex:101,opacity:.8,classifyType:'linear',classes:[],defaultColor:'rgba(255,255,255,0.5)',startColor:'#58F613',middleColor:'#FC5300',endColor:'#ff0000',breakValue:.5,colors:25,dweight:2,delta:2,getLat:function(a){return+a.lat},getLng:function(a){return+a.lng},getValue:function(a){return+a.value}},initCanvas:function(){var a=this.map,b=a.getPanes().overlayPane;this._canvas=d.DomUtil.create('canvas','leaflet-zoom-hide'),this._canvas.style.position='absolute',this._canvas.style.zIndex=this.options.zIndex,this._canvas.style.pointerEvents='none',this.resize(),b.appendChild(this._canvas)},resize:function(){var g=this.map,b=1,c=g.getSize(),e=this.width=c.x,f=this.height=c.y;this._canvas.width=b*e,this._canvas.height=b*f,this._canvas.style.width=e+'px',this._canvas.style.height=f+'px';var a=d.DomUtil.getPosition(this.map.getPanes().mapPane);a&&d.DomUtil.setPosition(this._canvas,{x:-a.x,y:-a.y})},getExtent:function(e){var l,a=this,c=Infinity,b=-Infinity;if(this.clipGeo){var i=f(this.clipGeo),j=this.map.latLngToContainerPoint(d.latLng(i[1],i[0])),k=this.map.latLngToContainerPoint(d.latLng(i[3],i[2])),e=this.newdata=e.map(function(e){var f=a.map.latLngToContainerPoint(d.latLng(a.options.getLat(e),a.options.getLng(e)));return c=a.options.getValue(e)>c?c:a.options.getValue(e),b=a.options.getValue(e)>b?a.options.getValue(e):b,{x:f.x,y:f.y,value:a.options.getValue(e)}});l=[j.x,j.y,k.x,k.y]}else{var g=minY=Infinity,h=maxY=-Infinity,e=this.newdata=e.map(function(f){var e=a.map.latLngToContainerPoint(d.latLng(a.options.getLat(f),a.options.getLng(f)));return g=e.x>g?g:e.x,minY=e.y>minY?minY:e.y,h=e.x>h?e.x:h,maxY=e.y>maxY?e.y:maxY,c=a.options.getValue(f)>c?c:a.options.getValue(f),b=a.options.getValue(f)>b?a.options.getValue(f):b,{x:e.x,y:e.y,value:a.options.getValue(f)}});l=[g,maxY,h,minY]}return this.minZ=c,this.maxZ=b,l},rerender:function(){var a=this,b=this._canvas.getContext('2d'),c=1;if(b.save(),b.scale(c,c),!(this.data&&this.data.length)){b.clearRect(0,0,a.width,a.height),b.restore();return}setTimeout(function(){var E=a.getExtent(a.data),f=a.options.delta/2,c=[0,a.height,a.width,0],d=E,w=[(c[0]+c[2])/2,(c[1]+c[3])/2],u=[(d[0]+d[2])/2,(d[1]+d[3])/2],B=Math.abs(c[2]-c[0]),C=Math.abs(c[1]-c[3]),D=Math.abs(d[2]-d[0]),H=Math.abs(d[1]-d[3]),I=Math.abs(w[0]-u[0])<=B/2+D/2&&Math.abs(w[1]-u[1])<=C/2+H/2;if(!I){b.clearRect(0,0,a.width,a.height),b.restore();return}var e=[Math.max(c[0],d[0]),Math.min(c[1],d[1]),Math.min(c[2],d[2]),Math.max(c[3],d[3])],K=Math.abs(e[2]-e[0]),A=Math.abs(e[1]-e[3]),s=e[0]-1,t=e[3]-1,l=s,J=0,F=a.getColor(),r=b.createImageData(a.width,a.height),k=r.data;while(l<s+K){var g=t;while(g<t+A){var x=[l+f,g+f],y,n=0,o=0;for(var m=a.newdata.length-1;m>=0;m--){var h=a.newdata[m],v=Math.sqrt(Math.pow(h.x-x[0],2)+Math.pow(h.y-x[1],2));if(v<=.01){n=h.value,o=1;break}y=1/Math.pow(v,a.options.dweight),o+=y,n+=y*h.value}var G=n/o,j=F(G).rgba();J++;for(var p=1;p<2*f+1;p++)for(var q=1;q<2*f+1;q++){var i=(a.width*(g+q)+p+l)*4;k[i+0]=j[0],k[i+1]=j[1],k[i+2]=j[2],k[i+3]=j[3]*255*a.options.opacity}g+=2*f}l+=2*f}b.clearRect(0,0,a.width,a.height),b.putImageData(r,0,0),b.globalCompositeOperation='destination-in',b.fillStyle='rgba(0,0,0,1)';var z=a.clipGeo;b.beginPath(),z.features&&z.features.forEach(function(c){switch(c.geometry.type){case'Polygon':a.renderPolygon(b,c.geometry.coordinates[0]);break;case'MultiPolygon':c.geometry.coordinates.forEach(function(c){a.renderPolygon(b,c[0])});break}}),b.fill(),b.restore(),a._canvas.style.visibility='visible'},100)},getColor:function(){var a=this;return a.options.classifyType==='linear'?e.scale([a.options.startColor,a.options.middleColor,a.options.endColor]).domain([a.minZ,a.minZ+(a.maxZ-a.minZ)*a.options.breakValue,a.maxZ]).mode('hsl').classes(a.options.colors):function(c){for(var b=0;b<a.options.classes.length;b++)if(c<a.options.classes[b].value)return e(a.options.classes[b].color);return e(a.options.classes[a.options.classes.length-1].color)}},renderPolygon:function(f,a){var b=this.map,c=b.latLngToContainerPoint(d.latLng(a[0][1],a[0][0]));for(f.moveTo(~~(.5+c.x),~~(.5+c.y)),j=1;j<a.length;j++){var e=b.latLngToContainerPoint(d.latLng(a[j][1],a[j][0]));f.lineTo(~~(.5+e.x),~~(.5+e.y))}},setClipGeo:function(a){a&&a.features?this.clipGeo=a:this.clipGeo=null},setData:function(a){this.data=a,this.rerender()},onresize:function(a){this.resize()},updateOptions:function(a){this.options=c.deepMerge(this.options,a),this.options.classes=a.classes,this.options.classes.sort(function(a,b){return a.value-b.value}),this.rerender()},destory:function(){this.map.getPanes().overlayPane.removeChild(this._canvas),this.clipGeo=null,this.data=null,this.map.off('moveend',this.onmoveend,this),this.map.off('movestart',this.onmove,this),this.map.off('resize',this.onresize,this),this.map.off('zoomstart',this.onmove,this)},onmoveend:function(b){var a=d.DomUtil.getPosition(this.map.getPanes().mapPane);a&&d.DomUtil.setPosition(this._canvas,{x:-a.x,y:-a.y}),this.rerender()},onmove:function(){this._canvas.style.visibility='hidden'},addTo:function(a){this.map=a,this.map.on('movestart',this.onmove,this),this.map.on('zoomstart',this.onmove,this),this.map.on('resize',this.onresize,this),this.map.on('moveend',this.onmoveend,this),this.initCanvas(),this.rerender()}})

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

"description": "2d map visualization lib",
"version": "0.1.31",
"version": "0.1.32",
"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