Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redoPlacement and unloadTile for GeoJSON sources #3366

Merged
merged 4 commits into from
Oct 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/source/geojson_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ GeoJSONSource.prototype = util.inherit(Evented, /** @lends GeoJSONSource.prototy

unloadTile: function(tile) {
tile.unloadVectorData();
this.dispatcher.send('remove tile', { uid: tile.uid, source: this.id }, function() {}, tile.workerID);
this.dispatcher.send('remove tile', { uid: tile.uid, type: this.type, source: this.id }, function() {}, tile.workerID);
},

serialize: function() {
Expand Down
2 changes: 1 addition & 1 deletion js/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ SourceCache.prototype = util.inherit(Evented, {
var ids = this.getIds();
for (var i = 0; i < ids.length; i++) {
var tile = this.getTileByID(ids[i]);
tile.redoPlacement(this);
tile.redoPlacement(this._source);
}
},

Expand Down
1 change: 1 addition & 0 deletions js/source/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Tile.prototype = {
this.state = 'reloading';

source.dispatcher.send('redo placement', {
type: source.type,
uid: this.uid,
source: source.id,
angle: source.map.transform.angle,
Expand Down
6 changes: 4 additions & 2 deletions js/source/vector_tile_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function VectorTileSource(id, options, dispatcher, eventedParent) {
}

VectorTileSource.prototype = util.inherit(Evented, {
type: 'vector',
minzoom: 0,
maxzoom: 22,
scheme: 'xyz',
Expand All @@ -55,6 +56,7 @@ VectorTileSource.prototype = util.inherit(Evented, {
coord: tile.coord,
zoom: tile.coord.z,
tileSize: this.tileSize * overscaling,
type: this.type,
source: this.id,
overscaling: overscaling,
angle: this.map.transform.angle,
Expand Down Expand Up @@ -96,11 +98,11 @@ VectorTileSource.prototype = util.inherit(Evented, {
},

abortTile: function(tile) {
this.dispatcher.send('abort tile', { uid: tile.uid, source: this.id }, null, tile.workerID);
this.dispatcher.send('abort tile', { uid: tile.uid, type: this.type, source: this.id }, null, tile.workerID);
},

unloadTile: function(tile) {
tile.unloadVectorData();
this.dispatcher.send('remove tile', { uid: tile.uid, source: this.id }, null, tile.workerID);
this.dispatcher.send('remove tile', { uid: tile.uid, type: this.type, source: this.id }, null, tile.workerID);
}
});
21 changes: 11 additions & 10 deletions js/source/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var util = require('../util/util');
var VectorTileWorkerSource = require('./vector_tile_worker_source');
var GeoJSONWorkerSource = require('./geojson_worker_source');
var featureFilter = require('feature-filter');
var assert = require('assert');

module.exports = function createWorker(self) {
return new Worker(self);
Expand Down Expand Up @@ -104,28 +105,28 @@ util.extend(Worker.prototype, {
},

'load tile': function(mapId, params, callback) {
var type = params.type || 'vector';
this.getWorkerSource(mapId, type).loadTile(params, callback);
assert(params.type);
this.getWorkerSource(mapId, params.type).loadTile(params, callback);
},

'reload tile': function(mapId, params, callback) {
var type = params.type || 'vector';
this.getWorkerSource(mapId, type).reloadTile(params, callback);
assert(params.type);
this.getWorkerSource(mapId, params.type).reloadTile(params, callback);
},

'abort tile': function(mapId, params) {
var type = params.type || 'vector';
this.getWorkerSource(mapId, type).abortTile(params);
assert(params.type);
this.getWorkerSource(mapId, params.type).abortTile(params);
},

'remove tile': function(mapId, params) {
var type = params.type || 'vector';
this.getWorkerSource(mapId, type).removeTile(params);
assert(params.type);
this.getWorkerSource(mapId, params.type).removeTile(params);
},

'redo placement': function(mapId, params, callback) {
var type = params.type || 'vector';
this.getWorkerSource(mapId, type).redoPlacement(params, callback);
assert(params.type);
this.getWorkerSource(mapId, params.type).redoPlacement(params, callback);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"jsdom": "^9.4.2",
"json-loader": "^0.5.4",
"lodash": "^4.13.1",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#ceba0a2e2e8e5860aa2550c53bb6083387d053d3",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#8db35f9130bce27102c5867d6542c42c074d9bfc",
"memory-fs": "^0.3.0",
"minifyify": "^7.0.1",
"npm-run-all": "^3.0.0",
Expand Down
1 change: 1 addition & 0 deletions test/js/source/worker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ test('load tile', function(t) {
window.useFakeXMLHttpRequest();
var worker = new Worker(_self);
worker['load tile'](0, {
type: 'vector',
source: 'source',
uid: 0,
url: '/error' // Sinon fake server gives 404 responses by default
Expand Down