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

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 (50) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/dist.min.js +1 -1
  3. package/dist/dist.min.js.map +1 -1
  4. package/dist/es5/bundle.js +1 -1
  5. package/dist/es5/bundle.js.map +1 -1
  6. package/dist/es5/helpers/binary-util-functions.js +18 -18
  7. package/dist/es5/helpers/binary-util-functions.js.map +1 -1
  8. package/dist/es5/helpers/mapbox-util-functions.js +11 -11
  9. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -1
  10. package/dist/es5/index.js +2 -2
  11. package/dist/es5/lib/binary-vector-tile/features-to-binary.js +130 -177
  12. package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +1 -1
  13. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +104 -131
  14. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
  15. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +15 -23
  16. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -1
  17. package/dist/es5/lib/binary-vector-tile/vector-tile.js +8 -8
  18. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -1
  19. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +147 -157
  20. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -1
  21. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +15 -23
  22. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -1
  23. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +8 -8
  24. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -1
  25. package/dist/es5/lib/parse-mvt.js +33 -35
  26. package/dist/es5/lib/parse-mvt.js.map +1 -1
  27. package/dist/es5/mvt-loader.js +5 -38
  28. package/dist/es5/mvt-loader.js.map +1 -1
  29. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +2 -2
  30. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
  31. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +3 -3
  32. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -1
  33. package/dist/esm/mvt-loader.js +1 -1
  34. package/dist/helpers/binary-util-functions.d.ts +38 -0
  35. package/dist/helpers/mapbox-util-functions.d.ts +28 -0
  36. package/dist/index.d.ts +1 -0
  37. package/dist/lib/binary-vector-tile/features-to-binary.d.ts +184 -0
  38. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +35 -0
  39. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +22 -0
  40. package/dist/lib/binary-vector-tile/vector-tile.d.ts +8 -0
  41. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +26 -0
  42. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +19 -0
  43. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +8 -0
  44. package/dist/lib/parse-mvt.d.ts +84 -0
  45. package/dist/lib/types.d.ts +91 -0
  46. package/dist/mvt-loader.d.ts +9 -0
  47. package/dist/mvt-worker.js +1 -1
  48. package/dist/mvt-worker.js.map +1 -1
  49. package/dist/workers/mvt-worker.d.ts +1 -0
  50. package/package.json +6 -5
@@ -0,0 +1,184 @@
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 {};
@@ -0,0 +1,35 @@
1
+ import Protobuf from 'pbf';
2
+ import { MvtBinaryCoordinates, MvtBinaryGeometry, MvtFirstPassedData } from '../types';
3
+ import { classifyRings } from '../../helpers/binary-util-functions';
4
+ export declare const TEST_EXPORTS: {
5
+ classifyRings: typeof classifyRings;
6
+ };
7
+ export default class VectorTileFeature {
8
+ properties: {
9
+ [x: string]: string | number | boolean | null;
10
+ };
11
+ extent: any;
12
+ type: number;
13
+ id: number | null;
14
+ _pbf: Protobuf;
15
+ _geometry: number;
16
+ _keys: string[];
17
+ _values: (string | number | boolean | null)[];
18
+ _firstPassData: MvtFirstPassedData;
19
+ static get types(): string[];
20
+ constructor(pbf: Protobuf, end: number, extent: any, keys: string[], values: (string | number | boolean | null)[], firstPassData: MvtFirstPassedData);
21
+ loadGeometry(): MvtBinaryGeometry;
22
+ /**
23
+ *
24
+ * @param transform
25
+ * @returns result
26
+ */
27
+ _toBinaryCoordinates(transform: any): MvtBinaryCoordinates;
28
+ toBinaryCoordinates(options: {
29
+ x: number;
30
+ y: number;
31
+ z: number;
32
+ } | ((data: number[], feature: {
33
+ extent: any;
34
+ }) => void)): MvtBinaryCoordinates;
35
+ }
@@ -0,0 +1,22 @@
1
+ import VectorTileFeature from './vector-tile-feature';
2
+ import Protobuf from 'pbf';
3
+ import { MvtFirstPassedData } from '../types';
4
+ export default class VectorTileLayer {
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 `VectorTileFeature`
16
+ *
17
+ * @param index
18
+ * @param firstPassData
19
+ * @returns {VectorTileFeature}
20
+ */
21
+ feature(i: number, firstPassData: MvtFirstPassedData): VectorTileFeature;
22
+ }
@@ -0,0 +1,8 @@
1
+ import VectorTileLayer from './vector-tile-layer';
2
+ import Protobuf from 'pbf';
3
+ export default class VectorTile {
4
+ layers: {
5
+ [x: string]: VectorTileLayer;
6
+ };
7
+ constructor(pbf: Protobuf, end?: number);
8
+ }
@@ -0,0 +1,26 @@
1
+ import Protobuf from 'pbf';
2
+ import { MvtMapboxCoordinates, MvtMapboxGeometry } from '../types';
3
+ export default 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
+ }
@@ -0,0 +1,19 @@
1
+ import Protobuf from 'pbf';
2
+ import VectorTileFeature from './vector-tile-feature';
3
+ export default class VectorTileLayer {
4
+ version: number;
5
+ name: string;
6
+ extent: number;
7
+ length: number;
8
+ _pbf: Protobuf;
9
+ _keys: string[];
10
+ _values: (string | number | boolean | null)[];
11
+ _features: number[];
12
+ constructor(pbf: Protobuf, end: number);
13
+ /**
14
+ * return feature `i` from this layer as a `VectorTileFeature`
15
+ * @param index
16
+ * @returns feature
17
+ */
18
+ feature(i: number): VectorTileFeature;
19
+ }
@@ -0,0 +1,8 @@
1
+ import VectorTileLayer from './vector-tile-layer';
2
+ import Protobuf from 'pbf';
3
+ export default class VectorTile {
4
+ layers: {
5
+ [x: string]: VectorTileLayer;
6
+ };
7
+ constructor(pbf: Protobuf, end?: number);
8
+ }
@@ -0,0 +1,84 @@
1
+ import { MvtBinaryCoordinates, MvtMapboxCoordinates } from '../lib/types';
2
+ import { LoaderOptions } from '@loaders.gl/loader-utils/';
3
+ /**
4
+ * Parse MVT arrayBuffer and return GeoJSON.
5
+ *
6
+ * @param arrayBuffer A MVT arrayBuffer
7
+ * @param options
8
+ * @returns A GeoJSON geometry object or a binary representation
9
+ */
10
+ export default function parseMVT(arrayBuffer: ArrayBuffer, options?: LoaderOptions): {
11
+ points: {
12
+ positions: {
13
+ value: Float32Array;
14
+ size: number;
15
+ };
16
+ globalFeatureIds: {
17
+ value: Uint16Array | Uint32Array;
18
+ size: number;
19
+ };
20
+ featureIds: {
21
+ value: Uint16Array | Uint32Array;
22
+ size: number;
23
+ };
24
+ numericProps: object;
25
+ properties: {}[];
26
+ fields: {
27
+ id?: number | undefined;
28
+ }[];
29
+ };
30
+ lines: {
31
+ pathIndices: {
32
+ value: Uint16Array | Uint32Array;
33
+ size: number;
34
+ };
35
+ positions: {
36
+ value: Float32Array;
37
+ size: number;
38
+ };
39
+ globalFeatureIds: {
40
+ value: Uint16Array | Uint32Array;
41
+ size: number;
42
+ };
43
+ featureIds: {
44
+ value: Uint16Array | Uint32Array;
45
+ size: number;
46
+ };
47
+ numericProps: object;
48
+ properties: {}[];
49
+ fields: {
50
+ id?: number | undefined;
51
+ }[];
52
+ };
53
+ polygons: {
54
+ polygonIndices: {
55
+ value: Uint16Array | Uint32Array;
56
+ size: number;
57
+ };
58
+ primitivePolygonIndices: {
59
+ value: Uint16Array | Uint32Array;
60
+ size: number;
61
+ };
62
+ positions: {
63
+ value: Float32Array;
64
+ size: number;
65
+ };
66
+ triangles: {
67
+ value: Uint32Array;
68
+ size: number;
69
+ };
70
+ globalFeatureIds: {
71
+ value: Uint16Array | Uint32Array;
72
+ size: number;
73
+ };
74
+ featureIds: {
75
+ value: Uint16Array | Uint32Array;
76
+ size: number;
77
+ };
78
+ numericProps: object;
79
+ properties: {}[];
80
+ fields: {
81
+ id?: number | undefined;
82
+ }[];
83
+ };
84
+ } | (MvtBinaryCoordinates | MvtMapboxCoordinates)[];
@@ -0,0 +1,91 @@
1
+ export declare type MvtOptions = {
2
+ coordinates: string | number[];
3
+ tileIndex: {
4
+ x: number;
5
+ y: number;
6
+ z: number;
7
+ };
8
+ layerProperty: string | number;
9
+ layerName: string;
10
+ };
11
+ export declare type MvtBinaryGeometry = {
12
+ data: number[];
13
+ lines: any[];
14
+ areas?: number[];
15
+ type?: string;
16
+ id?: number;
17
+ };
18
+ export declare type MvtMapboxGeometry = {
19
+ type?: string;
20
+ id?: number;
21
+ length: number;
22
+ coordinates?: any[];
23
+ };
24
+ export declare type MvtBinaryCoordinates = {
25
+ type: string;
26
+ geometry: MvtBinaryGeometry;
27
+ properties: {
28
+ [x: string]: string | number | boolean | null;
29
+ };
30
+ id?: number;
31
+ };
32
+ export declare type MvtMapboxCoordinates = {
33
+ type: string;
34
+ geometry: {
35
+ type: string;
36
+ coordinates: MvtMapboxGeometry;
37
+ };
38
+ properties: {
39
+ [x: string]: string | number | boolean | null;
40
+ };
41
+ id?: number;
42
+ };
43
+ export declare type MvtBinaryOptions = {
44
+ numericPropKeys: string[];
45
+ PositionDataType: Float32ArrayConstructor;
46
+ };
47
+ export declare type MvtFirstPassedData = {
48
+ pointPositionsCount: number;
49
+ pointFeaturesCount: number;
50
+ linePositionsCount: number;
51
+ linePathsCount: number;
52
+ lineFeaturesCount: number;
53
+ polygonPositionsCount: number;
54
+ polygonObjectsCount: number;
55
+ polygonRingsCount: number;
56
+ polygonFeaturesCount: number;
57
+ };
58
+ export declare type MvtPoints = {
59
+ positions: Float32Array;
60
+ globalFeatureIds: Uint16Array | Uint32Array;
61
+ featureIds: Uint16Array | Uint32Array;
62
+ numericProps: object;
63
+ properties: {}[];
64
+ fields: {
65
+ id?: number;
66
+ }[];
67
+ };
68
+ export declare type MvtLines = {
69
+ pathIndices: Uint16Array | Uint32Array;
70
+ positions: Float32Array;
71
+ globalFeatureIds: Uint16Array | Uint32Array;
72
+ featureIds: Uint16Array | Uint32Array;
73
+ numericProps: object;
74
+ properties: {}[];
75
+ fields: {
76
+ id?: number;
77
+ }[];
78
+ };
79
+ export declare type MvtPolygons = {
80
+ polygonIndices: Uint16Array | Uint32Array;
81
+ primitivePolygonIndices: Uint16Array | Uint32Array;
82
+ positions: Float32Array;
83
+ triangles: number[];
84
+ globalFeatureIds: Uint16Array | Uint32Array;
85
+ featureIds: Uint16Array | Uint32Array;
86
+ numericProps: object;
87
+ properties: {}[];
88
+ fields: {
89
+ id?: number;
90
+ }[];
91
+ };
@@ -0,0 +1,9 @@
1
+ import type { Loader, LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * Worker loader for the Mapbox Vector Tile format
4
+ */
5
+ export declare const MVTWorkerLoader: Loader;
6
+ /**
7
+ * Loader for the Mapbox Vector Tile format
8
+ */
9
+ export declare const MVTLoader: LoaderWithParser;