@loaders.gl/mvt 3.1.0-alpha.3 → 3.1.0-beta.2

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 (129) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2276 -4
  4. package/dist/es5/bundle.js +7 -0
  5. package/dist/es5/bundle.js.map +1 -0
  6. package/dist/es5/helpers/binary-util-functions.js +95 -0
  7. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  8. package/dist/es5/helpers/mapbox-util-functions.js +62 -0
  9. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  10. package/dist/es5/index.js +20 -0
  11. package/dist/es5/index.js.map +1 -0
  12. package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  13. package/dist/es5/lib/binary-vector-tile/features-to-binary.js +338 -0
  14. package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +1 -0
  15. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +162 -0
  16. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  17. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +69 -0
  18. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  19. package/dist/es5/lib/binary-vector-tile/vector-tile.js +35 -0
  20. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  21. package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
  22. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +207 -0
  23. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  24. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +69 -0
  25. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  26. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +35 -0
  27. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  28. package/dist/es5/lib/parse-mvt.js +129 -0
  29. package/dist/es5/lib/parse-mvt.js.map +1 -0
  30. package/dist/es5/lib/types.js +2 -0
  31. package/dist/{lib → es5/lib}/types.js.map +0 -0
  32. package/dist/es5/mvt-loader.js +38 -0
  33. package/dist/es5/mvt-loader.js.map +1 -0
  34. package/dist/es5/workers/mvt-worker.js +8 -0
  35. package/dist/es5/workers/mvt-worker.js.map +1 -0
  36. package/dist/esm/bundle.js +5 -0
  37. package/dist/esm/bundle.js.map +1 -0
  38. package/dist/esm/helpers/binary-util-functions.js +81 -0
  39. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  40. package/dist/esm/helpers/mapbox-util-functions.js +49 -0
  41. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  42. package/dist/esm/index.js +2 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  45. package/dist/esm/lib/binary-vector-tile/features-to-binary.js +327 -0
  46. package/dist/esm/lib/binary-vector-tile/features-to-binary.js.map +1 -0
  47. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +156 -0
  48. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  49. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +64 -0
  50. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  51. package/dist/esm/lib/binary-vector-tile/vector-tile.js +23 -0
  52. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  53. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  54. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +202 -0
  55. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  56. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +64 -0
  57. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  58. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +23 -0
  59. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  60. package/dist/esm/lib/parse-mvt.js +116 -0
  61. package/dist/esm/lib/parse-mvt.js.map +1 -0
  62. package/dist/esm/lib/types.js +2 -0
  63. package/dist/esm/lib/types.js.map +1 -0
  64. package/dist/esm/mvt-loader.js +26 -0
  65. package/dist/esm/mvt-loader.js.map +1 -0
  66. package/dist/esm/workers/mvt-worker.js +4 -0
  67. package/dist/esm/workers/mvt-worker.js.map +1 -0
  68. package/dist/helpers/binary-util-functions.d.ts +39 -0
  69. package/dist/helpers/binary-util-functions.d.ts.map +1 -0
  70. package/dist/helpers/binary-util-functions.js +109 -74
  71. package/dist/helpers/mapbox-util-functions.d.ts +29 -0
  72. package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
  73. package/dist/helpers/mapbox-util-functions.js +78 -45
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +6 -2
  77. package/dist/lib/binary-vector-tile/features-to-binary.d.ts +185 -0
  78. package/dist/lib/binary-vector-tile/features-to-binary.d.ts.map +1 -0
  79. package/dist/lib/binary-vector-tile/features-to-binary.js +323 -297
  80. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +36 -0
  81. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
  82. package/dist/lib/binary-vector-tile/vector-tile-feature.js +145 -142
  83. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
  84. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
  85. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
  86. package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
  87. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
  88. package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
  89. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
  90. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
  91. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
  92. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
  93. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
  94. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
  95. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
  96. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
  97. package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
  98. package/dist/lib/parse-mvt.d.ts +85 -0
  99. package/dist/lib/parse-mvt.d.ts.map +1 -0
  100. package/dist/lib/parse-mvt.js +126 -100
  101. package/dist/lib/types.d.ts +92 -0
  102. package/dist/lib/types.d.ts.map +1 -0
  103. package/dist/lib/types.js +2 -2
  104. package/dist/mvt-loader.d.ts +10 -0
  105. package/dist/mvt-loader.d.ts.map +1 -0
  106. package/dist/mvt-loader.js +42 -23
  107. package/dist/mvt-worker.js +2286 -3
  108. package/dist/workers/mvt-worker.d.ts +2 -0
  109. package/dist/workers/mvt-worker.d.ts.map +1 -0
  110. package/dist/workers/mvt-worker.js +5 -4
  111. package/package.json +9 -9
  112. package/src/lib/parse-mvt.ts +1 -1
  113. package/dist/bundle.js.map +0 -1
  114. package/dist/dist.min.js +0 -4
  115. package/dist/dist.min.js.map +0 -1
  116. package/dist/helpers/binary-util-functions.js.map +0 -1
  117. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  118. package/dist/index.js.map +0 -1
  119. package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
  120. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  121. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  122. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  123. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  124. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  125. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  126. package/dist/lib/parse-mvt.js.map +0 -1
  127. package/dist/mvt-loader.js.map +0 -1
  128. package/dist/mvt-worker.js.map +0 -1
  129. package/dist/workers/mvt-worker.js.map +0 -1
@@ -1,81 +1,116 @@
1
- import { getPolygonSignedArea } from '@math.gl/polygon';
2
- export function classifyRings(geom) {
3
- const len = geom.lines.length;
4
-
5
- if (len <= 1) {
6
- return {
7
- data: geom.data,
8
- areas: [[getPolygonSignedArea(geom.data)]],
9
- lines: [geom.lines]
10
- };
11
- }
12
-
13
- const areas = [];
14
- const polygons = [];
15
- let ringAreas = [];
16
- let polygon = [];
17
- let ccw;
18
- let offset = 0;
19
-
20
- for (let endIndex, i = 0, startIndex; i < len; i++) {
21
- startIndex = geom.lines[i] - offset;
22
- endIndex = geom.lines[i + 1] - offset || geom.data.length;
23
- const shape = geom.data.slice(startIndex, endIndex);
24
- const area = getPolygonSignedArea(shape);
25
-
26
- if (area === 0) {
27
- const before = geom.data.slice(0, startIndex);
28
- const after = geom.data.slice(endIndex);
29
- geom.data = before.concat(after);
30
- offset += endIndex - startIndex;
31
- 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.lines.length;
17
+ if (len <= 1) {
18
+ return {
19
+ data: geom.data,
20
+ areas: [[(0, polygon_1.getPolygonSignedArea)(geom.data)]],
21
+ lines: [geom.lines]
22
+ };
32
23
  }
33
-
34
- if (ccw === undefined) ccw = area < 0;
35
-
36
- if (ccw === area < 0) {
37
- if (polygon.length) {
24
+ const areas = [];
25
+ const polygons = [];
26
+ let ringAreas = [];
27
+ let polygon = [];
28
+ let ccw;
29
+ let offset = 0;
30
+ for (let endIndex, i = 0, startIndex; i < len; i++) {
31
+ startIndex = geom.lines[i] - offset;
32
+ endIndex = geom.lines[i + 1] - offset || geom.data.length;
33
+ const shape = geom.data.slice(startIndex, endIndex);
34
+ const area = (0, polygon_1.getPolygonSignedArea)(shape);
35
+ if (area === 0) {
36
+ // This polygon has no area, so remove it from the shape
37
+ // Remove the section from the data array
38
+ const before = geom.data.slice(0, startIndex);
39
+ const after = geom.data.slice(endIndex);
40
+ geom.data = before.concat(after);
41
+ // Need to offset any remaining indices as we have
42
+ // modified the data buffer
43
+ offset += endIndex - startIndex;
44
+ // Do not add this index to the output and process next shape
45
+ continue; // eslint-disable-line no-continue
46
+ }
47
+ if (ccw === undefined)
48
+ ccw = area < 0;
49
+ if (ccw === area < 0) {
50
+ if (polygon.length) {
51
+ areas.push(ringAreas);
52
+ polygons.push(polygon);
53
+ }
54
+ polygon = [startIndex];
55
+ ringAreas = [area];
56
+ }
57
+ else {
58
+ ringAreas.push(area);
59
+ polygon.push(startIndex);
60
+ }
61
+ }
62
+ if (ringAreas)
38
63
  areas.push(ringAreas);
64
+ if (polygon.length)
39
65
  polygons.push(polygon);
40
- }
41
-
42
- polygon = [startIndex];
43
- ringAreas = [area];
44
- } else {
45
- ringAreas.push(area);
46
- polygon.push(startIndex);
47
- }
48
- }
49
-
50
- if (ringAreas) areas.push(ringAreas);
51
- if (polygon.length) polygons.push(polygon);
52
- return {
53
- areas,
54
- lines: polygons,
55
- data: geom.data
56
- };
66
+ return { areas, lines: polygons, data: geom.data };
57
67
  }
58
- export function project(data, x0, y0, size) {
59
- for (let j = 0, jl = data.length; j < jl; j += 2) {
60
- data[j] = (data[j] + x0) * 360 / size - 180;
61
- const y2 = 180 - (data[j + 1] + y0) * 360 / size;
62
- data[j + 1] = 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
63
- }
68
+ exports.classifyRings = classifyRings;
69
+ /**
70
+ *
71
+ * @param data
72
+ * @param x0
73
+ * @param y0
74
+ * @param size
75
+ */
76
+ function project(data, x0, y0, size) {
77
+ for (let j = 0, jl = data.length; j < jl; j += 2) {
78
+ data[j] = ((data[j] + x0) * 360) / size - 180;
79
+ const y2 = 180 - ((data[j + 1] + y0) * 360) / size;
80
+ data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
81
+ }
64
82
  }
65
- export function readFeature(tag, feature, pbf) {
66
- if (feature && pbf) {
67
- 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;
68
- }
83
+ exports.project = project;
84
+ /**
85
+ * All code below is unchanged from the original Mapbox implemenation
86
+ *
87
+ * @param tag
88
+ * @param feature
89
+ * @param pbf
90
+ */
91
+ function readFeature(tag, feature, pbf) {
92
+ if (feature && pbf) {
93
+ if (tag === 1)
94
+ feature.id = pbf.readVarint();
95
+ else if (tag === 2)
96
+ readTag(pbf, feature);
97
+ else if (tag === 3)
98
+ feature.type = pbf.readVarint();
99
+ else if (tag === 4)
100
+ feature._geometry = pbf.pos;
101
+ }
69
102
  }
70
- export function readTag(pbf, feature) {
71
- const end = pbf.readVarint() + pbf.pos;
72
-
73
- while (pbf.pos < end) {
74
- const key = feature._keys[pbf.readVarint()];
75
-
76
- const value = feature._values[pbf.readVarint()];
77
-
78
- feature.properties[key] = value;
79
- }
103
+ exports.readFeature = readFeature;
104
+ /**
105
+ * @param pbf
106
+ * @param feature
107
+ */
108
+ function readTag(pbf, feature) {
109
+ const end = pbf.readVarint() + pbf.pos;
110
+ while (pbf.pos < end) {
111
+ const key = feature._keys[pbf.readVarint()];
112
+ const value = feature._values[pbf.readVarint()];
113
+ feature.properties[key] = value;
114
+ }
80
115
  }
81
- //# sourceMappingURL=binary-util-functions.js.map
116
+ exports.readTag = readTag;
@@ -0,0 +1,29 @@
1
+ import Protobuf from 'pbf';
2
+ import { MvtMapboxGeometry } from '../lib/types';
3
+ import VectorTileFeature from '../lib/mapbox-vector-tile/vector-tile-feature';
4
+ /**
5
+ * Classifies an array of rings into polygons with outer rings and holes
6
+ * @param rings
7
+ * @returns polygons
8
+ */
9
+ export declare function classifyRings(rings: MvtMapboxGeometry): MvtMapboxGeometry[] | number[][][];
10
+ /**
11
+ *
12
+ * @param ring
13
+ * @returns sum
14
+ */
15
+ export declare function signedArea(ring: number[][]): number;
16
+ /**
17
+ *
18
+ * @param tag
19
+ * @param feature
20
+ * @param pbf
21
+ */
22
+ export declare function readFeature(tag: number, feature?: VectorTileFeature, pbf?: Protobuf): void;
23
+ /**
24
+ *
25
+ * @param pbf
26
+ * @param feature
27
+ */
28
+ export declare function readTag(pbf: Protobuf, feature: VectorTileFeature): void;
29
+ //# sourceMappingURL=mapbox-util-functions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapbox-util-functions.d.ts","sourceRoot":"","sources":["../../src/helpers/mapbox-util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,iBAAiB,MAAM,+CAA+C,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,sCAuBrD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAQ1C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAO1F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAQvE"}
@@ -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;
@@ -0,0 +1,2 @@
1
+ export { MVTLoader, MVTWorkerLoader } from './mvt-loader';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
package/dist/index.js CHANGED
@@ -1,2 +1,6 @@
1
- export { MVTLoader, MVTWorkerLoader } from './mvt-loader';
2
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MVTWorkerLoader = exports.MVTLoader = void 0;
4
+ var mvt_loader_1 = require("./mvt-loader");
5
+ Object.defineProperty(exports, "MVTLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTLoader; } });
6
+ Object.defineProperty(exports, "MVTWorkerLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTWorkerLoader; } });
@@ -0,0 +1,185 @@
1
+ import { MvtBinaryCoordinates, MvtBinaryOptions, MvtFirstPassedData } from '../types';
2
+ /**
3
+ * Convert binary features to flat binary arrays. Similar to
4
+ * `geojsonToBinary` helper function, except that it expects
5
+ * a binary representation of the feature data, which enables
6
+ * 2X-3X speed increase in parse speed, compared to using
7
+ * geoJSON. See `binary-vector-tile/VectorTileFeature` for
8
+ * data format detais
9
+ *
10
+ * @param features
11
+ * @param firstPassData
12
+ * @param options
13
+ * @returns filled arrays
14
+ */
15
+ export declare function featuresToBinary(features: MvtBinaryCoordinates[], firstPassData: MvtFirstPassedData, options?: MvtBinaryOptions): {
16
+ points: {
17
+ positions: {
18
+ value: Float32Array;
19
+ size: number;
20
+ };
21
+ globalFeatureIds: {
22
+ value: Uint16Array | Uint32Array;
23
+ size: number;
24
+ };
25
+ featureIds: {
26
+ value: Uint16Array | Uint32Array;
27
+ size: number;
28
+ };
29
+ numericProps: object;
30
+ properties: {}[];
31
+ fields: {
32
+ id?: number | undefined;
33
+ }[];
34
+ };
35
+ lines: {
36
+ pathIndices: {
37
+ value: Uint16Array | Uint32Array;
38
+ size: number;
39
+ };
40
+ positions: {
41
+ value: Float32Array;
42
+ size: number;
43
+ };
44
+ globalFeatureIds: {
45
+ value: Uint16Array | Uint32Array;
46
+ size: number;
47
+ };
48
+ featureIds: {
49
+ value: Uint16Array | Uint32Array;
50
+ size: number;
51
+ };
52
+ numericProps: object;
53
+ properties: {}[];
54
+ fields: {
55
+ id?: number | undefined;
56
+ }[];
57
+ };
58
+ polygons: {
59
+ polygonIndices: {
60
+ value: Uint16Array | Uint32Array;
61
+ size: number;
62
+ };
63
+ primitivePolygonIndices: {
64
+ value: Uint16Array | Uint32Array;
65
+ size: number;
66
+ };
67
+ positions: {
68
+ value: Float32Array;
69
+ size: number;
70
+ };
71
+ triangles: {
72
+ value: Uint32Array;
73
+ size: number;
74
+ };
75
+ globalFeatureIds: {
76
+ value: Uint16Array | Uint32Array;
77
+ size: number;
78
+ };
79
+ featureIds: {
80
+ value: Uint16Array | Uint32Array;
81
+ size: number;
82
+ };
83
+ numericProps: object;
84
+ properties: {}[];
85
+ fields: {
86
+ id?: number | undefined;
87
+ }[];
88
+ };
89
+ };
90
+ export declare const TEST_EXPORTS: {
91
+ extractNumericPropKeys: typeof extractNumericPropKeys;
92
+ fillArrays: typeof fillArrays;
93
+ };
94
+ /**
95
+ * Extracts properties that are always numeric
96
+ *
97
+ * @param features
98
+ * @returns object with numeric keys
99
+ */
100
+ declare function extractNumericPropKeys(features: MvtBinaryCoordinates[]): string[];
101
+ /**
102
+ * Fills coordinates into pre-allocated typed arrays
103
+ *
104
+ * @param features
105
+ * @param firstPassData
106
+ * @param options
107
+ * @returns an accessor object with value and size keys
108
+ */
109
+ declare function fillArrays(features: MvtBinaryCoordinates[], firstPassData: MvtFirstPassedData, options: MvtBinaryOptions): {
110
+ points: {
111
+ positions: {
112
+ value: Float32Array;
113
+ size: number;
114
+ };
115
+ globalFeatureIds: {
116
+ value: Uint16Array | Uint32Array;
117
+ size: number;
118
+ };
119
+ featureIds: {
120
+ value: Uint16Array | Uint32Array;
121
+ size: number;
122
+ };
123
+ numericProps: object;
124
+ properties: {}[];
125
+ fields: {
126
+ id?: number | undefined;
127
+ }[];
128
+ };
129
+ lines: {
130
+ pathIndices: {
131
+ value: Uint16Array | Uint32Array;
132
+ size: number;
133
+ };
134
+ positions: {
135
+ value: Float32Array;
136
+ size: number;
137
+ };
138
+ globalFeatureIds: {
139
+ value: Uint16Array | Uint32Array;
140
+ size: number;
141
+ };
142
+ featureIds: {
143
+ value: Uint16Array | Uint32Array;
144
+ size: number;
145
+ };
146
+ numericProps: object;
147
+ properties: {}[];
148
+ fields: {
149
+ id?: number | undefined;
150
+ }[];
151
+ };
152
+ polygons: {
153
+ polygonIndices: {
154
+ value: Uint16Array | Uint32Array;
155
+ size: number;
156
+ };
157
+ primitivePolygonIndices: {
158
+ value: Uint16Array | Uint32Array;
159
+ size: number;
160
+ };
161
+ positions: {
162
+ value: Float32Array;
163
+ size: number;
164
+ };
165
+ triangles: {
166
+ value: Uint32Array;
167
+ size: number;
168
+ };
169
+ globalFeatureIds: {
170
+ value: Uint16Array | Uint32Array;
171
+ size: number;
172
+ };
173
+ featureIds: {
174
+ value: Uint16Array | Uint32Array;
175
+ size: number;
176
+ };
177
+ numericProps: object;
178
+ properties: {}[];
179
+ fields: {
180
+ id?: number | undefined;
181
+ }[];
182
+ };
183
+ };
184
+ export {};
185
+ //# sourceMappingURL=features-to-binary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features-to-binary.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/features-to-binary.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EAEpB,gBAAgB,EAChB,kBAAkB,EAInB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,oBAAoB,EAAE,EAChC,aAAa,EAAE,kBAAkB,EACjC,OAAO,CAAC,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM3B;AAED,eAAO,MAAM,YAAY;;;CAGxB,CAAC;AAEF;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CAkB1E;AAED;;;;;;;GAOG;AAEH,iBAAS,UAAU,CACjB,QAAQ,EAAE,oBAAoB,EAAE,EAChC,aAAa,EAAE,kBAAkB,EACjC,OAAO,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoI1B"}