@loaders.gl/mvt 4.0.0-alpha.1 → 4.0.0-alpha.11

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 (198) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/dist.min.js +3124 -0
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/helpers/binary-util-functions.js +82 -0
  8. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  9. package/dist/es5/helpers/mapbox-util-functions.js +50 -0
  10. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  11. package/dist/es5/index.js +26 -0
  12. package/dist/es5/index.js.map +1 -0
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -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 +62 -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 +28 -0
  18. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  19. package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
  20. package/dist/es5/lib/geojson-tiler/clip.js +237 -0
  21. package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
  22. package/dist/es5/lib/geojson-tiler/convert.js +161 -0
  23. package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
  24. package/dist/es5/lib/geojson-tiler/feature.js +62 -0
  25. package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
  26. package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
  27. package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  28. package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
  29. package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
  30. package/dist/es5/lib/geojson-tiler/tile.js +121 -0
  31. package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
  32. package/dist/es5/lib/geojson-tiler/transform.js +50 -0
  33. package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
  34. package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
  35. package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
  36. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -0
  37. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  38. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +62 -0
  39. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  40. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +28 -0
  41. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  42. package/dist/es5/lib/parse-mvt.js +143 -0
  43. package/dist/es5/lib/parse-mvt.js.map +1 -0
  44. package/dist/es5/lib/types.js +2 -0
  45. package/dist/es5/lib/types.js.map +1 -0
  46. package/dist/es5/mvt-loader.js +58 -0
  47. package/dist/es5/mvt-loader.js.map +1 -0
  48. package/dist/es5/workers/mvt-worker.js +6 -0
  49. package/dist/es5/workers/mvt-worker.js.map +1 -0
  50. package/dist/esm/bundle.js +4 -0
  51. package/dist/esm/bundle.js.map +1 -0
  52. package/dist/esm/helpers/binary-util-functions.js +73 -0
  53. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  54. package/dist/esm/helpers/mapbox-util-functions.js +41 -0
  55. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  56. package/dist/esm/index.js +3 -0
  57. package/dist/esm/index.js.map +1 -0
  58. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  59. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +136 -0
  60. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  61. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +47 -0
  62. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  63. package/dist/esm/lib/binary-vector-tile/vector-tile.js +19 -0
  64. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  65. package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
  66. package/dist/esm/lib/geojson-tiler/clip.js +173 -0
  67. package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
  68. package/dist/esm/lib/geojson-tiler/convert.js +116 -0
  69. package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
  70. package/dist/esm/lib/geojson-tiler/feature.js +35 -0
  71. package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
  72. package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
  73. package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  74. package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
  75. package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
  76. package/dist/esm/lib/geojson-tiler/tile.js +103 -0
  77. package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
  78. package/dist/esm/lib/geojson-tiler/transform.js +32 -0
  79. package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
  80. package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
  81. package/dist/esm/lib/geojson-tiler/wrap.js.map +1 -0
  82. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  83. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +163 -0
  84. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  85. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +47 -0
  86. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  87. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +19 -0
  88. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  89. package/dist/esm/lib/parse-mvt.js +138 -0
  90. package/dist/esm/lib/parse-mvt.js.map +1 -0
  91. package/dist/esm/lib/types.js +2 -0
  92. package/dist/esm/lib/types.js.map +1 -0
  93. package/dist/esm/mvt-loader.js +29 -0
  94. package/dist/esm/mvt-loader.js.map +1 -0
  95. package/dist/esm/workers/mvt-worker.js +4 -0
  96. package/dist/esm/workers/mvt-worker.js.map +1 -0
  97. package/dist/helpers/binary-util-functions.d.ts +35 -0
  98. package/dist/helpers/binary-util-functions.d.ts.map +1 -0
  99. package/dist/helpers/binary-util-functions.js +111 -74
  100. package/dist/helpers/mapbox-util-functions.d.ts +29 -0
  101. package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
  102. package/dist/helpers/mapbox-util-functions.js +78 -45
  103. package/dist/index.d.ts +4 -0
  104. package/dist/index.d.ts.map +1 -0
  105. package/dist/index.js +9 -2
  106. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +41 -0
  107. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
  108. package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -142
  109. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
  110. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
  111. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
  112. package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
  113. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
  114. package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
  115. package/dist/lib/geojson-tiler/clip.d.ts +16 -0
  116. package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
  117. package/dist/lib/geojson-tiler/clip.js +209 -0
  118. package/dist/lib/geojson-tiler/convert.d.ts +10 -0
  119. package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
  120. package/dist/lib/geojson-tiler/convert.js +134 -0
  121. package/dist/lib/geojson-tiler/feature.d.ts +3 -0
  122. package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
  123. package/dist/lib/geojson-tiler/feature.js +46 -0
  124. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
  125. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
  126. package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
  127. package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
  128. package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
  129. package/dist/lib/geojson-tiler/simplify.js +68 -0
  130. package/dist/lib/geojson-tiler/tile.d.ts +38 -0
  131. package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
  132. package/dist/lib/geojson-tiler/tile.js +125 -0
  133. package/dist/lib/geojson-tiler/transform.d.ts +7 -0
  134. package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
  135. package/dist/lib/geojson-tiler/transform.js +43 -0
  136. package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
  137. package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
  138. package/dist/lib/geojson-tiler/wrap.js +86 -0
  139. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
  140. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
  141. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
  142. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
  143. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
  144. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
  145. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
  146. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
  147. package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
  148. package/dist/lib/parse-mvt.d.ts +14 -0
  149. package/dist/lib/parse-mvt.d.ts.map +1 -0
  150. package/dist/lib/parse-mvt.js +149 -98
  151. package/dist/lib/types.d.ts +69 -0
  152. package/dist/lib/types.d.ts.map +1 -0
  153. package/dist/lib/types.js +2 -2
  154. package/dist/mvt-loader.d.ts +10 -0
  155. package/dist/mvt-loader.d.ts.map +1 -0
  156. package/dist/mvt-loader.js +43 -22
  157. package/dist/mvt-worker.js +845 -766
  158. package/dist/workers/mvt-worker.d.ts +2 -0
  159. package/dist/workers/mvt-worker.d.ts.map +1 -0
  160. package/dist/workers/mvt-worker.js +5 -4
  161. package/package.json +10 -9
  162. package/src/helpers/binary-util-functions.ts +9 -7
  163. package/src/helpers/mapbox-util-functions.ts +2 -2
  164. package/src/index.ts +7 -0
  165. package/src/lib/binary-vector-tile/vector-tile-feature.ts +42 -45
  166. package/src/lib/binary-vector-tile/vector-tile-layer.ts +4 -4
  167. package/src/lib/geojson-tiler/LICENSE +19 -0
  168. package/src/lib/geojson-tiler/clip.ts +248 -0
  169. package/src/lib/geojson-tiler/convert.ts +158 -0
  170. package/src/lib/geojson-tiler/feature.ts +45 -0
  171. package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
  172. package/src/lib/geojson-tiler/simplify.ts +77 -0
  173. package/src/lib/geojson-tiler/tile.ts +185 -0
  174. package/src/lib/geojson-tiler/transform.ts +55 -0
  175. package/src/lib/geojson-tiler/wrap.ts +108 -0
  176. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
  177. package/src/lib/parse-mvt.ts +138 -93
  178. package/src/lib/types.ts +49 -72
  179. package/src/mvt-loader.ts +13 -9
  180. package/dist/bundle.js.map +0 -1
  181. package/dist/helpers/binary-util-functions.js.map +0 -1
  182. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  183. package/dist/index.js.map +0 -1
  184. package/dist/lib/binary-vector-tile/features-to-binary.js +0 -327
  185. package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
  186. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  187. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  188. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  189. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  190. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  191. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  192. package/dist/lib/parse-mvt.js.map +0 -1
  193. package/dist/lib/types.js.map +0 -1
  194. package/dist/mvt-loader.js.map +0 -1
  195. package/dist/workers/mvt-worker.js.map +0 -1
  196. package/src/lib/binary-vector-tile/features-to-binary.ts +0 -518
  197. /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  198. /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/binary-vector-tile/vector-tile-layer.ts"],"names":["VectorTileFeature","VectorTileLayer","constructor","pbf","end","version","name","extent","length","_pbf","_keys","_values","_features","readFields","readLayer","feature","i","firstPassData","Error","pos","readVarint","tag","layer","readString","push","readValueMessage","value","readFloat","readDouble","readVarint64","readSVarint","readBoolean"],"mappings":";AAGA,OAAOA,iBAAP,MAA8B,uBAA9B;AAIA,eAAe,MAAMC,eAAN,CAAsB;AASnCC,EAAAA,WAAW,CAACC,GAAD,EAAgBC,GAAhB,EAA6B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEtC,SAAKC,OAAL,GAAe,CAAf;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,MAAL,GAAc,IAAd;AACA,SAAKC,MAAL,GAAc,CAAd;AAGA,SAAKC,IAAL,GAAYN,GAAZ;AACA,SAAKO,KAAL,GAAa,EAAb;AACA,SAAKC,OAAL,GAAe,EAAf;AACA,SAAKC,SAAL,GAAiB,EAAjB;AAEAT,IAAAA,GAAG,CAACU,UAAJ,CAAeC,SAAf,EAA0B,IAA1B,EAAgCV,GAAhC;AAEA,SAAKI,MAAL,GAAc,KAAKI,SAAL,CAAeJ,MAA7B;AACD;;AASDO,EAAAA,OAAO,CAACC,CAAD,EAAYC,aAAZ,E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CAA0BtB,GAA1B,EAAyC;AACvC,MAAIuB,KAAuC,GAAG,IAA9C;AACA,QAAMtB,GAAG,GAAGD,GAAG,CAACiB,UAAJ,KAAmBjB,GAAG,CAACgB,GAAnC;;AAEA,SAAOhB,GAAG,CAACgB,GAAJ,GAAUf,GAAjB,EAAsB;AACpB,UAAMiB,GAAG,GAAGlB,GAAG,CAACiB,UAAJ,MAAoB,CAAhC;AAEAM,IAAAA,KAAK,GACHL,GAAG,KAAK,CAAR,GACIlB,GAAG,CAACoB,UAAJ,EADJ,GAEIF,GAAG,KAAK,CAAR,GACAlB,GAAG,CAACwB,SAAJ,EADA,GAEAN,GAAG,KAAK,CAAR,GACAlB,GAAG,CAACyB,UAAJ,EADA,GAEAP,GAAG,KAAK,CAAR,GACAlB,GAAG,CAAC0B,YAAJ,EADA,GAEAR,GAAG,KAAK,CAAR,GACAlB,GAAG,CAACiB,UAAJ,EADA,GAEAC,GAAG,KAAK,CAAR,GACAlB,GAAG,CAAC2B,WAAJ,EADA,GAEAT,GAAG,KAAK,CAAR,GACAlB,GAAG,CAAC4B,WAAJ,EADA,GAEA,IAfN;AAgBD;;AAED,SAAOL,KAAP;AACD","sourcesContent":["/* eslint-disable indent */\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport VectorTileFeature from './vector-tile-feature';\nimport Protobuf from 'pbf';\nimport {MvtFirstPassedData} from '../types';\n\nexport default class VectorTileLayer {\n version: number;\n name: string;\n extent: number;\n length: number;\n _pbf: Protobuf;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _features: number[];\n constructor(pbf: Protobuf, end: number) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n }\n\n /**\n * return feature `i` from this layer as a `VectorTileFeature`\n *\n * @param index\n * @param firstPassData\n * @returns {VectorTileFeature}\n */\n feature(i: number, firstPassData: MvtFirstPassedData): VectorTileFeature {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n\n this._pbf.pos = this._features[i];\n\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(\n this._pbf,\n end,\n this.extent,\n this._keys,\n this._values,\n firstPassData\n );\n }\n}\n\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag: number, layer?: VectorTileLayer, pbf?: Protobuf): void {\n if (layer && pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n }\n}\n\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf: Protobuf) {\n let value: string | number | boolean | null = null;\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n\n return value;\n}\n"],"file":"vector-tile-layer.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/binary-vector-tile/vector-tile.ts"],"names":["VectorTileLayer","VectorTile","constructor","pbf","end","layers","readFields","readTile","tag","layer","readVarint","pos","length","name"],"mappings":";AAEA,OAAOA,eAAP,MAA4B,qBAA5B;AAGA,eAAe,MAAMC,UAAN,CAAiB;AAE9BC,EAAAA,WAAW,CAACC,GAAD,EAAgBC,GAAhB,EAA8B;AAAA;;AACvC,SAAKC,MAAL,GAAcF,GAAG,CAACG,UAAJ,CAAeC,QAAf,EAAyB,EAAzB,EAA6BH,GAA7B,CAAd;AACD;;AAJ6B;;AAahC,SAASG,QAAT,CAAkBC,GAAlB,EAA+BH,MAA/B,EAAwEF,GAAxE,EAA8F;AAC5F,MAAIK,GAAG,KAAK,CAAZ,EAAe;AACb,QAAIL,GAAJ,EAAS;AACP,YAAMM,KAAK,GAAG,IAAIT,eAAJ,CAAoBG,GAApB,EAAyBA,GAAG,CAACO,UAAJ,KAAmBP,GAAG,CAACQ,GAAhD,CAAd;;AACA,UAAIF,KAAK,CAACG,MAAN,IAAgBP,MAApB,EAA4B;AAC1BA,QAAAA,MAAM,CAACI,KAAK,CAACI,IAAP,CAAN,GAAqBJ,KAArB;AACD;AACF;AACF;AACF","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport VectorTileLayer from './vector-tile-layer';\nimport Protobuf from 'pbf';\n\nexport default class VectorTile {\n layers: {[x: string]: VectorTileLayer};\n constructor(pbf: Protobuf, end?: number) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag: number, layers?: {[x: string]: VectorTileLayer}, pbf?: Protobuf): void {\n if (tag === 3) {\n if (pbf) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n"],"file":"vector-tile.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mapbox-vector-tile/vector-tile-feature.ts"],"names":["readFeature","classifyRings","VectorTileFeature","types","constructor","pbf","end","extent","keys","values","properties","type","id","_pbf","_geometry","_keys","_values","readFields","loadGeometry","pos","readVarint","cmd","length","x","y","lines","line","cmdLen","readSVarint","push","slice","Error","bbox","x1","Infinity","x2","y1","y2","_toGeoJSON","transform","coords","i","j","points","result","geometry","coordinates","toGeoJSON","options","z","size","Math","pow","x0","y0","project","p","PI","atan","exp"],"mappings":";A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","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\nimport Protobuf from 'pbf';\nimport {MvtMapboxCoordinates, MvtMapboxGeometry} from '../types';\nimport {readFeature, classifyRings} from '../../helpers/mapbox-util-functions';\n\nexport default class VectorTileFeature {\n properties: {[x: string]: string | number | boolean | null};\n extent: any;\n type: number;\n id: number | null;\n _pbf: Protobuf;\n _geometry: number;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n static get types() {\n return ['Unknown', 'Point', 'LineString', 'Polygon'];\n }\n\n constructor(\n pbf: Protobuf,\n end: number,\n extent: any,\n keys: string[],\n values: (string | number | boolean | null)[]\n ) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): MvtMapboxGeometry {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n const lines: number[][][] = [];\n let line: number[][] | undefined;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // moveTo\n if (line) lines.push(line);\n line = [];\n }\n if (line) line.push([x, y]);\n } else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (line) {\n line.push(line[0].slice()); // closePolygon\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n if (line) lines.push(line);\n\n return lines;\n }\n\n // eslint-disable-next-line max-statements\n bbox() {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n let x1 = Infinity;\n let x2 = -Infinity;\n let y1 = Infinity;\n let y2 = -Infinity;\n\n while (pbf.pos < end) {\n if (length <= 0) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n if (x < x1) x1 = x;\n if (x > x2) x2 = x;\n if (y < y1) y1 = y;\n if (y > y2) y2 = y;\n } else if (cmd !== 7) {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return [x1, y1, x2, y2];\n }\n\n _toGeoJSON(transform) {\n let coords = this.loadGeometry();\n let type = VectorTileFeature.types[this.type];\n let i: number;\n let j: number;\n\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1:\n const points: number[] = [];\n for (i = 0; i < coords.length; i++) {\n points[i] = coords[i][0];\n }\n coords = points;\n transform(coords, this);\n break;\n\n case 2:\n for (i = 0; i < coords.length; i++) {\n transform(coords[i], this);\n }\n break;\n\n case 3:\n coords = classifyRings(coords);\n for (i = 0; i < coords.length; i++) {\n for (j = 0; j < coords[i].length; j++) {\n transform(coords[i][j], this);\n }\n }\n break;\n }\n\n if (coords.length === 1) {\n coords = coords[0];\n } else {\n type = `Multi${type}`;\n }\n\n const result: MvtMapboxCoordinates = {\n type: 'Feature',\n geometry: {\n type,\n coordinates: coords\n },\n properties: this.properties\n };\n\n if (this.id !== null) {\n result.id = this.id;\n }\n\n return result;\n }\n\n toGeoJSON(\n options: {x: number; y: number; z: number} | ((data: number[], feature: {extent: any}) => void)\n ): MvtMapboxCoordinates {\n if (typeof options === 'function') {\n return this._toGeoJSON(options);\n }\n const {x, y, z} = options;\n const size = this.extent * Math.pow(2, z);\n const x0 = this.extent * x;\n const y0 = this.extent * y;\n\n function project(line: number[]) {\n for (let j = 0; j < line.length; j++) {\n const p = line[j];\n p[0] = ((p[0] + x0) * 360) / size - 180;\n const y2 = 180 - ((p[1] + y0) * 360) / size;\n p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;\n }\n }\n return this._toGeoJSON(project);\n }\n}\n"],"file":"vector-tile-feature.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mapbox-vector-tile/vector-tile-layer.ts"],"names":["VectorTileFeature","VectorTileLayer","constructor","pbf","end","version","name","extent","length","_pbf","_keys","_values","_features","readFields","readLayer","feature","i","Error","pos","readVarint","tag","layer","readString","push","readValueMessage","value","readFloat","readDouble","readVarint64","readSVarint","readBoolean"],"mappings":";AAIA,OAAOA,iBAAP,MAA8B,uBAA9B;AAEA,eAAe,MAAMC,eAAN,CAAsB;AASnCC,EAAAA,WAAW,CAACC,GAAD,EAAgBC,GAAhB,EAA6B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEtC,SAAKC,OAAL,GAAe,CAAf;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,MAAL,GAAc,IAAd;AACA,SAAKC,MAAL,GAAc,CAAd;AAGA,SAAKC,IAAL,GAAYN,GAAZ;AACA,SAAKO,KAAL,GAAa,EAAb;AACA,SAAKC,OAAL,GAAe,EAAf;AACA,SAAKC,SAAL,GAAiB,EAAjB;AAEAT,IAAAA,GAAG,CAACU,UAAJ,CAAeC,SAAf,EAA0B,IAA1B,EAAgCV,GAAhC;AAEA,SAAKI,MAAL,GAAc,KAAKI,SAAL,CAAeJ,MAA7B;AACD;;AAQDO,EAAAA,OAAO,CAACC,CAAD,EAA+B;AACpC,QAAIA,CAAC,GAAG,CAAJ,IAASA,CAAC,IAAI,KAAKJ,SAAL,CAAeJ,MAAjC,EAAyC;AACvC,YAAM,IAAIS,KAAJ,CAAU,6BAAV,CAAN;AACD;;AAED,SAAKR,IAAL,CAAUS,GAAV,GAAgB,KAAKN,SAAL,CAAeI,CAAf,CAAhB;;AAEA,UAAMZ,GAAG,G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J,MAAoB,CAAhC;AAEAM,IAAAA,KAAK,GACHL,GAAG,KAAK,CAAR,GACIjB,GAAG,CAACmB,UAAJ,EADJ,GAEIF,GAAG,KAAK,CAAR,GACAjB,GAAG,CAACuB,SAAJ,EADA,GAEAN,GAAG,KAAK,CAAR,GACAjB,GAAG,CAACwB,UAAJ,EADA,GAEAP,GAAG,KAAK,CAAR,GACAjB,GAAG,CAACyB,YAAJ,EADA,GAEAR,GAAG,KAAK,CAAR,GACAjB,GAAG,CAACgB,UAAJ,EADA,GAEAC,GAAG,KAAK,CAAR,GACAjB,GAAG,CAAC0B,WAAJ,EADA,GAEAT,GAAG,KAAK,CAAR,GACAjB,GAAG,CAAC2B,WAAJ,EADA,GAEA,IAfN;AAgBD;;AAED,SAAOL,KAAP;AACD","sourcesContent":["/* eslint-disable indent */\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport VectorTileFeature from './vector-tile-feature';\n\nexport default class VectorTileLayer {\n version: number;\n name: string;\n extent: number;\n length: number;\n _pbf: Protobuf;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _features: number[];\n constructor(pbf: Protobuf, end: number) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n }\n\n /**\n * return feature `i` from this layer as a `VectorTileFeature`\n * @param index\n * @returns feature\n */\n\n feature(i: number): VectorTileFeature {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n\n this._pbf.pos = this._features[i];\n\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);\n }\n}\n\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag: number, layer?: VectorTileLayer, pbf?: Protobuf): void {\n if (layer && pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n }\n}\n\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf: Protobuf) {\n let value: string | number | boolean | null = null;\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n\n return value;\n}\n"],"file":"vector-tile-layer.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/mapbox-vector-tile/vector-tile.ts"],"names":["VectorTileLayer","VectorTile","constructor","pbf","end","layers","readFields","readTile","tag","layer","readVarint","pos","length","name"],"mappings":";AAEA,OAAOA,eAAP,MAA4B,qBAA5B;AAGA,eAAe,MAAMC,UAAN,CAAiB;AAE9BC,EAAAA,WAAW,CAACC,GAAD,EAAgBC,GAAhB,EAA8B;AAAA;;AACvC,SAAKC,MAAL,GAAcF,GAAG,CAACG,UAAJ,CAAeC,QAAf,EAAyB,EAAzB,EAA6BH,GAA7B,CAAd;AACD;;AAJ6B;;AAahC,SAASG,QAAT,CAAkBC,GAAlB,EAA+BH,MAA/B,EAAwEF,GAAxE,EAA8F;AAC5F,MAAIK,GAAG,KAAK,CAAZ,EAAe;AACb,QAAIL,GAAJ,EAAS;AACP,YAAMM,KAAK,GAAG,IAAIT,eAAJ,CAAoBG,GAApB,EAAyBA,GAAG,CAACO,UAAJ,KAAmBP,GAAG,CAACQ,GAAhD,CAAd;;AACA,UAAIF,KAAK,CAACG,MAAN,IAAgBP,MAApB,EAA4B;AAC1BA,QAAAA,MAAM,CAACI,KAAK,CAACI,IAAP,CAAN,GAAqBJ,KAArB;AACD;AACF;AACF;AACF","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport VectorTileLayer from './vector-tile-layer';\nimport Protobuf from 'pbf';\n\nexport default class VectorTile {\n layers: {[x: string]: VectorTileLayer};\n constructor(pbf: Protobuf, end?: number) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag: number, layers?: {[x: string]: VectorTileLayer}, pbf?: Protobuf): void {\n if (tag === 3) {\n if (pbf) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n"],"file":"vector-tile.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/lib/parse-mvt.ts"],"names":["VectorTile","BinaryVectorTile","featuresToBinary","Protobuf","parseMVT","arrayBuffer","options","normalizeOptions","features","binary","gis","format","firstPassData","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","byteLength","tile","loaderOptions","mvt","selectedLayers","Array","isArray","layers","Object","keys","forEach","layerName","vectorTileLayer","featureOptions","i","length","vectorTileFeature","feature","decodedFeature","getDecodedFeatureBinary","getDecodedFeature","push","data","wgs84Coordinates","coordinates","tileIndex","hasTileIndex","Number","isFinite","x","y","z","Error","toGeoJSON","transformToLocalCoordinates","layerProperty","properties","toBinaryCoordinates","transformToLocalCoordinatesBinary","line","extent","p","il"],"mappings":"AACA,OAAOA,UAAP,MAAuB,kCAAvB;AACA,OAAOC,gBAAP,MAA6B,kCAA7B;AAEA,SAAQC,gBAAR,QAA+B,yCAA/B;AACA,OAAOC,QAAP,MAAqB,KAArB;AAaA,eAA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CAA2ChB,IAA3C,EAA2DL,OAA3D,EAAmF;AAGjF,QAAM;AAACuB,IAAAA;AAAD,MAAWvB,OAAjB;;AACA,OAAK,IAAIH,CAAC,GAAG,CAAR,EAAW4B,EAAE,GAAGpB,IAAI,CAACP,MAA1B,EAAkCD,CAAC,GAAG4B,EAAtC,EAA0C,EAAE5B,CAA5C,EAA+C;AAC7CQ,IAAAA,IAAI,CAACR,CAAD,CAAJ,IAAW0B,MAAX;AACD;AACF","sourcesContent":["// import {VectorTile} from '@mapbox/vector-tile';\nimport VectorTile from './mapbox-vector-tile/vector-tile';\nimport BinaryVectorTile from './binary-vector-tile/vector-tile';\n\nimport {featuresToBinary} from './binary-vector-tile/features-to-binary';\nimport Protobuf from 'pbf';\nimport {MvtBinaryCoordinates, MvtMapboxCoordinates, MvtOptions} from '../lib/types';\nimport VectorTileFeatureBinary from './binary-vector-tile/vector-tile-feature';\nimport VectorTileFeatureMapBox from './mapbox-vector-tile/vector-tile-feature';\nimport {LoaderOptions} from '@loaders.gl/loader-utils/';\n\n/**\n * Parse MVT arrayBuffer and return GeoJSON.\n *\n * @param arrayBuffer A MVT arrayBuffer\n * @param options\n * @returns A GeoJSON geometry object or a binary representation\n */\nexport default function parseMVT(arrayBuffer: ArrayBuffer, options?: LoaderOptions) {\n options = normalizeOptions(options);\n const features: (MvtBinaryCoordinates | MvtMapboxCoordinates)[] = [];\n\n if (options) {\n const binary = options.gis.format === 'binary';\n const firstPassData = {\n pointPositionsCount: 0,\n pointFeaturesCount: 0,\n linePositionsCount: 0,\n linePathsCount: 0,\n lineFeaturesCount: 0,\n polygonPositionsCount: 0,\n polygonObjectsCount: 0,\n polygonRingsCount: 0,\n polygonFeaturesCount: 0\n };\n\n if (arrayBuffer.byteLength > 0) {\n const tile = binary\n ? new BinaryVectorTile(new Protobuf(arrayBuffer))\n : new VectorTile(new Protobuf(arrayBuffer));\n const loaderOptions = options.mvt;\n\n const selectedLayers = Array.isArray(loaderOptions.layers)\n ? loaderOptions.layers\n : Object.keys(tile.layers);\n\n selectedLayers.forEach((layerName: string) => {\n const vectorTileLayer = tile.layers[layerName];\n const featureOptions = {...loaderOptions, layerName};\n\n if (!vectorTileLayer) {\n return;\n }\n\n for (let i = 0; i < vectorTileLayer.length; i++) {\n const vectorTileFeature = vectorTileLayer.feature(i, firstPassData);\n\n const decodedFeature = binary\n ? getDecodedFeatureBinary(vectorTileFeature as VectorTileFeatureBinary, featureOptions)\n : getDecodedFeature(vectorTileFeature as VectorTileFeatureMapBox, featureOptions);\n features.push(decodedFeature);\n }\n });\n }\n\n if (binary) {\n const data = featuresToBinary(features as MvtBinaryCoordinates[], firstPassData);\n // Add the original byteLength (as a reasonable approximation of the size of the binary data)\n // TODO decide where to store extra fields like byteLength (header etc) and document\n // @ts-ignore\n data.byteLength = arrayBuffer.byteLength;\n return data;\n }\n }\n return features;\n}\n\n/**\n * @param options\n * @returns options\n */\nfunction normalizeOptions(options: LoaderOptions | undefined) {\n if (options) {\n options = {\n ...options,\n mvt: options.mvt || {},\n gis: options.gis || {}\n };\n\n // Validate\n const wgs84Coordinates = options.coordinates === 'wgs84';\n const {tileIndex} = options;\n const hasTileIndex =\n tileIndex &&\n Number.isFinite(tileIndex.x) &&\n Number.isFinite(tileIndex.y) &&\n Number.isFinite(tileIndex.z);\n\n if (wgs84Coordinates && !hasTileIndex) {\n throw new Error(\n 'MVT Loader: WGS84 coordinates need tileIndex property. Check documentation.'\n );\n }\n }\n return options;\n}\n\n/**\n * @param feature\n * @param options\n * @returns decoded feature\n */\nfunction getDecodedFeature(\n feature: VectorTileFeatureMapBox,\n options: MvtOptions\n): MvtMapboxCoordinates {\n const decodedFeature = feature.toGeoJSON(\n options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinates\n );\n\n // Add layer name to GeoJSON properties\n if (options.layerProperty) {\n decodedFeature.properties[options.layerProperty] = options.layerName;\n }\n\n return decodedFeature;\n}\n\n/**\n * @param feature\n * @param options\n * @returns decoded binary feature\n */\nfunction getDecodedFeatureBinary(\n feature: VectorTileFeatureBinary,\n options: MvtOptions\n): MvtBinaryCoordinates {\n const decodedFeature = feature.toBinaryCoordinates(\n options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinatesBinary\n );\n\n // Add layer name to GeoJSON properties\n if (options.layerProperty) {\n decodedFeature.properties[options.layerProperty] = options.layerName;\n }\n\n return decodedFeature;\n}\n\n/**\n * @param line\n * @param feature\n */\nfunction transformToLocalCoordinates(line: number[], feature: {extent: any}): void {\n // This function transforms local coordinates in a\n // [0 - bufferSize, this.extent + bufferSize] range to a\n // [0 - (bufferSize / this.extent), 1 + (bufferSize / this.extent)] range.\n // The resulting extent would be 1.\n const {extent} = feature;\n for (let i = 0; i < line.length; i++) {\n const p = line[i];\n p[0] /= extent;\n p[1] /= extent;\n }\n}\n\nfunction transformToLocalCoordinatesBinary(data: number[], feature: {extent: any}) {\n // For the binary code path, the feature data is just\n // one big flat array, so we just divide each value\n const {extent} = feature;\n for (let i = 0, il = data.length; i < il; ++i) {\n data[i] /= extent;\n }\n}\n"],"file":"parse-mvt.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/mvt-loader.ts"],"names":["parseMVT","VERSION","MVTWorkerLoader","name","id","module","version","extensions","mimeTypes","worker","category","options","mvt","coordinates","layerProperty","layers","tileIndex","MVTLoader","parse","arrayBuffer","parseSync","binary"],"mappings":"AACA,OAAOA,QAAP,MAAqB,iBAArB;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAKA,OAAO,MAAMC,eAAuB,GAAG;AACrCC,EAAAA,IAAI,EAAE,oBAD+B;AAErCC,EAAAA,EAAE,EAAE,KAFiC;AAGrCC,EAAAA,MAAM,EAAE,KAH6B;AAIrCC,EAAAA,OAAO,EAAEL,OAJ4B;AAMrCM,EAAAA,UAAU,EAAE,CAAC,KAAD,EAAQ,KAAR,CANyB;AAOrCC,EAAAA,SAAS,EAAE,CACT,oCADS,EAET,wBAFS,CAP0B;AAYrCC,EAAAA,MAAM,EAAE,IAZ6B;AAarCC,EAAAA,QAAQ,EAAE,UAb2B;AAcrCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,GAAG,EAAE;AACHC,MAAAA,WAAW,EAAE,OADV;AAEHC,MAAAA,aAAa,EAAE,WAFZ;AAGHC,MAAAA,MAAM,EAAE,IAHL;AAIHC,MAAAA,SAAS,EAAE;AAJR;AADE;AAd4B,CAAhC;AA2BP,OAAO,MAAMC,SAA2B,GAAG,EACzC,GAAGf,eADsC;AAEzCgB,EAAAA,KAAK,EAAE,OAAOC,WAAP,EAAoBR,OAApB,KAAgCX,QAAQ,CAACmB,WAAD,EAAcR,OAAd,CAFN;AAGzCS,EAAAA,SAAS,EAAEpB,QAH8B;AAIzCqB,EAAAA,MAAM,EAAE;AAJiC,CAApC","sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport parseMVT from './lib/parse-mvt';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Worker loader for the Mapbox Vector Tile format\n */\nexport const MVTWorkerLoader: Loader = {\n name: 'Mapbox Vector Tile',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'\n extensions: ['mvt', 'pbf'],\n mimeTypes: [\n 'application/vnd.mapbox-vector-tile',\n 'application/x-protobuf'\n // 'application/octet-stream'\n ],\n worker: true,\n category: 'geometry',\n options: {\n mvt: {\n coordinates: 'local',\n layerProperty: 'layerName',\n layers: null,\n tileIndex: null\n }\n }\n};\n\n/**\n * Loader for the Mapbox Vector Tile format\n */\nexport const MVTLoader: LoaderWithParser = {\n ...MVTWorkerLoader,\n parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),\n parseSync: parseMVT,\n binary: true\n};\n"],"file":"mvt-loader.js"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/workers/mvt-worker.ts"],"names":["MVTLoader","createLoaderWorker"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,eAAxB;AACA,SAAQC,kBAAR,QAAiC,0BAAjC;AAEAA,kBAAkB,CAACD,SAAD,CAAlB","sourcesContent":["import {MVTLoader} from '../mvt-loader';\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\n\ncreateLoaderWorker(MVTLoader);\n"],"file":"mvt-worker.js"}
@@ -1,518 +0,0 @@
1
- /* eslint-disable indent */
2
- import {earcut} from '@math.gl/polygon';
3
- import {
4
- MvtBinaryCoordinates,
5
- MvtBinaryGeometry,
6
- MvtBinaryOptions,
7
- MvtFirstPassedData,
8
- MvtLines,
9
- MvtPoints,
10
- MvtPolygons
11
- } from '../types';
12
-
13
- /**
14
- * Convert binary features to flat binary arrays. Similar to
15
- * `geojsonToBinary` helper function, except that it expects
16
- * a binary representation of the feature data, which enables
17
- * 2X-3X speed increase in parse speed, compared to using
18
- * geoJSON. See `binary-vector-tile/VectorTileFeature` for
19
- * data format detais
20
- *
21
- * @param features
22
- * @param firstPassData
23
- * @param options
24
- * @returns filled arrays
25
- */
26
- export function featuresToBinary(
27
- features: MvtBinaryCoordinates[],
28
- firstPassData: MvtFirstPassedData,
29
- options?: MvtBinaryOptions
30
- ) {
31
- return fillArrays(features, firstPassData, {
32
- numericPropKeys: options ? options.numericPropKeys : extractNumericPropKeys(features),
33
- PositionDataType: options ? options.PositionDataType : Float32Array
34
- });
35
- }
36
-
37
- export const TEST_EXPORTS = {
38
- extractNumericPropKeys,
39
- fillArrays
40
- };
41
-
42
- /**
43
- * Extracts properties that are always numeric
44
- *
45
- * @param features
46
- * @returns object with numeric keys
47
- */
48
- function extractNumericPropKeys(features: MvtBinaryCoordinates[]): string[] {
49
- const numericPropKeys = {};
50
- for (const feature of features) {
51
- if (feature.properties) {
52
- for (const key in feature.properties) {
53
- // If property has not been seen before, or if property has been numeric
54
- // in all previous features, check if numeric in this feature
55
- // If not numeric, false is stored to prevent rechecking in the future
56
- const numericSoFar = numericPropKeys[key];
57
- if (numericSoFar || numericSoFar === undefined) {
58
- const val = feature.properties[key];
59
- numericPropKeys[key] = isNumeric(val);
60
- }
61
- }
62
- }
63
- }
64
-
65
- return Object.keys(numericPropKeys).filter((k) => numericPropKeys[k]);
66
- }
67
-
68
- /**
69
- * Fills coordinates into pre-allocated typed arrays
70
- *
71
- * @param features
72
- * @param firstPassData
73
- * @param options
74
- * @returns an accessor object with value and size keys
75
- */
76
- // eslint-disable-next-line complexity
77
- function fillArrays(
78
- features: MvtBinaryCoordinates[],
79
- firstPassData: MvtFirstPassedData,
80
- options: MvtBinaryOptions
81
- ) {
82
- const {
83
- pointPositionsCount,
84
- pointFeaturesCount,
85
- linePositionsCount,
86
- linePathsCount,
87
- lineFeaturesCount,
88
- polygonPositionsCount,
89
- polygonObjectsCount,
90
- polygonRingsCount,
91
- polygonFeaturesCount
92
- } = firstPassData;
93
- const {numericPropKeys, PositionDataType = Float32Array} = options;
94
- const hasGlobalId = features[0] && 'id' in features[0];
95
- const coordLength = 2;
96
- const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
97
- const points: MvtPoints = {
98
- positions: new PositionDataType(pointPositionsCount * coordLength),
99
- globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
100
- featureIds:
101
- pointFeaturesCount > 65535
102
- ? new Uint32Array(pointPositionsCount)
103
- : new Uint16Array(pointPositionsCount),
104
- numericProps: {},
105
- properties: [],
106
- fields: []
107
- };
108
- const lines: MvtLines = {
109
- pathIndices:
110
- linePositionsCount > 65535
111
- ? new Uint32Array(linePathsCount + 1)
112
- : new Uint16Array(linePathsCount + 1),
113
- positions: new PositionDataType(linePositionsCount * coordLength),
114
- globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
115
- featureIds:
116
- lineFeaturesCount > 65535
117
- ? new Uint32Array(linePositionsCount)
118
- : new Uint16Array(linePositionsCount),
119
- numericProps: {},
120
- properties: [],
121
- fields: []
122
- };
123
- const polygons: MvtPolygons = {
124
- polygonIndices:
125
- polygonPositionsCount > 65535
126
- ? new Uint32Array(polygonObjectsCount + 1)
127
- : new Uint16Array(polygonObjectsCount + 1),
128
- primitivePolygonIndices:
129
- polygonPositionsCount > 65535
130
- ? new Uint32Array(polygonRingsCount + 1)
131
- : new Uint16Array(polygonRingsCount + 1),
132
- positions: new PositionDataType(polygonPositionsCount * coordLength),
133
- triangles: [],
134
- globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
135
- featureIds:
136
- polygonFeaturesCount > 65535
137
- ? new Uint32Array(polygonPositionsCount)
138
- : new Uint16Array(polygonPositionsCount),
139
- numericProps: {},
140
- properties: [],
141
- fields: []
142
- };
143
-
144
- // Instantiate numeric properties arrays; one value per vertex
145
- for (const object of [points, lines, polygons]) {
146
- for (const propName of numericPropKeys) {
147
- // If property has been numeric in all previous features in which the property existed, check
148
- // if numeric in this feature
149
- object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
150
- }
151
- }
152
-
153
- // Set last element of path/polygon indices as positions length
154
- lines.pathIndices[linePathsCount] = linePositionsCount;
155
- polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
156
- polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
157
-
158
- const indexMap = {
159
- pointPosition: 0,
160
- pointFeature: 0,
161
- linePosition: 0,
162
- linePath: 0,
163
- lineFeature: 0,
164
- polygonPosition: 0,
165
- polygonObject: 0,
166
- polygonRing: 0,
167
- polygonFeature: 0,
168
- feature: 0
169
- };
170
-
171
- for (const feature of features) {
172
- const geometry = feature.geometry;
173
- const properties = feature.properties || {};
174
-
175
- switch (geometry.type) {
176
- case 'Point':
177
- case 'MultiPoint':
178
- handlePoint(geometry, points, indexMap, coordLength, properties);
179
- points.properties.push(keepStringProperties(properties, numericPropKeys));
180
- if (hasGlobalId) {
181
- points.fields.push({id: feature.id});
182
- }
183
- indexMap.pointFeature++;
184
- break;
185
- case 'LineString':
186
- case 'MultiLineString':
187
- handleLineString(geometry, lines, indexMap, coordLength, properties);
188
- lines.properties.push(keepStringProperties(properties, numericPropKeys));
189
- if (hasGlobalId) {
190
- lines.fields.push({id: feature.id});
191
- }
192
- indexMap.lineFeature++;
193
- break;
194
- case 'Polygon':
195
- case 'MultiPolygon':
196
- handlePolygon(geometry, polygons, indexMap, coordLength, properties);
197
- polygons.properties.push(keepStringProperties(properties, numericPropKeys));
198
- if (hasGlobalId) {
199
- polygons.fields.push({id: feature.id});
200
- }
201
- indexMap.polygonFeature++;
202
- break;
203
- default:
204
- throw new Error('Invalid geometry type');
205
- }
206
-
207
- indexMap.feature++;
208
- }
209
-
210
- // Wrap each array in an accessor object with value and size keys
211
- return makeAccessorObjects(points, lines, polygons, coordLength);
212
- }
213
-
214
- /**
215
- * Fills (Multi)Point coordinates into points object of arrays
216
- *
217
- * @param geometry
218
- * @param points
219
- * @param indexMap
220
- * @param coordLength
221
- * @param properties
222
- */
223
- function handlePoint(
224
- geometry: MvtBinaryGeometry,
225
- points: MvtPoints,
226
- indexMap: {
227
- pointPosition: number;
228
- pointFeature: number;
229
- linePosition?: number;
230
- linePath?: number;
231
- lineFeature?: number;
232
- polygonPosition?: number;
233
- polygonObject?: number;
234
- polygonRing?: number;
235
- polygonFeature?: number;
236
- feature: number;
237
- },
238
- coordLength: number,
239
- properties: {[x: string]: string | number | boolean | null}
240
- ): void {
241
- points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
242
-
243
- const nPositions = geometry.data.length / coordLength;
244
- fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
245
- points.globalFeatureIds.fill(
246
- indexMap.feature,
247
- indexMap.pointPosition,
248
- indexMap.pointPosition + nPositions
249
- );
250
- points.featureIds.fill(
251
- indexMap.pointFeature,
252
- indexMap.pointPosition,
253
- indexMap.pointPosition + nPositions
254
- );
255
-
256
- indexMap.pointPosition += nPositions;
257
- }
258
-
259
- /**
260
- * Fills (Multi)LineString coordinates into lines object of arrays
261
- *
262
- * @param geometry
263
- * @param lines
264
- * @param indexMap
265
- * @param coordLength
266
- * @param properties
267
- */
268
- function handleLineString(
269
- geometry: MvtBinaryGeometry,
270
- lines: MvtLines,
271
- indexMap: {
272
- pointPosition?: number;
273
- pointFeature?: number;
274
- linePosition: number;
275
- linePath: number;
276
- lineFeature: number;
277
- polygonPosition?: number;
278
- polygonObject?: number;
279
- polygonRing?: number;
280
- polygonFeature?: number;
281
- feature: number;
282
- },
283
- coordLength: number,
284
- properties: {[x: string]: string | number | boolean | null}
285
- ): void {
286
- lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
287
-
288
- const nPositions = geometry.data.length / coordLength;
289
- fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
290
-
291
- lines.globalFeatureIds.fill(
292
- indexMap.feature,
293
- indexMap.linePosition,
294
- indexMap.linePosition + nPositions
295
- );
296
- lines.featureIds.fill(
297
- indexMap.lineFeature,
298
- indexMap.linePosition,
299
- indexMap.linePosition + nPositions
300
- );
301
-
302
- for (let i = 0, il = geometry.lines.length; i < il; ++i) {
303
- // Extract range of data we are working with, defined by start
304
- // and end indices (these index into the geometry.data array)
305
- const start = geometry.lines[i];
306
- const end =
307
- i === il - 1
308
- ? geometry.data.length // last line, so read to end of data
309
- : geometry.lines[i + 1]; // start index for next line
310
-
311
- lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
312
- indexMap.linePosition += (end - start) / coordLength;
313
- }
314
- }
315
-
316
- /**
317
- * Fills (Multi)Polygon coordinates into polygons object of arrays
318
- *
319
- * @param geometry
320
- * @param polygons
321
- * @param indexMap
322
- * @param coordLength
323
- * @param properties
324
- */
325
- function handlePolygon(
326
- geometry: MvtBinaryGeometry,
327
- polygons: MvtPolygons,
328
- indexMap: {
329
- pointPosition?: number;
330
- pointFeature?: number;
331
- linePosition?: number;
332
- linePath?: number;
333
- lineFeature?: number;
334
- polygonPosition: number;
335
- polygonObject: number;
336
- polygonRing: number;
337
- polygonFeature: number;
338
- feature: number;
339
- },
340
- coordLength: number,
341
- properties: {[x: string]: string | number | boolean | null}
342
- ): void {
343
- polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
344
-
345
- const nPositions = geometry.data.length / coordLength;
346
- fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
347
- polygons.globalFeatureIds.fill(
348
- indexMap.feature,
349
- indexMap.polygonPosition,
350
- indexMap.polygonPosition + nPositions
351
- );
352
- polygons.featureIds.fill(
353
- indexMap.polygonFeature,
354
- indexMap.polygonPosition,
355
- indexMap.polygonPosition + nPositions
356
- );
357
-
358
- // Unlike Point & LineString geometry.lines is a 2D array
359
- for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {
360
- const startPosition = indexMap.polygonPosition;
361
- polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
362
-
363
- const areas = geometry.areas![l];
364
- const lines = geometry.lines[l];
365
- const nextLines = geometry.lines[l + 1];
366
-
367
- for (let i = 0, il = lines.length; i < il; ++i) {
368
- const start = lines[i];
369
- const end =
370
- i === il - 1
371
- ? // last line, so either read to:
372
- nextLines === undefined
373
- ? geometry.data.length // end of data (no next lines)
374
- : nextLines[0] // start of first line in nextLines
375
- : lines[i + 1]; // start index for next line
376
-
377
- polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
378
- indexMap.polygonPosition += (end - start) / coordLength;
379
- }
380
-
381
- const endPosition = indexMap.polygonPosition;
382
- triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength});
383
- }
384
- }
385
-
386
- /**
387
- * Triangulate polygon using earcut
388
- *
389
- * @param polygons
390
- * @param areas
391
- * @param lines
392
- * @param param3
393
- */
394
- function triangulatePolygon(
395
- polygons: MvtPolygons,
396
- areas: number,
397
- lines: number[],
398
- {
399
- startPosition,
400
- endPosition,
401
- coordLength
402
- }: {startPosition: number; endPosition: number; coordLength: number}
403
- ): void {
404
- const start = startPosition * coordLength;
405
- const end = endPosition * coordLength;
406
-
407
- // Extract positions and holes for just this polygon
408
- const polygonPositions = polygons.positions.subarray(start, end);
409
-
410
- // Holes are referenced relative to outer polygon
411
- const offset = lines[0];
412
- const holes = lines.slice(1).map((n: number) => (n - offset) / coordLength);
413
-
414
- // Compute triangulation
415
- const indices = earcut(polygonPositions, holes, coordLength, areas);
416
-
417
- // Indices returned by triangulation are relative to start
418
- // of polygon, so we need to offset
419
- for (let t = 0, tl = indices.length; t < tl; ++t) {
420
- polygons.triangles.push(startPosition + indices[t]);
421
- }
422
- }
423
-
424
- /**
425
- * Wrap each array in an accessor object with value and size keys
426
- *
427
- * @param points
428
- * @param lines
429
- * @param polygons
430
- * @param coordLength
431
- * @returns object
432
- */
433
- function makeAccessorObjects(
434
- points: MvtPoints,
435
- lines: MvtLines,
436
- polygons: MvtPolygons,
437
- coordLength: number
438
- ) {
439
- const returnObj = {
440
- points: {
441
- ...points,
442
- positions: {value: points.positions, size: coordLength},
443
- globalFeatureIds: {value: points.globalFeatureIds, size: 1},
444
- featureIds: {value: points.featureIds, size: 1}
445
- },
446
- lines: {
447
- ...lines,
448
- pathIndices: {value: lines.pathIndices, size: 1},
449
- positions: {value: lines.positions, size: coordLength},
450
- globalFeatureIds: {value: lines.globalFeatureIds, size: 1},
451
- featureIds: {value: lines.featureIds, size: 1}
452
- },
453
- polygons: {
454
- ...polygons,
455
- polygonIndices: {value: polygons.polygonIndices, size: 1},
456
- primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},
457
- positions: {value: polygons.positions, size: coordLength},
458
- triangles: {value: new Uint32Array(polygons.triangles), size: 1},
459
- globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},
460
- featureIds: {value: polygons.featureIds, size: 1}
461
- }
462
- };
463
-
464
- for (const geomType in returnObj) {
465
- for (const numericProp in returnObj[geomType].numericProps) {
466
- returnObj[geomType].numericProps[numericProp] = {
467
- value: returnObj[geomType].numericProps[numericProp],
468
- size: 1
469
- };
470
- }
471
- }
472
- return returnObj;
473
- }
474
-
475
- /**
476
- * Add numeric properties to object
477
- *
478
- * @param object
479
- * @param properties
480
- * @param index
481
- * @param length
482
- */
483
- function fillNumericProperties(
484
- object: MvtPoints,
485
- properties: {[x: string]: string | number | boolean | null},
486
- index: number,
487
- length: number
488
- ): void {
489
- for (const numericPropName in object.numericProps) {
490
- if (numericPropName in properties) {
491
- object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
492
- }
493
- }
494
- }
495
-
496
- /**
497
- * Keep string properties in object
498
- *
499
- * @param properties
500
- * @param numericKeys
501
- * @returns object
502
- */
503
- function keepStringProperties(
504
- properties: {[x: string]: string | number | boolean | null},
505
- numericKeys: string[]
506
- ) {
507
- const props = {};
508
- for (const key in properties) {
509
- if (!numericKeys.includes(key)) {
510
- props[key] = properties[key];
511
- }
512
- }
513
- return props;
514
- }
515
-
516
- function isNumeric(x: unknown) {
517
- return Number.isFinite(x);
518
- }