Skip to content

Commit

Permalink
Support generateId option in clustered sources (#8945)
Browse files Browse the repository at this point in the history
* support generateId option in clustered sources

* add a unit test for generateId clustered
  • Loading branch information
mourner authored Nov 5, 2019
1 parent 02f93c8 commit 1eafc22
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"potpack": "^1.0.1",
"quickselect": "^2.0.0",
"rw": "^1.3.3",
"supercluster": "^6.0.1",
"supercluster": "^7.0.0",
"tinyqueue": "^2.0.0",
"vt-pbf": "^3.1.1"
},
Expand Down
3 changes: 2 additions & 1 deletion src/source/geojson_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ class GeoJSONSource extends Evented implements Source {
(this.maxzoom - 1),
extent: EXTENT,
radius: (options.clusterRadius || 50) * scale,
log: false
log: false,
generateId: options.generateId || false
},
clusterProperties: options.clusterProperties
}, options.workerOptions);
Expand Down
24 changes: 24 additions & 0 deletions test/unit/source/geojson_source.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,30 @@ test('GeoJSONSource#update', (t) => {
}, mockDispatcher).load();
});

t.test('forwards Supercluster options with worker request', (t) => {
const mockDispatcher = wrapDispatcher({
send(message, params) {
t.equal(message, 'geojson.loadData');
t.deepEqual(params.superclusterOptions, {
maxZoom: 12,
extent: 8192,
radius: 1600,
log: false,
generateId: true
});
t.end();
}
});

new GeoJSONSource('id', {
data: {},
cluster: true,
clusterMaxZoom: 12,
clusterRadius: 100,
generateId: true
}, mockDispatcher).load();
});

t.test('transforms url before making request', (t) => {
const mapStub = {
_requestManager: {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9689,10 +9689,10 @@ sugarss@^2.0.0:
dependencies:
postcss "^7.0.2"

supercluster@^6.0.1:
version "6.0.2"
resolved "https://registry.yarnpkg.com/supercluster/-/supercluster-6.0.2.tgz#aa2eaae185ef97872f388c683ec29f6991721ee3"
integrity sha512-aa0v2HURjBTOpbcknilcfxGDuArM8khklKSmZ/T8ZXL0BuRwb5aRw95lz+2bmWpFvCXDX/+FzqHxmg0TIaJErw==
supercluster@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/supercluster/-/supercluster-7.0.0.tgz#75d474fafb0a055db552ed7bd7bbda583f6ab321"
integrity sha512-8VuHI8ynylYQj7Qf6PBMWy1PdgsnBiIxujOgc9Z83QvJ8ualIYWNx2iMKyKeC4DZI5ntD9tz/CIwwZvIelixsA==
dependencies:
kdbush "^3.0.0"

Expand Down

0 comments on commit 1eafc22

Please sign in to comment.