maplibre-gl 3.5.1 → 3.5.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.
- package/build/rollup_plugins.ts +9 -0
- package/dist/maplibre-gl-csp-worker.js +1 -1
- package/dist/maplibre-gl-csp-worker.js.map +1 -1
- package/dist/maplibre-gl-csp.js +1 -1
- package/dist/maplibre-gl-csp.js.map +1 -1
- package/dist/maplibre-gl-dev.js +77 -71
- package/dist/maplibre-gl-dev.js.map +1 -1
- package/dist/maplibre-gl.d.ts +139 -63
- package/dist/maplibre-gl.js +4 -4
- package/dist/maplibre-gl.js.map +1 -1
- package/package.json +26 -25
- package/src/data/bucket/symbol_bucket.ts +1 -1
- package/src/data/bucket.ts +1 -1
- package/src/data/evaluation_feature.ts +2 -14
- package/src/gl/webgl2.ts +1 -1
- package/src/source/geojson_worker_source.ts +39 -45
- package/src/source/geojson_wrapper.ts +5 -15
- package/src/source/worker.test.ts +2 -1
- package/src/source/worker.ts +9 -9
- package/src/style/style.test.ts +27 -0
- package/src/style/style.ts +3 -1
- package/src/util/actor.test.ts +11 -9
- package/src/util/actor.ts +81 -42
- package/src/util/dispatcher.test.ts +7 -8
- package/src/util/dispatcher.ts +5 -12
- package/src/util/web_worker.ts +0 -15
- package/src/util/web_worker_transfer.ts +4 -5
- package/src/util/worker_pool.ts +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "maplibre-gl",
|
|
3
3
|
"description": "BSD licensed community fork of mapbox-gl, a WebGL interactive maps library",
|
|
4
|
-
"version": "3.5.
|
|
4
|
+
"version": "3.5.2",
|
|
5
5
|
"main": "dist/maplibre-gl.js",
|
|
6
6
|
"style": "dist/maplibre-gl.css",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"@mapbox/unitbezier": "^0.0.1",
|
|
21
21
|
"@mapbox/vector-tile": "^1.3.1",
|
|
22
22
|
"@mapbox/whoots-js": "^3.1.0",
|
|
23
|
-
"@maplibre/maplibre-gl-style-spec": "^19.3.
|
|
24
|
-
"@types/geojson": "^7946.0.
|
|
25
|
-
"@types/mapbox__point-geometry": "^0.1.
|
|
26
|
-
"@types/mapbox__vector-tile": "^1.3.
|
|
27
|
-
"@types/pbf": "^3.0.
|
|
28
|
-
"@types/supercluster": "^7.1.
|
|
23
|
+
"@maplibre/maplibre-gl-style-spec": "^19.3.3",
|
|
24
|
+
"@types/geojson": "^7946.0.12",
|
|
25
|
+
"@types/mapbox__point-geometry": "^0.1.3",
|
|
26
|
+
"@types/mapbox__vector-tile": "^1.3.3",
|
|
27
|
+
"@types/pbf": "^3.0.4",
|
|
28
|
+
"@types/supercluster": "^7.1.2",
|
|
29
29
|
"earcut": "^2.2.4",
|
|
30
30
|
"geojson-vt": "^3.2.1",
|
|
31
31
|
"gl-matrix": "^3.4.3",
|
|
@@ -52,41 +52,42 @@
|
|
|
52
52
|
"@types/benchmark": "^2.1.3",
|
|
53
53
|
"@types/cssnano": "^5.0.0",
|
|
54
54
|
"@types/d3": "^7.4.1",
|
|
55
|
-
"@types/diff": "^5.0.
|
|
56
|
-
"@types/earcut": "^2.1.
|
|
57
|
-
"@types/eslint": "^8.44.
|
|
58
|
-
"@types/
|
|
55
|
+
"@types/diff": "^5.0.7",
|
|
56
|
+
"@types/earcut": "^2.1.3",
|
|
57
|
+
"@types/eslint": "^8.44.6",
|
|
58
|
+
"@types/geojson-vt": "3.2.3",
|
|
59
|
+
"@types/gl": "^6.0.4",
|
|
59
60
|
"@types/glob": "^8.1.0",
|
|
60
61
|
"@types/jest": "^29.5.3",
|
|
61
62
|
"@types/jsdom": "^21.1.3",
|
|
62
|
-
"@types/minimist": "^1.2.
|
|
63
|
-
"@types/murmurhash-js": "^1.0.
|
|
63
|
+
"@types/minimist": "^1.2.4",
|
|
64
|
+
"@types/murmurhash-js": "^1.0.5",
|
|
64
65
|
"@types/nise": "^1.4.2",
|
|
65
66
|
"@types/node": "^20.8.3",
|
|
66
|
-
"@types/offscreencanvas": "^2019.7.
|
|
67
|
+
"@types/offscreencanvas": "^2019.7.2",
|
|
67
68
|
"@types/pixelmatch": "^5.2.4",
|
|
68
|
-
"@types/pngjs": "^6.0.
|
|
69
|
-
"@types/react": "^18.2.
|
|
69
|
+
"@types/pngjs": "^6.0.3",
|
|
70
|
+
"@types/react": "^18.2.31",
|
|
70
71
|
"@types/react-dom": "^18.2.13",
|
|
71
|
-
"@types/request": "^2.48.
|
|
72
|
-
"@types/shuffle-seed": "^1.1.
|
|
72
|
+
"@types/request": "^2.48.11",
|
|
73
|
+
"@types/shuffle-seed": "^1.1.1",
|
|
73
74
|
"@types/window-or-global": "^1.0.4",
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
75
|
-
"@typescript-eslint/parser": "^6.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
76
|
+
"@typescript-eslint/parser": "^6.8.0",
|
|
76
77
|
"address": "^2.0.1",
|
|
77
78
|
"benchmark": "^2.1.4",
|
|
78
79
|
"canvas": "^2.11.2",
|
|
79
80
|
"cssnano": "^6.0.1",
|
|
80
81
|
"d3": "^7.8.5",
|
|
81
82
|
"d3-queue": "^3.0.7",
|
|
82
|
-
"devtools-protocol": "^0.0.
|
|
83
|
+
"devtools-protocol": "^0.0.1212569",
|
|
83
84
|
"diff": "^5.1.0",
|
|
84
85
|
"dts-bundle-generator": "^8.0.1",
|
|
85
|
-
"eslint": "^8.
|
|
86
|
+
"eslint": "^8.52.0",
|
|
86
87
|
"eslint-config-mourner": "^3.0.0",
|
|
87
88
|
"eslint-plugin-html": "^7.1.0",
|
|
88
89
|
"eslint-plugin-import": "^2.28.1",
|
|
89
|
-
"eslint-plugin-jest": "^27.4.
|
|
90
|
+
"eslint-plugin-jest": "^27.4.3",
|
|
90
91
|
"eslint-plugin-react": "^7.33.2",
|
|
91
92
|
"eslint-plugin-tsdoc": "0.2.17",
|
|
92
93
|
"expect": "^29.7.0",
|
|
@@ -100,7 +101,7 @@
|
|
|
100
101
|
"json-stringify-pretty-compact": "^4.0.0",
|
|
101
102
|
"minimist": "^1.2.8",
|
|
102
103
|
"mock-geolocation": "^1.0.11",
|
|
103
|
-
"nise": "^5.1.
|
|
104
|
+
"nise": "^5.1.5",
|
|
104
105
|
"npm-font-open-sans": "^1.1.0",
|
|
105
106
|
"npm-run-all": "^4.1.5",
|
|
106
107
|
"pdf-merger-js": "^4.3.0",
|
|
@@ -120,7 +121,7 @@
|
|
|
120
121
|
"shuffle-seed": "^1.1.6",
|
|
121
122
|
"source-map-explorer": "^2.5.3",
|
|
122
123
|
"st": "^3.0.0",
|
|
123
|
-
"stylelint": "^15.
|
|
124
|
+
"stylelint": "^15.11.0",
|
|
124
125
|
"stylelint-config-standard": "^34.0.0",
|
|
125
126
|
"ts-jest": "^29.1.1",
|
|
126
127
|
"ts-node": "^10.9.1",
|
package/src/data/bucket.ts
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import {loadGeometry} from './load_geometry';
|
|
2
2
|
import type Point from '@mapbox/point-geometry';
|
|
3
3
|
import type {VectorTileFeature} from '@mapbox/vector-tile';
|
|
4
|
+
import type {Feature} from '@maplibre/maplibre-gl-style-spec';
|
|
4
5
|
|
|
5
|
-
type EvaluationFeature = {
|
|
6
|
-
readonly type: 1 | 2 | 3 | 'Unknown' | 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon';
|
|
7
|
-
readonly id?: any;
|
|
8
|
-
readonly properties: {[_: string]: any};
|
|
9
|
-
readonly patterns?: {
|
|
10
|
-
[_: string]: {
|
|
11
|
-
'min': string;
|
|
12
|
-
'mid': string;
|
|
13
|
-
'max': string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
geometry: Array<Array<Point>>;
|
|
17
|
-
};
|
|
18
|
-
|
|
6
|
+
type EvaluationFeature = Feature & { geometry: Array<Array<Point>> };
|
|
19
7
|
/**
|
|
20
8
|
* Construct a new feature based on a VectorTileFeature for expression evaluation, the geometry of which
|
|
21
9
|
* will be loaded based on necessity.
|
package/src/gl/webgl2.ts
CHANGED
|
@@ -5,7 +5,7 @@ export function isWebGL2(
|
|
|
5
5
|
if (cache.has(gl)) {
|
|
6
6
|
return cache.get(gl);
|
|
7
7
|
} else {
|
|
8
|
-
const value = gl.getParameter(gl.VERSION)
|
|
8
|
+
const value = gl.getParameter(gl.VERSION)?.startsWith('WebGL 2.0');
|
|
9
9
|
cache.set(gl, value);
|
|
10
10
|
return value;
|
|
11
11
|
}
|
|
@@ -4,8 +4,8 @@ import {RequestPerformance} from '../util/performance';
|
|
|
4
4
|
import rewind from '@mapbox/geojson-rewind';
|
|
5
5
|
import {GeoJSONWrapper} from './geojson_wrapper';
|
|
6
6
|
import vtpbf from 'vt-pbf';
|
|
7
|
-
import Supercluster, {type Options, type ClusterProperties} from 'supercluster';
|
|
8
|
-
import geojsonvt from 'geojson-vt';
|
|
7
|
+
import Supercluster, {type Options as SuperclusterOptions, type ClusterProperties} from 'supercluster';
|
|
8
|
+
import geojsonvt, {type Options as GeoJSONVTOptions} from 'geojson-vt';
|
|
9
9
|
import {VectorTileWorkerSource} from './vector_tile_worker_source';
|
|
10
10
|
import {createExpression} from '@maplibre/maplibre-gl-style-spec';
|
|
11
11
|
|
|
@@ -32,8 +32,8 @@ export type LoadGeoJSONParameters = {
|
|
|
32
32
|
dataDiff?: GeoJSONSourceDiff;
|
|
33
33
|
source: string;
|
|
34
34
|
cluster: boolean;
|
|
35
|
-
superclusterOptions?:
|
|
36
|
-
geojsonVtOptions?:
|
|
35
|
+
superclusterOptions?: SuperclusterOptions<any, any>;
|
|
36
|
+
geojsonVtOptions?: GeoJSONVTOptions;
|
|
37
37
|
clusterProperties?: ClusterProperties;
|
|
38
38
|
filter?: Array<unknown>;
|
|
39
39
|
promoteId?: string;
|
|
@@ -41,48 +41,13 @@ export type LoadGeoJSONParameters = {
|
|
|
41
41
|
|
|
42
42
|
export type LoadGeoJSON = (params: LoadGeoJSONParameters, callback: ResponseCallback<any>) => Cancelable;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
getTile(z: number, x: number, y: number): any;
|
|
46
|
-
// supercluster methods
|
|
47
|
-
getClusterExpansionZoom(clusterId: number): number;
|
|
48
|
-
getChildren(clusterId: number): Array<GeoJSON.Feature>;
|
|
49
|
-
getLeaves(clusterId: number, limit: number, offset: number): Array<GeoJSON.Feature>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function loadGeoJSONTile(params: WorkerTileParameters, callback: LoadVectorDataCallback): (() => void) | void {
|
|
53
|
-
const canonical = params.tileID.canonical;
|
|
54
|
-
|
|
55
|
-
if (!this._geoJSONIndex) {
|
|
56
|
-
return callback(null, null); // we couldn't load the file
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);
|
|
60
|
-
if (!geoJSONTile) {
|
|
61
|
-
return callback(null, null); // nothing in the given tile
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features);
|
|
65
|
-
|
|
66
|
-
// Encode the geojson-vt tile into binary vector tile form. This
|
|
67
|
-
// is a convenience that allows `FeatureIndex` to operate the same way
|
|
68
|
-
// across `VectorTileSource` and `GeoJSONSource` data.
|
|
69
|
-
let pbf = vtpbf(geojsonWrapper);
|
|
70
|
-
if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {
|
|
71
|
-
// Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)
|
|
72
|
-
pbf = new Uint8Array(pbf);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
callback(null, {
|
|
76
|
-
vectorTile: geojsonWrapper,
|
|
77
|
-
rawData: pbf.buffer
|
|
78
|
-
});
|
|
79
|
-
}
|
|
44
|
+
type GeoJSONIndex = ReturnType<typeof geojsonvt> | Supercluster;
|
|
80
45
|
|
|
81
46
|
/**
|
|
82
47
|
* The {@link WorkerSource} implementation that supports {@link GeoJSONSource}.
|
|
83
48
|
* This class is designed to be easily reused to support custom source types
|
|
84
49
|
* for data formats that can be parsed/converted into an in-memory GeoJSON
|
|
85
|
-
* representation.
|
|
50
|
+
* representation. To do so, create it with
|
|
86
51
|
* `new GeoJSONWorkerSource(actor, layerIndex, customLoadGeoJSONFunction)`.
|
|
87
52
|
* For a full example, see [mapbox-gl-topojson](https://github.com/developmentseed/mapbox-gl-topojson).
|
|
88
53
|
*/
|
|
@@ -101,12 +66,41 @@ export class GeoJSONWorkerSource extends VectorTileWorkerSource {
|
|
|
101
66
|
* See {@link GeoJSONWorkerSource#loadGeoJSON}.
|
|
102
67
|
*/
|
|
103
68
|
constructor(actor: Actor, layerIndex: StyleLayerIndex, availableImages: Array<string>, loadGeoJSON?: LoadGeoJSON | null) {
|
|
104
|
-
super(actor, layerIndex, availableImages
|
|
69
|
+
super(actor, layerIndex, availableImages);
|
|
70
|
+
this.loadVectorData = this.loadGeoJSONTile;
|
|
105
71
|
if (loadGeoJSON) {
|
|
106
72
|
this.loadGeoJSON = loadGeoJSON;
|
|
107
73
|
}
|
|
108
74
|
}
|
|
109
75
|
|
|
76
|
+
loadGeoJSONTile(params: WorkerTileParameters, callback: LoadVectorDataCallback): (() => void) | void {
|
|
77
|
+
const canonical = params.tileID.canonical;
|
|
78
|
+
|
|
79
|
+
if (!this._geoJSONIndex) {
|
|
80
|
+
return callback(null, null); // we couldn't load the file
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const geoJSONTile = this._geoJSONIndex.getTile(canonical.z, canonical.x, canonical.y);
|
|
84
|
+
if (!geoJSONTile) {
|
|
85
|
+
return callback(null, null); // nothing in the given tile
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const geojsonWrapper = new GeoJSONWrapper(geoJSONTile.features);
|
|
89
|
+
// Encode the geojson-vt tile into binary vector tile form. This
|
|
90
|
+
// is a convenience that allows `FeatureIndex` to operate the same way
|
|
91
|
+
// across `VectorTileSource` and `GeoJSONSource` data.
|
|
92
|
+
let pbf = vtpbf(geojsonWrapper);
|
|
93
|
+
if (pbf.byteOffset !== 0 || pbf.byteLength !== pbf.buffer.byteLength) {
|
|
94
|
+
// Compatibility with node Buffer (https://github.com/mapbox/pbf/issues/35)
|
|
95
|
+
pbf = new Uint8Array(pbf);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
callback(null, {
|
|
99
|
+
vectorTile: geojsonWrapper,
|
|
100
|
+
rawData: pbf.buffer
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
110
104
|
/**
|
|
111
105
|
* Fetches (if appropriate), parses, and index geojson data into tiles. This
|
|
112
106
|
* preparatory method must be called before {@link GeoJSONWorkerSource#loadTile}
|
|
@@ -264,7 +258,7 @@ export class GeoJSONWorkerSource extends VectorTileWorkerSource {
|
|
|
264
258
|
clusterId: number;
|
|
265
259
|
}, callback: Callback<number>) {
|
|
266
260
|
try {
|
|
267
|
-
callback(null, this._geoJSONIndex.getClusterExpansionZoom(params.clusterId));
|
|
261
|
+
callback(null, (this._geoJSONIndex as Supercluster).getClusterExpansionZoom(params.clusterId));
|
|
268
262
|
} catch (e) {
|
|
269
263
|
callback(e);
|
|
270
264
|
}
|
|
@@ -274,7 +268,7 @@ export class GeoJSONWorkerSource extends VectorTileWorkerSource {
|
|
|
274
268
|
clusterId: number;
|
|
275
269
|
}, callback: Callback<Array<GeoJSON.Feature>>) {
|
|
276
270
|
try {
|
|
277
|
-
callback(null, this._geoJSONIndex.getChildren(params.clusterId));
|
|
271
|
+
callback(null, (this._geoJSONIndex as Supercluster).getChildren(params.clusterId));
|
|
278
272
|
} catch (e) {
|
|
279
273
|
callback(e);
|
|
280
274
|
}
|
|
@@ -286,7 +280,7 @@ export class GeoJSONWorkerSource extends VectorTileWorkerSource {
|
|
|
286
280
|
offset: number;
|
|
287
281
|
}, callback: Callback<Array<GeoJSON.Feature>>) {
|
|
288
282
|
try {
|
|
289
|
-
callback(null, this._geoJSONIndex.getLeaves(params.clusterId, params.limit, params.offset));
|
|
283
|
+
callback(null, (this._geoJSONIndex as Supercluster).getLeaves(params.clusterId, params.limit, params.offset));
|
|
290
284
|
} catch (e) {
|
|
291
285
|
callback(e);
|
|
292
286
|
}
|
|
@@ -4,26 +4,16 @@ import mvt from '@mapbox/vector-tile';
|
|
|
4
4
|
import type {VectorTileFeature, VectorTileLayer, VectorTile} from '@mapbox/vector-tile';
|
|
5
5
|
const toGeoJSON = mvt.VectorTileFeature.prototype.toGeoJSON;
|
|
6
6
|
import {EXTENT} from '../data/extent';
|
|
7
|
+
import type {TileFeature, AnyProps} from 'supercluster';
|
|
8
|
+
import type {Feature as GeoJSONVTFeature} from 'geojson-vt';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
// global type and used in module definitions for those two modules.
|
|
10
|
-
export type Feature = {
|
|
11
|
-
type: 1;
|
|
12
|
-
id: any;
|
|
13
|
-
tags: {[_: string]: string | number | boolean};
|
|
14
|
-
geometry: Array<[number, number]>;
|
|
15
|
-
} | {
|
|
16
|
-
type: 2 | 3;
|
|
17
|
-
id: any;
|
|
18
|
-
tags: {[_: string]: string | number | boolean};
|
|
19
|
-
geometry: Array<Array<[number, number]>>;
|
|
20
|
-
};
|
|
10
|
+
export type Feature = TileFeature<AnyProps, AnyProps> | GeoJSONVTFeature;
|
|
21
11
|
|
|
22
12
|
class FeatureWrapper implements VectorTileFeature {
|
|
23
13
|
_feature: Feature;
|
|
24
14
|
|
|
25
15
|
extent: number;
|
|
26
|
-
type:
|
|
16
|
+
type: Feature['type'];
|
|
27
17
|
id: number;
|
|
28
18
|
properties: {[_: string]: string | number | boolean};
|
|
29
19
|
|
|
@@ -40,7 +30,7 @@ class FeatureWrapper implements VectorTileFeature {
|
|
|
40
30
|
// vector tile spec only supports integer values for feature ids --
|
|
41
31
|
// allowing non-integer values here results in a non-compliant PBF
|
|
42
32
|
// that causes an exception when it is parsed with vector-tile-js
|
|
43
|
-
if ('id' in feature && !isNaN(feature.id)) {
|
|
33
|
+
if ('id' in feature && !isNaN(feature.id as any)) {
|
|
44
34
|
this.id = parseInt(feature.id, 10);
|
|
45
35
|
}
|
|
46
36
|
}
|
|
@@ -6,10 +6,11 @@ import {WorkerGlobalScopeInterface} from '../util/web_worker';
|
|
|
6
6
|
import {CanonicalTileID, OverscaledTileID} from './tile_id';
|
|
7
7
|
import {TileParameters, WorkerSource, WorkerTileCallback, WorkerTileParameters} from './worker_source';
|
|
8
8
|
import {plugin as globalRTLTextPlugin} from './rtl_text_plugin';
|
|
9
|
+
import {ActorTarget} from '../util/actor';
|
|
9
10
|
|
|
10
11
|
const _self = {
|
|
11
12
|
addEventListener() {}
|
|
12
|
-
} as any as WorkerGlobalScopeInterface;
|
|
13
|
+
} as any as WorkerGlobalScopeInterface & ActorTarget;
|
|
13
14
|
|
|
14
15
|
class WorkerSourceMock implements WorkerSource {
|
|
15
16
|
availableImages: string[];
|
package/src/source/worker.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Actor} from '../util/actor';
|
|
1
|
+
import {Actor, ActorTarget} from '../util/actor';
|
|
2
2
|
import {StyleLayerIndex} from '../style/style_layer_index';
|
|
3
3
|
import {VectorTileWorkerSource} from './vector_tile_worker_source';
|
|
4
4
|
import {RasterDEMTileWorkerSource} from './raster_dem_tile_worker_source';
|
|
@@ -24,7 +24,7 @@ import type {PluginState} from './rtl_text_plugin';
|
|
|
24
24
|
* The Worker class responsidble for background thread related execution
|
|
25
25
|
*/
|
|
26
26
|
export default class Worker {
|
|
27
|
-
self: WorkerGlobalScopeInterface;
|
|
27
|
+
self: WorkerGlobalScopeInterface & ActorTarget;
|
|
28
28
|
actor: Actor;
|
|
29
29
|
layerIndexes: {[_: string]: StyleLayerIndex};
|
|
30
30
|
availableImages: {[_: string]: Array<string>};
|
|
@@ -47,7 +47,7 @@ export default class Worker {
|
|
|
47
47
|
};
|
|
48
48
|
referrer: string;
|
|
49
49
|
|
|
50
|
-
constructor(self: WorkerGlobalScopeInterface) {
|
|
50
|
+
constructor(self: WorkerGlobalScopeInterface & ActorTarget) {
|
|
51
51
|
this.self = self;
|
|
52
52
|
this.actor = new Actor(self, this);
|
|
53
53
|
|
|
@@ -222,13 +222,13 @@ export default class Worker {
|
|
|
222
222
|
return layerIndexes;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
getWorkerSource(mapId: string,
|
|
225
|
+
getWorkerSource(mapId: string, sourceType: string, sourceName: string): WorkerSource {
|
|
226
226
|
if (!this.workerSources[mapId])
|
|
227
227
|
this.workerSources[mapId] = {};
|
|
228
|
-
if (!this.workerSources[mapId][
|
|
229
|
-
this.workerSources[mapId][
|
|
228
|
+
if (!this.workerSources[mapId][sourceType])
|
|
229
|
+
this.workerSources[mapId][sourceType] = {};
|
|
230
230
|
|
|
231
|
-
if (!this.workerSources[mapId][
|
|
231
|
+
if (!this.workerSources[mapId][sourceType][sourceName]) {
|
|
232
232
|
// use a wrapped actor so that we can attach a target mapId param
|
|
233
233
|
// to any messages invoked by the WorkerSource
|
|
234
234
|
const actor = {
|
|
@@ -236,10 +236,10 @@ export default class Worker {
|
|
|
236
236
|
this.actor.send(type, data, callback, mapId);
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
|
-
this.workerSources[mapId][
|
|
239
|
+
this.workerSources[mapId][sourceType][sourceName] = new (this.workerSourceTypes[sourceType] as any)((actor as any), this.getLayerIndex(mapId), this.getAvailableImages(mapId));
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
return this.workerSources[mapId][
|
|
242
|
+
return this.workerSources[mapId][sourceType][sourceName];
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
getDEMWorkerSource(mapId: string, source: string) {
|
package/src/style/style.test.ts
CHANGED
|
@@ -68,6 +68,7 @@ class StubMap extends Evented {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
setTerrain() { }
|
|
71
|
+
getTerrain() { }
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
const getStubMap = () => new StubMap() as any;
|
|
@@ -2564,3 +2565,29 @@ describe('Style#hasTransitions', () => {
|
|
|
2564
2565
|
});
|
|
2565
2566
|
});
|
|
2566
2567
|
});
|
|
2568
|
+
|
|
2569
|
+
describe('Style#serialize', () => {
|
|
2570
|
+
test('include terrain property when map has 3D terrain', done => {
|
|
2571
|
+
const styleJson = createStyleJSON({terrain: {
|
|
2572
|
+
source: 'terrainSource',
|
|
2573
|
+
exaggeration: 1
|
|
2574
|
+
}});
|
|
2575
|
+
const style = new Style(getStubMap());
|
|
2576
|
+
style.loadJSON(styleJson);
|
|
2577
|
+
|
|
2578
|
+
style.on('style.load', () => {
|
|
2579
|
+
expect(style.serialize().terrain).toBe(styleJson.terrian);
|
|
2580
|
+
done();
|
|
2581
|
+
});
|
|
2582
|
+
});
|
|
2583
|
+
|
|
2584
|
+
test('do not include terrain property when map does not have 3D terrain', done => {
|
|
2585
|
+
const style = new Style(getStubMap());
|
|
2586
|
+
style.loadJSON(createStyleJSON());
|
|
2587
|
+
|
|
2588
|
+
style.on('style.load', () => {
|
|
2589
|
+
expect(style.serialize().terrain).toBeUndefined();
|
|
2590
|
+
done();
|
|
2591
|
+
});
|
|
2592
|
+
});
|
|
2593
|
+
});
|
package/src/style/style.ts
CHANGED
|
@@ -1215,6 +1215,7 @@ export class Style extends Evented {
|
|
|
1215
1215
|
|
|
1216
1216
|
const sources = mapObject(this.sourceCaches, (source) => source.serialize());
|
|
1217
1217
|
const layers = this._serializeByIds(this._order);
|
|
1218
|
+
const terrain = this.map.getTerrain() || undefined;
|
|
1218
1219
|
const myStyleSheet = this.stylesheet;
|
|
1219
1220
|
|
|
1220
1221
|
return filterObject({
|
|
@@ -1230,7 +1231,8 @@ export class Style extends Evented {
|
|
|
1230
1231
|
glyphs: myStyleSheet.glyphs,
|
|
1231
1232
|
transition: myStyleSheet.transition,
|
|
1232
1233
|
sources,
|
|
1233
|
-
layers
|
|
1234
|
+
layers,
|
|
1235
|
+
terrain
|
|
1234
1236
|
},
|
|
1235
1237
|
(value) => { return value !== undefined; });
|
|
1236
1238
|
}
|
package/src/util/actor.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Actor} from './actor';
|
|
1
|
+
import {Actor, ActorTarget} from './actor';
|
|
2
2
|
import {workerFactory} from './web_worker';
|
|
3
3
|
import {MessageBus} from '../../test/unit/lib/web_worker_mock';
|
|
4
4
|
|
|
@@ -33,18 +33,19 @@ describe('Actor', () => {
|
|
|
33
33
|
this.self = self;
|
|
34
34
|
this.actor = new Actor(self, this);
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
getTile(mapId, params, callback) {
|
|
37
37
|
setTimeout(callback, 0, null, params);
|
|
38
38
|
}
|
|
39
|
+
getWorkerSource() { return null; }
|
|
39
40
|
});
|
|
40
41
|
|
|
41
42
|
const worker = workerFactory();
|
|
42
43
|
|
|
43
|
-
const m1 = new Actor(worker, {}, '1');
|
|
44
|
-
const m2 = new Actor(worker, {}, '2');
|
|
44
|
+
const m1 = new Actor(worker, {} as any, '1');
|
|
45
|
+
const m2 = new Actor(worker, {} as any, '2');
|
|
45
46
|
|
|
46
47
|
let callbackCount = 0;
|
|
47
|
-
m1.send('
|
|
48
|
+
m1.send('getTile', {value: 1729}, (err, response) => {
|
|
48
49
|
expect(err).toBeFalsy();
|
|
49
50
|
expect(response).toEqual({value: 1729});
|
|
50
51
|
callbackCount++;
|
|
@@ -52,7 +53,7 @@ describe('Actor', () => {
|
|
|
52
53
|
done();
|
|
53
54
|
}
|
|
54
55
|
});
|
|
55
|
-
m2.send('
|
|
56
|
+
m2.send('getTile', {value: 4104}, (err, response) => {
|
|
56
57
|
expect(err).toBeFalsy();
|
|
57
58
|
expect(response).toEqual({value: 4104});
|
|
58
59
|
callbackCount++;
|
|
@@ -72,18 +73,19 @@ describe('Actor', () => {
|
|
|
72
73
|
this.self = self;
|
|
73
74
|
this.actor = workerActor = new Actor(self, this);
|
|
74
75
|
}
|
|
76
|
+
getWorkerSource() { return null; }
|
|
75
77
|
});
|
|
76
78
|
|
|
77
79
|
const worker = workerFactory();
|
|
78
80
|
|
|
79
81
|
new Actor(worker, {
|
|
80
82
|
test () { done(); }
|
|
81
|
-
}, '1');
|
|
83
|
+
} as any, '1');
|
|
82
84
|
new Actor(worker, {
|
|
83
85
|
test () {
|
|
84
86
|
done('test failed');
|
|
85
87
|
}
|
|
86
|
-
}, '2');
|
|
88
|
+
} as any, '2');
|
|
87
89
|
|
|
88
90
|
workerActor.send('test', {}, () => {}, '1');
|
|
89
91
|
});
|
|
@@ -97,7 +99,7 @@ describe('Actor', () => {
|
|
|
97
99
|
expect([type, callback, useCapture]).toEqual(this._addEventListenerArgs);
|
|
98
100
|
done();
|
|
99
101
|
}
|
|
100
|
-
}, {}, null);
|
|
102
|
+
} as ActorTarget, {} as any, null);
|
|
101
103
|
actor.remove();
|
|
102
104
|
});
|
|
103
105
|
|