@loaders.gl/mvt 4.2.1 → 4.3.0-alpha.1

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 (107) hide show
  1. package/dist/dist.dev.js +1311 -767
  2. package/dist/dist.min.js +1 -1
  3. package/dist/geojson-tile-source.d.ts +79 -0
  4. package/dist/geojson-tile-source.d.ts.map +1 -0
  5. package/dist/{lib/geojson-tiler/geojson-tiler.js → geojson-tile-source.js} +137 -27
  6. package/dist/index.cjs +568 -558
  7. package/dist/index.cjs.map +4 -4
  8. package/dist/index.d.ts +2 -2
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/lib/geojsonvt/clip.d.ts.map +1 -0
  12. package/dist/lib/geojsonvt/convert.d.ts +10 -0
  13. package/dist/lib/geojsonvt/convert.d.ts.map +1 -0
  14. package/dist/lib/geojsonvt/feature.d.ts.map +1 -0
  15. package/dist/lib/geojsonvt/simplify.d.ts.map +1 -0
  16. package/dist/lib/geojsonvt/tile.d.ts.map +1 -0
  17. package/dist/lib/geojsonvt/transform.d.ts.map +1 -0
  18. package/dist/lib/geojsonvt/wrap.d.ts.map +1 -0
  19. package/dist/lib/parse-mvt.d.ts +3 -2
  20. package/dist/lib/parse-mvt.d.ts.map +1 -1
  21. package/dist/lib/parse-mvt.js +13 -15
  22. package/dist/lib/types.d.ts +1 -39
  23. package/dist/lib/types.d.ts.map +1 -1
  24. package/dist/lib/utils/geometry-utils.d.ts +46 -0
  25. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  26. package/dist/{helpers/binary-util-functions.js → lib/utils/geometry-utils.js} +79 -46
  27. package/dist/lib/{binary-vector-tile → vector-tile}/vector-tile-feature.d.ts +27 -15
  28. package/dist/lib/vector-tile/vector-tile-feature.d.ts.map +1 -0
  29. package/dist/lib/vector-tile/vector-tile-feature.js +345 -0
  30. package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.d.ts +10 -1
  31. package/dist/lib/vector-tile/vector-tile-layer.d.ts.map +1 -0
  32. package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.js +16 -1
  33. package/dist/lib/vector-tile/vector-tile.d.ts.map +1 -0
  34. package/dist/mvt-loader.d.ts +20 -9
  35. package/dist/mvt-loader.d.ts.map +1 -1
  36. package/dist/mvt-loader.js +2 -1
  37. package/dist/mvt-source.js +4 -4
  38. package/dist/mvt-worker.js +1172 -735
  39. package/package.json +6 -6
  40. package/src/{lib/geojson-tiler/geojson-tiler.ts → geojson-tile-source.ts} +172 -33
  41. package/src/index.ts +3 -3
  42. package/src/lib/{geojson-tiler → geojsonvt}/convert.ts +2 -2
  43. package/src/lib/{geojson-tiler → geojsonvt}/tile.ts +2 -2
  44. package/src/lib/parse-mvt.ts +24 -33
  45. package/src/lib/types.ts +1 -39
  46. package/src/{helpers/binary-util-functions.ts → lib/utils/geometry-utils.ts} +92 -48
  47. package/src/lib/vector-tile/vector-tile-feature.ts +407 -0
  48. package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile-layer.ts +28 -2
  49. package/src/mvt-loader.ts +14 -6
  50. package/src/mvt-source.ts +4 -4
  51. package/dist/helpers/binary-util-functions.d.ts +0 -35
  52. package/dist/helpers/binary-util-functions.d.ts.map +0 -1
  53. package/dist/helpers/mapbox-util-functions.d.ts +0 -29
  54. package/dist/helpers/mapbox-util-functions.d.ts.map +0 -1
  55. package/dist/helpers/mapbox-util-functions.js +0 -78
  56. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +0 -1
  57. package/dist/lib/binary-vector-tile/vector-tile-feature.js +0 -163
  58. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +0 -23
  59. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +0 -1
  60. package/dist/lib/binary-vector-tile/vector-tile-layer.js +0 -96
  61. package/dist/lib/binary-vector-tile/vector-tile.d.ts +0 -9
  62. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +0 -1
  63. package/dist/lib/binary-vector-tile/vector-tile.js +0 -27
  64. package/dist/lib/geojson-tiler/clip.d.ts.map +0 -1
  65. package/dist/lib/geojson-tiler/convert.d.ts +0 -10
  66. package/dist/lib/geojson-tiler/convert.d.ts.map +0 -1
  67. package/dist/lib/geojson-tiler/feature.d.ts.map +0 -1
  68. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +0 -44
  69. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +0 -1
  70. package/dist/lib/geojson-tiler/simplify.d.ts.map +0 -1
  71. package/dist/lib/geojson-tiler/tile.d.ts.map +0 -1
  72. package/dist/lib/geojson-tiler/transform.d.ts.map +0 -1
  73. package/dist/lib/geojson-tiler/wrap.d.ts.map +0 -1
  74. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +0 -27
  75. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +0 -1
  76. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +0 -178
  77. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +0 -1
  78. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +0 -1
  79. package/src/helpers/mapbox-util-functions.ts +0 -82
  80. package/src/lib/binary-vector-tile/vector-tile-feature.ts +0 -203
  81. package/src/lib/binary-vector-tile/vector-tile-layer.ts +0 -113
  82. package/src/lib/binary-vector-tile/vector-tile.ts +0 -36
  83. package/src/lib/mapbox-vector-tile/LICENSE.txt +0 -31
  84. package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +0 -207
  85. /package/dist/lib/{geojson-tiler → geojsonvt}/clip.d.ts +0 -0
  86. /package/dist/lib/{geojson-tiler → geojsonvt}/clip.js +0 -0
  87. /package/dist/lib/{geojson-tiler → geojsonvt}/convert.js +0 -0
  88. /package/dist/lib/{geojson-tiler → geojsonvt}/feature.d.ts +0 -0
  89. /package/dist/lib/{geojson-tiler → geojsonvt}/feature.js +0 -0
  90. /package/dist/lib/{geojson-tiler → geojsonvt}/simplify.d.ts +0 -0
  91. /package/dist/lib/{geojson-tiler → geojsonvt}/simplify.js +0 -0
  92. /package/dist/lib/{geojson-tiler → geojsonvt}/tile.d.ts +0 -0
  93. /package/dist/lib/{geojson-tiler → geojsonvt}/tile.js +0 -0
  94. /package/dist/lib/{geojson-tiler → geojsonvt}/transform.d.ts +0 -0
  95. /package/dist/lib/{geojson-tiler → geojsonvt}/transform.js +0 -0
  96. /package/dist/lib/{geojson-tiler → geojsonvt}/wrap.d.ts +0 -0
  97. /package/dist/lib/{geojson-tiler → geojsonvt}/wrap.js +0 -0
  98. /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.d.ts +0 -0
  99. /package/dist/lib/{mapbox-vector-tile → vector-tile}/vector-tile.js +0 -0
  100. /package/src/lib/{geojson-tiler → geojsonvt}/LICENSE +0 -0
  101. /package/src/lib/{geojson-tiler → geojsonvt}/clip.ts +0 -0
  102. /package/src/lib/{geojson-tiler → geojsonvt}/feature.ts +0 -0
  103. /package/src/lib/{geojson-tiler → geojsonvt}/simplify.ts +0 -0
  104. /package/src/lib/{geojson-tiler → geojsonvt}/transform.ts +0 -0
  105. /package/src/lib/{geojson-tiler → geojsonvt}/wrap.ts +0 -0
  106. /package/src/lib/{binary-vector-tile → vector-tile}/LICENSE.txt +0 -0
  107. /package/src/lib/{mapbox-vector-tile → vector-tile}/vector-tile.ts +0 -0
@@ -1,163 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright vis.gl contributors
4
- import { classifyRings, project, readFeature } from "../../helpers/binary-util-functions.js";
5
- // Reduce GC by reusing variables
6
- let endPos;
7
- let cmd;
8
- let cmdLen;
9
- let length;
10
- let x;
11
- let y;
12
- let i;
13
- export const TEST_EXPORTS = {
14
- classifyRings
15
- };
16
- export class BinaryVectorTileFeature {
17
- properties;
18
- extent;
19
- type;
20
- id;
21
- _pbf;
22
- _geometry;
23
- _keys;
24
- _values;
25
- _geometryInfo;
26
- // eslint-disable-next-line max-params
27
- constructor(pbf, end, extent, keys, values, geometryInfo) {
28
- // Public
29
- this.properties = {};
30
- this.extent = extent;
31
- this.type = 0;
32
- this.id = null;
33
- // Private
34
- this._pbf = pbf;
35
- this._geometry = -1;
36
- this._keys = keys;
37
- this._values = values;
38
- this._geometryInfo = geometryInfo;
39
- pbf.readFields(readFeature, this, end);
40
- }
41
- // eslint-disable-next-line complexity, max-statements
42
- loadGeometry() {
43
- const pbf = this._pbf;
44
- pbf.pos = this._geometry;
45
- endPos = pbf.readVarint() + pbf.pos;
46
- cmd = 1;
47
- length = 0;
48
- x = 0;
49
- y = 0;
50
- i = 0;
51
- // Note: I attempted to replace the `data` array with a
52
- // Float32Array, but performance was worse, both using
53
- // `set()` and direct index access. Also, we cannot
54
- // know how large the buffer should be, so it would
55
- // increase memory usage
56
- const indices = []; // Indices where geometries start
57
- const data = []; // Flat array of coordinate data
58
- while (pbf.pos < endPos) {
59
- if (length <= 0) {
60
- cmdLen = pbf.readVarint();
61
- cmd = cmdLen & 0x7;
62
- length = cmdLen >> 3;
63
- }
64
- length--;
65
- if (cmd === 1 || cmd === 2) {
66
- x += pbf.readSVarint();
67
- y += pbf.readSVarint();
68
- if (cmd === 1) {
69
- // New line
70
- indices.push(i);
71
- }
72
- data.push(x, y);
73
- i += 2;
74
- }
75
- else if (cmd === 7) {
76
- // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
77
- if (i > 0) {
78
- const start = indices[indices.length - 1]; // start index of polygon
79
- data.push(data[start], data[start + 1]); // closePolygon
80
- i += 2;
81
- }
82
- }
83
- else {
84
- throw new Error(`unknown command ${cmd}`);
85
- }
86
- }
87
- return { data, indices };
88
- }
89
- /**
90
- *
91
- * @param transform
92
- * @returns result
93
- */
94
- _toBinaryCoordinates(transform) {
95
- // Expands the protobuf data to an intermediate Flat GeoJSON
96
- // data format, which maps closely to the binary data buffers.
97
- // It is similar to GeoJSON, but rather than storing the coordinates
98
- // in multidimensional arrays, we have a 1D `data` with all the
99
- // coordinates, and then index into this using the `indices`
100
- // parameter, e.g.
101
- //
102
- // geometry: {
103
- // type: 'Point', data: [1,2], indices: [0]
104
- // }
105
- // geometry: {
106
- // type: 'LineString', data: [1,2,3,4,...], indices: [0]
107
- // }
108
- // geometry: {
109
- // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
110
- // }
111
- // Thus the indices member lets us look up the relevant range
112
- // from the data array.
113
- // The Multi* versions of the above types share the same data
114
- // structure, just with multiple elements in the indices array
115
- const geom = this.loadGeometry();
116
- let geometry;
117
- // Apply the supplied transformation to data
118
- transform(geom.data, this);
119
- const coordLength = 2;
120
- // eslint-disable-next-line default-case
121
- switch (this.type) {
122
- case 1: // Point
123
- this._geometryInfo.pointFeaturesCount++;
124
- this._geometryInfo.pointPositionsCount += geom.indices.length;
125
- geometry = { type: 'Point', ...geom };
126
- break;
127
- case 2: // LineString
128
- this._geometryInfo.lineFeaturesCount++;
129
- this._geometryInfo.linePathsCount += geom.indices.length;
130
- this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
131
- geometry = { type: 'LineString', ...geom };
132
- break;
133
- case 3: // Polygon
134
- geometry = classifyRings(geom);
135
- // Unlike Point & LineString geom.indices is a 2D array, thanks
136
- // to the classifyRings method
137
- this._geometryInfo.polygonFeaturesCount++;
138
- this._geometryInfo.polygonObjectsCount += geometry.indices.length;
139
- for (const indices of geometry.indices) {
140
- this._geometryInfo.polygonRingsCount += indices.length;
141
- }
142
- this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
143
- break;
144
- default:
145
- throw new Error(`Invalid geometry type: ${this.type}`);
146
- }
147
- const result = { type: 'Feature', geometry, properties: this.properties };
148
- if (this.id !== null) {
149
- result.id = this.id;
150
- }
151
- return result;
152
- }
153
- toBinaryCoordinates(options) {
154
- if (typeof options === 'function') {
155
- return this._toBinaryCoordinates(options);
156
- }
157
- const { x, y, z } = options;
158
- const size = this.extent * Math.pow(2, z);
159
- const x0 = this.extent * x;
160
- const y0 = this.extent * y;
161
- return this._toBinaryCoordinates((data) => project(data, x0, y0, size));
162
- }
163
- }
@@ -1,23 +0,0 @@
1
- import { BinaryVectorTileFeature } from "./vector-tile-feature.js";
2
- import Protobuf from 'pbf';
3
- import { GeojsonGeometryInfo } from '@loaders.gl/schema';
4
- export declare class BinaryVectorTileLayer {
5
- version: number;
6
- name: string;
7
- extent: number;
8
- length: number;
9
- _pbf: Protobuf;
10
- _keys: string[];
11
- _values: (string | number | boolean | null)[];
12
- _features: number[];
13
- constructor(pbf: Protobuf, end: number);
14
- /**
15
- * return feature `i` from this layer as a `BinaryVectorTileFeature`
16
- *
17
- * @param index
18
- * @param geometryInfo
19
- * @returns {BinaryVectorTileFeature}
20
- */
21
- feature(i: number, geometryInfo: GeojsonGeometryInfo): BinaryVectorTileFeature;
22
- }
23
- //# sourceMappingURL=vector-tile-layer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector-tile-layer.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/vector-tile-layer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,uBAAuB,EAAC,iCAA8B;AAC9D,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,qBAAqB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;IAC9C,SAAS,EAAE,MAAM,EAAE,CAAC;gBACR,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM;IAkBtC;;;;;;OAMG;IACH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,GAAG,uBAAuB;CAiB/E"}
@@ -1,96 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright vis.gl contributors
4
- /* eslint-disable indent */
5
- // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
6
- import { BinaryVectorTileFeature } from "./vector-tile-feature.js";
7
- export class BinaryVectorTileLayer {
8
- version;
9
- name;
10
- extent;
11
- length;
12
- _pbf;
13
- _keys;
14
- _values;
15
- _features;
16
- constructor(pbf, end) {
17
- // Public
18
- this.version = 1;
19
- this.name = '';
20
- this.extent = 4096;
21
- this.length = 0;
22
- // Private
23
- this._pbf = pbf;
24
- this._keys = [];
25
- this._values = [];
26
- this._features = [];
27
- pbf.readFields(readLayer, this, end);
28
- this.length = this._features.length;
29
- }
30
- /**
31
- * return feature `i` from this layer as a `BinaryVectorTileFeature`
32
- *
33
- * @param index
34
- * @param geometryInfo
35
- * @returns {BinaryVectorTileFeature}
36
- */
37
- feature(i, geometryInfo) {
38
- if (i < 0 || i >= this._features.length) {
39
- throw new Error('feature index out of bounds');
40
- }
41
- this._pbf.pos = this._features[i];
42
- const end = this._pbf.readVarint() + this._pbf.pos;
43
- return new BinaryVectorTileFeature(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
44
- }
45
- }
46
- /**
47
- *
48
- * @param tag
49
- * @param layer
50
- * @param pbf
51
- */
52
- function readLayer(tag, layer, pbf) {
53
- if (layer && pbf) {
54
- if (tag === 15)
55
- layer.version = pbf.readVarint();
56
- else if (tag === 1)
57
- layer.name = pbf.readString();
58
- else if (tag === 5)
59
- layer.extent = pbf.readVarint();
60
- else if (tag === 2)
61
- layer._features.push(pbf.pos);
62
- else if (tag === 3)
63
- layer._keys.push(pbf.readString());
64
- else if (tag === 4)
65
- layer._values.push(readValueMessage(pbf));
66
- }
67
- }
68
- /**
69
- *
70
- * @param pbf
71
- * @returns value
72
- */
73
- function readValueMessage(pbf) {
74
- let value = null;
75
- const end = pbf.readVarint() + pbf.pos;
76
- while (pbf.pos < end) {
77
- const tag = pbf.readVarint() >> 3;
78
- value =
79
- tag === 1
80
- ? pbf.readString()
81
- : tag === 2
82
- ? pbf.readFloat()
83
- : tag === 3
84
- ? pbf.readDouble()
85
- : tag === 4
86
- ? pbf.readVarint64()
87
- : tag === 5
88
- ? pbf.readVarint()
89
- : tag === 6
90
- ? pbf.readSVarint()
91
- : tag === 7
92
- ? pbf.readBoolean()
93
- : null;
94
- }
95
- return value;
96
- }
@@ -1,9 +0,0 @@
1
- import { BinaryVectorTileLayer } from "./vector-tile-layer.js";
2
- import Protobuf from 'pbf';
3
- export declare class BinaryVectorTile {
4
- layers: {
5
- [x: string]: BinaryVectorTileLayer;
6
- };
7
- constructor(pbf: Protobuf, end?: number);
8
- }
9
- //# sourceMappingURL=vector-tile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/vector-tile.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,qBAAqB,EAAC,+BAA4B;AAC1D,OAAO,QAAQ,MAAM,KAAK,CAAC;AAE3B,qBAAa,gBAAgB;IAC3B,MAAM,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAA;KAAC,CAAC;gBACjC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM;CAGxC"}
@@ -1,27 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright vis.gl contributors
4
- // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
5
- import { BinaryVectorTileLayer } from "./vector-tile-layer.js";
6
- export class BinaryVectorTile {
7
- layers;
8
- constructor(pbf, end) {
9
- this.layers = pbf.readFields(readTile, {}, end);
10
- }
11
- }
12
- /**
13
- *
14
- * @param tag
15
- * @param layers
16
- * @param pbf
17
- */
18
- function readTile(tag, layers, pbf) {
19
- if (tag === 3) {
20
- if (pbf) {
21
- const layer = new BinaryVectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
22
- if (layer.length && layers) {
23
- layers[layer.name] = layer;
24
- }
25
- }
26
- }
27
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/clip.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAC,kBAAe;AAK/C;;;;;;;;;;GAUG;AAEH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,KAAA,EACJ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAC,WAAW,EAAE,OAAO,CAAA;CAAC,GAC9B,kBAAkB,EAAE,GAAG,IAAI,CA4E7B"}
@@ -1,10 +0,0 @@
1
- import type { Feature } from '@loaders.gl/schema';
2
- import type { GeoJSONTileFeature } from "./tile.js";
3
- export declare function convert(data: Feature, options: any): GeoJSONTileFeature[];
4
- export type ConvertFeatureOptions = {
5
- maxZoom?: number;
6
- tolerance: number;
7
- extent: number;
8
- lineMetrics: boolean;
9
- };
10
- //# sourceMappingURL=convert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convert.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/convert.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAC,kBAAkB,EAAC,kBAAe;AAO/C,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,KAAA,GAAG,kBAAkB,EAAE,CAcpE;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/feature.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,kBAAkB,EAAC,kBAAe;AAE1C,wBAAgB,aAAa,CAAC,EAAE,KAAA,EAAE,IAAI,KAAA,EAAE,IAAI,KAAA,EAAE,IAAI,KAAA,GAAG,kBAAkB,CA8BtE"}
@@ -1,44 +0,0 @@
1
- import type { GeoJSONTile, GeoJSONTileFeature } from "./tile.js";
2
- /** Options to configure tiling */
3
- export type GeoJSONTilerOptions = {
4
- maxZoom?: number /** max zoom to preserve detail on */;
5
- indexMaxZoom?: number /** max zoom in the tile index */;
6
- indexMaxPoints?: number /** max number of points per tile in the tile index */;
7
- tolerance?: number /** simplification tolerance (higher means simpler) */;
8
- extent?: number /** tile extent */;
9
- buffer?: number /** tile buffer on each side */;
10
- lineMetrics?: boolean /** whether to calculate line metrics */;
11
- promoteId?: string /** name of a feature property to be promoted to feature.id */;
12
- generateId?: boolean /** whether to generate feature ids. Cannot be used with promoteId */;
13
- debug?: number /** logging level (0, 1 or 2) */;
14
- };
15
- export declare class GeoJSONTiler {
16
- options: Required<GeoJSONTilerOptions>;
17
- tiles: Record<string, GeoJSONTile>;
18
- tileCoords: {
19
- x: number;
20
- y: number;
21
- z: number;
22
- }[];
23
- stats: Record<string, number>;
24
- total: number;
25
- constructor(data: any, options?: GeoJSONTilerOptions);
26
- /**
27
- * Get a tile at the specified index
28
- * @param z
29
- * @param x
30
- * @param y
31
- * @returns
32
- */
33
- getTile(z: number, x: number, y: number): GeoJSONTile | null;
34
- /**
35
- * splits features from a parent tile to sub-tiles.
36
- * @param z, x, and y are the coordinates of the parent tile
37
- * @param cz, cx, and cy are the coordinates of the target tile
38
- *
39
- * If no target tile is specified, splitting stops when we reach the maximum
40
- * zoom or the number of points is low as specified in the options.
41
- */
42
- splitTile(features: GeoJSONTileFeature[], z: number, x: number, y: number, cz?: number, cx?: number, cy?: number): void;
43
- }
44
- //# sourceMappingURL=geojson-tiler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"geojson-tiler.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/geojson-tiler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,WAAW,EAAE,kBAAkB,EAAC,kBAAe;AAQ5D,kCAAkC;AAClC,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,qCAAqC,CAAC;IACvD,YAAY,CAAC,EAAE,MAAM,CAAC,iCAAiC,CAAC;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC,sDAAsD,CAAC;IAC/E,SAAS,CAAC,EAAE,MAAM,CAAC,sDAAsD,CAAC;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC,kBAAkB,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,+BAA+B,CAAC;IAChD,WAAW,CAAC,EAAE,OAAO,CAAC,wCAAwC,CAAC;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC,8DAA8D,CAAC;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC,qEAAqE,CAAC;IAC3F,KAAK,CAAC,EAAE,MAAM,CAAC,gCAAgC,CAAC;CACjD,CAAC;AAgBF,qBAAa,YAAY;IACvB,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IAGvC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAM;IACxC,UAAU,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,EAAE,CAAM;IAErD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACnC,KAAK,EAAE,MAAM,CAAK;gBAEN,IAAI,KAAA,EAAE,OAAO,CAAC,EAAE,mBAAmB;IA6C/C;;;;;;OAMG;IAEH,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAkD5D;;;;;;;OAOG;IAEH,SAAS,CACP,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,CAAC,EAAE,MAAM,EACX,EAAE,CAAC,EAAE,MAAM,EACX,EAAE,CAAC,EAAE,MAAM,GACV,IAAI;CAyGR"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"simplify.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/simplify.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAkCjG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tile.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/tile.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,GAAG,CAAC;IAGd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAGhB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAG9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IAGV,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAEb,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,KAAA,EAAE,EAAE,KAAA,EAAE,EAAE,KAAA,EAAE,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAqB9F"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/transform.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,WAAW,EAAC,kBAAe;AAExC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAiC5E"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/wrap.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,kBAAkB,EAAC,kBAAe;AAI/C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,8CAA8C,CAAC;IAC9D,MAAM,EAAE,MAAM,CAAC,0BAA0B,CAAC;IAC1C,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,kBAAkB,EAAE,EAAE,OAAO,EAAE,WAAW,wBAkBxE"}
@@ -1,27 +0,0 @@
1
- import Protobuf from 'pbf';
2
- import { MVTMapboxCoordinates, MVTMapboxGeometry } from "../types.js";
3
- export declare class VectorTileFeature {
4
- properties: {
5
- [x: string]: string | number | boolean | null;
6
- };
7
- extent: any;
8
- type: number;
9
- id: number | null;
10
- _pbf: Protobuf;
11
- _geometry: number;
12
- _keys: string[];
13
- _values: (string | number | boolean | null)[];
14
- static get types(): string[];
15
- constructor(pbf: Protobuf, end: number, extent: any, keys: string[], values: (string | number | boolean | null)[]);
16
- loadGeometry(): MVTMapboxGeometry;
17
- bbox(): number[];
18
- _toGeoJSON(transform: any): MVTMapboxCoordinates;
19
- toGeoJSON(options: {
20
- x: number;
21
- y: number;
22
- z: number;
23
- } | ((data: number[], feature: {
24
- extent: any;
25
- }) => void)): MVTMapboxCoordinates;
26
- }
27
- //# sourceMappingURL=vector-tile-feature.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector-tile-feature.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile-feature.ts"],"names":[],"mappings":"AAKA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,oBAAoB,EAAE,iBAAiB,EAAC,oBAAiB;AAGjE,qBAAa,iBAAiB;IAC5B,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,IAAI,CAAC,EAAE,CAAC;IAC9C,MAAM,KAAK,KAAK,aAEf;gBAGC,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,GAAG,EACX,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE;IAkB9C,YAAY,IAAI,iBAAiB;IA+CjC,IAAI;IAsCJ,UAAU,CAAC,SAAS,KAAA;IAuDpB,SAAS,CACP,OAAO,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE;QAAC,MAAM,EAAE,GAAG,CAAA;KAAC,KAAK,IAAI,CAAC,GAC9F,oBAAoB;CAmBxB"}
@@ -1,178 +0,0 @@
1
- // loaders.gl
2
- // SPDX-License-Identifier: MIT
3
- // Copyright vis.gl contributors
4
- import { readFeature, classifyRings } from "../../helpers/mapbox-util-functions.js";
5
- export class VectorTileFeature {
6
- properties;
7
- extent;
8
- type;
9
- id;
10
- _pbf;
11
- _geometry;
12
- _keys;
13
- _values;
14
- static get types() {
15
- return ['Unknown', 'Point', 'LineString', 'Polygon'];
16
- }
17
- constructor(pbf, end, extent, keys, values) {
18
- // Public
19
- this.properties = {};
20
- this.extent = extent;
21
- this.type = 0;
22
- this.id = null;
23
- // Private
24
- this._pbf = pbf;
25
- this._geometry = -1;
26
- this._keys = keys;
27
- this._values = values;
28
- pbf.readFields(readFeature, this, end);
29
- }
30
- // eslint-disable-next-line complexity, max-statements
31
- loadGeometry() {
32
- const pbf = this._pbf;
33
- pbf.pos = this._geometry;
34
- const end = pbf.readVarint() + pbf.pos;
35
- let cmd = 1;
36
- let length = 0;
37
- let x = 0;
38
- let y = 0;
39
- const lines = [];
40
- let line;
41
- while (pbf.pos < end) {
42
- if (length <= 0) {
43
- const cmdLen = pbf.readVarint();
44
- cmd = cmdLen & 0x7;
45
- length = cmdLen >> 3;
46
- }
47
- length--;
48
- if (cmd === 1 || cmd === 2) {
49
- x += pbf.readSVarint();
50
- y += pbf.readSVarint();
51
- if (cmd === 1) {
52
- // moveTo
53
- if (line)
54
- lines.push(line);
55
- line = [];
56
- }
57
- if (line)
58
- line.push([x, y]);
59
- }
60
- else if (cmd === 7) {
61
- // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
62
- if (line) {
63
- line.push(line[0].slice()); // closePolygon
64
- }
65
- }
66
- else {
67
- throw new Error(`unknown command ${cmd}`);
68
- }
69
- }
70
- if (line)
71
- lines.push(line);
72
- return lines;
73
- }
74
- // eslint-disable-next-line max-statements
75
- bbox() {
76
- const pbf = this._pbf;
77
- pbf.pos = this._geometry;
78
- const end = pbf.readVarint() + pbf.pos;
79
- let cmd = 1;
80
- let length = 0;
81
- let x = 0;
82
- let y = 0;
83
- let x1 = Infinity;
84
- let x2 = -Infinity;
85
- let y1 = Infinity;
86
- let y2 = -Infinity;
87
- while (pbf.pos < end) {
88
- if (length <= 0) {
89
- const cmdLen = pbf.readVarint();
90
- cmd = cmdLen & 0x7;
91
- length = cmdLen >> 3;
92
- }
93
- length--;
94
- if (cmd === 1 || cmd === 2) {
95
- x += pbf.readSVarint();
96
- y += pbf.readSVarint();
97
- if (x < x1)
98
- x1 = x;
99
- if (x > x2)
100
- x2 = x;
101
- if (y < y1)
102
- y1 = y;
103
- if (y > y2)
104
- y2 = y;
105
- }
106
- else if (cmd !== 7) {
107
- throw new Error(`unknown command ${cmd}`);
108
- }
109
- }
110
- return [x1, y1, x2, y2];
111
- }
112
- _toGeoJSON(transform) {
113
- let coords = this.loadGeometry();
114
- let type = VectorTileFeature.types[this.type];
115
- let i;
116
- let j;
117
- // eslint-disable-next-line default-case
118
- switch (this.type) {
119
- case 1:
120
- const points = [];
121
- for (i = 0; i < coords.length; i++) {
122
- points[i] = coords[i][0];
123
- }
124
- coords = points;
125
- transform(coords, this);
126
- break;
127
- case 2:
128
- for (i = 0; i < coords.length; i++) {
129
- transform(coords[i], this);
130
- }
131
- break;
132
- case 3:
133
- coords = classifyRings(coords);
134
- for (i = 0; i < coords.length; i++) {
135
- for (j = 0; j < coords[i].length; j++) {
136
- transform(coords[i][j], this);
137
- }
138
- }
139
- break;
140
- }
141
- if (coords.length === 1) {
142
- coords = coords[0];
143
- }
144
- else {
145
- type = `Multi${type}`;
146
- }
147
- const result = {
148
- type: 'Feature',
149
- geometry: {
150
- type,
151
- coordinates: coords
152
- },
153
- properties: this.properties
154
- };
155
- if (this.id !== null) {
156
- result.id = this.id;
157
- }
158
- return result;
159
- }
160
- toGeoJSON(options) {
161
- if (typeof options === 'function') {
162
- return this._toGeoJSON(options);
163
- }
164
- const { x, y, z } = options;
165
- const size = this.extent * Math.pow(2, z);
166
- const x0 = this.extent * x;
167
- const y0 = this.extent * y;
168
- function project(line) {
169
- for (let j = 0; j < line.length; j++) {
170
- const p = line[j];
171
- p[0] = ((p[0] + x0) * 360) / size - 180;
172
- const y2 = 180 - ((p[1] + y0) * 360) / size;
173
- p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
174
- }
175
- }
176
- return this._toGeoJSON(project);
177
- }
178
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector-tile-layer.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile-layer.ts"],"names":[],"mappings":"AAOA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,iCAA8B;AAExD,qBAAa,eAAe;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC;IAC9C,SAAS,EAAE,MAAM,EAAE,CAAC;gBACR,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM;IAkBtC;;;;OAIG;IAEH,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,iBAAiB;CAUtC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"vector-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/mapbox-vector-tile/vector-tile.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,eAAe,EAAC,+BAA4B;AACpD,OAAO,QAAQ,MAAM,KAAK,CAAC;AAE3B,qBAAa,UAAU;IACrB,MAAM,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,eAAe,CAAA;KAAC,CAAC;gBAC3B,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,MAAM;CAGxC"}