@loaders.gl/mvt 3.1.0-alpha.3 → 3.1.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/dist.min.js +1 -1
  2. package/dist/es5/bundle.js +7 -0
  3. package/dist/es5/bundle.js.map +1 -0
  4. package/dist/es5/helpers/binary-util-functions.js +95 -0
  5. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  6. package/dist/es5/helpers/mapbox-util-functions.js +62 -0
  7. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  8. package/dist/es5/index.js +20 -0
  9. package/dist/es5/index.js.map +1 -0
  10. package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  11. package/dist/es5/lib/binary-vector-tile/features-to-binary.js +385 -0
  12. package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +1 -0
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +189 -0
  14. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  15. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +77 -0
  16. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  17. package/dist/es5/lib/binary-vector-tile/vector-tile.js +35 -0
  18. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  19. package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
  20. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +217 -0
  21. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  22. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +77 -0
  23. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  24. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +35 -0
  25. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  26. package/dist/es5/lib/parse-mvt.js +131 -0
  27. package/dist/es5/lib/parse-mvt.js.map +1 -0
  28. package/dist/es5/lib/types.js +2 -0
  29. package/dist/{lib → es5/lib}/types.js.map +0 -0
  30. package/dist/es5/mvt-loader.js +71 -0
  31. package/dist/es5/mvt-loader.js.map +1 -0
  32. package/dist/es5/workers/mvt-worker.js +8 -0
  33. package/dist/es5/workers/mvt-worker.js.map +1 -0
  34. package/dist/{bundle.js → esm/bundle.js} +0 -0
  35. package/dist/esm/bundle.js.map +1 -0
  36. package/dist/{helpers → esm/helpers}/binary-util-functions.js +0 -0
  37. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  38. package/dist/{helpers → esm/helpers}/mapbox-util-functions.js +0 -0
  39. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  40. package/dist/{index.js → esm/index.js} +0 -0
  41. package/dist/esm/index.js.map +1 -0
  42. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  43. package/dist/{lib → esm/lib}/binary-vector-tile/features-to-binary.js +0 -0
  44. package/dist/esm/lib/binary-vector-tile/features-to-binary.js.map +1 -0
  45. package/dist/{lib → esm/lib}/binary-vector-tile/vector-tile-feature.js +0 -0
  46. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  47. package/dist/{lib → esm/lib}/binary-vector-tile/vector-tile-layer.js +0 -0
  48. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  49. package/dist/{lib → esm/lib}/binary-vector-tile/vector-tile.js +0 -0
  50. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  51. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  52. package/dist/{lib → esm/lib}/mapbox-vector-tile/vector-tile-feature.js +0 -0
  53. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  54. package/dist/{lib → esm/lib}/mapbox-vector-tile/vector-tile-layer.js +0 -0
  55. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  56. package/dist/{lib → esm/lib}/mapbox-vector-tile/vector-tile.js +0 -0
  57. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  58. package/dist/{lib → esm/lib}/parse-mvt.js +0 -0
  59. package/dist/esm/lib/parse-mvt.js.map +1 -0
  60. package/dist/{lib → esm/lib}/types.js +0 -0
  61. package/dist/esm/lib/types.js.map +1 -0
  62. package/dist/{mvt-loader.js → esm/mvt-loader.js} +1 -1
  63. package/dist/esm/mvt-loader.js.map +1 -0
  64. package/dist/{workers → esm/workers}/mvt-worker.js +0 -0
  65. package/dist/esm/workers/mvt-worker.js.map +1 -0
  66. package/dist/mvt-worker.js +1 -1
  67. package/package.json +6 -6
  68. package/dist/bundle.js.map +0 -1
  69. package/dist/helpers/binary-util-functions.js.map +0 -1
  70. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  71. package/dist/index.js.map +0 -1
  72. package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
  73. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  74. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  75. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  76. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  77. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  78. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  79. package/dist/lib/parse-mvt.js.map +0 -1
  80. package/dist/mvt-loader.js.map +0 -1
  81. package/dist/workers/mvt-worker.js.map +0 -1
package/dist/dist.min.js CHANGED
@@ -1,4 +1,4 @@
1
1
  !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(window,(function(){return function(t){var e={};function i(n){if(e[n])return e[n].exports;var r=e[n]={i:n,l:!1,exports:{}};return t[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=2)}([function(t,e,i){"use strict";t.exports=r;var n=i(3);function r(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}r.Varint=0,r.Fixed64=1,r.Bytes=2,r.Fixed32=5;var s="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function o(t){return t.type===r.Bytes?t.readVarint()+t.pos:t.pos+1}function a(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function u(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=t;r--)i.buf[r+n]=i.buf[r]}function h(t,e){for(var i=0;i<t.length;i++)e.writeVarint(t[i])}function l(t,e){for(var i=0;i<t.length;i++)e.writeSVarint(t[i])}function f(t,e){for(var i=0;i<t.length;i++)e.writeFloat(t[i])}function p(t,e){for(var i=0;i<t.length;i++)e.writeDouble(t[i])}function c(t,e){for(var i=0;i<t.length;i++)e.writeBoolean(t[i])}function d(t,e){for(var i=0;i<t.length;i++)e.writeFixed32(t[i])}function y(t,e){for(var i=0;i<t.length;i++)e.writeSFixed32(t[i])}function x(t,e){for(var i=0;i<t.length;i++)e.writeFixed64(t[i])}function g(t,e){for(var i=0;i<t.length;i++)e.writeSFixed64(t[i])}function v(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function w(t,e,i){t[i]=e,t[i+1]=e>>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function b(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}r.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos<i;){var n=this.readVarint(),r=n>>3,s=this.pos;this.type=7&n,t(r,e,this),this.pos===s&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=v(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=b(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=v(this.buf,this.pos)+4294967296*v(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=v(this.buf,this.pos)+4294967296*b(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=n.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=n.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(t,e,i){var n,r,s=i.buf;if(r=s[i.pos++],n=(112&r)>>4,r<128)return a(t,n,e);if(r=s[i.pos++],n|=(127&r)<<3,r<128)return a(t,n,e);if(r=s[i.pos++],n|=(127&r)<<10,r<128)return a(t,n,e);if(r=s[i.pos++],n|=(127&r)<<17,r<128)return a(t,n,e);if(r=s[i.pos++],n|=(127&r)<<24,r<128)return a(t,n,e);if(r=s[i.pos++],n|=(1&r)<<31,r<128)return a(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&s?function(t,e,i){return s.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){var n="",r=e;for(;r<i;){var s,o,a,u=t[r],h=null,l=u>239?4:u>223?3:u>191?2:1;if(r+l>i)break;1===l?u<128&&(h=u):2===l?128==(192&(s=t[r+1]))&&(h=(31&u)<<6|63&s)<=127&&(h=null):3===l?(s=t[r+1],o=t[r+2],128==(192&s)&&128==(192&o)&&((h=(15&u)<<12|(63&s)<<6|63&o)<=2047||h>=55296&&h<=57343)&&(h=null)):4===l&&(s=t[r+1],o=t[r+2],a=t[r+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&((h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,l=1):h>65535&&(h-=65536,n+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),n+=String.fromCharCode(h),r+=l}return n}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==r.Bytes)return t.push(this.readVarint(e));var i=o(this);for(t=t||[];this.pos<i;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==r.Bytes)return t.push(this.readSVarint());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==r.Bytes)return t.push(this.readBoolean());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==r.Bytes)return t.push(this.readFloat());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==r.Bytes)return t.push(this.readDouble());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==r.Bytes)return t.push(this.readFixed32());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==r.Bytes)return t.push(this.readSFixed32());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==r.Bytes)return t.push(this.readFixed64());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==r.Bytes)return t.push(this.readSFixed64());var e=o(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===r.Varint)for(;this.buf[this.pos++]>127;);else if(e===r.Bytes)this.pos=this.readVarint()+this.pos;else if(e===r.Fixed32)this.pos+=4;else{if(e!==r.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var i=new Uint8Array(e);i.set(this.buf),this.buf=i,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),w(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),w(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),w(this.buf,-1&t,this.pos),w(this.buf,Math.floor(t*(1/4294967296)),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),w(this.buf,-1&t,this.pos),w(this.buf,Math.floor(t*(1/4294967296)),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var i,n;t>=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos]=127&t}(i,0,e),function(t,e){var i=(7&t)<<4;if(e.buf[e.pos++]|=i|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,i){for(var n,r,s=0;s<e.length;s++){if((n=e.charCodeAt(s))>55295&&n<57344){if(!r){n>56319||s+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(t[i++]=239,t[i++]=191,t[i++]=189,r=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&u(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),n.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),n.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var i=0;i<e;i++)this.buf[this.pos++]=t[i]},writeRawMessage:function(t,e){this.pos++;var i=this.pos;t(e,this);var n=this.pos-i;n>=128&&u(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,r.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,h,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,l,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,c,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,f,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,p,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,d,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,y,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,x,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,g,e)},writeBytesField:function(t,e){this.writeTag(t,r.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,r.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,r.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,r.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,r.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,r.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,r.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,r.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,r.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,r.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}}},,function(t,e,i){const n=i(4);globalThis.loaders=globalThis.loaders||{},t.exports=Object.assign(globalThis.loaders,n)},function(t,e){
2
2
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
3
- e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,u=(1<<a)-1,h=u>>1,l=-7,f=i?r-1:0,p=i?-1:1,c=t[e+f];for(f+=p,s=c&(1<<-l)-1,c>>=-l,l+=a;l>0;s=256*s+t[e+f],f+=p,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+f],f+=p,l-=8);if(0===s)s=1-h;else{if(s===u)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,n),s-=h}return(c?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,u,h=8*s-r-1,l=(1<<h)-1,f=l>>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,c=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*u-1)*Math.pow(2,r),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,r),o=0));r>=8;t[i+c]=255&a,c+=d,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[i+c]=255&o,c+=d,o/=256,h-=8);t[i+c-d]|=128*y}},function(t,e,i){"use strict";function n(t){let e=0;for(let i,n,r=0,s=t.length-1;r<t.length;s=r++)i=t[r],n=t[s],e+=(n[0]-i[0])*(i[1]+n[1]);return e}function r(t,e,i){e&&i&&(1===t?e.id=i.readVarint():2===t?function(t,e){const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}(i,e):3===t?e.type=i.readVarint():4===t&&(e._geometry=i.pos))}function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}i.r(e),i.d(e,"MVTLoader",(function(){return wt})),i.d(e,"MVTWorkerLoader",(function(){return vt}));class o{static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,e,i,n,o){s(this,"properties",void 0),s(this,"extent",void 0),s(this,"type",void 0),s(this,"id",void 0),s(this,"_pbf",void 0),s(this,"_geometry",void 0),s(this,"_keys",void 0),s(this,"_values",void 0),this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=n,this._values=o,t.readFields(r,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let i=1,n=0,r=0,s=0;const o=[];let a;for(;t.pos<e;){if(n<=0){const e=t.readVarint();i=7&e,n=e>>3}if(n--,1===i||2===i)r+=t.readSVarint(),s+=t.readSVarint(),1===i&&(a&&o.push(a),a=[]),a&&a.push([r,s]);else{if(7!==i)throw new Error("unknown command "+i);a&&a.push(a[0].slice())}}return a&&o.push(a),o}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let i=1,n=0,r=0,s=0,o=1/0,a=-1/0,u=1/0,h=-1/0;for(;t.pos<e;){if(n<=0){const e=t.readVarint();i=7&e,n=e>>3}if(n--,1===i||2===i)r+=t.readSVarint(),s+=t.readSVarint(),r<o&&(o=r),r>a&&(a=r),s<u&&(u=s),s>h&&(h=s);else if(7!==i)throw new Error("unknown command "+i)}return[o,u,a,h]}_toGeoJSON(t){let e,i,r=this.loadGeometry(),s=o.types[this.type];switch(this.type){case 1:const s=[];for(e=0;e<r.length;e++)s[e]=r[e][0];r=s,t(r,this);break;case 2:for(e=0;e<r.length;e++)t(r[e],this);break;case 3:for(r=function(t){const e=t.length;if(e<=1)return[t];const i=[];let r,s;for(let o=0;o<e;o++){const e=n(t[o]);0!==e&&(void 0===s&&(s=e<0),s===e<0?(r&&i.push(r),r=[t[o]]):r&&r.push(t[o]))}return r&&i.push(r),i}(r),e=0;e<r.length;e++)for(i=0;i<r[e].length;i++)t(r[e][i],this)}1===r.length?r=r[0]:s="Multi"+s;const a={type:"Feature",geometry:{type:s,coordinates:r},properties:this.properties};return null!==this.id&&(a.id=this.id),a}toGeoJSON(t){if("function"==typeof t)return this._toGeoJSON(t);const{x:e,y:i,z:n}=t,r=this.extent*Math.pow(2,n),s=this.extent*e,o=this.extent*i;return this._toGeoJSON((function(t){for(let e=0;e<t.length;e++){const i=t[e];i[0]=360*(i[0]+s)/r-180;const n=180-360*(i[1]+o)/r;i[1]=360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}}))}}function a(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class u{constructor(t,e){a(this,"version",void 0),a(this,"name",void 0),a(this,"extent",void 0),a(this,"length",void 0),a(this,"_pbf",void 0),a(this,"_keys",void 0),a(this,"_values",void 0),a(this,"_features",void 0),this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(h,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new o(this._pbf,e,this.extent,this._keys,this._values)}}function h(t,e,i){e&&i&&(15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}return e}(i)))}class l{constructor(t,e){var i,n,r;r=void 0,(n="layers")in(i=this)?Object.defineProperty(i,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[n]=r,this.layers=t.readFields(f,{},e)}}function f(t,e,i){if(3===t&&i){const t=new u(i,i.readVarint()+i.pos);t.length&&e&&(e[t.name]=t)}}Math.PI,Math.PI;const p={};p.EPSILON=1e-12,p.debug=!1,p.precision=4,p.printTypes=!1,p.printDegrees=!1,p.printRowMajor=!0;function c(t,e={}){const{start:i=0,end:n=t.length}=e,r=e.size||2;let s=0;for(let e=i,o=n-r;e<n;e+=r)s+=(t[e]-t[o])*(t[e+1]+t[o+1]),o=e;return s/2}function d(t,e,i,n){i=i||2;const r=e&&e.length,s=r?e[0]*i:t.length;let o=y(t,0,s,i,!0,n&&n[0]);const a=[];if(!o||o.next===o.prev)return a;let u,h,l,f,p,c,d;if(r&&(o=function(t,e,i,n,r){const s=[];let o,a,u,h,l;for(o=0,a=e.length;o<a;o++)u=e[o]*n,h=o<a-1?e[o+1]*n:t.length,l=y(t,u,h,n,!1,r&&r[o+1]),l===l.next&&(l.steiner=!0),s.push(S(l));for(s.sort(F),o=0;o<s.length;o++)m(s[o],i),i=x(i,i.next);return i}(t,e,o,i,n)),t.length>80*i){f=h=t[0],p=l=t[1];for(let e=i;e<s;e+=i)c=t[e],d=t[e+1],c<f&&(f=c),d<p&&(p=d),c>h&&(h=c),d>l&&(l=d);u=Math.max(h-f,l-p),u=0!==u?1/u:0}return g(o,a,i,f,p,u),a}function y(t,e,i,n,r,s){let o,a;if(void 0===s&&(s=c(t,{start:e,end:i,size:n})),r===s<0)for(o=e;o<i;o+=n)a=Z(o,t[o],t[o+1],a);else for(o=i-n;o>=e;o-=n)a=Z(o,t[o],t[o+1],a);return a&&B(a,a.next)&&(j(a),a=a.next),a}function x(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!B(n,n.next)&&0!==I(n.prev,n,n.next))n=n.next;else{if(j(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function g(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{null===r.z&&(r.z=V(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i,n,r,s,o,a,u,h=1;do{for(r=t,t=null,u=null,n=0;r;){for(n++,o=r,s=0,i=0;i<h&&(s++,o=o.nextZ,o);i++);for(a=h;s>0||a>0&&o;)0!==s&&(0===a||!o||r.z<=o.z)?(e=r,r=r.nextZ,s--):(e=o,o=o.nextZ,a--),u?u.nextZ=e:t=e,e.prevZ=u,u=e;r=o}u.nextZ=null,h*=2}while(n>1)}(r)}(t,n,r,s);let a,u,h=t;for(;t.prev!==t.next;)if(a=t.prev,u=t.next,s?w(t,n,r,s):v(t))e.push(a.i/i),e.push(t.i/i),e.push(u.i/i),j(t),t=u.next,h=u.next;else if((t=u)===h){o?1===o?g(t=b(x(t),e,i),e,i,n,r,s,2):2===o&&P(t,e,i,n,r,s):g(x(t),e,i,n,r,s,1);break}}function v(t){const e=t.prev,i=t,n=t.next;if(I(e,i,n)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(M(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&I(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function w(t,e,i,n){const r=t.prev,s=t,o=t.next;if(I(r,s,o)>=0)return!1;const a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,u=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,h=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,f=V(a,u,e,i,n),p=V(h,l,e,i,n);let c=t.prevZ,d=t.nextZ;for(;c&&c.z>=f&&d&&d.z<=p;){if(c!==t.prev&&c!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,c.x,c.y)&&I(c.prev,c,c.next)>=0)return!1;if(c=c.prevZ,d!==t.prev&&d!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&I(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;c&&c.z>=f;){if(c!==t.prev&&c!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,c.x,c.y)&&I(c.prev,c,c.next)>=0)return!1;c=c.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&I(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function b(t,e,i){let n=t;do{const r=n.prev,s=n.next.next;!B(r,s)&&C(r,n,n.next,s)&&z(r,s)&&z(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),j(n),j(n.next),n=t=s),n=n.next}while(n!==t);return x(n)}function P(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&k(o,t)){let a=O(o,t);return o=x(o,o.next),a=x(a,a.next),g(o,e,i,n,r,s),void g(a,e,i,n,r,s)}t=t.next}o=o.next}while(o!==t)}function F(t,e){return t.x-e.x}function m(t,e){if(e=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o){if(o=t,t===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!s)return null;if(n===o)return s;const a=s,u=s.x,h=s.y;let l,f=1/0;i=s;do{n>=i.x&&i.x>=u&&n!==i.x&&M(r<h?n:o,r,u,h,r<h?o:n,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(n-i.x),z(i,t)&&(l<f||l===f&&(i.x>s.x||i.x===s.x&&_(s,i)))&&(s=i,f=l)),i=i.next}while(i!==a);return s}(t,e)){const i=O(e,t);x(e,e.next),x(i,i.next)}}function _(t,e){return I(t.prev,t,e.prev)<0&&I(e.next,t,t.next)<0}function V(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function S(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function M(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function k(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&C(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(z(t,e)&&z(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(I(t.prev,t,e.prev)||I(t,e.prev,e))||B(t,e)&&I(t.prev,t,t.next)>0&&I(e.prev,e,e.next)>0)}function I(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function B(t,e){return t.x===e.x&&t.y===e.y}function C(t,e,i,n){const r=T(I(t,e,i)),s=T(I(t,e,n)),o=T(I(i,n,t)),a=T(I(i,n,e));return r!==s&&o!==a||(!(0!==r||!D(t,i,e))||(!(0!==s||!D(t,n,e))||(!(0!==o||!D(i,t,n))||!(0!==a||!D(i,e,n)))))}function D(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function T(t){return t>0?1:t<0?-1:0}function z(t,e){return I(t.prev,t,t.next)<0?I(t,e,t.next)>=0&&I(t,t.prev,e)>=0:I(t,e,t.prev)<0||I(t,t.next,e)<0}function O(t,e){const i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Z(t,e,i,n){const r=new A(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function j(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function N(t){const e=t.lines.length;if(e<=1)return{data:t.data,areas:[[c(t.data)]],lines:[t.lines]};const i=[],n=[];let r,s=[],o=[],a=0;for(let u,h,l=0;l<e;l++){h=t.lines[l]-a,u=t.lines[l+1]-a||t.data.length;const e=c(t.data.slice(h,u));if(0!==e)void 0===r&&(r=e<0),r===e<0?(o.length&&(i.push(s),n.push(o)),o=[h],s=[e]):(s.push(e),o.push(h));else{const e=t.data.slice(0,h),i=t.data.slice(u);t.data=e.concat(i),a+=u-h}}return s&&i.push(s),o.length&&n.push(o),{areas:i,lines:n,data:t.data}}function U(t,e,i,n){for(let r=0,s=t.length;r<s;r+=2){t[r]=360*(t[r]+e)/n-180;const s=180-360*(t[r+1]+i)/n;t[r+1]=360/Math.PI*Math.atan(Math.exp(s*Math.PI/180))-90}}function L(t,e,i){e&&i&&(1===t?e.id=i.readVarint():2===t?function(t,e){const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}(i,e):3===t?e.type=i.readVarint():4===t&&(e._geometry=i.pos))}function E(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let G,R,J,K,W,q,H;class Q{static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,e,i,n,r,s){E(this,"properties",void 0),E(this,"extent",void 0),E(this,"type",void 0),E(this,"id",void 0),E(this,"_pbf",void 0),E(this,"_geometry",void 0),E(this,"_keys",void 0),E(this,"_values",void 0),E(this,"_firstPassData",void 0),this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=n,this._values=r,this._firstPassData=s,t.readFields(L,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry,G=t.readVarint()+t.pos,R=1,K=0,W=0,q=0,H=0;const e=[],i=[];for(;t.pos<G;)if(K<=0&&(J=t.readVarint(),R=7&J,K=J>>3),K--,1===R||2===R)W+=t.readSVarint(),q+=t.readSVarint(),1===R&&e.push(H),i.push(W,q),H+=2;else{if(7!==R)throw new Error("unknown command "+R);if(H>0){const t=e[e.length-1];i.push(i[t],i[t+1]),H+=2}}return{data:i,lines:e}}_toBinaryCoordinates(t){let e=this.loadGeometry();t(e.data,this);switch(this.type){case 1:this._firstPassData.pointFeaturesCount++,this._firstPassData.pointPositionsCount+=e.lines.length;break;case 2:this._firstPassData.lineFeaturesCount++,this._firstPassData.linePathsCount+=e.lines.length,this._firstPassData.linePositionsCount+=e.data.length/2;break;case 3:const t=N(e);this._firstPassData.polygonFeaturesCount++,this._firstPassData.polygonObjectsCount+=t.lines.length;for(const e of t.lines)this._firstPassData.polygonRingsCount+=e.length;this._firstPassData.polygonPositionsCount+=t.data.length/2,e=t}e.type=Q.types[this.type],e.lines.length>1&&(e.type="Multi"+e.type);const i={type:"Feature",geometry:e,properties:this.properties};return null!==this.id&&(i.id=this.id),i}toBinaryCoordinates(t){return"function"==typeof t?this._toBinaryCoordinates(t):this._toBinaryCoordinates(U)}}function X(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Y{constructor(t,e){X(this,"version",void 0),X(this,"name",void 0),X(this,"extent",void 0),X(this,"length",void 0),X(this,"_pbf",void 0),X(this,"_keys",void 0),X(this,"_values",void 0),X(this,"_features",void 0),this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields($,this,e),this.length=this._features.length}feature(t,e){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const i=this._pbf.readVarint()+this._pbf.pos;return new Q(this._pbf,i,this.extent,this._keys,this._values,e)}}function $(t,e,i){e&&i&&(15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}return e}(i)))}class tt{constructor(t,e){var i,n,r;r=void 0,(n="layers")in(i=this)?Object.defineProperty(i,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[n]=r,this.layers=t.readFields(et,{},e)}}function et(t,e,i){if(3===t&&i){const t=new Y(i,i.readVarint()+i.pos);t.length&&e&&(e[t.name]=t)}}function it(t){const e={};for(const i of t)if(i.properties)for(const t in i.properties){const n=e[t];if(n||void 0===n){const n=i.properties[t];e[t]=lt(n)}}return Object.keys(e).filter(t=>e[t])}function nt(t,e,i){const{pointPositionsCount:n,pointFeaturesCount:r,linePositionsCount:s,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:u,polygonObjectsCount:h,polygonRingsCount:l,polygonFeaturesCount:f}=e,{numericPropKeys:p,PositionDataType:c=Float32Array}=i,d=t[0]&&"id"in t[0],y=t.length>65535?Uint32Array:Uint16Array,x={positions:new c(2*n),globalFeatureIds:new y(n),featureIds:r>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},g={pathIndices:s>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new c(2*s),globalFeatureIds:new y(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},v={polygonIndices:u>65535?new Uint32Array(h+1):new Uint16Array(h+1),primitivePolygonIndices:u>65535?new Uint32Array(l+1):new Uint16Array(l+1),positions:new c(2*u),triangles:[],globalFeatureIds:new y(u),featureIds:f>65535?new Uint32Array(u):new Uint16Array(u),numericProps:{},properties:[],fields:[]};for(const t of[x,g,v])for(const e of p)t.numericProps[e]=new Float32Array(t.positions.length/2);g.pathIndices[o]=s,v.polygonIndices[h]=u,v.primitivePolygonIndices[l]=u;const w={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(const e of t){const t=e.geometry,i=e.properties||{};switch(t.type){case"Point":case"MultiPoint":rt(t,x,w,2,i),x.properties.push(ht(i,p)),d&&x.fields.push({id:e.id}),w.pointFeature++;break;case"LineString":case"MultiLineString":st(t,g,w,2,i),g.properties.push(ht(i,p)),d&&g.fields.push({id:e.id}),w.lineFeature++;break;case"Polygon":case"MultiPolygon":ot(t,v,w,2,i),v.properties.push(ht(i,p)),d&&v.fields.push({id:e.id}),w.polygonFeature++;break;default:throw new Error("Invalid geometry type")}w.feature++}return function(t,e,i,n){const r={points:{...t,positions:{value:t.positions,size:n},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1}},lines:{...e,pathIndices:{value:e.pathIndices,size:1},positions:{value:e.positions,size:n},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1}},polygons:{...i,polygonIndices:{value:i.polygonIndices,size:1},primitivePolygonIndices:{value:i.primitivePolygonIndices,size:1},positions:{value:i.positions,size:n},triangles:{value:new Uint32Array(i.triangles),size:1},globalFeatureIds:{value:i.globalFeatureIds,size:1},featureIds:{value:i.featureIds,size:1}}};for(const t in r)for(const e in r[t].numericProps)r[t].numericProps[e]={value:r[t].numericProps[e],size:1};return r}(x,g,v,2)}function rt(t,e,i,n,r){e.positions.set(t.data,i.pointPosition*n);const s=t.data.length/n;ut(e,r,i.pointPosition,s),e.globalFeatureIds.fill(i.feature,i.pointPosition,i.pointPosition+s),e.featureIds.fill(i.pointFeature,i.pointPosition,i.pointPosition+s),i.pointPosition+=s}function st(t,e,i,n,r){e.positions.set(t.data,i.linePosition*n);const s=t.data.length/n;ut(e,r,i.linePosition,s),e.globalFeatureIds.fill(i.feature,i.linePosition,i.linePosition+s),e.featureIds.fill(i.lineFeature,i.linePosition,i.linePosition+s);for(let r=0,s=t.lines.length;r<s;++r){const o=t.lines[r],a=r===s-1?t.data.length:t.lines[r+1];e.pathIndices[i.linePath++]=i.linePosition,i.linePosition+=(a-o)/n}}function ot(t,e,i,n,r){e.positions.set(t.data,i.polygonPosition*n);const s=t.data.length/n;ut(e,r,i.polygonPosition,s),e.globalFeatureIds.fill(i.feature,i.polygonPosition,i.polygonPosition+s),e.featureIds.fill(i.polygonFeature,i.polygonPosition,i.polygonPosition+s);for(let r=0,s=t.lines.length;r<s;++r){const s=i.polygonPosition;e.polygonIndices[i.polygonObject++]=s;const o=t.areas[r],a=t.lines[r],u=t.lines[r+1];for(let r=0,s=a.length;r<s;++r){const o=a[r],h=r===s-1?void 0===u?t.data.length:u[0]:a[r+1];e.primitivePolygonIndices[i.polygonRing++]=i.polygonPosition,i.polygonPosition+=(h-o)/n}at(e,o,a,{startPosition:s,endPosition:i.polygonPosition,coordLength:n})}}function at(t,e,i,{startPosition:n,endPosition:r,coordLength:s}){const o=n*s,a=r*s,u=t.positions.subarray(o,a),h=i[0],l=d(u,i.slice(1).map(t=>(t-h)/s),s,e);for(let e=0,i=l.length;e<i;++e)t.triangles.push(n+l[e])}function ut(t,e,i,n){for(const r in t.numericProps)r in e&&t.numericProps[r].fill(e[r],i,i+n)}function ht(t,e){const i={};for(const n in t)e.includes(n)||(i[n]=t[n]);return i}function lt(t){return Number.isFinite(t)}var ft=i(0),pt=i.n(ft);function ct(t,e){e=function(t){if(t){const e="wgs84"===(t={...t,mvt:t.mvt||{},gis:t.gis||{}}).coordinates,{tileIndex:i}=t,n=i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z);if(e&&!n)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property. Check documentation.")}return t}(e);const i=[];if(e){const n="binary"===e.gis.format,r={pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength>0){const s=n?new tt(new pt.a(t)):new l(new pt.a(t)),o=e.mvt;(Array.isArray(o.layers)?o.layers:Object.keys(s.layers)).forEach(t=>{const e=s.layers[t],a={...o,layerName:t};if(e)for(let t=0;t<e.length;t++){const s=e.feature(t,r),o=n?yt(s,a):dt(s,a);i.push(o)}})}if(n){const e=function(t,e,i){return nt(t,e,{numericPropKeys:i?i.numericPropKeys:it(t),PositionDataType:i?i.PositionDataType:Float32Array})}(i,r);return e.byteLength=t.byteLength,e}}return i}function dt(t,e){const i=t.toGeoJSON("wgs84"===e.coordinates?e.tileIndex:xt);return e.layerProperty&&(i.properties[e.layerProperty]=e.layerName),i}function yt(t,e){const i=t.toBinaryCoordinates("wgs84"===e.coordinates?e.tileIndex:gt);return e.layerProperty&&(i.properties[e.layerProperty]=e.layerName),i}function xt(t,e){const{extent:i}=e;for(let e=0;e<t.length;e++){const n=t[e];n[0]/=i,n[1]/=i}}function gt(t,e){const{extent:i}=e;for(let e=0,n=t.length;e<n;++e)t[e]/=i}const vt={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:"3.1.0-alpha.3",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{coordinates:"local",layerProperty:"layerName",layers:null,tileIndex:null}}},wt={...vt,parse:async(t,e)=>ct(t,e),parseSync:ct,binary:!0}}])}));
3
+ e.read=function(t,e,i,n,r){var s,o,a=8*r-n-1,u=(1<<a)-1,h=u>>1,l=-7,f=i?r-1:0,p=i?-1:1,c=t[e+f];for(f+=p,s=c&(1<<-l)-1,c>>=-l,l+=a;l>0;s=256*s+t[e+f],f+=p,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=256*o+t[e+f],f+=p,l-=8);if(0===s)s=1-h;else{if(s===u)return o?NaN:1/0*(c?-1:1);o+=Math.pow(2,n),s-=h}return(c?-1:1)*o*Math.pow(2,s-n)},e.write=function(t,e,i,n,r,s){var o,a,u,h=8*s-r-1,l=(1<<h)-1,f=l>>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,c=n?0:s-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*u-1)*Math.pow(2,r),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,r),o=0));r>=8;t[i+c]=255&a,c+=d,a/=256,r-=8);for(o=o<<r|a,h+=r;h>0;t[i+c]=255&o,c+=d,o/=256,h-=8);t[i+c-d]|=128*y}},function(t,e,i){"use strict";function n(t){let e=0;for(let i,n,r=0,s=t.length-1;r<t.length;s=r++)i=t[r],n=t[s],e+=(n[0]-i[0])*(i[1]+n[1]);return e}function r(t,e,i){e&&i&&(1===t?e.id=i.readVarint():2===t?function(t,e){const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}(i,e):3===t?e.type=i.readVarint():4===t&&(e._geometry=i.pos))}function s(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}i.r(e),i.d(e,"MVTLoader",(function(){return wt})),i.d(e,"MVTWorkerLoader",(function(){return vt}));class o{static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,e,i,n,o){s(this,"properties",void 0),s(this,"extent",void 0),s(this,"type",void 0),s(this,"id",void 0),s(this,"_pbf",void 0),s(this,"_geometry",void 0),s(this,"_keys",void 0),s(this,"_values",void 0),this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=n,this._values=o,t.readFields(r,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let i=1,n=0,r=0,s=0;const o=[];let a;for(;t.pos<e;){if(n<=0){const e=t.readVarint();i=7&e,n=e>>3}if(n--,1===i||2===i)r+=t.readSVarint(),s+=t.readSVarint(),1===i&&(a&&o.push(a),a=[]),a&&a.push([r,s]);else{if(7!==i)throw new Error("unknown command "+i);a&&a.push(a[0].slice())}}return a&&o.push(a),o}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let i=1,n=0,r=0,s=0,o=1/0,a=-1/0,u=1/0,h=-1/0;for(;t.pos<e;){if(n<=0){const e=t.readVarint();i=7&e,n=e>>3}if(n--,1===i||2===i)r+=t.readSVarint(),s+=t.readSVarint(),r<o&&(o=r),r>a&&(a=r),s<u&&(u=s),s>h&&(h=s);else if(7!==i)throw new Error("unknown command "+i)}return[o,u,a,h]}_toGeoJSON(t){let e,i,r=this.loadGeometry(),s=o.types[this.type];switch(this.type){case 1:const s=[];for(e=0;e<r.length;e++)s[e]=r[e][0];r=s,t(r,this);break;case 2:for(e=0;e<r.length;e++)t(r[e],this);break;case 3:for(r=function(t){const e=t.length;if(e<=1)return[t];const i=[];let r,s;for(let o=0;o<e;o++){const e=n(t[o]);0!==e&&(void 0===s&&(s=e<0),s===e<0?(r&&i.push(r),r=[t[o]]):r&&r.push(t[o]))}return r&&i.push(r),i}(r),e=0;e<r.length;e++)for(i=0;i<r[e].length;i++)t(r[e][i],this)}1===r.length?r=r[0]:s="Multi"+s;const a={type:"Feature",geometry:{type:s,coordinates:r},properties:this.properties};return null!==this.id&&(a.id=this.id),a}toGeoJSON(t){if("function"==typeof t)return this._toGeoJSON(t);const{x:e,y:i,z:n}=t,r=this.extent*Math.pow(2,n),s=this.extent*e,o=this.extent*i;return this._toGeoJSON((function(t){for(let e=0;e<t.length;e++){const i=t[e];i[0]=360*(i[0]+s)/r-180;const n=180-360*(i[1]+o)/r;i[1]=360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90}}))}}function a(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class u{constructor(t,e){a(this,"version",void 0),a(this,"name",void 0),a(this,"extent",void 0),a(this,"length",void 0),a(this,"_pbf",void 0),a(this,"_keys",void 0),a(this,"_values",void 0),a(this,"_features",void 0),this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(h,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new o(this._pbf,e,this.extent,this._keys,this._values)}}function h(t,e,i){e&&i&&(15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}return e}(i)))}class l{constructor(t,e){var i,n,r;r=void 0,(n="layers")in(i=this)?Object.defineProperty(i,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[n]=r,this.layers=t.readFields(f,{},e)}}function f(t,e,i){if(3===t&&i){const t=new u(i,i.readVarint()+i.pos);t.length&&e&&(e[t.name]=t)}}Math.PI,Math.PI;const p={};p.EPSILON=1e-12,p.debug=!1,p.precision=4,p.printTypes=!1,p.printDegrees=!1,p.printRowMajor=!0;function c(t,e={}){const{start:i=0,end:n=t.length}=e,r=e.size||2;let s=0;for(let e=i,o=n-r;e<n;e+=r)s+=(t[e]-t[o])*(t[e+1]+t[o+1]),o=e;return s/2}function d(t,e,i,n){i=i||2;const r=e&&e.length,s=r?e[0]*i:t.length;let o=y(t,0,s,i,!0,n&&n[0]);const a=[];if(!o||o.next===o.prev)return a;let u,h,l,f,p,c,d;if(r&&(o=function(t,e,i,n,r){const s=[];let o,a,u,h,l;for(o=0,a=e.length;o<a;o++)u=e[o]*n,h=o<a-1?e[o+1]*n:t.length,l=y(t,u,h,n,!1,r&&r[o+1]),l===l.next&&(l.steiner=!0),s.push(S(l));for(s.sort(F),o=0;o<s.length;o++)m(s[o],i),i=x(i,i.next);return i}(t,e,o,i,n)),t.length>80*i){f=h=t[0],p=l=t[1];for(let e=i;e<s;e+=i)c=t[e],d=t[e+1],c<f&&(f=c),d<p&&(p=d),c>h&&(h=c),d>l&&(l=d);u=Math.max(h-f,l-p),u=0!==u?1/u:0}return g(o,a,i,f,p,u),a}function y(t,e,i,n,r,s){let o,a;if(void 0===s&&(s=c(t,{start:e,end:i,size:n})),r===s<0)for(o=e;o<i;o+=n)a=Z(o,t[o],t[o+1],a);else for(o=i-n;o>=e;o-=n)a=Z(o,t[o],t[o+1],a);return a&&B(a,a.next)&&(j(a),a=a.next),a}function x(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!B(n,n.next)&&0!==I(n.prev,n,n.next))n=n.next;else{if(j(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function g(t,e,i,n,r,s,o){if(!t)return;!o&&s&&function(t,e,i,n){let r=t;do{null===r.z&&(r.z=V(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i,n,r,s,o,a,u,h=1;do{for(r=t,t=null,u=null,n=0;r;){for(n++,o=r,s=0,i=0;i<h&&(s++,o=o.nextZ,o);i++);for(a=h;s>0||a>0&&o;)0!==s&&(0===a||!o||r.z<=o.z)?(e=r,r=r.nextZ,s--):(e=o,o=o.nextZ,a--),u?u.nextZ=e:t=e,e.prevZ=u,u=e;r=o}u.nextZ=null,h*=2}while(n>1)}(r)}(t,n,r,s);let a,u,h=t;for(;t.prev!==t.next;)if(a=t.prev,u=t.next,s?w(t,n,r,s):v(t))e.push(a.i/i),e.push(t.i/i),e.push(u.i/i),j(t),t=u.next,h=u.next;else if((t=u)===h){o?1===o?g(t=b(x(t),e,i),e,i,n,r,s,2):2===o&&P(t,e,i,n,r,s):g(x(t),e,i,n,r,s,1);break}}function v(t){const e=t.prev,i=t,n=t.next;if(I(e,i,n)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(M(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&I(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function w(t,e,i,n){const r=t.prev,s=t,o=t.next;if(I(r,s,o)>=0)return!1;const a=r.x<s.x?r.x<o.x?r.x:o.x:s.x<o.x?s.x:o.x,u=r.y<s.y?r.y<o.y?r.y:o.y:s.y<o.y?s.y:o.y,h=r.x>s.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,l=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,f=V(a,u,e,i,n),p=V(h,l,e,i,n);let c=t.prevZ,d=t.nextZ;for(;c&&c.z>=f&&d&&d.z<=p;){if(c!==t.prev&&c!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,c.x,c.y)&&I(c.prev,c,c.next)>=0)return!1;if(c=c.prevZ,d!==t.prev&&d!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&I(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;c&&c.z>=f;){if(c!==t.prev&&c!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,c.x,c.y)&&I(c.prev,c,c.next)>=0)return!1;c=c.prevZ}for(;d&&d.z<=p;){if(d!==t.prev&&d!==t.next&&M(r.x,r.y,s.x,s.y,o.x,o.y,d.x,d.y)&&I(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function b(t,e,i){let n=t;do{const r=n.prev,s=n.next.next;!B(r,s)&&C(r,n,n.next,s)&&z(r,s)&&z(s,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(s.i/i),j(n),j(n.next),n=t=s),n=n.next}while(n!==t);return x(n)}function P(t,e,i,n,r,s){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&k(o,t)){let a=O(o,t);return o=x(o,o.next),a=x(a,a.next),g(o,e,i,n,r,s),void g(a,e,i,n,r,s)}t=t.next}o=o.next}while(o!==t)}function F(t,e){return t.x-e.x}function m(t,e){if(e=function(t,e){let i=e;const n=t.x,r=t.y;let s,o=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o){if(o=t,t===n){if(r===i.y)return i;if(r===i.next.y)return i.next}s=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!s)return null;if(n===o)return s;const a=s,u=s.x,h=s.y;let l,f=1/0;i=s;do{n>=i.x&&i.x>=u&&n!==i.x&&M(r<h?n:o,r,u,h,r<h?o:n,r,i.x,i.y)&&(l=Math.abs(r-i.y)/(n-i.x),z(i,t)&&(l<f||l===f&&(i.x>s.x||i.x===s.x&&_(s,i)))&&(s=i,f=l)),i=i.next}while(i!==a);return s}(t,e)){const i=O(e,t);x(e,e.next),x(i,i.next)}}function _(t,e){return I(t.prev,t,e.prev)<0&&I(e.next,t,t.next)<0}function V(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function S(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function M(t,e,i,n,r,s,o,a){return(r-o)*(e-a)-(t-o)*(s-a)>=0&&(t-o)*(n-a)-(i-o)*(e-a)>=0&&(i-o)*(s-a)-(r-o)*(n-a)>=0}function k(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&C(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(z(t,e)&&z(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,s=(t.y+e.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(I(t.prev,t,e.prev)||I(t,e.prev,e))||B(t,e)&&I(t.prev,t,t.next)>0&&I(e.prev,e,e.next)>0)}function I(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function B(t,e){return t.x===e.x&&t.y===e.y}function C(t,e,i,n){const r=T(I(t,e,i)),s=T(I(t,e,n)),o=T(I(i,n,t)),a=T(I(i,n,e));return r!==s&&o!==a||(!(0!==r||!D(t,i,e))||(!(0!==s||!D(t,n,e))||(!(0!==o||!D(i,t,n))||!(0!==a||!D(i,e,n)))))}function D(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function T(t){return t>0?1:t<0?-1:0}function z(t,e){return I(t.prev,t,t.next)<0?I(t,e,t.next)>=0&&I(t,t.prev,e)>=0:I(t,e,t.prev)<0||I(t,t.next,e)<0}function O(t,e){const i=new A(t.i,t.x,t.y),n=new A(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,s.next=n,n.prev=s,n}function Z(t,e,i,n){const r=new A(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function j(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function N(t){const e=t.lines.length;if(e<=1)return{data:t.data,areas:[[c(t.data)]],lines:[t.lines]};const i=[],n=[];let r,s=[],o=[],a=0;for(let u,h,l=0;l<e;l++){h=t.lines[l]-a,u=t.lines[l+1]-a||t.data.length;const e=c(t.data.slice(h,u));if(0!==e)void 0===r&&(r=e<0),r===e<0?(o.length&&(i.push(s),n.push(o)),o=[h],s=[e]):(s.push(e),o.push(h));else{const e=t.data.slice(0,h),i=t.data.slice(u);t.data=e.concat(i),a+=u-h}}return s&&i.push(s),o.length&&n.push(o),{areas:i,lines:n,data:t.data}}function U(t,e,i,n){for(let r=0,s=t.length;r<s;r+=2){t[r]=360*(t[r]+e)/n-180;const s=180-360*(t[r+1]+i)/n;t[r+1]=360/Math.PI*Math.atan(Math.exp(s*Math.PI/180))-90}}function L(t,e,i){e&&i&&(1===t?e.id=i.readVarint():2===t?function(t,e){const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}(i,e):3===t?e.type=i.readVarint():4===t&&(e._geometry=i.pos))}function E(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let G,R,J,K,W,q,H;class Q{static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,e,i,n,r,s){E(this,"properties",void 0),E(this,"extent",void 0),E(this,"type",void 0),E(this,"id",void 0),E(this,"_pbf",void 0),E(this,"_geometry",void 0),E(this,"_keys",void 0),E(this,"_values",void 0),E(this,"_firstPassData",void 0),this.properties={},this.extent=i,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=n,this._values=r,this._firstPassData=s,t.readFields(L,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry,G=t.readVarint()+t.pos,R=1,K=0,W=0,q=0,H=0;const e=[],i=[];for(;t.pos<G;)if(K<=0&&(J=t.readVarint(),R=7&J,K=J>>3),K--,1===R||2===R)W+=t.readSVarint(),q+=t.readSVarint(),1===R&&e.push(H),i.push(W,q),H+=2;else{if(7!==R)throw new Error("unknown command "+R);if(H>0){const t=e[e.length-1];i.push(i[t],i[t+1]),H+=2}}return{data:i,lines:e}}_toBinaryCoordinates(t){let e=this.loadGeometry();t(e.data,this);switch(this.type){case 1:this._firstPassData.pointFeaturesCount++,this._firstPassData.pointPositionsCount+=e.lines.length;break;case 2:this._firstPassData.lineFeaturesCount++,this._firstPassData.linePathsCount+=e.lines.length,this._firstPassData.linePositionsCount+=e.data.length/2;break;case 3:const t=N(e);this._firstPassData.polygonFeaturesCount++,this._firstPassData.polygonObjectsCount+=t.lines.length;for(const e of t.lines)this._firstPassData.polygonRingsCount+=e.length;this._firstPassData.polygonPositionsCount+=t.data.length/2,e=t}e.type=Q.types[this.type],e.lines.length>1&&(e.type="Multi"+e.type);const i={type:"Feature",geometry:e,properties:this.properties};return null!==this.id&&(i.id=this.id),i}toBinaryCoordinates(t){return"function"==typeof t?this._toBinaryCoordinates(t):this._toBinaryCoordinates(U)}}function X(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}class Y{constructor(t,e){X(this,"version",void 0),X(this,"name",void 0),X(this,"extent",void 0),X(this,"length",void 0),X(this,"_pbf",void 0),X(this,"_keys",void 0),X(this,"_values",void 0),X(this,"_features",void 0),this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields($,this,e),this.length=this._features.length}feature(t,e){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const i=this._pbf.readVarint()+this._pbf.pos;return new Q(this._pbf,i,this.extent,this._keys,this._values,e)}}function $(t,e,i){e&&i&&(15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}return e}(i)))}class tt{constructor(t,e){var i,n,r;r=void 0,(n="layers")in(i=this)?Object.defineProperty(i,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):i[n]=r,this.layers=t.readFields(et,{},e)}}function et(t,e,i){if(3===t&&i){const t=new Y(i,i.readVarint()+i.pos);t.length&&e&&(e[t.name]=t)}}function it(t){const e={};for(const i of t)if(i.properties)for(const t in i.properties){const n=e[t];if(n||void 0===n){const n=i.properties[t];e[t]=lt(n)}}return Object.keys(e).filter(t=>e[t])}function nt(t,e,i){const{pointPositionsCount:n,pointFeaturesCount:r,linePositionsCount:s,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:u,polygonObjectsCount:h,polygonRingsCount:l,polygonFeaturesCount:f}=e,{numericPropKeys:p,PositionDataType:c=Float32Array}=i,d=t[0]&&"id"in t[0],y=t.length>65535?Uint32Array:Uint16Array,x={positions:new c(2*n),globalFeatureIds:new y(n),featureIds:r>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},g={pathIndices:s>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new c(2*s),globalFeatureIds:new y(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},v={polygonIndices:u>65535?new Uint32Array(h+1):new Uint16Array(h+1),primitivePolygonIndices:u>65535?new Uint32Array(l+1):new Uint16Array(l+1),positions:new c(2*u),triangles:[],globalFeatureIds:new y(u),featureIds:f>65535?new Uint32Array(u):new Uint16Array(u),numericProps:{},properties:[],fields:[]};for(const t of[x,g,v])for(const e of p)t.numericProps[e]=new Float32Array(t.positions.length/2);g.pathIndices[o]=s,v.polygonIndices[h]=u,v.primitivePolygonIndices[l]=u;const w={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(const e of t){const t=e.geometry,i=e.properties||{};switch(t.type){case"Point":case"MultiPoint":rt(t,x,w,2,i),x.properties.push(ht(i,p)),d&&x.fields.push({id:e.id}),w.pointFeature++;break;case"LineString":case"MultiLineString":st(t,g,w,2,i),g.properties.push(ht(i,p)),d&&g.fields.push({id:e.id}),w.lineFeature++;break;case"Polygon":case"MultiPolygon":ot(t,v,w,2,i),v.properties.push(ht(i,p)),d&&v.fields.push({id:e.id}),w.polygonFeature++;break;default:throw new Error("Invalid geometry type")}w.feature++}return function(t,e,i,n){const r={points:{...t,positions:{value:t.positions,size:n},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1}},lines:{...e,pathIndices:{value:e.pathIndices,size:1},positions:{value:e.positions,size:n},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1}},polygons:{...i,polygonIndices:{value:i.polygonIndices,size:1},primitivePolygonIndices:{value:i.primitivePolygonIndices,size:1},positions:{value:i.positions,size:n},triangles:{value:new Uint32Array(i.triangles),size:1},globalFeatureIds:{value:i.globalFeatureIds,size:1},featureIds:{value:i.featureIds,size:1}}};for(const t in r)for(const e in r[t].numericProps)r[t].numericProps[e]={value:r[t].numericProps[e],size:1};return r}(x,g,v,2)}function rt(t,e,i,n,r){e.positions.set(t.data,i.pointPosition*n);const s=t.data.length/n;ut(e,r,i.pointPosition,s),e.globalFeatureIds.fill(i.feature,i.pointPosition,i.pointPosition+s),e.featureIds.fill(i.pointFeature,i.pointPosition,i.pointPosition+s),i.pointPosition+=s}function st(t,e,i,n,r){e.positions.set(t.data,i.linePosition*n);const s=t.data.length/n;ut(e,r,i.linePosition,s),e.globalFeatureIds.fill(i.feature,i.linePosition,i.linePosition+s),e.featureIds.fill(i.lineFeature,i.linePosition,i.linePosition+s);for(let r=0,s=t.lines.length;r<s;++r){const o=t.lines[r],a=r===s-1?t.data.length:t.lines[r+1];e.pathIndices[i.linePath++]=i.linePosition,i.linePosition+=(a-o)/n}}function ot(t,e,i,n,r){e.positions.set(t.data,i.polygonPosition*n);const s=t.data.length/n;ut(e,r,i.polygonPosition,s),e.globalFeatureIds.fill(i.feature,i.polygonPosition,i.polygonPosition+s),e.featureIds.fill(i.polygonFeature,i.polygonPosition,i.polygonPosition+s);for(let r=0,s=t.lines.length;r<s;++r){const s=i.polygonPosition;e.polygonIndices[i.polygonObject++]=s;const o=t.areas[r],a=t.lines[r],u=t.lines[r+1];for(let r=0,s=a.length;r<s;++r){const o=a[r],h=r===s-1?void 0===u?t.data.length:u[0]:a[r+1];e.primitivePolygonIndices[i.polygonRing++]=i.polygonPosition,i.polygonPosition+=(h-o)/n}at(e,o,a,{startPosition:s,endPosition:i.polygonPosition,coordLength:n})}}function at(t,e,i,{startPosition:n,endPosition:r,coordLength:s}){const o=n*s,a=r*s,u=t.positions.subarray(o,a),h=i[0],l=d(u,i.slice(1).map(t=>(t-h)/s),s,e);for(let e=0,i=l.length;e<i;++e)t.triangles.push(n+l[e])}function ut(t,e,i,n){for(const r in t.numericProps)r in e&&t.numericProps[r].fill(e[r],i,i+n)}function ht(t,e){const i={};for(const n in t)e.includes(n)||(i[n]=t[n]);return i}function lt(t){return Number.isFinite(t)}var ft=i(0),pt=i.n(ft);function ct(t,e){e=function(t){if(t){const e="wgs84"===(t={...t,mvt:t.mvt||{},gis:t.gis||{}}).coordinates,{tileIndex:i}=t,n=i&&Number.isFinite(i.x)&&Number.isFinite(i.y)&&Number.isFinite(i.z);if(e&&!n)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property. Check documentation.")}return t}(e);const i=[];if(e){const n="binary"===e.gis.format,r={pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(t.byteLength>0){const s=n?new tt(new pt.a(t)):new l(new pt.a(t)),o=e.mvt;(Array.isArray(o.layers)?o.layers:Object.keys(s.layers)).forEach(t=>{const e=s.layers[t],a={...o,layerName:t};if(e)for(let t=0;t<e.length;t++){const s=e.feature(t,r),o=n?yt(s,a):dt(s,a);i.push(o)}})}if(n){const e=function(t,e,i){return nt(t,e,{numericPropKeys:i?i.numericPropKeys:it(t),PositionDataType:i?i.PositionDataType:Float32Array})}(i,r);return e.byteLength=t.byteLength,e}}return i}function dt(t,e){const i=t.toGeoJSON("wgs84"===e.coordinates?e.tileIndex:xt);return e.layerProperty&&(i.properties[e.layerProperty]=e.layerName),i}function yt(t,e){const i=t.toBinaryCoordinates("wgs84"===e.coordinates?e.tileIndex:gt);return e.layerProperty&&(i.properties[e.layerProperty]=e.layerName),i}function xt(t,e){const{extent:i}=e;for(let e=0;e<t.length;e++){const n=t[e];n[0]/=i,n[1]/=i}}function gt(t,e){const{extent:i}=e;for(let e=0,n=t.length;e<n;++e)t[e]/=i}const vt={name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:"3.1.0-alpha.4",extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{coordinates:"local",layerProperty:"layerName",layers:null,tileIndex:null}}},wt={...vt,parse:async(t,e)=>ct(t,e),parseSync:ct,binary:!0}}])}));
4
4
  //# sourceMappingURL=dist.min.js.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ var moduleExports = require('./index');
4
+
5
+ globalThis.loaders = globalThis.loaders || {};
6
+ module.exports = Object.assign(globalThis.loaders, moduleExports);
7
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.classifyRings = classifyRings;
7
+ exports.project = project;
8
+ exports.readFeature = readFeature;
9
+ exports.readTag = readTag;
10
+
11
+ var _polygon = require("@math.gl/polygon");
12
+
13
+ function classifyRings(geom) {
14
+ var len = geom.lines.length;
15
+
16
+ if (len <= 1) {
17
+ return {
18
+ data: geom.data,
19
+ areas: [[(0, _polygon.getPolygonSignedArea)(geom.data)]],
20
+ lines: [geom.lines]
21
+ };
22
+ }
23
+
24
+ var areas = [];
25
+ var polygons = [];
26
+ var ringAreas = [];
27
+ var polygon = [];
28
+ var ccw;
29
+ var offset = 0;
30
+
31
+ for (var endIndex, i = 0, startIndex; i < len; i++) {
32
+ startIndex = geom.lines[i] - offset;
33
+ endIndex = geom.lines[i + 1] - offset || geom.data.length;
34
+ var shape = geom.data.slice(startIndex, endIndex);
35
+ var area = (0, _polygon.getPolygonSignedArea)(shape);
36
+
37
+ if (area === 0) {
38
+ var before = geom.data.slice(0, startIndex);
39
+ var after = geom.data.slice(endIndex);
40
+ geom.data = before.concat(after);
41
+ offset += endIndex - startIndex;
42
+ continue;
43
+ }
44
+
45
+ if (ccw === undefined) ccw = area < 0;
46
+
47
+ if (ccw === area < 0) {
48
+ if (polygon.length) {
49
+ areas.push(ringAreas);
50
+ polygons.push(polygon);
51
+ }
52
+
53
+ polygon = [startIndex];
54
+ ringAreas = [area];
55
+ } else {
56
+ ringAreas.push(area);
57
+ polygon.push(startIndex);
58
+ }
59
+ }
60
+
61
+ if (ringAreas) areas.push(ringAreas);
62
+ if (polygon.length) polygons.push(polygon);
63
+ return {
64
+ areas: areas,
65
+ lines: polygons,
66
+ data: geom.data
67
+ };
68
+ }
69
+
70
+ function project(data, x0, y0, size) {
71
+ for (var j = 0, jl = data.length; j < jl; j += 2) {
72
+ data[j] = (data[j] + x0) * 360 / size - 180;
73
+ var y2 = 180 - (data[j + 1] + y0) * 360 / size;
74
+ data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
75
+ }
76
+ }
77
+
78
+ function readFeature(tag, feature, pbf) {
79
+ if (feature && pbf) {
80
+ if (tag === 1) feature.id = pbf.readVarint();else if (tag === 2) readTag(pbf, feature);else if (tag === 3) feature.type = pbf.readVarint();else if (tag === 4) feature._geometry = pbf.pos;
81
+ }
82
+ }
83
+
84
+ function readTag(pbf, feature) {
85
+ var end = pbf.readVarint() + pbf.pos;
86
+
87
+ while (pbf.pos < end) {
88
+ var key = feature._keys[pbf.readVarint()];
89
+
90
+ var value = feature._values[pbf.readVarint()];
91
+
92
+ feature.properties[key] = value;
93
+ }
94
+ }
95
+ //# sourceMappingURL=binary-util-functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/binary-util-functions.ts"],"names":["classifyRings","geom","len","lines","length","data","areas","polygons","ringAreas","polygon","ccw","offset","endIndex","i","startIndex","shape","slice","area","before","after","concat","undefined","push","project","x0","y0","size","j","jl","y2","Math","PI","atan","exp","readFeature","tag","feature","pbf","id","readVarint","readTag","type","_geometry","pos","end","key","_keys","value","_values","properties"],"mappings":";;;;;;;;;;AACA;;AAcO,SAASA,aAAT,CAAuBC,IAAvB,EAAgD;AACrD,MAAMC,GAAG,GAAGD,IAAI,CAACE,KAAL,CAAWC,MAAvB;;AAEA,MAAIF,GAAG,IAAI,CAAX,EAAc;AACZ,WAAO;AACLG,MAAAA,IAAI,EAAEJ,IAAI,CAACI,IADN;AAELC,MAAAA,KAAK,EAAE,CAAC,CAAC,mCAAqBL,IAAI,CAACI,IAA1B,CAAD,CAAD,CAFF;AAGLF,MAAAA,KAAK,EAAE,CAACF,IAAI,CAACE,KAAN;AAHF,KAAP;AAKD;;AAED,MAAMG,KAAY,GAAG,EAArB;AACA,MAAMC,QAAe,GAAG,EAAxB;AACA,MAAIC,SAAmB,GAAG,EAA1B;AACA,MAAIC,OAAiB,GAAG,EAAxB;AACA,MAAIC,GAAJ;AACA,MAAIC,MAAM,GAAG,CAAb;;AAEA,OAAK,IAAIC,QAAJ,EAAsBC,CAAC,GAAG,CAA1B,EAA6BC,UAAlC,EAAsDD,CAAC,GAAGX,GAA1D,EAA+DW,CAAC,EAAhE,EAAoE;AAClEC,IAAAA,UAAU,GAAGb,IAAI,CAACE,KAAL,CAAWU,CAAX,IAAgBF,MAA7B;AAEAC,IAAAA,QAAQ,GAAGX,IAAI,CAACE,KAAL,CAAWU,CAAC,GAAG,CAAf,IAAoBF,MAApB,IAA8BV,IAAI,CAACI,IAAL,CAAUD,MAAnD;AACA,QAAMW,KAAK,GAAGd,IAAI,CAACI,IAAL,CAAUW,KAAV,CAAgBF,UAAhB,EAA4BF,QAA5B,CAAd;AACA,QAAMK,IAAI,GAAG,mCAAqBF,KAArB,CAAb;;AAEA,QAAIE,IAAI,KAAK,CAAb,EAAgB;AAGd,UAAMC,MAAM,GAAGjB,IAAI,CAACI,IAAL,CAAUW,KAAV,CAAgB,CAAhB,EAAmBF,UAAnB,CAAf;AACA,UAAMK,KAAK,GAAGlB,IAAI,CAACI,IAAL,CAAUW,KAAV,CAAgBJ,QAAhB,CAAd;AACAX,MAAAA,IAAI,CAACI,IAAL,GAAYa,MAAM,CAACE,MAAP,CAAcD,KAAd,CAAZ;AAIAR,MAAAA,MAAM,IAAIC,QAAQ,GAAGE,UAArB;AAGA;AACD;;AAED,QAAIJ,GAAG,KAAKW,SAAZ,EAAuBX,GAAG,GAAGO,IAAI,GAAG,CAAb;;AAEvB,QAAIP,GAAG,KAAKO,IAAI,GAAG,CAAnB,EAAsB;AACpB,UAAIR,OAAO,CAACL,MAAZ,EAAoB;AAClBE,QAAAA,KAAK,CAACgB,IAAN,CAAWd,SAAX;AACAD,QAAAA,QAAQ,CAACe,IAAT,CAAcb,OAAd;AACD;;AACDA,MAAAA,OAAO,GAAG,CAACK,UAAD,CAAV;AACAN,MAAAA,SAAS,GAAG,CAACS,IAAD,CAAZ;AACD,KAPD,MAOO;AACLT,MAAAA,SAAS,CAACc,IAAV,CAAeL,IAAf;AACAR,MAAAA,OAAO,CAACa,IAAR,CAAaR,UAAb;AACD;AACF;;AACD,MAAIN,SAAJ,EAAeF,KAAK,CAACgB,IAAN,CAAWd,SAAX;AACf,MAAIC,OAAO,CAACL,MAAZ,EAAoBG,QAAQ,CAACe,IAAT,CAAcb,OAAd;AAEpB,SAAO;AAACH,IAAAA,KAAK,EAALA,KAAD;AAAQH,IAAAA,KAAK,EAAEI,QAAf;AAAyBF,IAAAA,IAAI,EAAEJ,IAAI,CAACI;AAApC,GAAP;AACD;;AASM,SAASkB,OAAT,CAAiBlB,IAAjB,EAAiCmB,EAAjC,EAA6CC,EAA7C,EAAyDC,IAAzD,EAA6E;AAClF,OAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,EAAE,GAAGvB,IAAI,CAACD,MAA1B,EAAkCuB,CAAC,GAAGC,EAAtC,EAA0CD,CAAC,IAAI,CAA/C,EAAkD;AAChDtB,IAAAA,IAAI,CAACsB,CAAD,CAAJ,GAAW,CAACtB,IAAI,CAACsB,CAAD,CAAJ,GAAUH,EAAX,IAAiB,GAAlB,GAAyBE,IAAzB,GAAgC,GAA1C;AACA,QAAMG,EAAE,GAAG,MAAO,CAACxB,IAAI,CAACsB,CAAC,GAAG,CAAL,CAAJ,GAAcF,EAAf,IAAqB,GAAtB,GAA6BC,IAA9C;AACArB,IAAAA,IAAI,CAACsB,CAAC,GAAG,CAAL,CAAJ,GAAe,MAAMG,IAAI,CAACC,EAAZ,GAAkBD,IAAI,CAACE,IAAL,CAAUF,IAAI,CAACG,GAAL,CAAUJ,EAAE,GAAGC,IAAI,CAACC,EAAX,GAAiB,GAA1B,CAAV,CAAlB,GAA8D,EAA5E;AACD;AACF;;AASM,SAASG,WAAT,CAAqBC,GAArB,EAAkCC,OAAlC,EAA+DC,GAA/D,EAAqF;AAC1F,MAAID,OAAO,IAAIC,GAAf,EAAoB;AAClB,QAAIF,GAAG,KAAK,CAAZ,EAAeC,OAAO,CAACE,EAAR,GAAaD,GAAG,CAACE,UAAJ,EAAb,CAAf,KACK,IAAIJ,GAAG,KAAK,CAAZ,EAAeK,OAAO,CAACH,GAAD,EAAMD,OAAN,CAAP,CAAf,KACA,IAAID,GAAG,KAAK,CAAZ,EAAeC,OAAO,CAACK,IAAR,GAAeJ,GAAG,CAACE,UAAJ,EAAf,CAAf,KACA,IAAIJ,GAAG,KAAK,CAAZ,EAAeC,OAAO,CAACM,SAAR,GAAoBL,GAAG,CAACM,GAAxB;AACrB;AACF;;AAMM,SAASH,OAAT,CAAiBH,GAAjB,EAAgCD,OAAhC,EAAkE;AACvE,MAAMQ,GAAG,GAAGP,GAAG,CAACE,UAAJ,KAAmBF,GAAG,CAACM,GAAnC;;AAEA,SAAON,GAAG,CAACM,GAAJ,GAAUC,GAAjB,EAAsB;AACpB,QAAMC,GAAG,GAAGT,OAAO,CAACU,KAAR,CAAcT,GAAG,CAACE,UAAJ,EAAd,CAAZ;;AACA,QAAMQ,KAAK,GAAGX,OAAO,CAACY,OAAR,CAAgBX,GAAG,CAACE,UAAJ,EAAhB,CAAd;;AACAH,IAAAA,OAAO,CAACa,UAAR,CAAmBJ,GAAnB,IAA0BE,KAA1B;AACD;AACF","sourcesContent":["import Protobuf from 'pbf';\nimport {getPolygonSignedArea} from '@math.gl/polygon';\nimport {MvtBinaryGeometry} from '../lib/types';\nimport VectorTileFeature from '../lib/binary-vector-tile/vector-tile-feature';\n\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * The function also detects holes which have zero area and\n * removes them. In doing so it modifies the input\n * `geom.data` array to remove the unneeded data\n *\n * @param geometry\n * @returns object\n */\n// eslint-disable-next-line max-statements\nexport function classifyRings(geom: MvtBinaryGeometry) {\n const len = geom.lines.length;\n\n if (len <= 1) {\n return {\n data: geom.data,\n areas: [[getPolygonSignedArea(geom.data)]],\n lines: [geom.lines]\n };\n }\n\n const areas: any[] = [];\n const polygons: any[] = [];\n let ringAreas: number[] = [];\n let polygon: number[] = [];\n let ccw: boolean | undefined;\n let offset = 0;\n\n for (let endIndex: number, i = 0, startIndex: number; i < len; i++) {\n startIndex = geom.lines[i] - offset;\n\n endIndex = geom.lines[i + 1] - offset || geom.data.length;\n const shape = geom.data.slice(startIndex, endIndex);\n const area = getPolygonSignedArea(shape);\n\n if (area === 0) {\n // This polygon has no area, so remove it from the shape\n // Remove the section from the data array\n const before = geom.data.slice(0, startIndex);\n const after = geom.data.slice(endIndex);\n geom.data = before.concat(after);\n\n // Need to offset any remaining indices as we have\n // modified the data buffer\n offset += endIndex - startIndex;\n\n // Do not add this index to the output and process next shape\n continue; // eslint-disable-line no-continue\n }\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon.length) {\n areas.push(ringAreas);\n polygons.push(polygon);\n }\n polygon = [startIndex];\n ringAreas = [area];\n } else {\n ringAreas.push(area);\n polygon.push(startIndex);\n }\n }\n if (ringAreas) areas.push(ringAreas);\n if (polygon.length) polygons.push(polygon);\n\n return {areas, lines: polygons, data: geom.data};\n}\n\n/**\n *\n * @param data\n * @param x0\n * @param y0\n * @param size\n */\nexport function project(data: number[], x0: number, y0: number, size: number): void {\n for (let j = 0, jl = data.length; j < jl; j += 2) {\n data[j] = ((data[j] + x0) * 360) / size - 180;\n const y2 = 180 - ((data[j + 1] + y0) * 360) / size;\n data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n }\n}\n\n/**\n * All code below is unchanged from the original Mapbox implemenation\n *\n * @param tag\n * @param feature\n * @param pbf\n */\nexport function readFeature(tag: number, feature?: VectorTileFeature, pbf?: Protobuf): void {\n if (feature && pbf) {\n if (tag === 1) feature.id = pbf.readVarint();\n else if (tag === 2) readTag(pbf, feature);\n else if (tag === 3) feature.type = pbf.readVarint();\n else if (tag === 4) feature._geometry = pbf.pos;\n }\n}\n\n/**\n * @param pbf\n * @param feature\n */\nexport function readTag(pbf: Protobuf, feature: VectorTileFeature): void {\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n"],"file":"binary-util-functions.js"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.classifyRings = classifyRings;
7
+ exports.signedArea = signedArea;
8
+ exports.readFeature = readFeature;
9
+ exports.readTag = readTag;
10
+
11
+ function classifyRings(rings) {
12
+ var len = rings.length;
13
+ if (len <= 1) return [rings];
14
+ var polygons = [];
15
+ var polygon;
16
+ var ccw;
17
+
18
+ for (var i = 0; i < len; i++) {
19
+ var area = signedArea(rings[i]);
20
+ if (area === 0) continue;
21
+ if (ccw === undefined) ccw = area < 0;
22
+
23
+ if (ccw === area < 0) {
24
+ if (polygon) polygons.push(polygon);
25
+ polygon = [rings[i]];
26
+ } else if (polygon) polygon.push(rings[i]);
27
+ }
28
+
29
+ if (polygon) polygons.push(polygon);
30
+ return polygons;
31
+ }
32
+
33
+ function signedArea(ring) {
34
+ var sum = 0;
35
+
36
+ for (var i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
37
+ p1 = ring[i];
38
+ p2 = ring[j];
39
+ sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
40
+ }
41
+
42
+ return sum;
43
+ }
44
+
45
+ function readFeature(tag, feature, pbf) {
46
+ if (feature && pbf) {
47
+ if (tag === 1) feature.id = pbf.readVarint();else if (tag === 2) readTag(pbf, feature);else if (tag === 3) feature.type = pbf.readVarint();else if (tag === 4) feature._geometry = pbf.pos;
48
+ }
49
+ }
50
+
51
+ function readTag(pbf, feature) {
52
+ var end = pbf.readVarint() + pbf.pos;
53
+
54
+ while (pbf.pos < end) {
55
+ var key = feature._keys[pbf.readVarint()];
56
+
57
+ var value = feature._values[pbf.readVarint()];
58
+
59
+ feature.properties[key] = value;
60
+ }
61
+ }
62
+ //# sourceMappingURL=mapbox-util-functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/helpers/mapbox-util-functions.ts"],"names":["classifyRings","rings","len","length","polygons","polygon","ccw","i","area","signedArea","undefined","push","ring","sum","j","p1","p2","readFeature","tag","feature","pbf","id","readVarint","readTag","type","_geometry","pos","end","key","_keys","value","_values","properties"],"mappings":";;;;;;;;;;AASO,SAASA,aAAT,CAAuBC,KAAvB,EAAiD;AACtD,MAAMC,GAAG,GAAGD,KAAK,CAACE,MAAlB;AAEA,MAAID,GAAG,IAAI,CAAX,EAAc,OAAO,CAACD,KAAD,CAAP;AAEd,MAAMG,QAAsB,GAAG,EAA/B;AACA,MAAIC,OAAJ;AACA,MAAIC,GAAJ;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,GAApB,EAAyBK,CAAC,EAA1B,EAA8B;AAC5B,QAAMC,IAAI,GAAGC,UAAU,CAACR,KAAK,CAACM,CAAD,CAAN,CAAvB;AACA,QAAIC,IAAI,KAAK,CAAb,EAAgB;AAEhB,QAAIF,GAAG,KAAKI,SAAZ,EAAuBJ,GAAG,GAAGE,IAAI,GAAG,CAAb;;AAEvB,QAAIF,GAAG,KAAKE,IAAI,GAAG,CAAnB,EAAsB;AACpB,UAAIH,OAAJ,EAAaD,QAAQ,CAACO,IAAT,CAAcN,OAAd;AACbA,MAAAA,OAAO,GAAG,CAACJ,KAAK,CAACM,CAAD,CAAN,CAAV;AACD,KAHD,MAGO,IAAIF,OAAJ,EAAaA,OAAO,CAACM,IAAR,CAAaV,KAAK,CAACM,CAAD,CAAlB;AACrB;;AACD,MAAIF,OAAJ,EAAaD,QAAQ,CAACO,IAAT,CAAcN,OAAd;AAEb,SAAOD,QAAP;AACD;;AAOM,SAASK,UAAT,CAAoBG,IAApB,EAAsC;AAC3C,MAAIC,GAAG,GAAG,CAAV;;AACA,OAAK,IAAIN,CAAC,GAAG,CAAR,EAAWO,CAAC,GAAGF,IAAI,CAACT,MAAL,GAAc,CAA7B,EAAgCY,EAAhC,EAA8CC,EAAnD,EAAiET,CAAC,GAAGK,IAAI,CAACT,MAA1E,EAAkFW,CAAC,GAAGP,CAAC,EAAvF,EAA2F;AACzFQ,IAAAA,EAAE,GAAGH,IAAI,CAACL,CAAD,CAAT;AACAS,IAAAA,EAAE,GAAGJ,IAAI,CAACE,CAAD,CAAT;AACAD,IAAAA,GAAG,IAAI,CAACG,EAAE,CAAC,CAAD,CAAF,GAAQD,EAAE,CAAC,CAAD,CAAX,KAAmBA,EAAE,CAAC,CAAD,CAAF,GAAQC,EAAE,CAAC,CAAD,CAA7B,CAAP;AACD;;AACD,SAAOH,GAAP;AACD;;AAQM,SAASI,WAAT,CAAqBC,GAArB,EAAkCC,OAAlC,EAA+DC,GAA/D,EAAqF;AAC1F,MAAID,OAAO,IAAIC,GAAf,EAAoB;AAClB,QAAIF,GAAG,KAAK,CAAZ,EAAeC,OAAO,CAACE,EAAR,GAAaD,GAAG,CAACE,UAAJ,EAAb,CAAf,KACK,IAAIJ,GAAG,KAAK,CAAZ,EAAeK,OAAO,CAACH,GAAD,EAAMD,OAAN,CAAP,CAAf,KACA,IAAID,GAAG,KAAK,CAAZ,EAAeC,OAAO,CAACK,IAAR,GAAeJ,GAAG,CAACE,UAAJ,EAAf,CAAf,KACA,IAAIJ,GAAG,KAAK,CAAZ,EAAeC,OAAO,CAACM,SAAR,GAAoBL,GAAG,CAACM,GAAxB;AACrB;AACF;;AAOM,SAASH,OAAT,CAAiBH,GAAjB,EAAgCD,OAAhC,EAAkE;AACvE,MAAMQ,GAAG,GAAGP,GAAG,CAACE,UAAJ,KAAmBF,GAAG,CAACM,GAAnC;;AAEA,SAAON,GAAG,CAACM,GAAJ,GAAUC,GAAjB,EAAsB;AACpB,QAAMC,GAAG,GAAGT,OAAO,CAACU,KAAR,CAAcT,GAAG,CAACE,UAAJ,EAAd,CAAZ;;AACA,QAAMQ,KAAK,GAAGX,OAAO,CAACY,OAAR,CAAgBX,GAAG,CAACE,UAAJ,EAAhB,CAAd;;AACAH,IAAAA,OAAO,CAACa,UAAR,CAAmBJ,GAAnB,IAA0BE,KAA1B;AACD;AACF","sourcesContent":["import Protobuf from 'pbf';\nimport {MvtMapboxGeometry} from '../lib/types';\nimport VectorTileFeature from '../lib/mapbox-vector-tile/vector-tile-feature';\n\n/**\n * Classifies an array of rings into polygons with outer rings and holes\n * @param rings\n * @returns polygons\n */\nexport function classifyRings(rings: MvtMapboxGeometry) {\n const len = rings.length;\n\n if (len <= 1) return [rings];\n\n const polygons: number[][][] = [];\n let polygon: number[][] | undefined;\n let ccw: boolean | undefined;\n\n for (let i = 0; i < len; i++) {\n const area = signedArea(rings[i]);\n if (area === 0) continue; // eslint-disable-line no-continue\n\n if (ccw === undefined) ccw = area < 0;\n\n if (ccw === area < 0) {\n if (polygon) polygons.push(polygon);\n polygon = [rings[i]];\n } else if (polygon) polygon.push(rings[i]);\n }\n if (polygon) polygons.push(polygon);\n\n return polygons;\n}\n\n/**\n *\n * @param ring\n * @returns sum\n */\nexport function signedArea(ring: number[][]) {\n let sum = 0;\n for (let i = 0, j = ring.length - 1, p1: number[], p2: number[]; i < ring.length; j = i++) {\n p1 = ring[i];\n p2 = ring[j];\n sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);\n }\n return sum;\n}\n\n/**\n *\n * @param tag\n * @param feature\n * @param pbf\n */\nexport function readFeature(tag: number, feature?: VectorTileFeature, pbf?: Protobuf): void {\n if (feature && pbf) {\n if (tag === 1) feature.id = pbf.readVarint();\n else if (tag === 2) readTag(pbf, feature);\n else if (tag === 3) feature.type = pbf.readVarint();\n else if (tag === 4) feature._geometry = pbf.pos;\n }\n}\n\n/**\n *\n * @param pbf\n * @param feature\n */\nexport function readTag(pbf: Protobuf, feature: VectorTileFeature): void {\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n const key = feature._keys[pbf.readVarint()];\n const value = feature._values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n}\n"],"file":"mapbox-util-functions.js"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "MVTLoader", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _mvtLoader.MVTLoader;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "MVTWorkerLoader", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _mvtLoader.MVTWorkerLoader;
16
+ }
17
+ });
18
+
19
+ var _mvtLoader = require("./mvt-loader");
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA","sourcesContent":["export {MVTLoader, MVTWorkerLoader} from './mvt-loader';\n"],"file":"index.js"}
@@ -0,0 +1,385 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.featuresToBinary = featuresToBinary;
9
+ exports.TEST_EXPORTS = void 0;
10
+
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+
13
+ var _polygon = require("@math.gl/polygon");
14
+
15
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
16
+
17
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
18
+
19
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
20
+
21
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
+
23
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
+
25
+ function featuresToBinary(features, firstPassData, options) {
26
+ return fillArrays(features, firstPassData, {
27
+ numericPropKeys: options ? options.numericPropKeys : extractNumericPropKeys(features),
28
+ PositionDataType: options ? options.PositionDataType : Float32Array
29
+ });
30
+ }
31
+
32
+ var TEST_EXPORTS = {
33
+ extractNumericPropKeys: extractNumericPropKeys,
34
+ fillArrays: fillArrays
35
+ };
36
+ exports.TEST_EXPORTS = TEST_EXPORTS;
37
+
38
+ function extractNumericPropKeys(features) {
39
+ var numericPropKeys = {};
40
+
41
+ var _iterator = _createForOfIteratorHelper(features),
42
+ _step;
43
+
44
+ try {
45
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
46
+ var feature = _step.value;
47
+
48
+ if (feature.properties) {
49
+ for (var key in feature.properties) {
50
+ var numericSoFar = numericPropKeys[key];
51
+
52
+ if (numericSoFar || numericSoFar === undefined) {
53
+ var val = feature.properties[key];
54
+ numericPropKeys[key] = isNumeric(val);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ } catch (err) {
60
+ _iterator.e(err);
61
+ } finally {
62
+ _iterator.f();
63
+ }
64
+
65
+ return Object.keys(numericPropKeys).filter(function (k) {
66
+ return numericPropKeys[k];
67
+ });
68
+ }
69
+
70
+ function fillArrays(features, firstPassData, options) {
71
+ var pointPositionsCount = firstPassData.pointPositionsCount,
72
+ pointFeaturesCount = firstPassData.pointFeaturesCount,
73
+ linePositionsCount = firstPassData.linePositionsCount,
74
+ linePathsCount = firstPassData.linePathsCount,
75
+ lineFeaturesCount = firstPassData.lineFeaturesCount,
76
+ polygonPositionsCount = firstPassData.polygonPositionsCount,
77
+ polygonObjectsCount = firstPassData.polygonObjectsCount,
78
+ polygonRingsCount = firstPassData.polygonRingsCount,
79
+ polygonFeaturesCount = firstPassData.polygonFeaturesCount;
80
+ var numericPropKeys = options.numericPropKeys,
81
+ _options$PositionData = options.PositionDataType,
82
+ PositionDataType = _options$PositionData === void 0 ? Float32Array : _options$PositionData;
83
+ var hasGlobalId = features[0] && 'id' in features[0];
84
+ var coordLength = 2;
85
+ var GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
86
+ var points = {
87
+ positions: new PositionDataType(pointPositionsCount * coordLength),
88
+ globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
89
+ featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
90
+ numericProps: {},
91
+ properties: [],
92
+ fields: []
93
+ };
94
+ var lines = {
95
+ pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
96
+ positions: new PositionDataType(linePositionsCount * coordLength),
97
+ globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
98
+ featureIds: lineFeaturesCount > 65535 ? new Uint32Array(linePositionsCount) : new Uint16Array(linePositionsCount),
99
+ numericProps: {},
100
+ properties: [],
101
+ fields: []
102
+ };
103
+ var polygons = {
104
+ polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
105
+ primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
106
+ positions: new PositionDataType(polygonPositionsCount * coordLength),
107
+ triangles: [],
108
+ globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
109
+ featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
110
+ numericProps: {},
111
+ properties: [],
112
+ fields: []
113
+ };
114
+
115
+ for (var _i = 0, _arr = [points, lines, polygons]; _i < _arr.length; _i++) {
116
+ var object = _arr[_i];
117
+
118
+ var _iterator2 = _createForOfIteratorHelper(numericPropKeys),
119
+ _step2;
120
+
121
+ try {
122
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
123
+ var propName = _step2.value;
124
+ object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
125
+ }
126
+ } catch (err) {
127
+ _iterator2.e(err);
128
+ } finally {
129
+ _iterator2.f();
130
+ }
131
+ }
132
+
133
+ lines.pathIndices[linePathsCount] = linePositionsCount;
134
+ polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
135
+ polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
136
+ var indexMap = {
137
+ pointPosition: 0,
138
+ pointFeature: 0,
139
+ linePosition: 0,
140
+ linePath: 0,
141
+ lineFeature: 0,
142
+ polygonPosition: 0,
143
+ polygonObject: 0,
144
+ polygonRing: 0,
145
+ polygonFeature: 0,
146
+ feature: 0
147
+ };
148
+
149
+ var _iterator3 = _createForOfIteratorHelper(features),
150
+ _step3;
151
+
152
+ try {
153
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
154
+ var feature = _step3.value;
155
+ var geometry = feature.geometry;
156
+ var properties = feature.properties || {};
157
+
158
+ switch (geometry.type) {
159
+ case 'Point':
160
+ case 'MultiPoint':
161
+ handlePoint(geometry, points, indexMap, coordLength, properties);
162
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
163
+
164
+ if (hasGlobalId) {
165
+ points.fields.push({
166
+ id: feature.id
167
+ });
168
+ }
169
+
170
+ indexMap.pointFeature++;
171
+ break;
172
+
173
+ case 'LineString':
174
+ case 'MultiLineString':
175
+ handleLineString(geometry, lines, indexMap, coordLength, properties);
176
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
177
+
178
+ if (hasGlobalId) {
179
+ lines.fields.push({
180
+ id: feature.id
181
+ });
182
+ }
183
+
184
+ indexMap.lineFeature++;
185
+ break;
186
+
187
+ case 'Polygon':
188
+ case 'MultiPolygon':
189
+ handlePolygon(geometry, polygons, indexMap, coordLength, properties);
190
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
191
+
192
+ if (hasGlobalId) {
193
+ polygons.fields.push({
194
+ id: feature.id
195
+ });
196
+ }
197
+
198
+ indexMap.polygonFeature++;
199
+ break;
200
+
201
+ default:
202
+ throw new Error('Invalid geometry type');
203
+ }
204
+
205
+ indexMap.feature++;
206
+ }
207
+ } catch (err) {
208
+ _iterator3.e(err);
209
+ } finally {
210
+ _iterator3.f();
211
+ }
212
+
213
+ return makeAccessorObjects(points, lines, polygons, coordLength);
214
+ }
215
+
216
+ function handlePoint(geometry, points, indexMap, coordLength, properties) {
217
+ points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
218
+ var nPositions = geometry.data.length / coordLength;
219
+ fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
220
+ points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
221
+ points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
222
+ indexMap.pointPosition += nPositions;
223
+ }
224
+
225
+ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
226
+ lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
227
+ var nPositions = geometry.data.length / coordLength;
228
+ fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
229
+ lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
230
+ lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
231
+
232
+ for (var i = 0, il = geometry.lines.length; i < il; ++i) {
233
+ var start = geometry.lines[i];
234
+ var end = i === il - 1 ? geometry.data.length : geometry.lines[i + 1];
235
+ lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
236
+ indexMap.linePosition += (end - start) / coordLength;
237
+ }
238
+ }
239
+
240
+ function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
241
+ polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
242
+ var nPositions = geometry.data.length / coordLength;
243
+ fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
244
+ polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
245
+ polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
246
+
247
+ for (var l = 0, ll = geometry.lines.length; l < ll; ++l) {
248
+ var startPosition = indexMap.polygonPosition;
249
+ polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
250
+ var areas = geometry.areas[l];
251
+ var lines = geometry.lines[l];
252
+ var nextLines = geometry.lines[l + 1];
253
+
254
+ for (var i = 0, il = lines.length; i < il; ++i) {
255
+ var start = lines[i];
256
+ var end = i === il - 1 ? nextLines === undefined ? geometry.data.length : nextLines[0] : lines[i + 1];
257
+ polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
258
+ indexMap.polygonPosition += (end - start) / coordLength;
259
+ }
260
+
261
+ var endPosition = indexMap.polygonPosition;
262
+ triangulatePolygon(polygons, areas, lines, {
263
+ startPosition: startPosition,
264
+ endPosition: endPosition,
265
+ coordLength: coordLength
266
+ });
267
+ }
268
+ }
269
+
270
+ function triangulatePolygon(polygons, areas, lines, _ref) {
271
+ var startPosition = _ref.startPosition,
272
+ endPosition = _ref.endPosition,
273
+ coordLength = _ref.coordLength;
274
+ var start = startPosition * coordLength;
275
+ var end = endPosition * coordLength;
276
+ var polygonPositions = polygons.positions.subarray(start, end);
277
+ var offset = lines[0];
278
+ var holes = lines.slice(1).map(function (n) {
279
+ return (n - offset) / coordLength;
280
+ });
281
+ var indices = (0, _polygon.earcut)(polygonPositions, holes, coordLength, areas);
282
+
283
+ for (var t = 0, tl = indices.length; t < tl; ++t) {
284
+ polygons.triangles.push(startPosition + indices[t]);
285
+ }
286
+ }
287
+
288
+ function makeAccessorObjects(points, lines, polygons, coordLength) {
289
+ var returnObj = {
290
+ points: _objectSpread(_objectSpread({}, points), {}, {
291
+ positions: {
292
+ value: points.positions,
293
+ size: coordLength
294
+ },
295
+ globalFeatureIds: {
296
+ value: points.globalFeatureIds,
297
+ size: 1
298
+ },
299
+ featureIds: {
300
+ value: points.featureIds,
301
+ size: 1
302
+ }
303
+ }),
304
+ lines: _objectSpread(_objectSpread({}, lines), {}, {
305
+ pathIndices: {
306
+ value: lines.pathIndices,
307
+ size: 1
308
+ },
309
+ positions: {
310
+ value: lines.positions,
311
+ size: coordLength
312
+ },
313
+ globalFeatureIds: {
314
+ value: lines.globalFeatureIds,
315
+ size: 1
316
+ },
317
+ featureIds: {
318
+ value: lines.featureIds,
319
+ size: 1
320
+ }
321
+ }),
322
+ polygons: _objectSpread(_objectSpread({}, polygons), {}, {
323
+ polygonIndices: {
324
+ value: polygons.polygonIndices,
325
+ size: 1
326
+ },
327
+ primitivePolygonIndices: {
328
+ value: polygons.primitivePolygonIndices,
329
+ size: 1
330
+ },
331
+ positions: {
332
+ value: polygons.positions,
333
+ size: coordLength
334
+ },
335
+ triangles: {
336
+ value: new Uint32Array(polygons.triangles),
337
+ size: 1
338
+ },
339
+ globalFeatureIds: {
340
+ value: polygons.globalFeatureIds,
341
+ size: 1
342
+ },
343
+ featureIds: {
344
+ value: polygons.featureIds,
345
+ size: 1
346
+ }
347
+ })
348
+ };
349
+
350
+ for (var geomType in returnObj) {
351
+ for (var numericProp in returnObj[geomType].numericProps) {
352
+ returnObj[geomType].numericProps[numericProp] = {
353
+ value: returnObj[geomType].numericProps[numericProp],
354
+ size: 1
355
+ };
356
+ }
357
+ }
358
+
359
+ return returnObj;
360
+ }
361
+
362
+ function fillNumericProperties(object, properties, index, length) {
363
+ for (var numericPropName in object.numericProps) {
364
+ if (numericPropName in properties) {
365
+ object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
366
+ }
367
+ }
368
+ }
369
+
370
+ function keepStringProperties(properties, numericKeys) {
371
+ var props = {};
372
+
373
+ for (var key in properties) {
374
+ if (!numericKeys.includes(key)) {
375
+ props[key] = properties[key];
376
+ }
377
+ }
378
+
379
+ return props;
380
+ }
381
+
382
+ function isNumeric(x) {
383
+ return Number.isFinite(x);
384
+ }
385
+ //# sourceMappingURL=features-to-binary.js.map