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

slippy-tile

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

slippy-tile - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

4

CHANGELOG.md
# Changelog
## 2.1.0 - 2017-04-24
- Fix Bing Quadkey Regex parsing issue
## 2.0.0 - 2017-04-01

@@ -5,0 +9,0 @@

2

docs/slippy-tile.js

@@ -2062,3 +2062,3 @@ (function (global, factory) {

// Custom switch
var pattern = /{switch:([a-z,\d]*)}/gi;
var pattern = /{switch:([a-z,\d]*)}/i;
var found = url.match(pattern);

@@ -2065,0 +2065,0 @@ if (found) {

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

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.slippyTile=r()}(this,function(){function e(r,t,o){var n,i,a,u,l,f,c,s,g,h,d=0,p=0,y="FeatureCollection"===r.type,m="Feature"===r.type,v=y?r.features.length:1;for(n=0;v>n;n++)for(g=y?r.features[n].geometry:m?r.geometry:r,h="GeometryCollection"===g.type,c=h?g.geometries.length:1,u=0;c>u;u++)if(f=h?g.geometries[u]:g,s=f.coordinates,d=!o||"Polygon"!==f.type&&"MultiPolygon"!==f.type?0:1,"Point"===f.type)t(s,p),p++;else if("LineString"===f.type||"MultiPoint"===f.type)for(i=0;i<s.length;i++)t(s[i],p),p++;else if("Polygon"===f.type||"MultiLineString"===f.type)for(i=0;i<s.length;i++)for(a=0;a<s[i].length-d;a++)t(s[i][a],p),p++;else if("MultiPolygon"===f.type)for(i=0;i<s.length;i++)for(a=0;a<s[i].length;a++)for(l=0;l<s[i][a].length-d;l++)t(s[i][a][l],p),p++;else{if("GeometryCollection"!==f.type)throw new Error("Unknown Geometry Type");for(i=0;i<f.geometries.length;i++)e(f.geometries[i],t,o)}}function r(r,t,o,n){var i=o;return e(r,function(e,r){i=0===r&&void 0===o?e:t(i,e,r)},n),i}function t(e,r){var t;switch(e.type){case"FeatureCollection":for(t=0;t<e.features.length;t++)r(e.features[t].properties,t);break;case"Feature":r(e.properties,0)}}function o(e,r,o){var n=o;return t(e,function(e,t){n=0===t&&void 0===o?e:r(n,e,t)}),n}function n(e,r){if("Feature"===e.type)r(e,0);else if("FeatureCollection"===e.type)for(var t=0;t<e.features.length;t++)r(e.features[t],t)}function i(e,r,t){var o=t;return n(e,function(e,n){o=0===n&&void 0===t?e:r(o,e,n)}),o}function a(r){var t=[];return e(r,function(e){t.push(e)}),t}function u(e,r){var t,o,n,i,a,u,l,f=0,c="FeatureCollection"===e.type,s="Feature"===e.type,g=c?e.features.length:1;for(t=0;g>t;t++)for(u=c?e.features[t].geometry:s?e.geometry:e,l="GeometryCollection"===u.type,a=l?u.geometries.length:1,n=0;a>n;n++)if(i=l?u.geometries[n]:u,"Point"===i.type||"LineString"===i.type||"MultiPoint"===i.type||"Polygon"===i.type||"MultiLineString"===i.type||"MultiPolygon"===i.type)r(i,f),f++;else{if("GeometryCollection"!==i.type)throw new Error("Unknown Geometry Type");for(o=0;o<i.geometries.length;o++)r(i.geometries[o],f),f++}}function l(e,r,t){var o=t;return u(e,function(e,n){o=0===n&&void 0===t?e:r(o,e,n)}),o}function f(e,r){if(!e)throw new Error("No geometry passed");return{type:"Feature",properties:r||{},geometry:e}}function c(e){if(!e)throw new Error("bbox is required");if(Array.isArray(e)||(e=Me(e)),4!==e.length)throw new Error("bbox must have 4 numbers");var r=e[0],t=e[1],o=e[2],n=e[3];return-180>r&&o>180&&(r=-180,o=180),-180>o&&r>180&&(r=-180,o=180),-90>t&&n>90&&(t=-90,n=90),-90>n&&t>90&&(t=-90,n=90),n>90&&(n=90),-90>t&&(t=-90),Math.abs(e[0]-e[2])>360&&(r=-180,o=180),Math.abs(e[1]-e[3])>180&&(t=-90,n=90),r=h(r),t=g(t),o=h(o),n=g(n),[r,t,o,n]}function s(e){var r;if(!e)throw new Error("center is required");if(Array.isArray(e))if(4===e.length){var t=e,o=t[0],n=t[1],i=t[2],a=t[3];r=[(o+i)/2,(n+a)/2]}else r=[e[0],e[1]];else r=Te(e).geometry.coordinates;if(2!==r.length)throw new Error("center must have 2 numbers");var u=h(r[0]),l=g(r[1]);return[u,l]}function g(e){if(void 0===e||null===e)throw new Error("lat is required");return(e>90||-90>e)&&(e%=180,e>90&&(e=-180+e),-90>e&&(e=180+e),e===-0&&(e=0)),e}function h(e){if(void 0===e||void 0===e)throw new Error("lng is required");return(e>180||-180>e)&&(e%=360,e>180&&(e=-360+e),-180>e&&(e=360+e),e===-0&&(e=0)),e}function d(e){return e=e||256,2*Math.PI*6378137/e}function p(e){var r=e[0],t=e[1],o=e[2];return(1<<o)*((1<<o)+r)+t}function y(e){var r=e[0],t=e[1],o=e[2],n=e[3],i=(r-o)/2+o,a=(t-n)/2+n;return i=Number(i.toFixed(6)),a=Number(a.toFixed(6)),[i,a]}function m(e,r){e=A(e,r);var t=e[0],o=e[1],n=t*ke/180,i=Math.log(Math.tan((90+o)*Math.PI/360))/(Math.PI/180);return i=i*ke/180,n=Number(n.toFixed(1)),i=Number(i.toFixed(1)),[n,i]}function v(e){var r=e[0],t=e[1],o=r/ke*180,n=t/ke*180;return n=180/Math.PI*(2*Math.atan(Math.exp(n*Math.PI/180))-Math.PI/2),o=Number(o.toFixed(6)),n=Number(n.toFixed(6)),[o,n]}function w(e,r,t){var o=e[0],n=e[1],i=j(r,t),a=(o+ke)/i,u=(n+ke)/i;return[a,u,r]}function b(e,r,t){e=A(e,t);var o=m(e),n=w(o,r);return x(n)}function M(e,r,t){if(e=A(e,t),0===r)return[0,0,0];var o=b(e,r);return F(o)}function T(e,r){if(0===r)return[0,0,0];var t=w(e,r);return x(t)}function E(e,r){var t=e[0],o=e[1],n=e[2],i=j(n,r),a=t*i-ke,u=o*i-ke;return a=Number(a.toFixed(1)),u=Number(u.toFixed(1)),[a,u]}function x(e,r,t){r=r||256;var o=e[0],n=e[1],i=e[2];if(0===i)return[0,0,0];z(i,t);var a=Math.ceil(o/r)-1,u=Math.ceil(n/r)-1;return 0>a&&(a=0),0>u&&(u=0),[a,u,i]}function P(e,r,t){R(e,t),r=r||256;var o=e[0],n=e[1],i=e[2],a=E([o*r,n*r,i]),u=E([(o+1)*r,(n+1)*r,i]);return[a[0],a[1],u[0],u[1]]}function k(e,r){R(e,r);var t=e[0],o=e[1],n=e[2];if(0===n)return[-180,-85.051129,180,85.051129];var i=P([t,o,n]),a=i[0],u=i[1],l=i[2],f=i[3],c=v([a,u,n]),s=v([l,f,n]);return[c[0],c[1],s[0],s[1]]}function C(e){var r=N(e);return P(r)}function S(e){var r=N(e);return k(r)}function F(e,r){R(e,r);var t=e[0],o=e[1],n=e[2];if(0===n)return[0,0,0];var i=t,a=Math.pow(2,n)-1-o;return[i,a,n]}function N(e){var r=e[0],t=e[1],o=e[2],n=r,i=Math.pow(2,o)-t-1;return[n,i,o]}function L(e){var r=N(e);return q(r)}function q(e,r){R(e,r);var t=e[0],o=e[1],n=e[2];if(0===n)return"";var i="";return o=Math.pow(2,n)-1-o,Q(n,0,-1).map(function(e){var r=0,n=1<<e-1;0!==(t&n)&&(r+=1),0!==(o&n)&&(r+=2),i=i.concat(r)}),i}function G(e){var r=I(e);return N(r)}function I(e){var r=0,t=0,o=e.length;return Q(o,0,-1).map(function(n){var i=1<<n-1;switch(parseInt(e[o-n],0)){case 0:break;case 1:r+=i;break;case 2:t+=i;break;case 3:r+=i,t+=i;break;default:throw new Error("Invalid Quadkey digit sequence")}}),[r,t,o]}function B(e){var r=m([e[0],e[1]]),t=m([e[2],e[3]]);return[r[0],r[1],t[0],t[1]]}function R(e,r){var t=e[0],o=e[1],n=e[2];if(r===!1)return e;if(z(n),void 0===t||null===t)throw new Error("<x> is required");if(void 0===o||null===o)throw new Error("<y> is required");if(0>t)throw new Error("<x> must not be less than 0");if(0>o)throw new Error("<y> must not be less than 0");var i=Math.pow(2,n);if(t>=i||o>=i)throw new Error("Illegal parameters for tile");return e}function z(e){if(e===!1)return e;if(void 0===e||null===e)throw new Error("<zoom> is required");if(0>e)throw new Error("<zoom> cannot be less than 0");if(e>30)throw new Error("<zoom> cannot be greater than 30");return e}function A(e,r){if(r===!1)return e;var t=Pe(e[0]),o=xe(e[1]);return o>85&&(o=85),-85>o&&(o=-85),[t,o]}function j(e,r){return d(r)/Math.pow(2,e)}function Q(e,r,t){null==r&&(r=e||0,e=0),t||(t=e>r?-1:1);for(var o=Math.max(Math.ceil((r-e)/t),0),n=Array(o),i=0;o>i;i++,e+=t)n[i]=e;return n}function U(e){if(e&&e[0]&&4===e.length&&void 0===e[0][0])return e;if(e&&e[0]&&void 0!==e[0][0]){var r=e[0][0],t=e[0][1],o=e[0][2],n=e[0][3];return e.map(function(e){e[0]<r&&(r=e[0]),e[1]<t&&(t=e[1]),e[2]>o&&(o=e[2]),e[3]>n&&(n=e[3])}),[r,t,o,n]}}function D(e,r){if(r.match(/{height|width|proj|srs|crs|bbox}/gi)){r=r.replace(/{height}/gi,"256"),r=r.replace(/{width}/gi,"256"),r=r.replace(/{(proj|srs|crs)}/gi,"EPSG:3857");var t;t=r.match(/EPSG:(3857|900913)/i)?qe(Fe(e)):Fe(e),r.match(/{bbox}/i)&&(r=r.replace(/{bbox}/gi,t.join(",")))}return r}function Z(e){return e.match(/{TileCol|TileRow|TileMatrix|TileMatrixSet|Style}/gi)&&(e=e.replace(/{TileCol}/gi,"{x}"),e=e.replace(/{TileRow}/gi,"{y}"),e=e.replace(/{TileMatrix}/gi,"{z}"),e=e.replace(/{TileMatrixSet}/gi,"GoogleMapsCompatible"),e=e.replace(/{Style}/gi,"default")),e}function H(e){if(e.match(/{s}/gi))return e.replace(/{s}/gi,String(J(["a","b","c"])));var r=/{switch:([a-z,\d]*)}/gi,t=e.match(r);return t?e.replace(r,String(J(t[1].split(",")))):e}function J(e){return null===e||void 0===e||0===e.length?void 0:e[Math.floor(Math.random()*e.length)]}var K=e,O=r,V=t,W=o,X=n,Y=i,$=a,_=u,ee=l,re={coordEach:K,coordReduce:O,propEach:V,propReduce:W,featureEach:X,featureReduce:Y,coordAll:$,geomEach:_,geomReduce:ee},te=re.coordEach,oe=function(e){var r=[1/0,1/0,-(1/0),-(1/0)];return te(e,function(e){r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r},ne=f,ie=function(e,r){if(!e)throw new Error("No coordinates passed");if(void 0===e.length)throw new Error("Coordinates must be an array");if(e.length<2)throw new Error("Coordinates must be at least 2 numbers long");if("number"!=typeof e[0]||"number"!=typeof e[1])throw new Error("Coordinates must numbers");return f({type:"Point",coordinates:e},r)},ae=function(e,r){if(!e)throw new Error("No coordinates passed");for(var t=0;t<e.length;t++){var o=e[t];if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var n=0;n<o[o.length-1].length;n++)if(o[o.length-1][n]!==o[0][n])throw new Error("First and last Position are not equivalent.")}return f({type:"Polygon",coordinates:e},r)},ue=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"LineString",coordinates:e},r)},le=function(e){if(!e)throw new Error("No features passed");return{type:"FeatureCollection",features:e}},fe=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"MultiLineString",coordinates:e},r)},ce=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"MultiPoint",coordinates:e},r)},se=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"MultiPolygon",coordinates:e},r)},ge=function(e,r){if(!e)throw new Error("No geometries passed");return f({type:"GeometryCollection",geometries:e},r)},he={miles:3960,nauticalmiles:3441.145,degrees:57.2957795,radians:1,inches:250905600,yards:6969600,meters:6373e3,metres:6373e3,kilometers:6373,kilometres:6373,feet:20908792.65},de=function(e,r){var t=he[r||"kilometers"];if(void 0===t)throw new Error("Invalid unit");return e*t},pe=function(e,r){var t=he[r||"kilometers"];if(void 0===t)throw new Error("Invalid unit");return e/t},ye=function(e,r){var t=he[r||"kilometers"];if(void 0===t)throw new Error("Invalid unit");return e/t*57.2958},me={feature:ne,point:ie,polygon:ae,lineString:ue,featureCollection:le,multiLineString:fe,multiPoint:ce,multiPolygon:se,geometryCollection:ge,radiansToDistance:de,distanceToRadians:pe,distanceToDegrees:ye},ve=oe,we=me.point,be=function(e){var r=ve(e),t=(r[0]+r[2])/2,o=(r[1]+r[3])/2;return we([t,o])},Me=oe,Te=be,Ee={bbox:c,longitude:h,latitude:g,center:s},xe=Ee.latitude,Pe=Ee.longitude,ke=2*Math.PI*6378137/2,Ce={hash:p,bboxToCenter:y,lngLatToMeters:m,metersToLngLat:v,metersToPixels:w,lngLatToTile:b,lngLatToGoogle:M,metersToTile:T,pixelsToMeters:E,pixelsToTile:x,tileToBBoxMeters:P,tileToBBox:k,googleToBBoxMeters:C,googleToBBox:S,tileToGoogle:F,googleToTile:N,googleToQuadkey:L,tileToQuadkey:q,quadkeyToTile:G,quadkeyToGoogle:I,bboxToMeters:B,validateTile:R,validateZoom:z,validateLngLat:A,resolution:j,range:Q,maxBBox:U},Se=Ce,Fe=Se.googleToBBox,Ne=Se.googleToTile,Le=Se.googleToQuadkey,qe=Se.bboxToMeters,Ge=function(e,r){var t=e[0],o=e[1],n=e[2];if(r=D(e,r),r=Z(r),r=H(r),r=r.replace(/{(zoom|z|level)}/gi,String(n)),r=r.replace(/{(x|col)}/gi,String(t)),r=r.replace(/{(y|row)}/gi,String(o)),r.match(/{-y}/)&&(r=r.replace(/{-y}/gi,String(Ne(e)[1]))),r.match(/{(quadkey|q)}/)&&(r=r.replace(/{(quadkey|q)}/gi,Le(e))),r.match(/{.*}/))throw new Error("Could not completly parse URL"+r);return r};return Ge});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):e.slippyTile=r()}(this,function(){function e(r,t,o){var n,i,a,u,l,f,c,s,g,h,d=0,p=0,y="FeatureCollection"===r.type,m="Feature"===r.type,v=y?r.features.length:1;for(n=0;v>n;n++)for(g=y?r.features[n].geometry:m?r.geometry:r,h="GeometryCollection"===g.type,c=h?g.geometries.length:1,u=0;c>u;u++)if(f=h?g.geometries[u]:g,s=f.coordinates,d=!o||"Polygon"!==f.type&&"MultiPolygon"!==f.type?0:1,"Point"===f.type)t(s,p),p++;else if("LineString"===f.type||"MultiPoint"===f.type)for(i=0;i<s.length;i++)t(s[i],p),p++;else if("Polygon"===f.type||"MultiLineString"===f.type)for(i=0;i<s.length;i++)for(a=0;a<s[i].length-d;a++)t(s[i][a],p),p++;else if("MultiPolygon"===f.type)for(i=0;i<s.length;i++)for(a=0;a<s[i].length;a++)for(l=0;l<s[i][a].length-d;l++)t(s[i][a][l],p),p++;else{if("GeometryCollection"!==f.type)throw new Error("Unknown Geometry Type");for(i=0;i<f.geometries.length;i++)e(f.geometries[i],t,o)}}function r(r,t,o,n){var i=o;return e(r,function(e,r){i=0===r&&void 0===o?e:t(i,e,r)},n),i}function t(e,r){var t;switch(e.type){case"FeatureCollection":for(t=0;t<e.features.length;t++)r(e.features[t].properties,t);break;case"Feature":r(e.properties,0)}}function o(e,r,o){var n=o;return t(e,function(e,t){n=0===t&&void 0===o?e:r(n,e,t)}),n}function n(e,r){if("Feature"===e.type)r(e,0);else if("FeatureCollection"===e.type)for(var t=0;t<e.features.length;t++)r(e.features[t],t)}function i(e,r,t){var o=t;return n(e,function(e,n){o=0===n&&void 0===t?e:r(o,e,n)}),o}function a(r){var t=[];return e(r,function(e){t.push(e)}),t}function u(e,r){var t,o,n,i,a,u,l,f=0,c="FeatureCollection"===e.type,s="Feature"===e.type,g=c?e.features.length:1;for(t=0;g>t;t++)for(u=c?e.features[t].geometry:s?e.geometry:e,l="GeometryCollection"===u.type,a=l?u.geometries.length:1,n=0;a>n;n++)if(i=l?u.geometries[n]:u,"Point"===i.type||"LineString"===i.type||"MultiPoint"===i.type||"Polygon"===i.type||"MultiLineString"===i.type||"MultiPolygon"===i.type)r(i,f),f++;else{if("GeometryCollection"!==i.type)throw new Error("Unknown Geometry Type");for(o=0;o<i.geometries.length;o++)r(i.geometries[o],f),f++}}function l(e,r,t){var o=t;return u(e,function(e,n){o=0===n&&void 0===t?e:r(o,e,n)}),o}function f(e,r){if(!e)throw new Error("No geometry passed");return{type:"Feature",properties:r||{},geometry:e}}function c(e){if(!e)throw new Error("bbox is required");if(Array.isArray(e)||(e=Me(e)),4!==e.length)throw new Error("bbox must have 4 numbers");var r=e[0],t=e[1],o=e[2],n=e[3];return-180>r&&o>180&&(r=-180,o=180),-180>o&&r>180&&(r=-180,o=180),-90>t&&n>90&&(t=-90,n=90),-90>n&&t>90&&(t=-90,n=90),n>90&&(n=90),-90>t&&(t=-90),Math.abs(e[0]-e[2])>360&&(r=-180,o=180),Math.abs(e[1]-e[3])>180&&(t=-90,n=90),r=h(r),t=g(t),o=h(o),n=g(n),[r,t,o,n]}function s(e){var r;if(!e)throw new Error("center is required");if(Array.isArray(e))if(4===e.length){var t=e,o=t[0],n=t[1],i=t[2],a=t[3];r=[(o+i)/2,(n+a)/2]}else r=[e[0],e[1]];else r=Te(e).geometry.coordinates;if(2!==r.length)throw new Error("center must have 2 numbers");var u=h(r[0]),l=g(r[1]);return[u,l]}function g(e){if(void 0===e||null===e)throw new Error("lat is required");return(e>90||-90>e)&&(e%=180,e>90&&(e=-180+e),-90>e&&(e=180+e),e===-0&&(e=0)),e}function h(e){if(void 0===e||void 0===e)throw new Error("lng is required");return(e>180||-180>e)&&(e%=360,e>180&&(e=-360+e),-180>e&&(e=360+e),e===-0&&(e=0)),e}function d(e){return e=e||256,2*Math.PI*6378137/e}function p(e){var r=e[0],t=e[1],o=e[2];return(1<<o)*((1<<o)+r)+t}function y(e){var r=e[0],t=e[1],o=e[2],n=e[3],i=(r-o)/2+o,a=(t-n)/2+n;return i=Number(i.toFixed(6)),a=Number(a.toFixed(6)),[i,a]}function m(e,r){e=A(e,r);var t=e[0],o=e[1],n=t*ke/180,i=Math.log(Math.tan((90+o)*Math.PI/360))/(Math.PI/180);return i=i*ke/180,n=Number(n.toFixed(1)),i=Number(i.toFixed(1)),[n,i]}function v(e){var r=e[0],t=e[1],o=r/ke*180,n=t/ke*180;return n=180/Math.PI*(2*Math.atan(Math.exp(n*Math.PI/180))-Math.PI/2),o=Number(o.toFixed(6)),n=Number(n.toFixed(6)),[o,n]}function w(e,r,t){var o=e[0],n=e[1],i=j(r,t),a=(o+ke)/i,u=(n+ke)/i;return[a,u,r]}function b(e,r,t){e=A(e,t);var o=m(e),n=w(o,r);return x(n)}function M(e,r,t){if(e=A(e,t),0===r)return[0,0,0];var o=b(e,r);return F(o)}function T(e,r){if(0===r)return[0,0,0];var t=w(e,r);return x(t)}function E(e,r){var t=e[0],o=e[1],n=e[2],i=j(n,r),a=t*i-ke,u=o*i-ke;return a=Number(a.toFixed(1)),u=Number(u.toFixed(1)),[a,u]}function x(e,r,t){r=r||256;var o=e[0],n=e[1],i=e[2];if(0===i)return[0,0,0];z(i,t);var a=Math.ceil(o/r)-1,u=Math.ceil(n/r)-1;return 0>a&&(a=0),0>u&&(u=0),[a,u,i]}function P(e,r,t){R(e,t),r=r||256;var o=e[0],n=e[1],i=e[2],a=E([o*r,n*r,i]),u=E([(o+1)*r,(n+1)*r,i]);return[a[0],a[1],u[0],u[1]]}function k(e,r){R(e,r);var t=e[0],o=e[1],n=e[2];if(0===n)return[-180,-85.051129,180,85.051129];var i=P([t,o,n]),a=i[0],u=i[1],l=i[2],f=i[3],c=v([a,u,n]),s=v([l,f,n]);return[c[0],c[1],s[0],s[1]]}function C(e){var r=N(e);return P(r)}function S(e){var r=N(e);return k(r)}function F(e,r){R(e,r);var t=e[0],o=e[1],n=e[2];if(0===n)return[0,0,0];var i=t,a=Math.pow(2,n)-1-o;return[i,a,n]}function N(e){var r=e[0],t=e[1],o=e[2],n=r,i=Math.pow(2,o)-t-1;return[n,i,o]}function L(e){var r=N(e);return q(r)}function q(e,r){R(e,r);var t=e[0],o=e[1],n=e[2];if(0===n)return"";var i="";return o=Math.pow(2,n)-1-o,Q(n,0,-1).map(function(e){var r=0,n=1<<e-1;0!==(t&n)&&(r+=1),0!==(o&n)&&(r+=2),i=i.concat(r)}),i}function G(e){var r=I(e);return N(r)}function I(e){var r=0,t=0,o=e.length;return Q(o,0,-1).map(function(n){var i=1<<n-1;switch(parseInt(e[o-n],0)){case 0:break;case 1:r+=i;break;case 2:t+=i;break;case 3:r+=i,t+=i;break;default:throw new Error("Invalid Quadkey digit sequence")}}),[r,t,o]}function B(e){var r=m([e[0],e[1]]),t=m([e[2],e[3]]);return[r[0],r[1],t[0],t[1]]}function R(e,r){var t=e[0],o=e[1],n=e[2];if(r===!1)return e;if(z(n),void 0===t||null===t)throw new Error("<x> is required");if(void 0===o||null===o)throw new Error("<y> is required");if(0>t)throw new Error("<x> must not be less than 0");if(0>o)throw new Error("<y> must not be less than 0");var i=Math.pow(2,n);if(t>=i||o>=i)throw new Error("Illegal parameters for tile");return e}function z(e){if(e===!1)return e;if(void 0===e||null===e)throw new Error("<zoom> is required");if(0>e)throw new Error("<zoom> cannot be less than 0");if(e>30)throw new Error("<zoom> cannot be greater than 30");return e}function A(e,r){if(r===!1)return e;var t=Pe(e[0]),o=xe(e[1]);return o>85&&(o=85),-85>o&&(o=-85),[t,o]}function j(e,r){return d(r)/Math.pow(2,e)}function Q(e,r,t){null==r&&(r=e||0,e=0),t||(t=e>r?-1:1);for(var o=Math.max(Math.ceil((r-e)/t),0),n=Array(o),i=0;o>i;i++,e+=t)n[i]=e;return n}function U(e){if(e&&e[0]&&4===e.length&&void 0===e[0][0])return e;if(e&&e[0]&&void 0!==e[0][0]){var r=e[0][0],t=e[0][1],o=e[0][2],n=e[0][3];return e.map(function(e){e[0]<r&&(r=e[0]),e[1]<t&&(t=e[1]),e[2]>o&&(o=e[2]),e[3]>n&&(n=e[3])}),[r,t,o,n]}}function D(e,r){if(r.match(/{height|width|proj|srs|crs|bbox}/gi)){r=r.replace(/{height}/gi,"256"),r=r.replace(/{width}/gi,"256"),r=r.replace(/{(proj|srs|crs)}/gi,"EPSG:3857");var t;t=r.match(/EPSG:(3857|900913)/i)?qe(Fe(e)):Fe(e),r.match(/{bbox}/i)&&(r=r.replace(/{bbox}/gi,t.join(",")))}return r}function Z(e){return e.match(/{TileCol|TileRow|TileMatrix|TileMatrixSet|Style}/gi)&&(e=e.replace(/{TileCol}/gi,"{x}"),e=e.replace(/{TileRow}/gi,"{y}"),e=e.replace(/{TileMatrix}/gi,"{z}"),e=e.replace(/{TileMatrixSet}/gi,"GoogleMapsCompatible"),e=e.replace(/{Style}/gi,"default")),e}function H(e){if(e.match(/{s}/gi))return e.replace(/{s}/gi,String(J(["a","b","c"])));var r=/{switch:([a-z,\d]*)}/i,t=e.match(r);return t?e.replace(r,String(J(t[1].split(",")))):e}function J(e){return null===e||void 0===e||0===e.length?void 0:e[Math.floor(Math.random()*e.length)]}var K=e,O=r,V=t,W=o,X=n,Y=i,$=a,_=u,ee=l,re={coordEach:K,coordReduce:O,propEach:V,propReduce:W,featureEach:X,featureReduce:Y,coordAll:$,geomEach:_,geomReduce:ee},te=re.coordEach,oe=function(e){var r=[1/0,1/0,-(1/0),-(1/0)];return te(e,function(e){r[0]>e[0]&&(r[0]=e[0]),r[1]>e[1]&&(r[1]=e[1]),r[2]<e[0]&&(r[2]=e[0]),r[3]<e[1]&&(r[3]=e[1])}),r},ne=f,ie=function(e,r){if(!e)throw new Error("No coordinates passed");if(void 0===e.length)throw new Error("Coordinates must be an array");if(e.length<2)throw new Error("Coordinates must be at least 2 numbers long");if("number"!=typeof e[0]||"number"!=typeof e[1])throw new Error("Coordinates must numbers");return f({type:"Point",coordinates:e},r)},ae=function(e,r){if(!e)throw new Error("No coordinates passed");for(var t=0;t<e.length;t++){var o=e[t];if(o.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var n=0;n<o[o.length-1].length;n++)if(o[o.length-1][n]!==o[0][n])throw new Error("First and last Position are not equivalent.")}return f({type:"Polygon",coordinates:e},r)},ue=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"LineString",coordinates:e},r)},le=function(e){if(!e)throw new Error("No features passed");return{type:"FeatureCollection",features:e}},fe=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"MultiLineString",coordinates:e},r)},ce=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"MultiPoint",coordinates:e},r)},se=function(e,r){if(!e)throw new Error("No coordinates passed");return f({type:"MultiPolygon",coordinates:e},r)},ge=function(e,r){if(!e)throw new Error("No geometries passed");return f({type:"GeometryCollection",geometries:e},r)},he={miles:3960,nauticalmiles:3441.145,degrees:57.2957795,radians:1,inches:250905600,yards:6969600,meters:6373e3,metres:6373e3,kilometers:6373,kilometres:6373,feet:20908792.65},de=function(e,r){var t=he[r||"kilometers"];if(void 0===t)throw new Error("Invalid unit");return e*t},pe=function(e,r){var t=he[r||"kilometers"];if(void 0===t)throw new Error("Invalid unit");return e/t},ye=function(e,r){var t=he[r||"kilometers"];if(void 0===t)throw new Error("Invalid unit");return e/t*57.2958},me={feature:ne,point:ie,polygon:ae,lineString:ue,featureCollection:le,multiLineString:fe,multiPoint:ce,multiPolygon:se,geometryCollection:ge,radiansToDistance:de,distanceToRadians:pe,distanceToDegrees:ye},ve=oe,we=me.point,be=function(e){var r=ve(e),t=(r[0]+r[2])/2,o=(r[1]+r[3])/2;return we([t,o])},Me=oe,Te=be,Ee={bbox:c,longitude:h,latitude:g,center:s},xe=Ee.latitude,Pe=Ee.longitude,ke=2*Math.PI*6378137/2,Ce={hash:p,bboxToCenter:y,lngLatToMeters:m,metersToLngLat:v,metersToPixels:w,lngLatToTile:b,lngLatToGoogle:M,metersToTile:T,pixelsToMeters:E,pixelsToTile:x,tileToBBoxMeters:P,tileToBBox:k,googleToBBoxMeters:C,googleToBBox:S,tileToGoogle:F,googleToTile:N,googleToQuadkey:L,tileToQuadkey:q,quadkeyToTile:G,quadkeyToGoogle:I,bboxToMeters:B,validateTile:R,validateZoom:z,validateLngLat:A,resolution:j,range:Q,maxBBox:U},Se=Ce,Fe=Se.googleToBBox,Ne=Se.googleToTile,Le=Se.googleToQuadkey,qe=Se.bboxToMeters,Ge=function(e,r){var t=e[0],o=e[1],n=e[2];if(r=D(e,r),r=Z(r),r=H(r),r=r.replace(/{(zoom|z|level)}/gi,String(n)),r=r.replace(/{(x|col)}/gi,String(t)),r=r.replace(/{(y|row)}/gi,String(o)),r.match(/{-y}/)&&(r=r.replace(/{-y}/gi,String(Ne(e)[1]))),r.match(/{(quadkey|q)}/)&&(r=r.replace(/{(quadkey|q)}/gi,Le(e))),r.match(/{.*}/))throw new Error("Could not completly parse URL"+r);return r};return Ge});

@@ -99,3 +99,3 @@ var mercator = require('global-mercator')

// Custom switch
var pattern = /{switch:([a-z,\d]*)}/gi
var pattern = /{switch:([a-z,\d]*)}/i
var found = url.match(pattern)

@@ -102,0 +102,0 @@ if (found) {

{
"name": "slippy-tile",
"version": "2.0.0",
"version": "2.1.0",
"description": "Helps convert Slippy Map url tile schemas",

@@ -5,0 +5,0 @@ "main": "index.js",

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