@loaders.gl/mvt 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (175) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dist.min.js +1748 -913
  3. package/dist/es5/bundle.js +6 -0
  4. package/dist/es5/bundle.js.map +1 -0
  5. package/dist/es5/helpers/binary-util-functions.js +82 -0
  6. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  7. package/dist/es5/helpers/mapbox-util-functions.js +50 -0
  8. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  9. package/dist/es5/index.js +26 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -0
  12. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +62 -0
  14. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  15. package/dist/es5/lib/binary-vector-tile/vector-tile.js +28 -0
  16. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  17. package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
  18. package/dist/es5/lib/geojson-tiler/clip.js +237 -0
  19. package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
  20. package/dist/es5/lib/geojson-tiler/convert.js +161 -0
  21. package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
  22. package/dist/es5/lib/geojson-tiler/feature.js +62 -0
  23. package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
  24. package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
  25. package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  26. package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
  27. package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
  28. package/dist/es5/lib/geojson-tiler/tile.js +121 -0
  29. package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
  30. package/dist/es5/lib/geojson-tiler/transform.js +50 -0
  31. package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
  32. package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
  33. package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
  34. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -0
  35. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  36. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +62 -0
  37. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  38. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +28 -0
  39. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  40. package/dist/es5/lib/parse-mvt.js +143 -0
  41. package/dist/es5/lib/parse-mvt.js.map +1 -0
  42. package/dist/es5/lib/types.js +2 -0
  43. package/dist/es5/lib/types.js.map +1 -0
  44. package/dist/es5/mvt-loader.js +58 -0
  45. package/dist/es5/mvt-loader.js.map +1 -0
  46. package/dist/es5/workers/mvt-worker.js +6 -0
  47. package/dist/es5/workers/mvt-worker.js.map +1 -0
  48. package/dist/esm/bundle.js +4 -0
  49. package/dist/esm/bundle.js.map +1 -0
  50. package/dist/esm/helpers/binary-util-functions.js +73 -0
  51. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  52. package/dist/esm/helpers/mapbox-util-functions.js +41 -0
  53. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  54. package/dist/esm/index.js +3 -0
  55. package/dist/esm/index.js.map +1 -0
  56. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  57. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +136 -0
  58. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  59. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +47 -0
  60. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  61. package/dist/esm/lib/binary-vector-tile/vector-tile.js +19 -0
  62. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  63. package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
  64. package/dist/esm/lib/geojson-tiler/clip.js +173 -0
  65. package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
  66. package/dist/esm/lib/geojson-tiler/convert.js +116 -0
  67. package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
  68. package/dist/esm/lib/geojson-tiler/feature.js +35 -0
  69. package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
  70. package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
  71. package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
  72. package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
  73. package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
  74. package/dist/esm/lib/geojson-tiler/tile.js +103 -0
  75. package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
  76. package/dist/esm/lib/geojson-tiler/transform.js +32 -0
  77. package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
  78. package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
  79. package/dist/esm/lib/geojson-tiler/wrap.js.map +1 -0
  80. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  81. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +163 -0
  82. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  83. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +47 -0
  84. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  85. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +19 -0
  86. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  87. package/dist/esm/lib/parse-mvt.js +138 -0
  88. package/dist/esm/lib/parse-mvt.js.map +1 -0
  89. package/dist/esm/lib/types.js +2 -0
  90. package/dist/esm/lib/types.js.map +1 -0
  91. package/dist/esm/mvt-loader.js +29 -0
  92. package/dist/esm/mvt-loader.js.map +1 -0
  93. package/dist/esm/workers/mvt-worker.js +4 -0
  94. package/dist/esm/workers/mvt-worker.js.map +1 -0
  95. package/dist/helpers/binary-util-functions.js +111 -77
  96. package/dist/helpers/mapbox-util-functions.d.ts +2 -2
  97. package/dist/helpers/mapbox-util-functions.js +78 -45
  98. package/dist/index.d.ts +2 -0
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +9 -2
  101. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
  102. package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -143
  103. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
  104. package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
  105. package/dist/lib/geojson-tiler/clip.d.ts +16 -0
  106. package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
  107. package/dist/lib/geojson-tiler/clip.js +209 -0
  108. package/dist/lib/geojson-tiler/convert.d.ts +10 -0
  109. package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
  110. package/dist/lib/geojson-tiler/convert.js +134 -0
  111. package/dist/lib/geojson-tiler/feature.d.ts +3 -0
  112. package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
  113. package/dist/lib/geojson-tiler/feature.js +46 -0
  114. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
  115. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
  116. package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
  117. package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
  118. package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
  119. package/dist/lib/geojson-tiler/simplify.js +68 -0
  120. package/dist/lib/geojson-tiler/tile.d.ts +38 -0
  121. package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
  122. package/dist/lib/geojson-tiler/tile.js +125 -0
  123. package/dist/lib/geojson-tiler/transform.d.ts +7 -0
  124. package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
  125. package/dist/lib/geojson-tiler/transform.js +43 -0
  126. package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
  127. package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
  128. package/dist/lib/geojson-tiler/wrap.js +86 -0
  129. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +4 -4
  130. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
  131. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
  132. package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
  133. package/dist/lib/parse-mvt.d.ts +6 -9
  134. package/dist/lib/parse-mvt.d.ts.map +1 -1
  135. package/dist/lib/parse-mvt.js +148 -98
  136. package/dist/lib/types.d.ts +48 -7
  137. package/dist/lib/types.d.ts.map +1 -1
  138. package/dist/lib/types.js +2 -2
  139. package/dist/mvt-loader.d.ts.map +1 -1
  140. package/dist/mvt-loader.js +43 -22
  141. package/dist/mvt-worker.js +903 -829
  142. package/dist/workers/mvt-worker.js +5 -4
  143. package/package.json +7 -7
  144. package/src/helpers/mapbox-util-functions.ts +2 -2
  145. package/src/index.ts +7 -0
  146. package/src/lib/binary-vector-tile/vector-tile-feature.ts +6 -1
  147. package/src/lib/geojson-tiler/LICENSE +19 -0
  148. package/src/lib/geojson-tiler/clip.ts +248 -0
  149. package/src/lib/geojson-tiler/convert.ts +158 -0
  150. package/src/lib/geojson-tiler/feature.ts +45 -0
  151. package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
  152. package/src/lib/geojson-tiler/simplify.ts +77 -0
  153. package/src/lib/geojson-tiler/tile.ts +185 -0
  154. package/src/lib/geojson-tiler/transform.ts +55 -0
  155. package/src/lib/geojson-tiler/wrap.ts +108 -0
  156. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
  157. package/src/lib/parse-mvt.ts +136 -93
  158. package/src/lib/types.ts +53 -7
  159. package/src/mvt-loader.ts +13 -9
  160. package/dist/bundle.js.map +0 -1
  161. package/dist/helpers/binary-util-functions.js.map +0 -1
  162. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  165. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  166. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  167. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  168. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  169. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  170. package/dist/lib/parse-mvt.js.map +0 -1
  171. package/dist/lib/types.js.map +0 -1
  172. package/dist/mvt-loader.js.map +0 -1
  173. package/dist/workers/mvt-worker.js.map +0 -1
  174. /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  175. /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mvt-loader.js","names":["parseMVT","VERSION","DEFAULT_MVT_LOADER_OPTIONS","mvt","shape","coordinates","layerProperty","layers","undefined","tileIndex","MVTWorkerLoader","name","id","module","version","extensions","mimeTypes","worker","category","options","MVTLoader","parse","arrayBuffer","parseSync","binary"],"sources":["../../src/mvt-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {MVTLoaderOptions} from './lib/types';\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\nconst DEFAULT_MVT_LOADER_OPTIONS: MVTLoaderOptions = {\n mvt: {\n shape: 'geojson',\n coordinates: 'local',\n layerProperty: 'layerName',\n layers: undefined,\n tileIndex: null\n }\n};\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: DEFAULT_MVT_LOADER_OPTIONS\n};\n\n/**\n * Loader for the Mapbox Vector Tile format\n */\nexport const MVTLoader: LoaderWithParser = {\n ...MVTWorkerLoader,\n parse: async (arrayBuffer, options?: MVTLoaderOptions) => parseMVT(arrayBuffer, options),\n parseSync: parseMVT,\n binary: true\n};\n"],"mappings":"AAEA,OAAOA,QAAQ,MAAM,iBAAiB;AAItC,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAE3E,MAAMC,0BAA4C,GAAG;EACnDC,GAAG,EAAE;IACHC,KAAK,EAAE,SAAS;IAChBC,WAAW,EAAE,OAAO;IACpBC,aAAa,EAAE,WAAW;IAC1BC,MAAM,EAAEC,SAAS;IACjBC,SAAS,EAAE;EACb;AACF,CAAC;AAKD,OAAO,MAAMC,eAAuB,GAAG;EACrCC,IAAI,EAAE,oBAAoB;EAC1BC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEb,OAAO;EAEhBc,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;EAC1BC,SAAS,EAAE,CACT,oCAAoC,EACpC,wBAAwB,CAEzB;EACDC,MAAM,EAAE,IAAI;EACZC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAEjB;AACX,CAAC;AAKD,OAAO,MAAMkB,SAA2B,GAAG;EACzC,GAAGV,eAAe;EAClBW,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEH,OAA0B,KAAKnB,QAAQ,CAACsB,WAAW,EAAEH,OAAO,CAAC;EACxFI,SAAS,EAAEvB,QAAQ;EACnBwB,MAAM,EAAE;AACV,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { MVTLoader } from '../mvt-loader';
2
+ import { createLoaderWorker } from '@loaders.gl/loader-utils';
3
+ createLoaderWorker(MVTLoader);
4
+ //# sourceMappingURL=mvt-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mvt-worker.js","names":["MVTLoader","createLoaderWorker"],"sources":["../../../src/workers/mvt-worker.ts"],"sourcesContent":["import {MVTLoader} from '../mvt-loader';\nimport {createLoaderWorker} from '@loaders.gl/loader-utils';\n\ncreateLoaderWorker(MVTLoader);\n"],"mappings":"AAAA,SAAQA,SAAS,QAAO,eAAe;AACvC,SAAQC,kBAAkB,QAAO,0BAA0B;AAE3DA,kBAAkB,CAACD,SAAS,CAAC"}
@@ -1,84 +1,118 @@
1
- import { getPolygonSignedArea } from '@math.gl/polygon';
2
- export function classifyRings(geom) {
3
- const len = geom.indices.length;
4
- const type = 'Polygon';
5
-
6
- if (len <= 1) {
7
- return {
8
- type,
9
- data: geom.data,
10
- areas: [[getPolygonSignedArea(geom.data)]],
11
- indices: [geom.indices]
12
- };
13
- }
14
-
15
- const areas = [];
16
- const polygons = [];
17
- let ringAreas = [];
18
- let polygon = [];
19
- let ccw;
20
- let offset = 0;
21
-
22
- for (let endIndex, i = 0, startIndex; i < len; i++) {
23
- startIndex = geom.indices[i] - offset;
24
- endIndex = geom.indices[i + 1] - offset || geom.data.length;
25
- const shape = geom.data.slice(startIndex, endIndex);
26
- const area = getPolygonSignedArea(shape);
27
-
28
- if (area === 0) {
29
- const before = geom.data.slice(0, startIndex);
30
- const after = geom.data.slice(endIndex);
31
- geom.data = before.concat(after);
32
- offset += endIndex - startIndex;
33
- continue;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readTag = exports.readFeature = exports.project = exports.classifyRings = void 0;
4
+ const polygon_1 = require("@math.gl/polygon");
5
+ /**
6
+ * Classifies an array of rings into polygons with outer rings and holes
7
+ * The function also detects holes which have zero area and
8
+ * removes them. In doing so it modifies the input
9
+ * `geom.data` array to remove the unneeded data
10
+ *
11
+ * @param geometry
12
+ * @returns object
13
+ */
14
+ // eslint-disable-next-line max-statements
15
+ function classifyRings(geom) {
16
+ const len = geom.indices.length;
17
+ const type = 'Polygon';
18
+ if (len <= 1) {
19
+ return {
20
+ type,
21
+ data: geom.data,
22
+ areas: [[(0, polygon_1.getPolygonSignedArea)(geom.data)]],
23
+ indices: [geom.indices]
24
+ };
34
25
  }
35
-
36
- if (ccw === undefined) ccw = area < 0;
37
-
38
- if (ccw === area < 0) {
39
- if (polygon.length) {
26
+ const areas = [];
27
+ const polygons = [];
28
+ let ringAreas = [];
29
+ let polygon = [];
30
+ let ccw;
31
+ let offset = 0;
32
+ for (let endIndex, i = 0, startIndex; i < len; i++) {
33
+ startIndex = geom.indices[i] - offset;
34
+ endIndex = geom.indices[i + 1] - offset || geom.data.length;
35
+ const shape = geom.data.slice(startIndex, endIndex);
36
+ const area = (0, polygon_1.getPolygonSignedArea)(shape);
37
+ if (area === 0) {
38
+ // This polygon has no area, so remove it from the shape
39
+ // Remove the section from the data array
40
+ const before = geom.data.slice(0, startIndex);
41
+ const after = geom.data.slice(endIndex);
42
+ geom.data = before.concat(after);
43
+ // Need to offset any remaining indices as we have
44
+ // modified the data buffer
45
+ offset += endIndex - startIndex;
46
+ // Do not add this index to the output and process next shape
47
+ continue; // eslint-disable-line no-continue
48
+ }
49
+ if (ccw === undefined)
50
+ ccw = area < 0;
51
+ if (ccw === area < 0) {
52
+ if (polygon.length) {
53
+ areas.push(ringAreas);
54
+ polygons.push(polygon);
55
+ }
56
+ polygon = [startIndex];
57
+ ringAreas = [area];
58
+ }
59
+ else {
60
+ ringAreas.push(area);
61
+ polygon.push(startIndex);
62
+ }
63
+ }
64
+ if (ringAreas)
40
65
  areas.push(ringAreas);
66
+ if (polygon.length)
41
67
  polygons.push(polygon);
42
- }
43
-
44
- polygon = [startIndex];
45
- ringAreas = [area];
46
- } else {
47
- ringAreas.push(area);
48
- polygon.push(startIndex);
49
- }
50
- }
51
-
52
- if (ringAreas) areas.push(ringAreas);
53
- if (polygon.length) polygons.push(polygon);
54
- return {
55
- type,
56
- areas,
57
- indices: polygons,
58
- data: geom.data
59
- };
68
+ return { type, areas, indices: polygons, data: geom.data };
60
69
  }
61
- export function project(data, x0, y0, size) {
62
- for (let j = 0, jl = data.length; j < jl; j += 2) {
63
- data[j] = (data[j] + x0) * 360 / size - 180;
64
- const y2 = 180 - (data[j + 1] + y0) * 360 / size;
65
- data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
66
- }
70
+ exports.classifyRings = classifyRings;
71
+ /**
72
+ *
73
+ * @param data
74
+ * @param x0
75
+ * @param y0
76
+ * @param size
77
+ */
78
+ function project(data, x0, y0, size) {
79
+ for (let j = 0, jl = data.length; j < jl; j += 2) {
80
+ data[j] = ((data[j] + x0) * 360) / size - 180;
81
+ const y2 = 180 - ((data[j + 1] + y0) * 360) / size;
82
+ data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
83
+ }
67
84
  }
68
- export function readFeature(tag, feature, pbf) {
69
- if (feature && pbf) {
70
- 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;
71
- }
85
+ exports.project = project;
86
+ /**
87
+ * All code below is unchanged from the original Mapbox implemenation
88
+ *
89
+ * @param tag
90
+ * @param feature
91
+ * @param pbf
92
+ */
93
+ function readFeature(tag, feature, pbf) {
94
+ if (feature && pbf) {
95
+ if (tag === 1)
96
+ feature.id = pbf.readVarint();
97
+ else if (tag === 2)
98
+ readTag(pbf, feature);
99
+ else if (tag === 3)
100
+ feature.type = pbf.readVarint();
101
+ else if (tag === 4)
102
+ feature._geometry = pbf.pos;
103
+ }
72
104
  }
73
- export function readTag(pbf, feature) {
74
- const end = pbf.readVarint() + pbf.pos;
75
-
76
- while (pbf.pos < end) {
77
- const key = feature._keys[pbf.readVarint()];
78
-
79
- const value = feature._values[pbf.readVarint()];
80
-
81
- feature.properties[key] = value;
82
- }
105
+ exports.readFeature = readFeature;
106
+ /**
107
+ * @param pbf
108
+ * @param feature
109
+ */
110
+ function readTag(pbf, feature) {
111
+ const end = pbf.readVarint() + pbf.pos;
112
+ while (pbf.pos < end) {
113
+ const key = feature._keys[pbf.readVarint()];
114
+ const value = feature._values[pbf.readVarint()];
115
+ feature.properties[key] = value;
116
+ }
83
117
  }
84
- //# sourceMappingURL=binary-util-functions.js.map
118
+ exports.readTag = readTag;
@@ -1,12 +1,12 @@
1
1
  import Protobuf from 'pbf';
2
- import { MvtMapboxGeometry } from '../lib/types';
2
+ import { MVTMapboxGeometry } from '../lib/types';
3
3
  import VectorTileFeature from '../lib/mapbox-vector-tile/vector-tile-feature';
4
4
  /**
5
5
  * Classifies an array of rings into polygons with outer rings and holes
6
6
  * @param rings
7
7
  * @returns polygons
8
8
  */
9
- export declare function classifyRings(rings: MvtMapboxGeometry): MvtMapboxGeometry[] | number[][][];
9
+ export declare function classifyRings(rings: MVTMapboxGeometry): MVTMapboxGeometry[] | number[][][];
10
10
  /**
11
11
  *
12
12
  * @param ring
@@ -1,49 +1,82 @@
1
- export function classifyRings(rings) {
2
- const len = rings.length;
3
- if (len <= 1) return [rings];
4
- const polygons = [];
5
- let polygon;
6
- let ccw;
7
-
8
- for (let i = 0; i < len; i++) {
9
- const area = signedArea(rings[i]);
10
- if (area === 0) continue;
11
- if (ccw === undefined) ccw = area < 0;
12
-
13
- if (ccw === area < 0) {
14
- if (polygon) polygons.push(polygon);
15
- polygon = [rings[i]];
16
- } else if (polygon) polygon.push(rings[i]);
17
- }
18
-
19
- if (polygon) polygons.push(polygon);
20
- return polygons;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readTag = exports.readFeature = exports.signedArea = exports.classifyRings = void 0;
4
+ /**
5
+ * Classifies an array of rings into polygons with outer rings and holes
6
+ * @param rings
7
+ * @returns polygons
8
+ */
9
+ function classifyRings(rings) {
10
+ const len = rings.length;
11
+ if (len <= 1)
12
+ return [rings];
13
+ const polygons = [];
14
+ let polygon;
15
+ let ccw;
16
+ for (let i = 0; i < len; i++) {
17
+ const area = signedArea(rings[i]);
18
+ if (area === 0)
19
+ continue; // eslint-disable-line no-continue
20
+ if (ccw === undefined)
21
+ ccw = area < 0;
22
+ if (ccw === area < 0) {
23
+ if (polygon)
24
+ polygons.push(polygon);
25
+ polygon = [rings[i]];
26
+ }
27
+ else if (polygon)
28
+ polygon.push(rings[i]);
29
+ }
30
+ if (polygon)
31
+ polygons.push(polygon);
32
+ return polygons;
21
33
  }
22
- export function signedArea(ring) {
23
- let sum = 0;
24
-
25
- for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
26
- p1 = ring[i];
27
- p2 = ring[j];
28
- sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
29
- }
30
-
31
- return sum;
34
+ exports.classifyRings = classifyRings;
35
+ /**
36
+ *
37
+ * @param ring
38
+ * @returns sum
39
+ */
40
+ function signedArea(ring) {
41
+ let sum = 0;
42
+ for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
43
+ p1 = ring[i];
44
+ p2 = ring[j];
45
+ sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
46
+ }
47
+ return sum;
32
48
  }
33
- export function readFeature(tag, feature, pbf) {
34
- if (feature && pbf) {
35
- 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;
36
- }
49
+ exports.signedArea = signedArea;
50
+ /**
51
+ *
52
+ * @param tag
53
+ * @param feature
54
+ * @param pbf
55
+ */
56
+ function readFeature(tag, feature, pbf) {
57
+ if (feature && pbf) {
58
+ if (tag === 1)
59
+ feature.id = pbf.readVarint();
60
+ else if (tag === 2)
61
+ readTag(pbf, feature);
62
+ else if (tag === 3)
63
+ feature.type = pbf.readVarint();
64
+ else if (tag === 4)
65
+ feature._geometry = pbf.pos;
66
+ }
37
67
  }
38
- export function readTag(pbf, feature) {
39
- const end = pbf.readVarint() + pbf.pos;
40
-
41
- while (pbf.pos < end) {
42
- const key = feature._keys[pbf.readVarint()];
43
-
44
- const value = feature._values[pbf.readVarint()];
45
-
46
- feature.properties[key] = value;
47
- }
68
+ exports.readFeature = readFeature;
69
+ /**
70
+ *
71
+ * @param pbf
72
+ * @param feature
73
+ */
74
+ function readTag(pbf, feature) {
75
+ const end = pbf.readVarint() + pbf.pos;
76
+ while (pbf.pos < end) {
77
+ const key = feature._keys[pbf.readVarint()];
78
+ const value = feature._values[pbf.readVarint()];
79
+ feature.properties[key] = value;
80
+ }
48
81
  }
49
- //# sourceMappingURL=mapbox-util-functions.js.map
82
+ exports.readTag = readTag;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export { MVTLoader, MVTWorkerLoader } from './mvt-loader';
2
+ export type { GeoJSONTilerOptions } from './lib/geojson-tiler/geojson-tiler';
3
+ export { GeoJSONTiler } from './lib/geojson-tiler/geojson-tiler';
2
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAIxD,YAAY,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,9 @@
1
- export { MVTLoader, MVTWorkerLoader } from './mvt-loader';
2
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ // loaders.gl, MIT license
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GeoJSONTiler = exports.MVTWorkerLoader = exports.MVTLoader = void 0;
5
+ var mvt_loader_1 = require("./mvt-loader");
6
+ Object.defineProperty(exports, "MVTLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTLoader; } });
7
+ Object.defineProperty(exports, "MVTWorkerLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTWorkerLoader; } });
8
+ var geojson_tiler_1 = require("./lib/geojson-tiler/geojson-tiler");
9
+ Object.defineProperty(exports, "GeoJSONTiler", { enumerable: true, get: function () { return geojson_tiler_1.GeoJSONTiler; } });
@@ -1 +1 @@
1
- {"version":3,"file":"vector-tile-feature.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAC,aAAa,EAAuB,MAAM,qCAAqC,CAAC;AAWxF,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,UAAU,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;KAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAA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