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

@deck.gl/geo-layers

Package Overview
Dependencies
Maintainers
9
Versions
413
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deck.gl/geo-layers - npm Package Compare versions

Comparing version 7.0.0-alpha.6 to 7.0.0-beta.1

dist/es5/h3-layers/h3-cluster-layer.js

7

dist.min.js

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

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("deck"),require("luma"));else if("function"==typeof define&&define.amd)define(["deck","luma"],e);else{var n="object"==typeof exports?e(require("deck"),require("luma")):e(t.deck,t.luma);for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(window,function(t,e){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=17)}([function(e,n){e.exports=t},function(t,e,n){var r,i,o;
/**
* @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
* Released under the Apache License, Version 2.0
* see: https://github.com/dcodeIO/long.js for details
*/i=[],void 0===(o="function"==typeof(r=function(){"use strict";function t(t,e,n){this.low=0|t,this.high=0|e,this.unsigned=!!n}function e(t){return!0===(t&&t.__isLong__)}t.prototype.__isLong__,Object.defineProperty(t.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),t.isLong=e;var n={},r={};function i(t,e){var i,o,s;return e?(s=0<=(t>>>=0)&&t<256)&&(o=r[t])?o:(i=a(t,(0|t)<0?-1:0,!0),s&&(r[t]=i),i):(s=-128<=(t|=0)&&t<128)&&(o=n[t])?o:(i=a(t,t<0?-1:0,!1),s&&(n[t]=i),i)}function o(t,e){if(isNaN(t)||!isFinite(t))return e?v:d;if(e){if(t<0)return v;if(t>=h)return S}else{if(t<=-f)return L;if(t+1>=f)return b}return t<0?o(-t,e).neg():a(t%l|0,t/l|0,e)}function a(e,n,r){return new t(e,n,r)}t.fromInt=i,t.fromNumber=o,t.fromBits=a;var s=Math.pow;function u(t,e,n){if(0===t.length)throw Error("empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return d;if("number"==typeof e?(n=e,e=!1):e=!!e,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=t.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return u(t.substring(1),e,n).neg();for(var i=o(s(n,8)),a=d,c=0;c<t.length;c+=8){var l=Math.min(8,t.length-c),h=parseInt(t.substring(c,c+l),n);if(l<8){var f=o(s(n,l));a=a.mul(f).add(o(h))}else a=(a=a.mul(i)).add(o(h))}return a.unsigned=e,a}function c(e){return e instanceof t?e:"number"==typeof e?o(e):"string"==typeof e?u(e):a(e.low,e.high,e.unsigned)}t.fromString=u,t.fromValue=c;var l=4294967296,h=l*l,f=h/2,g=i(1<<24),d=i(0);t.ZERO=d;var v=i(0,!0);t.UZERO=v;var p=i(1);t.ONE=p;var y=i(1,!0);t.UONE=y;var m=i(-1);t.NEG_ONE=m;var b=a(-1,2147483647,!1);t.MAX_VALUE=b;var S=a(-1,-1,!0);t.MAX_UNSIGNED_VALUE=S;var L=a(0,-2147483648,!1);t.MIN_VALUE=L;var E=t.prototype;return E.toInt=function(){return this.unsigned?this.low>>>0:this.low},E.toNumber=function(){return this.unsigned?(this.high>>>0)*l+(this.low>>>0):this.high*l+(this.low>>>0)},E.toString=function(t){if((t=t||10)<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(L)){var e=o(t),n=this.div(e),r=n.mul(e).sub(this);return n.toString(t)+r.toInt().toString(t)}return"-"+this.neg().toString(t)}for(var i=o(s(t,6),this.unsigned),a=this,u="";;){var c=a.div(i),l=(a.sub(c.mul(i)).toInt()>>>0).toString(t);if((a=c).isZero())return l+u;for(;l.length<6;)l="0"+l;u=""+l+u}},E.getHighBits=function(){return this.high},E.getHighBitsUnsigned=function(){return this.high>>>0},E.getLowBits=function(){return this.low},E.getLowBitsUnsigned=function(){return this.low>>>0},E.getNumBitsAbs=function(){if(this.isNegative())return this.eq(L)?64:this.neg().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,e=31;e>0&&0==(t&1<<e);e--);return 0!=this.high?e+33:e+1},E.isZero=function(){return 0===this.high&&0===this.low},E.isNegative=function(){return!this.unsigned&&this.high<0},E.isPositive=function(){return this.unsigned||this.high>=0},E.isOdd=function(){return 1==(1&this.low)},E.isEven=function(){return 0==(1&this.low)},E.equals=function(t){return e(t)||(t=c(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},E.eq=E.equals,E.notEquals=function(t){return!this.eq(t)},E.neq=E.notEquals,E.lessThan=function(t){return this.comp(t)<0},E.lt=E.lessThan,E.lessThanOrEqual=function(t){return this.comp(t)<=0},E.lte=E.lessThanOrEqual,E.greaterThan=function(t){return this.comp(t)>0},E.gt=E.greaterThan,E.greaterThanOrEqual=function(t){return this.comp(t)>=0},E.gte=E.greaterThanOrEqual,E.compare=function(t){if(e(t)||(t=c(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1},E.comp=E.compare,E.negate=function(){return!this.unsigned&&this.eq(L)?L:this.not().add(p)},E.neg=E.negate,E.add=function(t){e(t)||(t=c(t));var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,o=65535&this.low,s=t.high>>>16,u=65535&t.high,l=t.low>>>16,h=0,f=0,g=0,d=0;return g+=(d+=o+(65535&t.low))>>>16,f+=(g+=i+l)>>>16,h+=(f+=r+u)>>>16,h+=n+s,a((g&=65535)<<16|(d&=65535),(h&=65535)<<16|(f&=65535),this.unsigned)},E.subtract=function(t){return e(t)||(t=c(t)),this.add(t.neg())},E.sub=E.subtract,E.multiply=function(t){if(this.isZero())return d;if(e(t)||(t=c(t)),t.isZero())return d;if(this.eq(L))return t.isOdd()?L:d;if(t.eq(L))return this.isOdd()?L:d;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(g)&&t.lt(g))return o(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,r=65535&this.high,i=this.low>>>16,s=65535&this.low,u=t.high>>>16,l=65535&t.high,h=t.low>>>16,f=65535&t.low,v=0,p=0,y=0,m=0;return y+=(m+=s*f)>>>16,p+=(y+=i*f)>>>16,y&=65535,p+=(y+=s*h)>>>16,v+=(p+=r*f)>>>16,p&=65535,v+=(p+=i*h)>>>16,p&=65535,v+=(p+=s*l)>>>16,v+=n*f+r*h+i*l+s*u,a((y&=65535)<<16|(m&=65535),(v&=65535)<<16|(p&=65535),this.unsigned)},E.mul=E.multiply,E.divide=function(t){if(e(t)||(t=c(t)),t.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?v:d;var n,r,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return v;if(t.gt(this.shru(1)))return y;i=v}else{if(this.eq(L))return t.eq(p)||t.eq(m)?L:t.eq(L)?p:(n=this.shr(1).div(t).shl(1)).eq(d)?t.isNegative()?p:m:(r=this.sub(t.mul(n)),i=n.add(r.div(t)));if(t.eq(L))return this.unsigned?v:d;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=d}for(r=this;r.gte(t);){n=Math.max(1,Math.floor(r.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),u=a<=48?1:s(2,a-48),l=o(n),h=l.mul(t);h.isNegative()||h.gt(r);)h=(l=o(n-=u,this.unsigned)).mul(t);l.isZero()&&(l=p),i=i.add(l),r=r.sub(h)}return i},E.div=E.divide,E.modulo=function(t){return e(t)||(t=c(t)),this.sub(this.div(t).mul(t))},E.mod=E.modulo,E.not=function(){return a(~this.low,~this.high,this.unsigned)},E.and=function(t){return e(t)||(t=c(t)),a(this.low&t.low,this.high&t.high,this.unsigned)},E.or=function(t){return e(t)||(t=c(t)),a(this.low|t.low,this.high|t.high,this.unsigned)},E.xor=function(t){return e(t)||(t=c(t)),a(this.low^t.low,this.high^t.high,this.unsigned)},E.shiftLeft=function(t){return e(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?a(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):a(0,this.low<<t-32,this.unsigned)},E.shl=E.shiftLeft,E.shiftRight=function(t){return e(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?a(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):a(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},E.shr=E.shiftRight,E.shiftRightUnsigned=function(t){if(e(t)&&(t=t.toInt()),0==(t&=63))return this;var n=this.high;return t<32?a(this.low>>>t|n<<32-t,n>>>t,this.unsigned):a(32===t?n:n>>>t-32,0,this.unsigned)},E.shru=E.shiftRightUnsigned,E.toSigned=function(){return this.unsigned?a(this.low,this.high,!1):this},E.toUnsigned=function(){return this.unsigned?this:a(this.low,this.high,!0)},E.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()},E.toBytesLE=function(){var t=this.high,e=this.low;return[255&e,e>>>8&255,e>>>16&255,e>>>24&255,255&t,t>>>8&255,t>>>16&255,t>>>24&255]},E.toBytesBE=function(){var t=this.high,e=this.low;return[t>>>24&255,t>>>16&255,t>>>8&255,255&t,e>>>24&255,e>>>16&255,e>>>8&255,255&e]},t})?r.apply(e,i):r)||(t.exports=o)},function(t,e,n){!function(t){"use strict";var e=t.S2={L:{}};e.L.LatLng=function(t,e,n){var r=parseFloat(t,10),i=parseFloat(e,10);if(isNaN(r)||isNaN(i))throw new Error("Invalid LatLng object: ("+t+", "+e+")");return!0!==n&&(r=Math.max(Math.min(r,90),-90),i=(i+180)%360+(i<-180||180===i?180:-180)),{lat:r,lng:i}},e.L.LatLng.DEG_TO_RAD=Math.PI/180,e.L.LatLng.RAD_TO_DEG=180/Math.PI,e.LatLngToXYZ=function(t){var n=e.L.LatLng.DEG_TO_RAD,r=t.lat*n,i=t.lng*n,o=Math.cos(r);return[Math.cos(i)*o,Math.sin(i)*o,Math.sin(r)]},e.XYZToLatLng=function(t){var n=e.L.LatLng.RAD_TO_DEG,r=Math.atan2(t[2],Math.sqrt(t[0]*t[0]+t[1]*t[1])),i=Math.atan2(t[1],t[0]);return e.L.LatLng(r*n,i*n)};e.XYZToFaceUV=function(t){var e=function(t){var e=[Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2])];return e[0]>e[1]?e[0]>e[2]?0:2:e[1]>e[2]?1:2}(t);return t[e]<0&&(e+=3),[e,function(t,e){var n,r;switch(t){case 0:n=e[1]/e[0],r=e[2]/e[0];break;case 1:n=-e[0]/e[1],r=e[2]/e[1];break;case 2:n=-e[0]/e[2],r=-e[1]/e[2];break;case 3:n=e[2]/e[0],r=e[1]/e[0];break;case 4:n=e[2]/e[1],r=-e[0]/e[1];break;case 5:n=-e[1]/e[2],r=-e[0]/e[2];break;default:throw{error:"Invalid face"}}return[n,r]}(e,t)]},e.FaceUVToXYZ=function(t,e){var n=e[0],r=e[1];switch(t){case 0:return[1,n,r];case 1:return[-n,1,r];case 2:return[-n,-r,1];case 3:return[-1,-r,-n];case 4:return[r,-1,-n];case 5:return[r,n,-1];default:throw{error:"Invalid face"}}};var r=function(t){return t>=.5?1/3*(4*t*t-1):1/3*(1-4*(1-t)*(1-t))};e.STToUV=function(t){return[r(t[0]),r(t[1])]};var i=function(t){return t>=0?.5*Math.sqrt(1+3*t):1-.5*Math.sqrt(1-3*t)};e.UVToST=function(t){return[i(t[0]),i(t[1])]},e.STToIJ=function(t,e){var n=1<<e,r=function(t){var e=Math.floor(t*n);return Math.max(0,Math.min(n-1,e))};return[r(t[0]),r(t[1])]},e.IJToST=function(t,e,n){var r=1<<e;return[(t[0]+n[0])/r,(t[1]+n[1])/r]};var o=function(t,e,n,r){if(0==r){1==n&&(e.x=t-1-e.x,e.y=t-1-e.y);var i=e.x;e.x=e.y,e.y=i}},a=function(t,e,n,r){var i={a:[[0,"d"],[1,"a"],[3,"b"],[2,"a"]],b:[[2,"b"],[1,"b"],[3,"a"],[0,"c"]],c:[[2,"c"],[3,"d"],[1,"c"],[0,"b"]],d:[[0,"a"],[3,"c"],[1,"d"],[2,"d"]]};"number"!=typeof r&&console.warn(new Error("called pointToHilbertQuadList without face value, defaulting to '0'").stack);for(var o=r%2?"d":"a",a=[],s=n-1;s>=0;s--){var u=1<<s,c=i[o][2*(t&u?1:0)+(e&u?1:0)];a.push(c[0]),o=c[1]}return a};e.S2Cell=function(){},e.S2Cell.FromHilbertQuadKey=function(t){var n,r,i,a,s,u,c=t.split("/"),l=parseInt(c[0]),h=c[1],f=h.length,g={x:0,y:0};for(n=f-1;n>=0;n--)r=f-n,a=0,s=0,"1"===(i=h[n])?s=1:"2"===i?(a=1,s=1):"3"===i&&(a=1),u=Math.pow(2,r-1),o(u,g,a,s),g.x+=u*a,g.y+=u*s;if(l%2==1){var d=g.x;g.x=g.y,g.y=d}return e.S2Cell.FromFaceIJ(parseInt(l),[g.x,g.y],r)},e.S2Cell.FromLatLng=function(t,n){if(!t.lat&&0!==t.lat||!t.lng&&0!==t.lng)throw new Error("Pass { lat: lat, lng: lng } to S2.S2Cell.FromLatLng");var r=e.LatLngToXYZ(t),i=e.XYZToFaceUV(r),o=e.UVToST(i[1]),a=e.STToIJ(o,n);return e.S2Cell.FromFaceIJ(i[0],a,n)},e.S2Cell.FromFaceIJ=function(t,n,r){var i=new e.S2Cell;return i.face=t,i.ij=n,i.level=r,i},e.S2Cell.prototype.toString=function(){return"F"+this.face+"ij["+this.ij[0]+","+this.ij[1]+"]@"+this.level},e.S2Cell.prototype.getLatLng=function(){var t=e.IJToST(this.ij,this.level,[.5,.5]),n=e.STToUV(t),r=e.FaceUVToXYZ(this.face,n);return e.XYZToLatLng(r)},e.S2Cell.prototype.getCornerLatLngs=function(){for(var t=[],n=[[0,0],[0,1],[1,1],[1,0]],r=0;r<4;r++){var i=e.IJToST(this.ij,this.level,n[r]),o=e.STToUV(i),a=e.FaceUVToXYZ(this.face,o);t.push(e.XYZToLatLng(a))}return t},e.S2Cell.prototype.getFaceAndQuads=function(){var t=a(this.ij[0],this.ij[1],this.level,this.face);return[this.face,t]},e.S2Cell.prototype.toHilbertQuadkey=function(){var t=a(this.ij[0],this.ij[1],this.level,this.face);return this.face.toString(10)+"/"+t.join("")},e.latLngToNeighborKeys=e.S2Cell.latLngToNeighborKeys=function(t,n,r){return e.S2Cell.FromLatLng({lat:t,lng:n},r).getNeighbors().map(function(t){return t.toHilbertQuadkey()})},e.S2Cell.prototype.getNeighbors=function(){var t=function(t,n,r){var i=1<<r;if(n[0]>=0&&n[1]>=0&&n[0]<i&&n[1]<i)return e.S2Cell.FromFaceIJ(t,n,r);var o=e.IJToST(n,r,[.5,.5]),a=e.STToUV(o),s=e.FaceUVToXYZ(t,a),u=e.XYZToFaceUV(s);return t=u[0],a=u[1],o=e.UVToST(a),n=e.STToIJ(o,r),e.S2Cell.FromFaceIJ(t,n,r)},n=this.face,r=this.ij[0],i=this.ij[1],o=this.level;return[t(n,[r-1,i],o),t(n,[r,i-1],o),t(n,[r+1,i],o),t(n,[r,i+1],o)]},e.FACE_BITS=3,e.MAX_LEVEL=30,e.POS_BITS=2*e.MAX_LEVEL+1,e.facePosLevelToId=e.S2Cell.facePosLevelToId=e.fromFacePosLevel=function(r,i,o){var a,s,u,c=t.dcodeIO&&t.dcodeIO.Long||n(1);for(o||(o=i.length),i.length>o&&(i=i.substr(0,o)),a=c.fromString(r.toString(10),!0,10).toString(2);a.length<e.FACE_BITS;)a="0"+a;for(s=c.fromString(i,!0,4).toString(2);s.length<2*o;)s="0"+s;for(u=a+s,u+="1";u.length<e.FACE_BITS+e.POS_BITS;)u+="0";return c.fromString(u,!0,2).toString(10)},e.keyToId=e.S2Cell.keyToId=e.toId=e.toCellId=e.fromKey=function(t){var n=t.split("/");return e.fromFacePosLevel(n[0],n[1],n[1].length)},e.idToKey=e.S2Cell.idToKey=e.S2Cell.toKey=e.toKey=e.fromId=e.fromCellId=e.S2Cell.toHilbertQuadkey=e.toHilbertQuadkey=function(r){for(var i=t.dcodeIO&&t.dcodeIO.Long||n(1),o=i.fromString(r,!0,10).toString(2);o.length<e.FACE_BITS+e.POS_BITS;)o="0"+o;for(var a=o.lastIndexOf("1"),s=o.substring(0,3),u=o.substring(3,a),c=u.length/2,l=i.fromString(s,!0,2).toString(10),h=i.fromString(u,!0,2).toString(4);h.length<c;)h="0"+h;return l+"/"+h},e.keyToLatLng=e.S2Cell.keyToLatLng=function(t){return e.S2Cell.FromHilbertQuadKey(t).getLatLng()},e.idToLatLng=e.S2Cell.idToLatLng=function(t){var n=e.idToKey(t);return e.keyToLatLng(n)},e.S2Cell.latLngToKey=e.latLngToKey=e.latLngToQuadkey=function(t,n,r){if(isNaN(r)||r<1||r>30)throw new Error("'level' is not a number between 1 and 30 (but it should be)");return e.S2Cell.FromLatLng({lat:t,lng:n},r).toHilbertQuadkey()},e.stepKey=function(e,r){var i,o=t.dcodeIO&&t.dcodeIO.Long||n(1),a=e.split("/"),s=a[0],u=a[1],c=a[1].length,l=o.fromString(u,!0,4);r>0?i=l.add(Math.abs(r)):r<0&&(i=l.subtract(Math.abs(r)));var h=i.toString(4);for("0"===h&&console.warning(new Error("face/position wrapping is not yet supported"));h.length<c;)h="0"+h;return s+"/"+h},e.S2Cell.prevKey=e.prevKey=function(t){return e.stepKey(t,-1)},e.S2Cell.nextKey=e.nextKey=function(t){return e.stepKey(t,1)}}(t.exports)},function(t,e){t.exports=function(t,e,n){var r=n[0],i=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}},function(t,e){t.exports=function(t,e,n){var r,i,o,a,s,u,c,l,h,f,g,d,v=n[0],p=n[1],y=n[2];e===t?(t[12]=e[0]*v+e[4]*p+e[8]*y+e[12],t[13]=e[1]*v+e[5]*p+e[9]*y+e[13],t[14]=e[2]*v+e[6]*p+e[10]*y+e[14],t[15]=e[3]*v+e[7]*p+e[11]*y+e[15]):(r=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],l=e[7],h=e[8],f=e[9],g=e[10],d=e[11],t[0]=r,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=u,t[6]=c,t[7]=l,t[8]=h,t[9]=f,t[10]=g,t[11]=d,t[12]=r*v+s*p+h*y+e[12],t[13]=i*v+u*p+f*y+e[13],t[14]=o*v+c*p+g*y+e[14],t[15]=a*v+l*p+d*y+e[15]);return t}},function(t,n){t.exports=e},function(t,e){t.exports=function(t,e,n,r,i){var o=1/Math.tan(e/2),a=1/(r-i);return t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(i+r)*a,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*i*r*a,t[15]=0,t}},function(t,e){t.exports=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],l=e[9],h=e[10],f=e[11];e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]);return t[4]=o*i+c*r,t[5]=a*i+l*r,t[6]=s*i+h*r,t[7]=u*i+f*r,t[8]=c*i-o*r,t[9]=l*i-a*r,t[10]=h*i-s*r,t[11]=f*i-u*r,t}},function(t,e){t.exports=function(t,e,n){var r=Math.sin(n),i=Math.cos(n),o=e[0],a=e[1],s=e[2],u=e[3],c=e[4],l=e[5],h=e[6],f=e[7];e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]);return t[0]=o*i+c*r,t[1]=a*i+l*r,t[2]=s*i+h*r,t[3]=u*i+f*r,t[4]=c*i-o*r,t[5]=l*i-a*r,t[6]=h*i-s*r,t[7]=f*i-u*r,t}},function(t,e){t.exports=function(t,e,n,r){var i=e[0],o=e[1];return t[0]=i+r*(n[0]-i),t[1]=o+r*(n[1]-o),t}},function(t,e){t.exports=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}},function(t,e){t.exports=function(t,e,n){var r=e[0],i=e[1],o=e[2],a=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,t[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,t[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,t[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,t}},function(t,e,n){t.exports=function(t,e){var n=r(t[0],t[1],t[2]),a=r(e[0],e[1],e[2]);i(n,n),i(a,a);var s=o(n,a);return s>1?0:Math.acos(s)};var r=n(19),i=n(20),o=n(21)},function(t,e){t.exports=function(t,e,n){var r=e[0],i=e[1],o=e[2],a=n[0],s=n[1],u=n[2];return t[0]=i*u-o*s,t[1]=o*a-r*u,t[2]=r*s-i*a,t}},function(t,e){t.exports=function(t,e,n,r){var i=n[1],o=n[2],a=e[1]-i,s=e[2]-o,u=Math.sin(r),c=Math.cos(r);return t[0]=e[0],t[1]=i+a*c-s*u,t[2]=o+a*u+s*c,t}},function(t,e){t.exports=function(t,e,n,r){var i=n[0],o=n[2],a=e[0]-i,s=e[2]-o,u=Math.sin(r),c=Math.cos(r);return t[0]=i+s*u+a*c,t[1]=e[1],t[2]=o+s*c-a*u,t}},function(t,e){t.exports=function(t,e,n,r){var i=n[0],o=n[1],a=e[0]-i,s=e[1]-o,u=Math.sin(r),c=Math.cos(r);return t[0]=i+a*c-s*u,t[1]=o+a*u+s*c,t[2]=e[2],t}},function(t,e,n){(function(e){const r=n(22),i=("undefined"==typeof window?e:window).deck||{};if(!i.LineLayer)throw new Error("@deck.gl/layers is not found");t.exports=Object.assign(i,r)}).call(this,n(18))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e){t.exports=function(t,e,n){var r=new Float32Array(3);return r[0]=t,r[1]=e,r[2]=n,r}},function(t,e){t.exports=function(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o);return t}},function(t,e){t.exports=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}},function(t,e,n){"use strict";n.r(e);var r=n(0),i="#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\nuniform float widthScale;\n\nvarying vec4 vColor;\n\n// offset vector by strokeWidth pixels\n// offset_direction is -1 (left) or 1 (right)\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths * widthScale / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\n\n// get angular distance in radian\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n float a =\n sin(delta.y / 2.0) * sin(delta.y / 2.0) +\n cos(source.y) * cos(target.y) *\n sin(delta.x / 2.0) * sin(delta.x / 2.0);\n\treturn 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n\n\tfloat a = sin((1.0 - t) * angularDist) / sin(angularDist);\n\tfloat b = sin(t * angularDist) / sin(angularDist);\n\tfloat x = a * cos(source.y) * cos(source.x) + b * cos(target.y) * cos(target.x);\n\tfloat y = a * cos(source.y) * sin(source.x) + b * cos(target.y) * sin(target.x);\n\tfloat z = a * sin(source.y) + b * sin(target.y);\n\treturn vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main(void) {\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n \n // if it's the first point, use next - current as direction\n // otherwise use current - prev\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n \n vec2 source = radians(instancePositions.xy);\n vec2 target = radians(instancePositions.zw);\n \n float angularDist = getAngularDist(source, target);\n\n vec3 currPos = vec3(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0);\n vec3 nextPos = vec3(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0);\n\n vec2 currPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, segmentRatio);\n vec2 nextPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, nextSegmentRatio);\n\n vec4 curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0));\n vec4 next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n\n // extrude\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;\n vColor = vec4(color.rgb, color.a * opacity);\n \n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n}\n";class o extends r.ArcLayer{getShaders(){return Object.assign({},super.getShaders(),{vs:i,modules:["picking","project32"]})}}var a=n(2);function s(t){const e=16-t.length,n=t+new Array(e+1).join("0");return String(parseInt(n,16))}const u=function(){const t={};for(const e in r.PolygonLayer.defaultProps)"getPolygon"!==e&&(t[e]=r.PolygonLayer.defaultProps[e]);return t.getS2Token={type:"accessor",value:t=>t.token},t}();class c extends r.CompositeLayer{renderLayers(){const{data:t,getS2Token:e}=this.props,{elevationScale:n,extruded:i,wireframe:o,filled:u,stroked:c,lineWidthScale:l,lineWidthMinPixels:h,lineWidthMaxPixels:f,lineJointRounded:g,lineMiterLimit:d,lineDashJustified:v,fp64:p,getElevation:y,getFillColor:m,getLineColor:b,getLineWidth:S,getLineDashArray:L}=this.props,{updateTriggers:E,material:T}=this.props;return new(this.getSubLayerClass("cell",r.PolygonLayer))({fp64:p,filled:u,wireframe:o,extruded:i,elevationScale:n,stroked:c,lineWidthScale:l,lineWidthMinPixels:h,lineWidthMaxPixels:f,lineJointRounded:g,lineMiterLimit:d,lineDashJustified:v,material:T,getElevation:y,getFillColor:m,getLineColor:b,getLineWidth:S,getLineDashArray:L},this.getSubLayerProps({id:"cell",updateTriggers:{getElevation:E.getElevation,getFillColor:E.getFillColor,getLineColor:E.getLineColor,getLineWidth:E.getLineWidth,getLineDashArray:E.getLineDashArray}}),{data:t,getPolygon:t=>(function(t){const e=s(t),n=function(t){const e=t.substr(t.length-1);return 2*(t.length-1)-(0==(1&e))}(t),r=a.S2.S2Cell.FromLatLng(a.S2.idToLatLng(e),n).getCornerLatLngs().map(t=>[t.lng,t.lat]);return r.push(r[0]),r})(e(t))})}}c.layerName="S2Layer",c.defaultProps=u;class l{constructor({getTileData:t,x:e,y:n,z:r,onTileError:i}){this.x=e,this.y=n,this.z=r,this.isVisible=!0,this.getTileData=t,this._data=null,this._isLoaded=!1,this._loader=this._loadData(),this.onTileError=i}get data(){return this._data?Promise.resolve(this._data):this._loader}get isLoaded(){return this._isLoaded}_loadData(){const{x:t,y:e,z:n}=this;return this.getTileData?this.getTileData({x:t,y:e,z:n}).then(t=>(this._data=t,this._isLoaded=!0,t)).catch(t=>{this._isLoaded=!0,this.onTileError(t)}):null}isOverlapped(t){const{x:e,y:n,z:r}=this,i=Math.pow(2,t.z-r);return Math.floor(t.x/i)===e&&Math.floor(t.y/i)===n}}function h(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var f={};function g(t){if(!Number.isFinite(t))throw new Error("Invalid number ".concat(t));return t}function d(t){return Math.round(t/f.EPSILON)*f.EPSILON}function v(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).precision,n=void 0===e?f.precision||4:e;return t=d(t),parseFloat(t.toPrecision(n))}function p(t,e){if(Array.isArray(t)&&Array.isArray(e)){if(t===e)return!0;if(t.length!==e.length)return!1;for(var n=0;n<t.length;++n)if(!p(t[n],e[n]))return!1;return!0}return Math.abs(t-e)<=f.EPSILON*Math.max(1,Math.abs(t),Math.abs(e))}function y(t){return(y="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 m(t,e){if(n=t,!(null!=(r=e)&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?r[Symbol.hasInstance](n):n instanceof r))throw new TypeError("Cannot call a class as a function");var n,r}function b(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function S(t,e){return!e||"object"!==y(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function L(t){function e(){var e=Reflect.construct(t,Array.from(arguments));return Object.setPrototypeOf(e,Object.getPrototypeOf(this)),e}return e.prototype=Object.create(t.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t,e}f.EPSILON=1e-12,f.debug=!0,f.precision=4,f.printTypes=!1,f.printDegrees=!1,f.printRowMajor=!0;var E=function(t){function e(){return m(this,e),S(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}var n,r,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,L(Array)),n=e,(r=[{key:"clone",value:function(){return(new this.constructor).copy(this).check()}},{key:"copy",value:function(t){for(var e=0;e<this.ELEMENTS;++e)this[e]=t[e];return this.check()}},{key:"set",value:function(){for(var t=0;t<this.ELEMENTS;++t)this[t]=(t<0||arguments.length<=t?void 0:arguments[t])||0;return this.check()}},{key:"fromArray",value:function(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<this.ELEMENTS;++n)this[n]=t[n+e];return this.check()}},{key:"toString",value:function(){return this.formatString(f)}},{key:"formatString",value:function(t){for(var e="",n=0;n<this.ELEMENTS;++n)e+=(n>0?", ":"")+v(this[n],t);return"".concat(t.printTypes?this.constructor.name:"","[").concat(e,"]")}},{key:"toArray",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0;n<this.ELEMENTS;++n)t[e+n]=this[n];return t}},{key:"toFloat32Array",value:function(){return new Float32Array(this)}},{key:"equals",value:function(t){if(!t||this.length!==t.length)return!1;for(var e=0;e<this.ELEMENTS;++e)if(!p(this[e],t[e]))return!1;return!0}},{key:"exactEquals",value:function(t){if(!t||this.length!==t.length)return!1;for(var e=0;e<this.ELEMENTS;++e)if(this[e]!==t[e])return!1;return!0}},{key:"negate",value:function(){for(var t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}},{key:"inverse",value:function(){for(var t=0;t<this.ELEMENTS;++t)this[t]=1/this[t];return this.check()}},{key:"lerp",value:function(t,e,n){void 0===n&&(n=e,e=t,t=this);for(var r=0;r<this.ELEMENTS;++r){var i=t[r];this[r]=i+n*(e[r]-i)}return this.check()}},{key:"min",value:function(t){for(var e=0;e<this.ELEMENTS;++e)this[e]=Math.min(t[e],this[e]);return this.check()}},{key:"max",value:function(t){for(var e=0;e<this.ELEMENTS;++e)this[e]=Math.max(t[e],this[e]);return this.check()}},{key:"clamp",value:function(t,e){for(var n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),e[n]);return this.check()}},{key:"validate",value:function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this,e=t&&t.length===this.ELEMENTS,n=0;n<this.ELEMENTS;++n)e=e&&Number.isFinite(t[n]);return e}},{key:"check",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this;if(f.debug&&!this.validate(t))throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}},{key:"sub",value:function(t){return this.subtract(t)}},{key:"setScalar",value:function(t){for(var e=0;e<this.ELEMENTS;++e)this[e]=t;return this.check()}},{key:"addScalar",value:function(t){for(var e=0;e<this.ELEMENTS;++e)this[e]+=t;return this.check()}},{key:"subScalar",value:function(t){return this.addScalar(-t)}},{key:"multiplyScalar",value:function(t){return this.scale(t)}},{key:"divideScalar",value:function(t){return this.scale(1/t)}},{key:"clampScalar",value:function(t,e){for(var n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),e);return this.check()}}])&&b(n.prototype,r),i&&b(n,i),e}();function T(t){return(T="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 w(t,e){if(n=t,!(null!=(r=e)&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?r[Symbol.hasInstance](n):n instanceof r))throw new TypeError("Cannot call a class as a function");var n,r}function x(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function _(t,e){return!e||"object"!==T(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var k=function(t,e){if(!t)throw new Error(e)},M=function(t){function e(){return w(this,e),_(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}var n,r,i;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,E),n=e,(r=[{key:"len",value:function(){return Math.sqrt(this.lengthSquared())}},{key:"magnitude",value:function(){return Math.sqrt(this.lengthSquared())}},{key:"lengthSquared",value:function(){for(var t=0,e=0;e<this.ELEMENTS;++e)t+=this[e]*this[e];return t}},{key:"distance",value:function(t){return Math.sqrt(this.distanceSquared(t))}},{key:"distanceSquared",value:function(t){for(var e=0,n=0;n<this.ELEMENTS;++n){var r=this[n]-t[n];e+=r*r}return g(e)}},{key:"dot",value:function(t){for(var e=0,n=0;n<this.ELEMENTS;++n)e+=this[n]*t[n];return g(e)}},{key:"normalize",value:function(){var t=this.magnitude();if(0!==t)for(var e=0;e<this.ELEMENTS;++e)this[e]/=t;return this.check()}},{key:"add",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=0;o<this.ELEMENTS;++o)this[o]+=i[o];return this.check()}},{key:"subtract",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=0;o<this.ELEMENTS;++o)this[o]-=i[o];return this.check()}},{key:"multiply",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=0;o<this.ELEMENTS;++o)this[o]*=i[o];return this.check()}},{key:"divide",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];for(var r=0;r<e.length;r++)for(var i=e[r],o=0;o<this.ELEMENTS;++o)this[o]/=i[o];return this.check()}},{key:"scale",value:function(t){if(Array.isArray(t))return this.multiply(t);for(var e=0;e<this.ELEMENTS;++e)this[e]*=t;return this.check()}},{key:"scaleAndAdd",value:function(t,e){for(var n=0;n<this.ELEMENTS;++n)this[n]=this[n]*e+t[n];return this.check()}},{key:"lengthSq",value:function(){return this.lengthSquared()}},{key:"distanceTo",value:function(t){return this.distance(t)}},{key:"distanceToSquared",value:function(t){return this.distanceSquared(t)}},{key:"getComponent",value:function(t){return k(t>=0&&t<this.ELEMENTS,"index is out of range"),g(this[t])}},{key:"setComponent",value:function(t,e){return k(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=e,this.check()}},{key:"addVectors",value:function(t,e){return this.copy(t).add(e)}},{key:"subVectors",value:function(t,e){return this.copy(t).subtract(e)}},{key:"multiplyVectors",value:function(t,e){return this.copy(t).multiply(e)}},{key:"addScaledVector",value:function(t,e){return this.add(new this.constructor(t).multiplyScalar(e))}},{key:"x",get:function(){return this[0]},set:function(t){return this[0]=g(t)}},{key:"y",get:function(){return this[1]},set:function(t){return this[1]=g(t)}}])&&x(n.prototype,r),i&&x(n,i),e}(),C=n(12),N=n.n(C),I=n(13),O=n.n(I),P=n(14),A=n.n(P),j=n(15),F=n.n(j),D=n(16),z=n.n(D);function q(t){return(q="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 Z(t,e){if(n=t,!(null!=(r=e)&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?r[Symbol.hasInstance](n):n instanceof r))throw new TypeError("Cannot call a class as a function");var n,r}function R(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function V(t,e){return!e||"object"!==q(e)&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}var U=[0,0,0];(function(t){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Z(this,e),t=V(this,(e.__proto__||Object.getPrototypeOf(e)).call(this)),Array.isArray(n)&&1===arguments.length?t.copy(n):t.set(n,r,i),t}var n,r,i;(function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)})(e,M),n=e,(r=[{key:"angle",value:function(t){return N()(this,t)}},{key:"cross",value:function(t){return O()(this,this,t),this.check()}},{key:"rotateX",value:function(t){var e=t.radians,n=t.origin,r=void 0===n?U:n;return A()(this,this,r,e),this.check()}},{key:"rotateY",value:function(t){var e=t.radians,n=t.origin,r=void 0===n?U:n;return F()(this,this,r,e),this.check()}},{key:"rotateZ",value:function(t){var e=t.radians,n=t.origin,r=void 0===n?U:n;return z()(this,this,r,e),this.check()}},{key:"operation",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return t.apply(void 0,[this,this].concat(n)),this.check()}},{key:"ELEMENTS",get:function(){return 3}},{key:"z",get:function(){return this[2]},set:function(t){return this[2]=g(t)}}])&&R(n.prototype,r),i&&R(n,i)})(),n(10),n(11);n(6),n(3),n(4),n(7),n(8),n(9);var B=Math.PI,K=B/4,J=B/180,X=512;function H(t,e){var n=h(t,2),r=n[0],i=n[1]*J;return[(e*=X)*(r*J+B)/(2*B),e*(B-Math.log(Math.tan(K+.5*i)))/(2*B)]}const Y=512;function W(t){return Math.floor(t/Y)}function G({x:t,y:e,z:n},r){const i=Math.pow(2,n-r);return{x:Math.floor(t/i),y:Math.floor(e/i),z:r}}class Q{constructor({getTileData:t,maxSize:e,maxZoom:n,minZoom:r,onTileError:i}){this._getTileData=t,this._maxSize=e,this.onTileError=i,this._cache=new Map,n&&parseInt(n,10)===n&&(this._maxZoom=n),r&&parseInt(r,10)===r&&(this._minZoom=r)}finalize(){this._cache.clear()}update(t,e){const{_cache:n,_getTileData:r,_maxSize:i,_maxZoom:o,_minZoom:a}=this;this._markOldTiles();const s=function(t,e,n){const r=Math.floor(t.zoom);if(n&&r<n)return[];const i=function(t){const e=[t.unproject([0,0]),t.unproject([t.width,0]),t.unproject([0,t.height]),t.unproject([t.width,t.height])];return[e.reduce((t,e)=>t<e[0]?t:e[0],180),e.reduce((t,e)=>t<e[1]?t:e[1],90),e.reduce((t,e)=>t>e[0]?t:e[0],-180),e.reduce((t,e)=>t>e[1]?t:e[1],-90)]}(t=new t.constructor(Object.assign({},t,{zoom:r}))),[o,a]=H([i[0],i[3]],t.scale).map(W),[s,u]=H([i[2],i[1]],t.scale).map(W),c=[];for(let t=o;t<=s;t++)for(let n=a;n<=u;n++)e&&r>e?c.push(G({x:t,y:n,z:r},e)):c.push({x:t,y:n,z:r});return c}(t,o,a);if(!s||0===s.length)return void e(s);const u=new Set;n.forEach(t=>{s.some(e=>t.isOverlapped(e))&&(t.isVisible=!0,u.add(t))});for(let t=0;t<s.length;t++){const e=s[t],{x:i,y:o,z:a}=e;let c=this._getTile(i,o,a);c||(c=new l({getTileData:r,x:i,y:o,z:a,onTileError:this.onTileError}));const h=this._getTileId(i,o,a);n.set(h,c),u.add(c)}this._resizeCache(i||5*s.length),e(Array.from(u).sort((t,e)=>t.z-e.z))}_resizeCache(t){const{_cache:e}=this;if(e.size>t){const n=e[Symbol.iterator]();for(const r of n){if(e.size<=t)break;const n=r[0];r[1].isVisible||e.delete(n)}}}_markOldTiles(){this._cache.forEach(t=>{t.isVisible=!1})}_getTile(t,e,n){const r=this._getTileId(t,e,n);return this._cache.get(r)}_getTileId(t,e,n){return`${n}-${t}-${e}`}}const $={renderSubLayers:{type:"function",value:t=>new r.GeoJsonLayer(t)},getTileData:{type:"function",value:({x:t,y:e,z:n})=>Promise.resolve(null)},onViewportLoaded:{type:"function",value:()=>{}},onTileError:{type:"function",value:t=>console.error(t)},maxZoom:null,minZoom:0,maxCacheSize:null};class tt extends r.CompositeLayer{initializeState(){const{maxZoom:t,minZoom:e,getTileData:n,onTileError:r}=this.props;this.state={tiles:[],tileCache:new Q({getTileData:n,maxZoom:t,minZoom:e,onTileError:r}),isLoaded:!1}}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({props:t,oldProps:e,context:n,changeFlags:r}){const{onViewportLoaded:i,onTileError:o}=t;if(r.updateTriggersChanged&&(r.updateTriggersChanged.all||r.updateTriggersChanged.getTileData)){const{getTileData:e,maxZoom:n,minZoom:r,maxCacheSize:i}=t;this.state.tileCache.finalize(),this.setState({tileCache:new Q({getTileData:e,maxSize:i,maxZoom:n,minZoom:r,onTileError:o})})}if(r.viewportChanged){const{viewport:t}=n,e=this.getLayerZoomLevel();"DEFAULT-INITIAL-VIEWPORT"!==t.id&&this.state.tileCache.update(t,t=>{const n=t.filter(t=>t.z===e),r=n.every(t=>t.isLoaded);this.setState({tiles:t,isLoaded:r}),r?i(n.filter(t=>t._data).map(t=>t._data)):Promise.all(n.map(t=>t.data)).then(()=>{this.setState({isLoaded:!0}),i(n.filter(t=>t._data).map(t=>t._data))})})}}getPickingInfo({info:t,sourceLayer:e}){return t.sourceLayer=e,t.tile=e.props.tile,t}getLayerZoomLevel(){const t=Math.floor(this.context.viewport.zoom),{maxZoom:e,minZoom:n}=this.props;return e&&parseInt(e,10)===e&&t>e?e:n&&parseInt(n,10)===n&&t<n?n:t}renderLayers(){const{renderSubLayers:t,visible:e}=this.props,n=this.getLayerZoomLevel();return this.state.tiles.map(r=>t(Object.assign({},this.props,{id:`${this.id}-${r.x}-${r.y}-${r.z}`,data:r.data,visible:e&&(!this.state.isLoaded||r.z===n),tile:r})))}}tt.layerName="TileLayer",tt.defaultProps=$;var et=n(5),nt="#define SHADER_NAME trips-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec3 colors;\n\nuniform float opacity;\nuniform float currentTime;\nuniform float trailLength;\n\nvarying float vTime;\nvarying vec4 vColor;\n\nvoid main(void) {\n vec2 p = project_position(positions.xy);\n // the magic de-flickering factor\n vec4 shift = vec4(0., 0., mod(positions.z, trailLength) * 1e-4, 0.);\n\n gl_Position = project_to_clipspace(vec4(p, 1., 1.)) + shift;\n\n vColor = vec4(colors / 255.0, opacity);\n vTime = 1.0 - (currentTime - positions.z) / trailLength;\n}\n",rt="#define SHADER_NAME trips-layer-fragment-shader\n\nprecision highp float;\n\nvarying float vTime;\nvarying vec4 vColor;\n\nvoid main(void) {\n if (vTime > 1.0 || vTime < 0.0) {\n discard;\n }\n gl_FragColor = vec4(vColor.rgb, vColor.a * vTime);\n}\n";class it extends r.Layer{initializeState(){const{gl:t}=this.context,e=this.getAttributeManager(),n=this.getModel(t);e.add({indices:{size:1,update:this.calculateIndices,isIndexed:!0},positions:{size:3,update:this.calculatePositions},colors:{size:3,accessor:"getColor",update:this.calculateColors}}),t.getExtension("OES_element_index_uint"),this.setState({model:n})}updateState({props:t,changeFlags:{dataChanged:e}}){e&&(this.countVertices(t.data),this.state.attributeManager.invalidateAll())}getModel(t){return new et.Model(t,{id:this.props.id,vs:nt,fs:rt,geometry:new et.Geometry({id:this.props.id,drawMode:"LINES"}),vertexCount:0,isIndexed:!0,onBeforeRender:()=>{t.enable(t.BLEND),t.enable(t.POLYGON_OFFSET_FILL),t.polygonOffset(2,1),t.blendFunc(t.SRC_ALPHA,t.ONE),t.blendEquation(t.FUNC_ADD)},onAfterRender:()=>{t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),t.disable(t.POLYGON_OFFSET_FILL)}})}countVertices(t){if(!t)return;const{getPath:e}=this.props;let n=0;const r=t.reduce((t,r)=>{const i=e(r).length;return n+=i,[...t,i]},[]);this.setState({pathLengths:r,vertexCount:n})}draw({uniforms:t}){const{trailLength:e,currentTime:n}=this.props;this.state.model.render(Object.assign({},t,{trailLength:e,currentTime:n}))}calculateIndices(t){const{pathLengths:e,vertexCount:n}=this.state,r=2*(n-e.length),i=new Uint32Array(r);let o=0,a=0;for(let t=0;t<e.length;t++){const n=e[t];i[a++]=o;for(let t=1;t<n-1;t++)i[a++]=t+o,i[a++]=t+o;i[a++]=o+n-1,o+=n}t.value=i,this.state.model.setVertexCount(r)}calculatePositions(t){const{data:e,getPath:n}=this.props,{vertexCount:r}=this.state,i=new Float32Array(3*r);let o=0;for(let t=0;t<e.length;t++){const r=n(e[t]);for(let t=0;t<r.length;t++){const e=r[t];i[o++]=e[0],i[o++]=e[1],i[o++]=e[2]}}t.value=i}calculateColors(t){const{data:e,getColor:n}=this.props,{pathLengths:r,vertexCount:i}=this.state,o=new Float32Array(3*i);let a=0;for(let t=0;t<e.length;t++){const i=n(e[t]),s=r[t];for(let t=0;t<s;t++)o[a++]=i[0],o[a++]=i[1],o[a++]=i[2]}t.value=o}}it.layerName="TripsLayer",it.defaultProps={trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:t=>t.color}},n.d(e,"GreatCircleLayer",function(){return o}),n.d(e,"S2Layer",function(){return c}),n.d(e,"TileLayer",function(){return tt}),n.d(e,"TripsLayer",function(){return it})}])});
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("deck"),require("H3"),require("S2"));else if("function"==typeof define&&define.amd)define(["deck","H3","S2"],t);else{var n="object"==typeof exports?t(require("deck"),require("H3"),require("S2")):t(e.deck,e.H3,e.S2);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(window,function(e,t,n){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t,n){(function(t){const i=n(5),r=("undefined"==typeof window?t:window).deck||{};if(!r.LineLayer)throw new Error("@deck.gl/layers is not found");e.exports=Object.assign(r,i)}).call(this,n(4))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";n.r(t);var i=n(0),r="#define SHADER_NAME great-circle-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\n\nvarying vec4 vColor;\n\n// offset vector by strokeWidth pixels\n// offset_direction is -1 (left) or 1 (right)\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\n // normalized direction of the line\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n // rotate by 90 degrees\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\n\n// get angular distance in radian\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n // if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main(void) {\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n \n // if it's the first point, use next - current as direction\n // otherwise use current - prev\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n \n vec2 source = radians(instancePositions.xy);\n vec2 target = radians(instancePositions.zw);\n \n float angularDist = getAngularDist(source, target);\n\n vec3 currPos = vec3(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0);\n vec3 nextPos = vec3(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0);\n\n vec2 currPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, segmentRatio);\n vec2 nextPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, nextSegmentRatio);\n\n vec4 curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0));\n vec4 next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n\n // Multiply out width and clamp to limits\n // mercator pixels are interpreted as screen pixels\n float width = clamp(\n project_scale(instanceWidths * widthScale),\n widthMinPixels, widthMaxPixels\n );\n\n // extrude\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, width);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;\n vColor = vec4(color.rgb, color.a * opacity);\n \n // Set color to be rendered to picking fbo (also used to check for selection highlight).\n picking_setPickingColor(instancePickingColors);\n}\n";class o extends i.ArcLayer{getShaders(){return Object.assign({},super.getShaders(),{vs:r,modules:["picking","project32"]})}}o.layerName="GreatCircleLayer";var a=n(2);const s=180/Math.PI,l=100;function c([e,t,n]){const i=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*s,i*s]}function u(e){const t=function(e){const t=e.padEnd(16,"0");return String(parseInt(t,16))}(e),n=function(e){const t=e.substr(e.length-1);return 2*(e.length-1)-(0==(1&t))}(e);return function({face:e,ij:t,level:n}){const i=[],r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,l*Math.pow(2,-n));for(let s=0;s<4;s++){const l=r[s].slice(0),u=r[s+1],d=(u[0]-l[0])/o,g=(u[1]-l[1])/o;for(let r=0;r<o;r++){l[0]+=d,l[1]+=g;const r=a.S2.IJToST(t,n,l),o=a.S2.STToUV(r),s=a.S2.FaceUVToXYZ(e,o);i.push(c(s))}}return i}(a.S2.S2Cell.FromLatLng(a.S2.idToLatLng(t),n))}const d=Object.assign({getS2Token:{type:"accessor",value:e=>e.token}},i.PolygonLayer.defaultProps);class g extends i.CompositeLayer{renderLayers(){const{data:e,getS2Token:t}=this.props,{elevationScale:n,extruded:r,wireframe:o,filled:a,stroked:s,lineWidthUnits:l,lineWidthScale:c,lineWidthMinPixels:d,lineWidthMaxPixels:g,lineJointRounded:h,lineMiterLimit:f,lineDashJustified:p,fp64:m,getElevation:y,getFillColor:x,getLineColor:v,getLineWidth:L,getLineDashArray:_}=this.props,{updateTriggers:b,material:S}=this.props;return new(this.getSubLayerClass("cell",i.PolygonLayer))({fp64:m,filled:a,wireframe:o,extruded:r,elevationScale:n,stroked:s,lineWidthUnits:l,lineWidthScale:c,lineWidthMinPixels:d,lineWidthMaxPixels:g,lineJointRounded:h,lineMiterLimit:f,lineDashJustified:p,material:S,getElevation:y,getFillColor:x,getLineColor:v,getLineWidth:L,getLineDashArray:_},this.getSubLayerProps({id:"cell",updateTriggers:{getElevation:b.getElevation,getFillColor:b.getFillColor,getLineColor:b.getLineColor,getLineWidth:b.getLineWidth,getLineDashArray:b.getLineDashArray}}),{data:e,getPolygon:e=>u(t(e))})}}function h(e,t,n){const i=e/Math.pow(2,n)*360-180,r=Math.PI-2*Math.PI*t/Math.pow(2,n);return[i,180/Math.PI*Math.atan(.5*(Math.exp(r)-Math.exp(-r)))]}g.layerName="S2Layer",g.defaultProps=d;class f{constructor({getTileData:e,x:t,y:n,z:i,onTileError:r}){this.x=t,this.y=n,this.z=i,this.bbox=function(e,t,n){const[i,r]=h(e,t,n),[o,a]=h(e+1,t+1,n);return{west:i,north:r,east:o,south:a}}(this.x,this.y,this.z),this.isVisible=!0,this.getTileData=e,this._data=null,this._isLoaded=!1,this._loader=this._loadData(),this.onTileError=r}get data(){return this._data?Promise.resolve(this._data):this._loader}get isLoaded(){return this._isLoaded}_loadData(){const{x:e,y:t,z:n}=this;return this.getTileData?this.getTileData({x:e,y:t,z:n}).then(e=>(this._data=e,this._isLoaded=!0,e)).catch(e=>{this._isLoaded=!0,this.onTileError(e)}):null}isOverlapped(e){const{x:t,y:n,z:i}=this,r=Math.pow(2,e.z-i);return Math.floor(e.x/r)===t&&Math.floor(e.y/r)===n}}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(e){r=!0,o=e}finally{try{i||null==s.return||s.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var m="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;var y,x;y=new m(4),m!=Float32Array&&(y[0]=0,y[1]=0,y[2]=0,y[3]=0),x=y;!function(){var e,t=(e=new m(2),m!=Float32Array&&(e[0]=0,e[1]=0),e)}();!function(){var e,t=(e=new m(3),m!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e)}();function v(e,t){if(!e)throw new Error(t||"viewport-mercator-project: assertion failed.")}var L=Math.PI,_=L/4,b=L/180,S=512;function P(e,t){var n=p(e,2),i=n[0],r=n[1];v(Number.isFinite(i)&&Number.isFinite(t)),v(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");var o=r*b;return[(t*=S)*(i*b+L)/(2*L),t*(L-Math.log(Math.tan(_+.5*o)))/(2*L)]}const T=512;function w(e){return Math.floor(e/T)}function C({x:e,y:t,z:n},i){const r=Math.pow(2,n-i);return{x:Math.floor(e/r),y:Math.floor(t/r),z:i}}class j{constructor({getTileData:e,maxSize:t,maxZoom:n,minZoom:i,onTileError:r}){this._getTileData=e,this._maxSize=t,this.onTileError=r,this._cache=new Map,n&&parseInt(n,10)===n&&(this._maxZoom=n),i&&parseInt(i,10)===i&&(this._minZoom=i)}finalize(){this._cache.clear()}update(e,t){const{_cache:n,_getTileData:i,_maxSize:r,_maxZoom:o,_minZoom:a}=this;this._markOldTiles();const s=function(e,t,n){const i=Math.floor(e.zoom);if(n&&i<n)return[];const r=function(e){const t=[e.unproject([0,0]),e.unproject([e.width,0]),e.unproject([0,e.height]),e.unproject([e.width,e.height])];return[t.reduce((e,t)=>e<t[0]?e:t[0],180),t.reduce((e,t)=>e<t[1]?e:t[1],90),t.reduce((e,t)=>e>t[0]?e:t[0],-180),t.reduce((e,t)=>e>t[1]?e:t[1],-90)]}(e=new e.constructor(Object.assign({},e,{zoom:i}))),[o,a]=P([r[0],r[3]],e.scale).map(w),[s,l]=P([r[2],r[1]],e.scale).map(w),c=[];for(let e=o;e<=s;e++)for(let n=a;n<=l;n++)t&&i>t?c.push(C({x:e,y:n,z:i},t)):c.push({x:e,y:n,z:i});return c}(e,o,a);if(!s||0===s.length)return void t(s);const l=new Set;n.forEach(e=>{s.some(t=>e.isOverlapped(t))&&(e.isVisible=!0,l.add(e))});for(let e=0;e<s.length;e++){const t=s[e],{x:r,y:o,z:a}=t;let c=this._getTile(r,o,a);c||(c=new f({getTileData:i,x:r,y:o,z:a,onTileError:this.onTileError}));const u=this._getTileId(r,o,a);n.set(u,c),l.add(c)}this._resizeCache(r||5*s.length),t(Array.from(l).sort((e,t)=>e.z-t.z))}_resizeCache(e){const{_cache:t}=this;if(t.size>e){const n=t[Symbol.iterator]();for(const i of n){if(t.size<=e)break;const n=i[0];i[1].isVisible||t.delete(n)}}}_markOldTiles(){this._cache.forEach(e=>{e.isVisible=!1})}_getTile(e,t,n){const i=this._getTileId(e,t,n);return this._cache.get(i)}_getTileId(e,t,n){return`${n}-${e}-${t}`}}const M={renderSubLayers:{type:"function",value:e=>new i.GeoJsonLayer(e)},getTileData:{type:"function",value:({x:e,y:t,z:n})=>Promise.resolve(null)},onViewportLoaded:{type:"function",value:()=>{}},onTileError:{type:"function",value:e=>console.error(e)},maxZoom:null,minZoom:0,maxCacheSize:null};class z extends i.CompositeLayer{initializeState(){const{maxZoom:e,minZoom:t,getTileData:n,onTileError:i}=this.props;this.state={tiles:[],tileCache:new j({getTileData:n,maxZoom:e,minZoom:t,onTileError:i}),isLoaded:!1}}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:t,context:n,changeFlags:i}){const{onViewportLoaded:r,onTileError:o}=e;if(i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getTileData)){const{getTileData:t,maxZoom:n,minZoom:i,maxCacheSize:r}=e;this.state.tileCache.finalize(),this.setState({tileCache:new j({getTileData:t,maxSize:r,maxZoom:n,minZoom:i,onTileError:o})})}if(i.viewportChanged){const{viewport:e}=n,t=this.getLayerZoomLevel();"DEFAULT-INITIAL-VIEWPORT"!==e.id&&this.state.tileCache.update(e,e=>{const n=e.filter(e=>e.z===t),i=n.every(e=>e.isLoaded);this.setState({tiles:e,isLoaded:i}),i?r(n.filter(e=>e._data).map(e=>e._data)):Promise.all(n.map(e=>e.data)).then(()=>{this.setState({isLoaded:!0}),r(n.filter(e=>e._data).map(e=>e._data))})})}}getPickingInfo({info:e,sourceLayer:t}){return e.sourceLayer=t,e.tile=t.props.tile,e}getLayerZoomLevel(){const e=Math.floor(this.context.viewport.zoom),{maxZoom:t,minZoom:n}=this.props;return t&&parseInt(t,10)===t&&e>t?t:n&&parseInt(n,10)===n&&e<n?n:e}renderLayers(){const{renderSubLayers:e,visible:t}=this.props,n=this.getLayerZoomLevel();return this.state.tiles.map(i=>e(Object.assign({},this.props,{id:`${this.id}-${i.x}-${i.y}-${i.z}`,data:i.data,visible:t&&(!this.state.isLoaded||i.z===n),tile:i})))}}z.layerName="TileLayer",z.defaultProps=M;class D extends i.PathLayer{getShaders(){const e=super.getShaders();return e.inject={"vs:#decl":"uniform float trailLength;\nvarying float vTime;\n","vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);":"pos.z = 0.0;","vs:#main-end":"float shiftZ = mod(instanceEndPositions.z, trailLength) * 1e-4;\ngl_Position.z += shiftZ;\nvTime = instanceStartPositions.z + (instanceEndPositions.z - instanceStartPositions.z) * vPathPosition.y / vPathLength;\n","fs:#decl":"uniform float trailLength;\nuniform float currentTime;\nvarying float vTime;\n","fs:#main-start":"if(vTime > currentTime || vTime < currentTime - trailLength) {\n discard;\n}\n","gl_FragColor = vColor;":"gl_FragColor.a *= 1.0 - (currentTime - vTime) / trailLength;"},e}draw(e){const{trailLength:t,currentTime:n}=this.props;e.uniforms=Object.assign({},e.uniforms,{trailLength:t,currentTime:n}),super.draw(e)}}D.layerName="TripsLayer",D.defaultProps={trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0}};var E=n(1);const I=Object.assign({getHexagons:{type:"accessor",value:e=>e.hexagons}},i.PolygonLayer.defaultProps);class O extends i.CompositeLayer{updateState({props:e,oldProps:t,changeFlags:n}){if(n.dataChanged||n.updateTriggers&&n.updateTriggers.getHexagons){const{data:t,getHexagons:n}=e,r=[],{iterable:o,objectInfo:a}=Object(i.createIterable)(t);for(const e of o){a.index++;const t=n(e,a),i=Object(E.h3SetToMultiPolygon)(t,!0);for(const t of i)r.push({polygon:t,object:e,index:a.index})}this.setState({polygons:r})}}getPickingInfo({info:e}){return Object.assign(e,{object:e.object&&e.object.object,index:e.object&&e.object.index})}getSubLayerAccessor(e){return"function"!=typeof e?e:(t,n)=>e(t.object,n)}renderLayers(){const{elevationScale:e,extruded:t,wireframe:n,filled:r,stroked:o,lineWidthScale:a,lineWidthMinPixels:s,lineWidthMaxPixels:l,lineJointRounded:c,lineMiterLimit:u,lineDashJustified:d,fp64:g,material:h,getFillColor:f,getLineColor:p,getLineWidth:m,getLineDashArray:y,getElevation:x,updateTriggers:v}=this.props;return new(this.getSubLayerClass("cluster-region",i.PolygonLayer))({fp64:g,filled:r,wireframe:n,extruded:t,elevationScale:e,stroked:o,lineWidthScale:a,lineWidthMinPixels:s,lineWidthMaxPixels:l,lineJointRounded:c,lineMiterLimit:u,lineDashJustified:d,material:h,getFillColor:this.getSubLayerAccessor(f),getLineColor:this.getSubLayerAccessor(p),getLineWidth:this.getSubLayerAccessor(m),getLineDashArray:this.getSubLayerAccessor(y),getElevation:this.getSubLayerAccessor(x)},this.getSubLayerProps({id:"cluster-region",updateTriggers:v}),{data:this.state.polygons,getPolygon:e=>e.polygon})}}function k(e,t,n){const i=e(t,n),[r,o]=Object(E.h3ToGeo)(i);return[o,r]}O.defaultProps=I,O.layerName="H3ClusterLayer";const A=Object.assign({getHexagon:{type:"accessor",value:e=>e.hexagon}},i.ColumnLayer.defaultProps);class F extends i.CompositeLayer{shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:t,changeFlags:n}){if(n.dataChanged||n.updateTriggers&&n.updateTriggers.getHexagon){let t=-1;const{iterable:n,objectInfo:r}=Object(i.createIterable)(e.data);for(const i of n){r.index++;const n=e.getHexagon(i,r);t=Object(E.h3GetResolution)(n);break}this.setState({resolution:t,vertices:null})}n.viewportChanged&&this._updateVertices(this.context.viewport)}_updateVertices(e){const{resolution:t,centerHex:n}=this.state;if(t<0)return;const i=Object(E.geoToH3)(e.latitude,e.longitude,t);if(n===i)return;const{pixelsPerMeter:r}=e.distanceScales;let o=Object(E.h3ToGeoBoundary)(i,!0);const[a,s]=Object(E.h3ToGeo)(i),[l,c]=e.projectFlat([s,a]);o=o.map(t=>{const n=e.projectFlat(t);return n[0]=(n[0]-l)/r[0],n[1]=(n[1]-c)/r[1],n}),this.setState({centerHex:i,vertices:o})}renderLayers(){const{data:e,getHexagon:t,updateTriggers:n,coverage:r,elevationScale:o,extruded:a,fp64:s,getColor:l,getElevation:c,material:u}=this.props;return new(this.getSubLayerClass("hexagon-cell",i.ColumnLayer))({coverage:r,elevationScale:o,extruded:a,fp64:s,getColor:l,getElevation:c,material:u},this.getSubLayerProps({id:"hexagon-cell",updateTriggers:n}),{data:e,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:k.bind(null,t)})}}F.defaultProps=A,F.layerName="H3HexagonLayer",n.d(t,"GreatCircleLayer",function(){return o}),n.d(t,"S2Layer",function(){return g}),n.d(t,"TileLayer",function(){return z}),n.d(t,"TripsLayer",function(){return D}),n.d(t,"H3ClusterLayer",function(){return O}),n.d(t,"H3HexagonLayer",function(){return F})}])});

@@ -48,2 +48,3 @@ "use strict";

exports.default = GreatCircleLayer;
GreatCircleLayer.layerName = 'GreatCircleLayer';
//# sourceMappingURL=great-circle-layer.js.map

@@ -7,4 +7,4 @@ "use strict";

exports.default = void 0;
var _default = "#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\nuniform float widthScale;\n\nvarying vec4 vColor;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths * widthScale / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n float a =\n sin(delta.y / 2.0) * sin(delta.y / 2.0) +\n cos(source.y) * cos(target.y) *\n sin(delta.x / 2.0) * sin(delta.x / 2.0);\n\treturn 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n\n\tfloat a = sin((1.0 - t) * angularDist) / sin(angularDist);\n\tfloat b = sin(t * angularDist) / sin(angularDist);\n\tfloat x = a * cos(source.y) * cos(source.x) + b * cos(target.y) * cos(target.x);\n\tfloat y = a * cos(source.y) * sin(source.x) + b * cos(target.y) * sin(target.x);\n\tfloat z = a * sin(source.y) + b * sin(target.y);\n\treturn vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main(void) {\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n \n vec2 source = radians(instancePositions.xy);\n vec2 target = radians(instancePositions.zw);\n \n float angularDist = getAngularDist(source, target);\n\n vec3 currPos = vec3(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0);\n vec3 nextPos = vec3(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0);\n\n vec2 currPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, segmentRatio);\n vec2 nextPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, nextSegmentRatio);\n\n vec4 curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0));\n vec4 next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;\n vColor = vec4(color.rgb, color.a * opacity);\n picking_setPickingColor(instancePickingColors);\n}\n";
var _default = "#define SHADER_NAME great-circle-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\n\nvarying vec4 vColor;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main(void) {\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n \n vec2 source = radians(instancePositions.xy);\n vec2 target = radians(instancePositions.zw);\n \n float angularDist = getAngularDist(source, target);\n\n vec3 currPos = vec3(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0);\n vec3 nextPos = vec3(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0);\n\n vec2 currPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, segmentRatio);\n vec2 nextPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, nextSegmentRatio);\n\n vec4 curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0));\n vec4 next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n float width = clamp(\n project_scale(instanceWidths * widthScale),\n widthMinPixels, widthMaxPixels\n );\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, width);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;\n vColor = vec4(color.rgb, color.a * opacity);\n picking_setPickingColor(instancePickingColors);\n}\n";
exports.default = _default;
//# sourceMappingURL=great-circle-vertex.glsl.js.map

@@ -32,2 +32,14 @@ "use strict";

});
Object.defineProperty(exports, "H3ClusterLayer", {
enumerable: true,
get: function get() {
return _h3ClusterLayer.default;
}
});
Object.defineProperty(exports, "H3HexagonLayer", {
enumerable: true,
get: function get() {
return _h3HexagonLayer.default;
}
});

@@ -41,2 +53,6 @@ var _greatCircleLayer = _interopRequireDefault(require("./great-circle-layer/great-circle-layer"));

var _tripsLayer = _interopRequireDefault(require("./trips-layer/trips-layer"));
var _h3ClusterLayer = _interopRequireDefault(require("./h3-layers/h3-cluster-layer"));
var _h3HexagonLayer = _interopRequireDefault(require("./h3-layers/h3-hexagon-layer"));
//# sourceMappingURL=index.js.map

@@ -26,22 +26,11 @@ "use strict";

function getDefaultProps() {
var defaultProps = {};
for (var prop in _layers.PolygonLayer.defaultProps) {
if (prop !== 'getPolygon') {
defaultProps[prop] = _layers.PolygonLayer.defaultProps[prop];
var defaultProps = Object.assign({
getS2Token: {
type: 'accessor',
value: function value(d) {
return d.token;
}
}
}, _layers.PolygonLayer.defaultProps);
defaultProps.getS2Token = {
type: 'accessor',
value: function value(f) {
return f.token;
}
};
return defaultProps;
}
var defaultProps = getDefaultProps();
var S2Layer = function (_CompositeLayer) {

@@ -67,2 +56,3 @@ (0, _inherits2.default)(S2Layer, _CompositeLayer);

stroked = _this$props2.stroked,
lineWidthUnits = _this$props2.lineWidthUnits,
lineWidthScale = _this$props2.lineWidthScale,

@@ -91,2 +81,3 @@ lineWidthMinPixels = _this$props2.lineWidthMinPixels,

stroked: stroked,
lineWidthUnits: lineWidthUnits,
lineWidthScale: lineWidthScale,

@@ -93,0 +84,0 @@ lineWidthMinPixels: lineWidthMinPixels,

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -8,8 +10,6 @@ value: true

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var _s2Geometry = require("s2-geometry");
function hexToDec(hexString) {
return String(parseInt(hexString, 16));
}
function getLevelFromToken(token) {

@@ -22,7 +22,51 @@ var lastHex = token.substr(token.length - 1);

function getIdFromToken(token) {
var padding = 16 - token.length;
var paddedToken = token + new Array(padding + 1).join('0');
return hexToDec(paddedToken);
var paddedToken = token.padEnd(16, '0');
return String(parseInt(paddedToken, 16));
}
var RADIAN_TO_DEGREE = 180 / Math.PI;
var MAX_RESOLUTION = 100;
function XYZToLngLat(_ref) {
var _ref2 = (0, _slicedToArray2.default)(_ref, 3),
x = _ref2[0],
y = _ref2[1],
z = _ref2[2];
var lat = Math.atan2(z, Math.sqrt(x * x + y * y));
var lng = Math.atan2(y, x);
return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
}
function getGeoBounds(_ref3) {
var face = _ref3.face,
ij = _ref3.ij,
level = _ref3.level;
var result = [];
var offsets = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]];
var resolution = Math.max(1, MAX_RESOLUTION * Math.pow(2, -level));
for (var i = 0; i < 4; i++) {
var offset = offsets[i].slice(0);
var nextOffset = offsets[i + 1];
var stepI = (nextOffset[0] - offset[0]) / resolution;
var stepJ = (nextOffset[1] - offset[1]) / resolution;
for (var j = 0; j < resolution; j++) {
offset[0] += stepI;
offset[1] += stepJ;
var st = _s2Geometry.S2.IJToST(ij, level, offset);
var uv = _s2Geometry.S2.STToUV(st);
var xyz = _s2Geometry.S2.FaceUVToXYZ(face, uv);
result.push(XYZToLngLat(xyz));
}
}
return result;
}
function getS2Polygon(token) {

@@ -34,9 +78,4 @@ var id = getIdFromToken(token);

var corners = s2cell.getCornerLatLngs();
var polygon = corners.map(function (corner) {
return [corner.lng, corner.lat];
});
polygon.push(polygon[0]);
return polygon;
return getGeoBounds(s2cell);
}
//# sourceMappingURL=s2-utils.js.map

@@ -8,2 +8,4 @@ "use strict";

});
exports.tile2latLng = tile2latLng;
exports.tile2boundingBox = tile2boundingBox;
exports.default = void 0;

@@ -15,2 +17,30 @@

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
function tile2latLng(x, y, z) {
var lng = x / Math.pow(2, z) * 360 - 180;
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
var lat = 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
return [lng, lat];
}
function tile2boundingBox(x, y, z) {
var _tile2latLng = tile2latLng(x, y, z),
_tile2latLng2 = (0, _slicedToArray2.default)(_tile2latLng, 2),
west = _tile2latLng2[0],
north = _tile2latLng2[1];
var _tile2latLng3 = tile2latLng(x + 1, y + 1, z),
_tile2latLng4 = (0, _slicedToArray2.default)(_tile2latLng3, 2),
east = _tile2latLng4[0],
south = _tile2latLng4[1];
return {
west: west,
north: north,
east: east,
south: south
};
}
var Tile = function () {

@@ -27,2 +57,3 @@ function Tile(_ref) {

this.z = z;
this.bbox = tile2boundingBox(this.x, this.y, this.z);
this.isVisible = true;

@@ -29,0 +60,0 @@ this.getTileData = getTileData;

@@ -10,4 +10,2 @@ "use strict";

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

@@ -21,12 +19,8 @@

var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _core = require("@deck.gl/core");
var _layers = require("@deck.gl/layers");
var _luma = require("luma.gl");
var _tripsLayerVertex = _interopRequireDefault(require("./trips-layer-vertex.glsl"));
var _tripsLayerFragment = _interopRequireDefault(require("./trips-layer-fragment.glsl"));
var defaultProps = {

@@ -42,19 +36,7 @@ trailLength: {

min: 0
},
getPath: {
type: 'accessor',
value: function value(d) {
return d.path;
}
},
getColor: {
type: 'accessor',
value: function value(d) {
return d.color;
}
}
};
var TripsLayer = function (_Layer) {
(0, _inherits2.default)(TripsLayer, _Layer);
var TripsLayer = function (_PathLayer) {
(0, _inherits2.default)(TripsLayer, _PathLayer);

@@ -67,174 +49,30 @@ function TripsLayer() {

(0, _createClass2.default)(TripsLayer, [{
key: "initializeState",
value: function initializeState() {
var gl = this.context.gl;
var attributeManager = this.getAttributeManager();
var model = this.getModel(gl);
attributeManager.add({
indices: {
size: 1,
update: this.calculateIndices,
isIndexed: true
},
positions: {
size: 3,
update: this.calculatePositions
},
colors: {
size: 3,
accessor: 'getColor',
update: this.calculateColors
}
});
gl.getExtension('OES_element_index_uint');
this.setState({
model: model
});
key: "getShaders",
value: function getShaders() {
var shaders = (0, _get2.default)((0, _getPrototypeOf2.default)(TripsLayer.prototype), "getShaders", this).call(this);
shaders.inject = {
'vs:#decl': "uniform float trailLength;\nvarying float vTime;\n",
'vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);': 'pos.z = 0.0;',
'vs:#main-end': "float shiftZ = mod(instanceEndPositions.z, trailLength) * 1e-4;\ngl_Position.z += shiftZ;\nvTime = instanceStartPositions.z + (instanceEndPositions.z - instanceStartPositions.z) * vPathPosition.y / vPathLength;\n",
'fs:#decl': "uniform float trailLength;\nuniform float currentTime;\nvarying float vTime;\n",
'fs:#main-start': "if(vTime > currentTime || vTime < currentTime - trailLength) {\n discard;\n}\n",
'gl_FragColor = vColor;': 'gl_FragColor.a *= 1.0 - (currentTime - vTime) / trailLength;'
};
return shaders;
}
}, {
key: "updateState",
value: function updateState(_ref) {
var props = _ref.props,
dataChanged = _ref.changeFlags.dataChanged;
if (dataChanged) {
this.countVertices(props.data);
this.state.attributeManager.invalidateAll();
}
}
}, {
key: "getModel",
value: function getModel(gl) {
return new _luma.Model(gl, {
id: this.props.id,
vs: _tripsLayerVertex.default,
fs: _tripsLayerFragment.default,
geometry: new _luma.Geometry({
id: this.props.id,
drawMode: 'LINES'
}),
vertexCount: 0,
isIndexed: true,
onBeforeRender: function onBeforeRender() {
gl.enable(gl.BLEND);
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(2.0, 1.0);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendEquation(gl.FUNC_ADD);
},
onAfterRender: function onAfterRender() {
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.disable(gl.POLYGON_OFFSET_FILL);
}
});
}
}, {
key: "countVertices",
value: function countVertices(data) {
if (!data) {
return;
}
var getPath = this.props.getPath;
var vertexCount = 0;
var pathLengths = data.reduce(function (acc, d) {
var l = getPath(d).length;
vertexCount += l;
return [].concat((0, _toConsumableArray2.default)(acc), [l]);
}, []);
this.setState({
pathLengths: pathLengths,
vertexCount: vertexCount
});
}
}, {
key: "draw",
value: function draw(_ref2) {
var uniforms = _ref2.uniforms;
value: function draw(params) {
var _this$props = this.props,
trailLength = _this$props.trailLength,
currentTime = _this$props.currentTime;
this.state.model.render(Object.assign({}, uniforms, {
params.uniforms = Object.assign({}, params.uniforms, {
trailLength: trailLength,
currentTime: currentTime
}));
});
(0, _get2.default)((0, _getPrototypeOf2.default)(TripsLayer.prototype), "draw", this).call(this, params);
}
}, {
key: "calculateIndices",
value: function calculateIndices(attribute) {
var _this$state = this.state,
pathLengths = _this$state.pathLengths,
vertexCount = _this$state.vertexCount;
var indicesCount = (vertexCount - pathLengths.length) * 2;
var indices = new Uint32Array(indicesCount);
var offset = 0;
var index = 0;
for (var i = 0; i < pathLengths.length; i++) {
var l = pathLengths[i];
indices[index++] = offset;
for (var j = 1; j < l - 1; j++) {
indices[index++] = j + offset;
indices[index++] = j + offset;
}
indices[index++] = offset + l - 1;
offset += l;
}
attribute.value = indices;
this.state.model.setVertexCount(indicesCount);
}
}, {
key: "calculatePositions",
value: function calculatePositions(attribute) {
var _this$props2 = this.props,
data = _this$props2.data,
getPath = _this$props2.getPath;
var vertexCount = this.state.vertexCount;
var positions = new Float32Array(vertexCount * 3);
var index = 0;
for (var i = 0; i < data.length; i++) {
var path = getPath(data[i]);
for (var j = 0; j < path.length; j++) {
var pt = path[j];
positions[index++] = pt[0];
positions[index++] = pt[1];
positions[index++] = pt[2];
}
}
attribute.value = positions;
}
}, {
key: "calculateColors",
value: function calculateColors(attribute) {
var _this$props3 = this.props,
data = _this$props3.data,
getColor = _this$props3.getColor;
var _this$state2 = this.state,
pathLengths = _this$state2.pathLengths,
vertexCount = _this$state2.vertexCount;
var colors = new Float32Array(vertexCount * 3);
var index = 0;
for (var i = 0; i < data.length; i++) {
var color = getColor(data[i]);
var l = pathLengths[i];
for (var j = 0; j < l; j++) {
colors[index++] = color[0];
colors[index++] = color[1];
colors[index++] = color[2];
}
}
attribute.value = colors;
}
}]);
return TripsLayer;
}(_core.Layer);
}(_layers.PathLayer);

@@ -241,0 +79,0 @@ exports.default = TripsLayer;

@@ -13,2 +13,3 @@ import { ArcLayer } from '@deck.gl/layers';

}
GreatCircleLayer.layerName = 'GreatCircleLayer';
//# sourceMappingURL=great-circle-layer.js.map
export default `\
#define SHADER_NAME arc-layer-vertex-shader
#define SHADER_NAME great-circle-layer-vertex-shader

@@ -15,2 +15,4 @@ attribute vec3 positions;

uniform float widthScale;
uniform float widthMinPixels;
uniform float widthMaxPixels;

@@ -21,3 +23,3 @@ varying vec4 vColor;

// offset_direction is -1 (left) or 1 (right)
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
// normalized direction of the line

@@ -27,4 +29,6 @@ vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);

dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths * widthScale / 2.0;
vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;
vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;
return offset_clipspace;

@@ -40,11 +44,12 @@ }

vec2 delta = source - target;
vec2 sin_half_delta = sin(delta / 2.0);
float a =
sin(delta.y / 2.0) * sin(delta.y / 2.0) +
sin_half_delta.y * sin_half_delta.y +
cos(source.y) * cos(target.y) *
sin(delta.x / 2.0) * sin(delta.x / 2.0);
return 2.0 * atan(sqrt(a), sqrt(1.0 - a));
sin_half_delta.x * sin_half_delta.x;
return 2.0 * atan(sqrt(a), sqrt(1.0 - a));
}
vec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {
// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
if(abs(angularDist - PI) < 0.001) {

@@ -54,8 +59,13 @@ return (1.0 - t) * source + t * target;

float a = sin((1.0 - t) * angularDist) / sin(angularDist);
float b = sin(t * angularDist) / sin(angularDist);
float x = a * cos(source.y) * cos(source.x) + b * cos(target.y) * cos(target.x);
float y = a * cos(source.y) * sin(source.x) + b * cos(target.y) * sin(target.x);
float z = a * sin(source.y) + b * sin(target.y);
return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));
float a = sin((1.0 - t) * angularDist) / sin(angularDist);
float b = sin(t * angularDist) / sin(angularDist);
vec2 sin_source = sin(source);
vec2 cos_source = cos(source);
vec2 sin_target = sin(target);
vec2 cos_target = cos(target);
float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;
float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;
float z = a * sin_source.y + b * sin_target.y;
return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));
}

@@ -86,5 +96,13 @@

// Multiply out width and clamp to limits
// mercator pixels are interpreted as screen pixels
float width = clamp(
project_scale(instanceWidths * widthScale),
widthMinPixels, widthMaxPixels
);
// extrude
vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);
vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, width);
gl_Position = curr + vec4(offset, 0.0, 0.0);
vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;

@@ -91,0 +109,0 @@ vColor = vec4(color.rgb, color.a * opacity);

@@ -5,2 +5,4 @@ export { default as GreatCircleLayer } from './great-circle-layer/great-circle-layer';

export { default as TripsLayer } from './trips-layer/trips-layer';
export { default as H3ClusterLayer } from './h3-layers/h3-cluster-layer';
export { default as H3HexagonLayer } from './h3-layers/h3-hexagon-layer';
//# sourceMappingURL=index.js.map
import { CompositeLayer } from '@deck.gl/core';
import { PolygonLayer } from '@deck.gl/layers';
import { getS2Polygon } from './s2-utils';
function getDefaultProps() {
const defaultProps = {};
for (const prop in PolygonLayer.defaultProps) {
if (prop !== 'getPolygon') {
defaultProps[prop] = PolygonLayer.defaultProps[prop];
}
const defaultProps = Object.assign({
getS2Token: {
type: 'accessor',
value: d => d.token
}
defaultProps.getS2Token = {
type: 'accessor',
value: f => f.token
};
return defaultProps;
}
const defaultProps = getDefaultProps();
}, PolygonLayer.defaultProps);
export default class S2Layer extends CompositeLayer {

@@ -33,2 +21,3 @@ renderLayers() {

stroked = _this$props2.stroked,
lineWidthUnits = _this$props2.lineWidthUnits,
lineWidthScale = _this$props2.lineWidthScale,

@@ -57,2 +46,3 @@ lineWidthMinPixels = _this$props2.lineWidthMinPixels,

stroked,
lineWidthUnits,
lineWidthScale,

@@ -59,0 +49,0 @@ lineWidthMinPixels,

@@ -0,7 +1,4 @@

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { S2 } from 's2-geometry';
function hexToDec(hexString) {
return String(parseInt(hexString, 16));
}
function getLevelFromToken(token) {

@@ -14,7 +11,47 @@ const lastHex = token.substr(token.length - 1);

function getIdFromToken(token) {
const padding = 16 - token.length;
const paddedToken = token + new Array(padding + 1).join('0');
return hexToDec(paddedToken);
const paddedToken = token.padEnd(16, '0');
return String(parseInt(paddedToken, 16));
}
const RADIAN_TO_DEGREE = 180 / Math.PI;
const MAX_RESOLUTION = 100;
function XYZToLngLat(_ref) {
let _ref2 = _slicedToArray(_ref, 3),
x = _ref2[0],
y = _ref2[1],
z = _ref2[2];
const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
const lng = Math.atan2(y, x);
return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
}
function getGeoBounds(_ref3) {
let face = _ref3.face,
ij = _ref3.ij,
level = _ref3.level;
const result = [];
const offsets = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]];
const resolution = Math.max(1, MAX_RESOLUTION * Math.pow(2, -level));
for (let i = 0; i < 4; i++) {
const offset = offsets[i].slice(0);
const nextOffset = offsets[i + 1];
const stepI = (nextOffset[0] - offset[0]) / resolution;
const stepJ = (nextOffset[1] - offset[1]) / resolution;
for (let j = 0; j < resolution; j++) {
offset[0] += stepI;
offset[1] += stepJ;
const st = S2.IJToST(ij, level, offset);
const uv = S2.STToUV(st);
const xyz = S2.FaceUVToXYZ(face, uv);
result.push(XYZToLngLat(xyz));
}
}
return result;
}
export function getS2Polygon(token) {

@@ -24,7 +61,4 @@ const id = getIdFromToken(token);

const s2cell = S2.S2Cell.FromLatLng(S2.idToLatLng(id), level);
const corners = s2cell.getCornerLatLngs();
const polygon = corners.map(corner => [corner.lng, corner.lat]);
polygon.push(polygon[0]);
return polygon;
return getGeoBounds(s2cell);
}
//# sourceMappingURL=s2-utils.js.map

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

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
export function tile2latLng(x, y, z) {
const lng = x / Math.pow(2, z) * 360 - 180;
const n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
const lat = 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
return [lng, lat];
}
export function tile2boundingBox(x, y, z) {
const _tile2latLng = tile2latLng(x, y, z),
_tile2latLng2 = _slicedToArray(_tile2latLng, 2),
west = _tile2latLng2[0],
north = _tile2latLng2[1];
const _tile2latLng3 = tile2latLng(x + 1, y + 1, z),
_tile2latLng4 = _slicedToArray(_tile2latLng3, 2),
east = _tile2latLng4[0],
south = _tile2latLng4[1];
return {
west,
north,
east,
south
};
}
export default class Tile {

@@ -11,2 +36,3 @@ constructor(_ref) {

this.z = z;
this.bbox = tile2boundingBox(this.x, this.y, this.z);
this.isVisible = true;

@@ -13,0 +39,0 @@ this.getTileData = getTileData;

@@ -1,5 +0,2 @@

import { Layer } from '@deck.gl/core';
import { Model, Geometry } from 'luma.gl';
import tripsVertex from './trips-layer-vertex.glsl';
import tripsFragment from './trips-layer-fragment.glsl';
import { PathLayer } from '@deck.gl/layers';
const defaultProps = {

@@ -15,175 +12,44 @@ trailLength: {

min: 0
},
getPath: {
type: 'accessor',
value: d => d.path
},
getColor: {
type: 'accessor',
value: d => d.color
}
};
export default class TripsLayer extends Layer {
initializeState() {
const gl = this.context.gl;
const attributeManager = this.getAttributeManager();
const model = this.getModel(gl);
attributeManager.add({
indices: {
size: 1,
update: this.calculateIndices,
isIndexed: true
},
positions: {
size: 3,
update: this.calculatePositions
},
colors: {
size: 3,
accessor: 'getColor',
update: this.calculateColors
}
});
gl.getExtension('OES_element_index_uint');
this.setState({
model
});
export default class TripsLayer extends PathLayer {
getShaders() {
const shaders = super.getShaders();
shaders.inject = {
'vs:#decl': `\
uniform float trailLength;
varying float vTime;
`,
'vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);': 'pos.z = 0.0;',
'vs:#main-end': `\
float shiftZ = mod(instanceEndPositions.z, trailLength) * 1e-4;
gl_Position.z += shiftZ;
vTime = instanceStartPositions.z + (instanceEndPositions.z - instanceStartPositions.z) * vPathPosition.y / vPathLength;
`,
'fs:#decl': `\
uniform float trailLength;
uniform float currentTime;
varying float vTime;
`,
'fs:#main-start': `\
if(vTime > currentTime || vTime < currentTime - trailLength) {
discard;
}
`,
'gl_FragColor = vColor;': 'gl_FragColor.a *= 1.0 - (currentTime - vTime) / trailLength;'
};
return shaders;
}
updateState(_ref) {
let props = _ref.props,
dataChanged = _ref.changeFlags.dataChanged;
if (dataChanged) {
this.countVertices(props.data);
this.state.attributeManager.invalidateAll();
}
}
getModel(gl) {
return new Model(gl, {
id: this.props.id,
vs: tripsVertex,
fs: tripsFragment,
geometry: new Geometry({
id: this.props.id,
drawMode: 'LINES'
}),
vertexCount: 0,
isIndexed: true,
onBeforeRender: () => {
gl.enable(gl.BLEND);
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(2.0, 1.0);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendEquation(gl.FUNC_ADD);
},
onAfterRender: () => {
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.disable(gl.POLYGON_OFFSET_FILL);
}
});
}
countVertices(data) {
if (!data) {
return;
}
const getPath = this.props.getPath;
let vertexCount = 0;
const pathLengths = data.reduce((acc, d) => {
const l = getPath(d).length;
vertexCount += l;
return [...acc, l];
}, []);
this.setState({
pathLengths,
vertexCount
});
}
draw(_ref2) {
let uniforms = _ref2.uniforms;
draw(params) {
const _this$props = this.props,
trailLength = _this$props.trailLength,
currentTime = _this$props.currentTime;
this.state.model.render(Object.assign({}, uniforms, {
params.uniforms = Object.assign({}, params.uniforms, {
trailLength,
currentTime
}));
});
super.draw(params);
}
calculateIndices(attribute) {
const _this$state = this.state,
pathLengths = _this$state.pathLengths,
vertexCount = _this$state.vertexCount;
const indicesCount = (vertexCount - pathLengths.length) * 2;
const indices = new Uint32Array(indicesCount);
let offset = 0;
let index = 0;
for (let i = 0; i < pathLengths.length; i++) {
const l = pathLengths[i];
indices[index++] = offset;
for (let j = 1; j < l - 1; j++) {
indices[index++] = j + offset;
indices[index++] = j + offset;
}
indices[index++] = offset + l - 1;
offset += l;
}
attribute.value = indices;
this.state.model.setVertexCount(indicesCount);
}
calculatePositions(attribute) {
const _this$props2 = this.props,
data = _this$props2.data,
getPath = _this$props2.getPath;
const vertexCount = this.state.vertexCount;
const positions = new Float32Array(vertexCount * 3);
let index = 0;
for (let i = 0; i < data.length; i++) {
const path = getPath(data[i]);
for (let j = 0; j < path.length; j++) {
const pt = path[j];
positions[index++] = pt[0];
positions[index++] = pt[1];
positions[index++] = pt[2];
}
}
attribute.value = positions;
}
calculateColors(attribute) {
const _this$props3 = this.props,
data = _this$props3.data,
getColor = _this$props3.getColor;
const _this$state2 = this.state,
pathLengths = _this$state2.pathLengths,
vertexCount = _this$state2.vertexCount;
const colors = new Float32Array(vertexCount * 3);
let index = 0;
for (let i = 0; i < data.length; i++) {
const color = getColor(data[i]);
const l = pathLengths[i];
for (let j = 0; j < l; j++) {
colors[index++] = color[0];
colors[index++] = color[1];
colors[index++] = color[2];
}
}
attribute.value = colors;
}
}

@@ -190,0 +56,0 @@ TripsLayer.layerName = 'TripsLayer';

@@ -34,2 +34,3 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

export { GreatCircleLayer as default };
GreatCircleLayer.layerName = 'GreatCircleLayer';
//# sourceMappingURL=great-circle-layer.js.map

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

export default "#define SHADER_NAME arc-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\nuniform float widthScale;\n\nvarying vec4 vColor;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths * widthScale / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n float a =\n sin(delta.y / 2.0) * sin(delta.y / 2.0) +\n cos(source.y) * cos(target.y) *\n sin(delta.x / 2.0) * sin(delta.x / 2.0);\n\treturn 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n\n\tfloat a = sin((1.0 - t) * angularDist) / sin(angularDist);\n\tfloat b = sin(t * angularDist) / sin(angularDist);\n\tfloat x = a * cos(source.y) * cos(source.x) + b * cos(target.y) * cos(target.x);\n\tfloat y = a * cos(source.y) * sin(source.x) + b * cos(target.y) * sin(target.x);\n\tfloat z = a * sin(source.y) + b * sin(target.y);\n\treturn vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main(void) {\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n \n vec2 source = radians(instancePositions.xy);\n vec2 target = radians(instancePositions.zw);\n \n float angularDist = getAngularDist(source, target);\n\n vec3 currPos = vec3(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0);\n vec3 nextPos = vec3(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0);\n\n vec2 currPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, segmentRatio);\n vec2 nextPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, nextSegmentRatio);\n\n vec4 curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0));\n vec4 next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;\n vColor = vec4(color.rgb, color.a * opacity);\n picking_setPickingColor(instancePickingColors);\n}\n";
export default "#define SHADER_NAME great-circle-layer-vertex-shader\n\nattribute vec3 positions;\nattribute vec4 instanceSourceColors;\nattribute vec4 instanceTargetColors;\nattribute vec4 instancePositions;\nattribute vec4 instancePositions64Low;\nattribute vec3 instancePickingColors;\nattribute float instanceWidths;\n\nuniform float numSegments;\nuniform float opacity;\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\n\nvarying vec4 vColor;\nvec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {\n vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);\n dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);\n\n vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;\n vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;\n\n return offset_clipspace;\n}\n\nfloat getSegmentRatio(float index) {\n return smoothstep(0.0, 1.0, index / (numSegments - 1.0));\n}\nfloat getAngularDist (vec2 source, vec2 target) {\n vec2 delta = source - target;\n vec2 sin_half_delta = sin(delta / 2.0);\n float a =\n sin_half_delta.y * sin_half_delta.y +\n cos(source.y) * cos(target.y) *\n sin_half_delta.x * sin_half_delta.x;\n return 2.0 * atan(sqrt(a), sqrt(1.0 - a));\n}\n\nvec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {\n if(abs(angularDist - PI) < 0.001) {\n return (1.0 - t) * source + t * target;\n }\n\n float a = sin((1.0 - t) * angularDist) / sin(angularDist);\n float b = sin(t * angularDist) / sin(angularDist);\n vec2 sin_source = sin(source);\n vec2 cos_source = cos(source);\n vec2 sin_target = sin(target);\n vec2 cos_target = cos(target);\n\n float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;\n float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;\n float z = a * sin_source.y + b * sin_target.y;\n return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));\n}\n\nvoid main(void) {\n float segmentIndex = positions.x;\n float segmentRatio = getSegmentRatio(segmentIndex);\n float indexDir = mix(-1.0, 1.0, step(segmentIndex, 0.0));\n float nextSegmentRatio = getSegmentRatio(segmentIndex + indexDir);\n \n vec2 source = radians(instancePositions.xy);\n vec2 target = radians(instancePositions.zw);\n \n float angularDist = getAngularDist(source, target);\n\n vec3 currPos = vec3(degrees(interpolate(source, target, angularDist, segmentRatio)), 0.0);\n vec3 nextPos = vec3(degrees(interpolate(source, target, angularDist, nextSegmentRatio)), 0.0);\n\n vec2 currPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, segmentRatio);\n vec2 nextPos64Low = mix(instancePositions64Low.xy, instancePositions64Low.zw, nextSegmentRatio);\n\n vec4 curr = project_position_to_clipspace(currPos, currPos64Low, vec3(0.0));\n vec4 next = project_position_to_clipspace(nextPos, nextPos64Low, vec3(0.0));\n float width = clamp(\n project_scale(instanceWidths * widthScale),\n widthMinPixels, widthMaxPixels\n );\n vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, width);\n gl_Position = curr + vec4(offset, 0.0, 0.0);\n\n vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;\n vColor = vec4(color.rgb, color.a * opacity);\n picking_setPickingColor(instancePickingColors);\n}\n";
//# sourceMappingURL=great-circle-vertex.glsl.js.map

@@ -5,2 +5,4 @@ export { default as GreatCircleLayer } from './great-circle-layer/great-circle-layer';

export { default as TripsLayer } from './trips-layer/trips-layer';
export { default as H3ClusterLayer } from './h3-layers/h3-cluster-layer';
export { default as H3HexagonLayer } from './h3-layers/h3-hexagon-layer';
//# sourceMappingURL=index.js.map

@@ -9,23 +9,11 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

import { getS2Polygon } from './s2-utils';
function getDefaultProps() {
var defaultProps = {};
for (var prop in PolygonLayer.defaultProps) {
if (prop !== 'getPolygon') {
defaultProps[prop] = PolygonLayer.defaultProps[prop];
var defaultProps = Object.assign({
getS2Token: {
type: 'accessor',
value: function value(d) {
return d.token;
}
}
}, PolygonLayer.defaultProps);
defaultProps.getS2Token = {
type: 'accessor',
value: function value(f) {
return f.token;
}
};
return defaultProps;
}
var defaultProps = getDefaultProps();
var S2Layer = function (_CompositeLayer) {

@@ -52,2 +40,3 @@ _inherits(S2Layer, _CompositeLayer);

stroked = _this$props2.stroked,
lineWidthUnits = _this$props2.lineWidthUnits,
lineWidthScale = _this$props2.lineWidthScale,

@@ -76,2 +65,3 @@ lineWidthMinPixels = _this$props2.lineWidthMinPixels,

stroked: stroked,
lineWidthUnits: lineWidthUnits,
lineWidthScale: lineWidthScale,

@@ -78,0 +68,0 @@ lineWidthMinPixels: lineWidthMinPixels,

@@ -0,7 +1,4 @@

import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import { S2 } from 's2-geometry';
function hexToDec(hexString) {
return String(parseInt(hexString, 16));
}
function getLevelFromToken(token) {

@@ -14,7 +11,47 @@ var lastHex = token.substr(token.length - 1);

function getIdFromToken(token) {
var padding = 16 - token.length;
var paddedToken = token + new Array(padding + 1).join('0');
return hexToDec(paddedToken);
var paddedToken = token.padEnd(16, '0');
return String(parseInt(paddedToken, 16));
}
var RADIAN_TO_DEGREE = 180 / Math.PI;
var MAX_RESOLUTION = 100;
function XYZToLngLat(_ref) {
var _ref2 = _slicedToArray(_ref, 3),
x = _ref2[0],
y = _ref2[1],
z = _ref2[2];
var lat = Math.atan2(z, Math.sqrt(x * x + y * y));
var lng = Math.atan2(y, x);
return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
}
function getGeoBounds(_ref3) {
var face = _ref3.face,
ij = _ref3.ij,
level = _ref3.level;
var result = [];
var offsets = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]];
var resolution = Math.max(1, MAX_RESOLUTION * Math.pow(2, -level));
for (var i = 0; i < 4; i++) {
var offset = offsets[i].slice(0);
var nextOffset = offsets[i + 1];
var stepI = (nextOffset[0] - offset[0]) / resolution;
var stepJ = (nextOffset[1] - offset[1]) / resolution;
for (var j = 0; j < resolution; j++) {
offset[0] += stepI;
offset[1] += stepJ;
var st = S2.IJToST(ij, level, offset);
var uv = S2.STToUV(st);
var xyz = S2.FaceUVToXYZ(face, uv);
result.push(XYZToLngLat(xyz));
}
}
return result;
}
export function getS2Polygon(token) {

@@ -24,9 +61,4 @@ var id = getIdFromToken(token);

var s2cell = S2.S2Cell.FromLatLng(S2.idToLatLng(id), level);
var corners = s2cell.getCornerLatLngs();
var polygon = corners.map(function (corner) {
return [corner.lng, corner.lat];
});
polygon.push(polygon[0]);
return polygon;
return getGeoBounds(s2cell);
}
//# sourceMappingURL=s2-utils.js.map
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
export function tile2latLng(x, y, z) {
var lng = x / Math.pow(2, z) * 360 - 180;
var n = Math.PI - 2 * Math.PI * y / Math.pow(2, z);
var lat = 180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
return [lng, lat];
}
export function tile2boundingBox(x, y, z) {
var _tile2latLng = tile2latLng(x, y, z),
_tile2latLng2 = _slicedToArray(_tile2latLng, 2),
west = _tile2latLng2[0],
north = _tile2latLng2[1];
var _tile2latLng3 = tile2latLng(x + 1, y + 1, z),
_tile2latLng4 = _slicedToArray(_tile2latLng3, 2),
east = _tile2latLng4[0],
south = _tile2latLng4[1];
return {
west: west,
north: north,
east: east,
south: south
};
}
var Tile = function () {

@@ -17,2 +42,3 @@ function Tile(_ref) {

this.z = z;
this.bbox = tile2boundingBox(this.x, this.y, this.z);
this.isVisible = true;

@@ -19,0 +45,0 @@ this.getTileData = getTileData;

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

import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

@@ -6,7 +5,5 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";

import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _get from "@babel/runtime/helpers/esm/get";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import { Layer } from '@deck.gl/core';
import { Model, Geometry } from 'luma.gl';
import tripsVertex from './trips-layer-vertex.glsl';
import tripsFragment from './trips-layer-fragment.glsl';
import { PathLayer } from '@deck.gl/layers';
var defaultProps = {

@@ -22,19 +19,7 @@ trailLength: {

min: 0
},
getPath: {
type: 'accessor',
value: function value(d) {
return d.path;
}
},
getColor: {
type: 'accessor',
value: function value(d) {
return d.color;
}
}
};
var TripsLayer = function (_Layer) {
_inherits(TripsLayer, _Layer);
var TripsLayer = function (_PathLayer) {
_inherits(TripsLayer, _PathLayer);

@@ -48,175 +33,33 @@ function TripsLayer() {

_createClass(TripsLayer, [{
key: "initializeState",
value: function initializeState() {
var gl = this.context.gl;
var attributeManager = this.getAttributeManager();
var model = this.getModel(gl);
attributeManager.add({
indices: {
size: 1,
update: this.calculateIndices,
isIndexed: true
},
positions: {
size: 3,
update: this.calculatePositions
},
colors: {
size: 3,
accessor: 'getColor',
update: this.calculateColors
}
});
gl.getExtension('OES_element_index_uint');
this.setState({
model: model
});
}
}, {
key: "updateState",
value: function updateState(_ref) {
var props = _ref.props,
dataChanged = _ref.changeFlags.dataChanged;
key: "getShaders",
value: function getShaders() {
var shaders = _get(_getPrototypeOf(TripsLayer.prototype), "getShaders", this).call(this);
if (dataChanged) {
this.countVertices(props.data);
this.state.attributeManager.invalidateAll();
}
shaders.inject = {
'vs:#decl': "uniform float trailLength;\nvarying float vTime;\n",
'vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);': 'pos.z = 0.0;',
'vs:#main-end': "float shiftZ = mod(instanceEndPositions.z, trailLength) * 1e-4;\ngl_Position.z += shiftZ;\nvTime = instanceStartPositions.z + (instanceEndPositions.z - instanceStartPositions.z) * vPathPosition.y / vPathLength;\n",
'fs:#decl': "uniform float trailLength;\nuniform float currentTime;\nvarying float vTime;\n",
'fs:#main-start': "if(vTime > currentTime || vTime < currentTime - trailLength) {\n discard;\n}\n",
'gl_FragColor = vColor;': 'gl_FragColor.a *= 1.0 - (currentTime - vTime) / trailLength;'
};
return shaders;
}
}, {
key: "getModel",
value: function getModel(gl) {
return new Model(gl, {
id: this.props.id,
vs: tripsVertex,
fs: tripsFragment,
geometry: new Geometry({
id: this.props.id,
drawMode: 'LINES'
}),
vertexCount: 0,
isIndexed: true,
onBeforeRender: function onBeforeRender() {
gl.enable(gl.BLEND);
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(2.0, 1.0);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendEquation(gl.FUNC_ADD);
},
onAfterRender: function onAfterRender() {
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.disable(gl.POLYGON_OFFSET_FILL);
}
});
}
}, {
key: "countVertices",
value: function countVertices(data) {
if (!data) {
return;
}
var getPath = this.props.getPath;
var vertexCount = 0;
var pathLengths = data.reduce(function (acc, d) {
var l = getPath(d).length;
vertexCount += l;
return [].concat(_toConsumableArray(acc), [l]);
}, []);
this.setState({
pathLengths: pathLengths,
vertexCount: vertexCount
});
}
}, {
key: "draw",
value: function draw(_ref2) {
var uniforms = _ref2.uniforms;
value: function draw(params) {
var _this$props = this.props,
trailLength = _this$props.trailLength,
currentTime = _this$props.currentTime;
this.state.model.render(Object.assign({}, uniforms, {
params.uniforms = Object.assign({}, params.uniforms, {
trailLength: trailLength,
currentTime: currentTime
}));
}
}, {
key: "calculateIndices",
value: function calculateIndices(attribute) {
var _this$state = this.state,
pathLengths = _this$state.pathLengths,
vertexCount = _this$state.vertexCount;
var indicesCount = (vertexCount - pathLengths.length) * 2;
var indices = new Uint32Array(indicesCount);
var offset = 0;
var index = 0;
});
for (var i = 0; i < pathLengths.length; i++) {
var l = pathLengths[i];
indices[index++] = offset;
for (var j = 1; j < l - 1; j++) {
indices[index++] = j + offset;
indices[index++] = j + offset;
}
indices[index++] = offset + l - 1;
offset += l;
}
attribute.value = indices;
this.state.model.setVertexCount(indicesCount);
_get(_getPrototypeOf(TripsLayer.prototype), "draw", this).call(this, params);
}
}, {
key: "calculatePositions",
value: function calculatePositions(attribute) {
var _this$props2 = this.props,
data = _this$props2.data,
getPath = _this$props2.getPath;
var vertexCount = this.state.vertexCount;
var positions = new Float32Array(vertexCount * 3);
var index = 0;
for (var i = 0; i < data.length; i++) {
var path = getPath(data[i]);
for (var j = 0; j < path.length; j++) {
var pt = path[j];
positions[index++] = pt[0];
positions[index++] = pt[1];
positions[index++] = pt[2];
}
}
attribute.value = positions;
}
}, {
key: "calculateColors",
value: function calculateColors(attribute) {
var _this$props3 = this.props,
data = _this$props3.data,
getColor = _this$props3.getColor;
var _this$state2 = this.state,
pathLengths = _this$state2.pathLengths,
vertexCount = _this$state2.vertexCount;
var colors = new Float32Array(vertexCount * 3);
var index = 0;
for (var i = 0; i < data.length; i++) {
var color = getColor(data[i]);
var l = pathLengths[i];
for (var j = 0; j < l; j++) {
colors[index++] = color[0];
colors[index++] = color[1];
colors[index++] = color[2];
}
}
attribute.value = colors;
}
}]);
return TripsLayer;
}(Layer);
}(PathLayer);

@@ -223,0 +66,0 @@ export { TripsLayer as default };

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

"license": "MIT",
"version": "7.0.0-alpha.6",
"version": "7.0.0-beta.1",
"publishConfig": {

@@ -35,2 +35,3 @@ "access": "public"

"dependencies": {
"h3-js": "^3.0.0",
"s2-geometry": "^1.2.10"

@@ -37,0 +38,0 @@ },

@@ -33,1 +33,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

}
GreatCircleLayer.layerName = 'GreatCircleLayer';

@@ -22,3 +22,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

export default `\
#define SHADER_NAME arc-layer-vertex-shader
#define SHADER_NAME great-circle-layer-vertex-shader

@@ -36,2 +36,4 @@ attribute vec3 positions;

uniform float widthScale;
uniform float widthMinPixels;
uniform float widthMaxPixels;

@@ -42,3 +44,3 @@ varying vec4 vColor;

// offset_direction is -1 (left) or 1 (right)
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction) {
vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) {
// normalized direction of the line

@@ -48,4 +50,6 @@ vec2 dir_screenspace = normalize(line_clipspace * project_uViewportSize);

dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x);
vec2 offset_screenspace = dir_screenspace * offset_direction * instanceWidths * widthScale / 2.0;
vec2 offset_screenspace = dir_screenspace * offset_direction * width / 2.0;
vec2 offset_clipspace = project_pixel_to_clipspace(offset_screenspace).xy;
return offset_clipspace;

@@ -61,11 +65,12 @@ }

vec2 delta = source - target;
vec2 sin_half_delta = sin(delta / 2.0);
float a =
sin(delta.y / 2.0) * sin(delta.y / 2.0) +
sin_half_delta.y * sin_half_delta.y +
cos(source.y) * cos(target.y) *
sin(delta.x / 2.0) * sin(delta.x / 2.0);
return 2.0 * atan(sqrt(a), sqrt(1.0 - a));
sin_half_delta.x * sin_half_delta.x;
return 2.0 * atan(sqrt(a), sqrt(1.0 - a));
}
vec2 interpolate (vec2 source, vec2 target, float angularDist, float t) {
// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
// if the angularDist is PI, linear interpolation is applied. otherwise, use spherical interpolation
if(abs(angularDist - PI) < 0.001) {

@@ -75,8 +80,13 @@ return (1.0 - t) * source + t * target;

float a = sin((1.0 - t) * angularDist) / sin(angularDist);
float b = sin(t * angularDist) / sin(angularDist);
float x = a * cos(source.y) * cos(source.x) + b * cos(target.y) * cos(target.x);
float y = a * cos(source.y) * sin(source.x) + b * cos(target.y) * sin(target.x);
float z = a * sin(source.y) + b * sin(target.y);
return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));
float a = sin((1.0 - t) * angularDist) / sin(angularDist);
float b = sin(t * angularDist) / sin(angularDist);
vec2 sin_source = sin(source);
vec2 cos_source = cos(source);
vec2 sin_target = sin(target);
vec2 cos_target = cos(target);
float x = a * cos_source.y * cos_source.x + b * cos_target.y * cos_target.x;
float y = a * cos_source.y * sin_source.x + b * cos_target.y * sin_target.x;
float z = a * sin_source.y + b * sin_target.y;
return vec2(atan(y, x), atan(z, sqrt(x * x + y * y)));
}

@@ -107,5 +117,13 @@

// Multiply out width and clamp to limits
// mercator pixels are interpreted as screen pixels
float width = clamp(
project_scale(instanceWidths * widthScale),
widthMinPixels, widthMaxPixels
);
// extrude
vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y);
vec2 offset = getExtrusionOffset((next.xy - curr.xy) * indexDir, positions.y, width);
gl_Position = curr + vec4(offset, 0.0, 0.0);
vec4 color = mix(instanceSourceColors, instanceTargetColors, segmentRatio) / 255.0;

@@ -112,0 +130,0 @@ vColor = vec4(color.rgb, color.a * opacity);

@@ -26,1 +26,3 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

export {default as TripsLayer} from './trips-layer/trips-layer';
export {default as H3ClusterLayer} from './h3-layers/h3-cluster-layer';
export {default as H3HexagonLayer} from './h3-layers/h3-hexagon-layer';

@@ -26,16 +26,9 @@ // Copyright (c) 2015 - 2017 Uber Technologies, Inc.

function getDefaultProps() {
const defaultProps = {};
for (const prop in PolygonLayer.defaultProps) {
if (prop !== 'getPolygon') {
defaultProps[prop] = PolygonLayer.defaultProps[prop];
}
}
const defaultProps = Object.assign(
{
getS2Token: {type: 'accessor', value: d => d.token}
},
PolygonLayer.defaultProps
);
defaultProps.getS2Token = {type: 'accessor', value: f => f.token};
return defaultProps;
}
const defaultProps = getDefaultProps();
export default class S2Layer extends CompositeLayer {

@@ -53,2 +46,3 @@ renderLayers() {

stroked,
lineWidthUnits,
lineWidthScale,

@@ -83,2 +77,3 @@ lineWidthMinPixels,

stroked,
lineWidthUnits,
lineWidthScale,

@@ -85,0 +80,0 @@ lineWidthMinPixels,

@@ -5,7 +5,2 @@ // s2-geometry is a pure JavaScript port of Google/Niantic's S2 Geometry library

// import {hexToDec} from 'hex2dec';
function hexToDec(hexString) {
return String(parseInt(hexString, 16));
}
/**

@@ -33,7 +28,50 @@ * Given a S2 hex token this function returns cell level

// pad token with zeros to make the length 16
const padding = 16 - token.length;
const paddedToken = token + new Array(padding + 1).join('0');
return hexToDec(paddedToken);
const paddedToken = token.padEnd(16, '0');
return String(parseInt(paddedToken, 16));
}
const RADIAN_TO_DEGREE = 180 / Math.PI;
const MAX_RESOLUTION = 100;
/* Adapted from s2-geometry's S2.XYZToLatLng */
function XYZToLngLat([x, y, z]) {
const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
const lng = Math.atan2(y, x);
return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
}
/* Adapted from s2-geometry's S2Cell.getCornerLatLngs */
function getGeoBounds({face, ij, level}) {
const result = [];
const offsets = [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]];
// The S2 cell edge is curved: http://s2geometry.io/
// This is more prominent at lower levels
// resolution is the number of segments to generate per edge.
// We exponentially reduce resolution as level increases so it doesn't affect perf
// when there are a large number of cells
const resolution = Math.max(1, MAX_RESOLUTION * Math.pow(2, -level));
for (let i = 0; i < 4; i++) {
const offset = offsets[i].slice(0);
const nextOffset = offsets[i + 1];
const stepI = (nextOffset[0] - offset[0]) / resolution;
const stepJ = (nextOffset[1] - offset[1]) / resolution;
for (let j = 0; j < resolution; j++) {
offset[0] += stepI;
offset[1] += stepJ;
// Cell can be represented by coordinates IJ, ST, UV, XYZ
// http://s2geometry.io/devguide/s2cell_hierarchy#coordinate-systems
const st = S2.IJToST(ij, level, offset);
const uv = S2.STToUV(st);
const xyz = S2.FaceUVToXYZ(face, uv);
result.push(XYZToLngLat(xyz));
}
}
return result;
}
/**

@@ -51,7 +89,4 @@ * Get a polygon with corner coordinates for an s2 cell

const s2cell = S2.S2Cell.FromLatLng(S2.idToLatLng(id), level);
const corners = s2cell.getCornerLatLngs();
const polygon = corners.map(corner => [corner.lng, corner.lat]);
// close the polygon: first and last position of the ring should be the same
polygon.push(polygon[0]);
return polygon;
return getGeoBounds(s2cell);
}

@@ -87,3 +87,2 @@ import {CompositeLayer} from '@deck.gl/core';

renderLayers() {
// eslint-disable-next-line no-unused-vars
const {renderSubLayers, visible} = this.props;

@@ -90,0 +89,0 @@ const z = this.getLayerZoomLevel();

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

// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Lon..2Flat._to_tile_numbers_2
export function tile2latLng(x, y, z) {
const lng = (x / Math.pow(2, z)) * 360 - 180;
const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z);
const lat = (180 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
return [lng, lat];
}
export function tile2boundingBox(x, y, z) {
const [west, north] = tile2latLng(x, y, z);
const [east, south] = tile2latLng(x + 1, y + 1, z);
return {west, north, east, south};
}
export default class Tile {

@@ -6,2 +20,3 @@ constructor({getTileData, x, y, z, onTileError}) {

this.z = z;
this.bbox = tile2boundingBox(this.x, this.y, this.z);
this.isVisible = true;

@@ -8,0 +23,0 @@ this.getTileData = getTileData;

@@ -1,148 +0,72 @@

import {Layer} from '@deck.gl/core';
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import {Model, Geometry} from 'luma.gl';
import {PathLayer} from '@deck.gl/layers';
import tripsVertex from './trips-layer-vertex.glsl';
import tripsFragment from './trips-layer-fragment.glsl';
const defaultProps = {
trailLength: {type: 'number', value: 120, min: 0},
currentTime: {type: 'number', value: 0, min: 0},
getPath: {type: 'accessor', value: d => d.path},
getColor: {type: 'accessor', value: d => d.color}
currentTime: {type: 'number', value: 0, min: 0}
};
export default class TripsLayer extends Layer {
initializeState() {
const {gl} = this.context;
const attributeManager = this.getAttributeManager();
const model = this.getModel(gl);
attributeManager.add({
indices: {size: 1, update: this.calculateIndices, isIndexed: true},
positions: {size: 3, update: this.calculatePositions},
colors: {size: 3, accessor: 'getColor', update: this.calculateColors}
});
gl.getExtension('OES_element_index_uint');
this.setState({model});
export default class TripsLayer extends PathLayer {
getShaders() {
const shaders = super.getShaders();
shaders.inject = {
// Timestamp of the vertex
'vs:#decl': `\
uniform float trailLength;
varying float vTime;
`,
// Remove the z component (timestamp) from position
'vec3 pos = lineJoin(prevPosition, currPosition, nextPosition);': 'pos.z = 0.0;',
// Apply a small shift to battle z-fighting
'vs:#main-end': `\
float shiftZ = mod(instanceEndPositions.z, trailLength) * 1e-4;
gl_Position.z += shiftZ;
vTime = instanceStartPositions.z + (instanceEndPositions.z - instanceStartPositions.z) * vPathPosition.y / vPathLength;
`,
'fs:#decl': `\
uniform float trailLength;
uniform float currentTime;
varying float vTime;
`,
// Drop the segments outside of the time window
'fs:#main-start': `\
if(vTime > currentTime || vTime < currentTime - trailLength) {
discard;
}
`,
// Fade the color (currentTime - 100%, end of trail - 0%)
'gl_FragColor = vColor;': 'gl_FragColor.a *= 1.0 - (currentTime - vTime) / trailLength;'
};
return shaders;
}
updateState({props, changeFlags: {dataChanged}}) {
if (dataChanged) {
this.countVertices(props.data);
this.state.attributeManager.invalidateAll();
}
}
draw(params) {
const {trailLength, currentTime} = this.props;
getModel(gl) {
return new Model(gl, {
id: this.props.id,
vs: tripsVertex,
fs: tripsFragment,
geometry: new Geometry({
id: this.props.id,
drawMode: 'LINES'
}),
vertexCount: 0,
isIndexed: true,
// TODO-state-management: onBeforeRender can go to settings, onAfterRender, we should
// move this settings of corresponding draw.
onBeforeRender: () => {
gl.enable(gl.BLEND);
gl.enable(gl.POLYGON_OFFSET_FILL);
gl.polygonOffset(2.0, 1.0);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
gl.blendEquation(gl.FUNC_ADD);
},
onAfterRender: () => {
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.disable(gl.POLYGON_OFFSET_FILL);
}
params.uniforms = Object.assign({}, params.uniforms, {
trailLength,
currentTime
});
}
countVertices(data) {
if (!data) {
return;
}
const {getPath} = this.props;
let vertexCount = 0;
const pathLengths = data.reduce((acc, d) => {
const l = getPath(d).length;
vertexCount += l;
return [...acc, l];
}, []);
this.setState({pathLengths, vertexCount});
super.draw(params);
}
draw({uniforms}) {
const {trailLength, currentTime} = this.props;
this.state.model.render(
Object.assign({}, uniforms, {
trailLength,
currentTime
})
);
}
calculateIndices(attribute) {
const {pathLengths, vertexCount} = this.state;
const indicesCount = (vertexCount - pathLengths.length) * 2;
const indices = new Uint32Array(indicesCount);
let offset = 0;
let index = 0;
for (let i = 0; i < pathLengths.length; i++) {
const l = pathLengths[i];
indices[index++] = offset;
for (let j = 1; j < l - 1; j++) {
indices[index++] = j + offset;
indices[index++] = j + offset;
}
indices[index++] = offset + l - 1;
offset += l;
}
attribute.value = indices;
this.state.model.setVertexCount(indicesCount);
}
calculatePositions(attribute) {
const {data, getPath} = this.props;
const {vertexCount} = this.state;
const positions = new Float32Array(vertexCount * 3);
let index = 0;
for (let i = 0; i < data.length; i++) {
const path = getPath(data[i]);
for (let j = 0; j < path.length; j++) {
const pt = path[j];
positions[index++] = pt[0];
positions[index++] = pt[1];
positions[index++] = pt[2];
}
}
attribute.value = positions;
}
calculateColors(attribute) {
const {data, getColor} = this.props;
const {pathLengths, vertexCount} = this.state;
const colors = new Float32Array(vertexCount * 3);
let index = 0;
for (let i = 0; i < data.length; i++) {
const color = getColor(data[i]);
const l = pathLengths[i];
for (let j = 0; j < l; j++) {
colors[index++] = color[0];
colors[index++] = color[1];
colors[index++] = color[2];
}
}
attribute.value = colors;
}
}

@@ -149,0 +73,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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