Rename _ol_VectorTile_ to VectorTile

This commit is contained in:
Frederic Junod
2017-12-22 09:06:58 +01:00
parent c46aec3196
commit b358a7daf5
6 changed files with 42 additions and 42 deletions
+20 -20
View File
@@ -15,7 +15,7 @@ import TileState from './TileState.js';
* @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function. * @param {ol.TileLoadFunctionType} tileLoadFunction Tile load function.
* @param {olx.TileOptions=} opt_options Tile options. * @param {olx.TileOptions=} opt_options Tile options.
*/ */
var _ol_VectorTile_ = function(tileCoord, state, src, format, tileLoadFunction, opt_options) { var VectorTile = function(tileCoord, state, src, format, tileLoadFunction, opt_options) {
_ol_Tile_.call(this, tileCoord, state, opt_options); _ol_Tile_.call(this, tileCoord, state, opt_options);
@@ -75,13 +75,13 @@ var _ol_VectorTile_ = function(tileCoord, state, src, format, tileLoadFunction,
}; };
inherits(_ol_VectorTile_, _ol_Tile_); inherits(VectorTile, _ol_Tile_);
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_VectorTile_.prototype.disposeInternal = function() { VectorTile.prototype.disposeInternal = function() {
this.features_ = null; this.features_ = null;
this.replayGroups_ = {}; this.replayGroups_ = {};
this.state = TileState.ABORT; this.state = TileState.ABORT;
@@ -95,8 +95,8 @@ _ol_VectorTile_.prototype.disposeInternal = function() {
* @return {ol.Extent} The extent. * @return {ol.Extent} The extent.
* @api * @api
*/ */
_ol_VectorTile_.prototype.getExtent = function() { VectorTile.prototype.getExtent = function() {
return this.extent_ || _ol_VectorTile_.DEFAULT_EXTENT; return this.extent_ || VectorTile.DEFAULT_EXTENT;
}; };
@@ -105,7 +105,7 @@ _ol_VectorTile_.prototype.getExtent = function() {
* @return {ol.format.Feature} Feature format. * @return {ol.format.Feature} Feature format.
* @api * @api
*/ */
_ol_VectorTile_.prototype.getFormat = function() { VectorTile.prototype.getFormat = function() {
return this.format_; return this.format_;
}; };
@@ -116,7 +116,7 @@ _ol_VectorTile_.prototype.getFormat = function() {
* @return {Array.<ol.Feature|ol.render.Feature>} Features. * @return {Array.<ol.Feature|ol.render.Feature>} Features.
* @api * @api
*/ */
_ol_VectorTile_.prototype.getFeatures = function() { VectorTile.prototype.getFeatures = function() {
return this.features_; return this.features_;
}; };
@@ -124,7 +124,7 @@ _ol_VectorTile_.prototype.getFeatures = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_VectorTile_.prototype.getKey = function() { VectorTile.prototype.getKey = function() {
return this.url_; return this.url_;
}; };
@@ -135,7 +135,7 @@ _ol_VectorTile_.prototype.getKey = function() {
* @return {ol.proj.Projection} Feature projection. * @return {ol.proj.Projection} Feature projection.
* @api * @api
*/ */
_ol_VectorTile_.prototype.getProjection = function() { VectorTile.prototype.getProjection = function() {
return this.projection_; return this.projection_;
}; };
@@ -145,7 +145,7 @@ _ol_VectorTile_.prototype.getProjection = function() {
* @param {string} key Key. * @param {string} key Key.
* @return {ol.render.ReplayGroup} Replay group. * @return {ol.render.ReplayGroup} Replay group.
*/ */
_ol_VectorTile_.prototype.getReplayGroup = function(layer, key) { VectorTile.prototype.getReplayGroup = function(layer, key) {
return this.replayGroups_[getUid(layer) + ',' + key]; return this.replayGroups_[getUid(layer) + ',' + key];
}; };
@@ -153,7 +153,7 @@ _ol_VectorTile_.prototype.getReplayGroup = function(layer, key) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_VectorTile_.prototype.load = function() { VectorTile.prototype.load = function() {
if (this.state == TileState.IDLE) { if (this.state == TileState.IDLE) {
this.setState(TileState.LOADING); this.setState(TileState.LOADING);
this.tileLoadFunction_(this, this.url_); this.tileLoadFunction_(this, this.url_);
@@ -168,7 +168,7 @@ _ol_VectorTile_.prototype.load = function() {
* @param {ol.proj.Projection} dataProjection Data projection. * @param {ol.proj.Projection} dataProjection Data projection.
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
*/ */
_ol_VectorTile_.prototype.onLoad = function(features, dataProjection, extent) { VectorTile.prototype.onLoad = function(features, dataProjection, extent) {
this.setProjection(dataProjection); this.setProjection(dataProjection);
this.setFeatures(features); this.setFeatures(features);
this.setExtent(extent); this.setExtent(extent);
@@ -178,7 +178,7 @@ _ol_VectorTile_.prototype.onLoad = function(features, dataProjection, extent) {
/** /**
* Handler for tile load errors. * Handler for tile load errors.
*/ */
_ol_VectorTile_.prototype.onError = function() { VectorTile.prototype.onError = function() {
this.setState(TileState.ERROR); this.setState(TileState.ERROR);
}; };
@@ -195,7 +195,7 @@ _ol_VectorTile_.prototype.onError = function() {
* @param {ol.Extent} extent The extent. * @param {ol.Extent} extent The extent.
* @api * @api
*/ */
_ol_VectorTile_.prototype.setExtent = function(extent) { VectorTile.prototype.setExtent = function(extent) {
this.extent_ = extent; this.extent_ = extent;
}; };
@@ -206,7 +206,7 @@ _ol_VectorTile_.prototype.setExtent = function(extent) {
* @param {Array.<ol.Feature>} features Features. * @param {Array.<ol.Feature>} features Features.
* @api * @api
*/ */
_ol_VectorTile_.prototype.setFeatures = function(features) { VectorTile.prototype.setFeatures = function(features) {
this.features_ = features; this.features_ = features;
this.setState(TileState.LOADED); this.setState(TileState.LOADED);
}; };
@@ -219,7 +219,7 @@ _ol_VectorTile_.prototype.setFeatures = function(features) {
* @param {ol.proj.Projection} projection Feature projection. * @param {ol.proj.Projection} projection Feature projection.
* @api * @api
*/ */
_ol_VectorTile_.prototype.setProjection = function(projection) { VectorTile.prototype.setProjection = function(projection) {
this.projection_ = projection; this.projection_ = projection;
}; };
@@ -229,7 +229,7 @@ _ol_VectorTile_.prototype.setProjection = function(projection) {
* @param {string} key Key. * @param {string} key Key.
* @param {ol.render.ReplayGroup} replayGroup Replay group. * @param {ol.render.ReplayGroup} replayGroup Replay group.
*/ */
_ol_VectorTile_.prototype.setReplayGroup = function(layer, key, replayGroup) { VectorTile.prototype.setReplayGroup = function(layer, key, replayGroup) {
this.replayGroups_[getUid(layer) + ',' + key] = replayGroup; this.replayGroups_[getUid(layer) + ',' + key] = replayGroup;
}; };
@@ -239,7 +239,7 @@ _ol_VectorTile_.prototype.setReplayGroup = function(layer, key, replayGroup) {
* @param {ol.FeatureLoader} loader Feature loader. * @param {ol.FeatureLoader} loader Feature loader.
* @api * @api
*/ */
_ol_VectorTile_.prototype.setLoader = function(loader) { VectorTile.prototype.setLoader = function(loader) {
this.loader_ = loader; this.loader_ = loader;
}; };
@@ -248,5 +248,5 @@ _ol_VectorTile_.prototype.setLoader = function(loader) {
* @const * @const
* @type {ol.Extent} * @type {ol.Extent}
*/ */
_ol_VectorTile_.DEFAULT_EXTENT = [0, 0, 4096, 4096]; VectorTile.DEFAULT_EXTENT = [0, 0, 4096, 4096];
export default _ol_VectorTile_; export default VectorTile;
+2 -2
View File
@@ -4,7 +4,7 @@
import {inherits} from '../index.js'; import {inherits} from '../index.js';
import TileState from '../TileState.js'; import TileState from '../TileState.js';
import VectorImageTile from '../VectorImageTile.js'; import VectorImageTile from '../VectorImageTile.js';
import _ol_VectorTile_ from '../VectorTile.js'; import VectorTile from '../VectorTile.js';
import _ol_size_ from '../size.js'; import _ol_size_ from '../size.js';
import _ol_source_UrlTile_ from '../source/UrlTile.js'; import _ol_source_UrlTile_ from '../source/UrlTile.js';
import _ol_tilecoord_ from '../tilecoord.js'; import _ol_tilecoord_ from '../tilecoord.js';
@@ -78,7 +78,7 @@ var _ol_source_VectorTile_ = function(options) {
* @type {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string, * @type {function(new: ol.VectorTile, ol.TileCoord, ol.TileState, string,
* ol.format.Feature, ol.TileLoadFunctionType)} * ol.format.Feature, ol.TileLoadFunctionType)}
*/ */
this.tileClass = options.tileClass ? options.tileClass : _ol_VectorTile_; this.tileClass = options.tileClass ? options.tileClass : VectorTile;
/** /**
* @private * @private
@@ -4,7 +4,7 @@ import _ol_Feature_ from '../../../../../src/ol/Feature.js';
import Map from '../../../../../src/ol/Map.js'; import Map from '../../../../../src/ol/Map.js';
import TileState from '../../../../../src/ol/TileState.js'; import TileState from '../../../../../src/ol/TileState.js';
import VectorImageTile from '../../../../../src/ol/VectorImageTile.js'; import VectorImageTile from '../../../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../../../src/ol/VectorTile.js'; import VectorTile from '../../../../../src/ol/VectorTile.js';
import _ol_View_ from '../../../../../src/ol/View.js'; import _ol_View_ from '../../../../../src/ol/View.js';
import * as _ol_extent_ from '../../../../../src/ol/extent.js'; import * as _ol_extent_ from '../../../../../src/ol/extent.js';
import MVT from '../../../../../src/ol/format/MVT.js'; import MVT from '../../../../../src/ol/format/MVT.js';
@@ -60,13 +60,13 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
feature3 = new _ol_render_Feature_('Point', [1, -1], []); feature3 = new _ol_render_Feature_('Point', [1, -1], []);
feature2.setStyle(featureStyle); feature2.setStyle(featureStyle);
var TileClass = function() { var TileClass = function() {
_ol_VectorTile_.apply(this, arguments); VectorTile.apply(this, arguments);
this.setState('loaded'); this.setState('loaded');
this.setFeatures([feature1, feature2, feature3]); this.setFeatures([feature1, feature2, feature3]);
this.setProjection(getProjection('EPSG:4326')); this.setProjection(getProjection('EPSG:4326'));
tileCallback(this); tileCallback(this);
}; };
inherits(TileClass, _ol_VectorTile_); inherits(TileClass, VectorTile);
source = new _ol_source_VectorTile_({ source = new _ol_source_VectorTile_({
format: new MVT(), format: new MVT(),
tileClass: TileClass, tileClass: TileClass,
@@ -224,9 +224,9 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
}); });
map.addLayer(layer2); map.addLayer(layer2);
var spy1 = sinon.spy(_ol_VectorTile_.prototype, var spy1 = sinon.spy(VectorTile.prototype,
'getReplayGroup'); 'getReplayGroup');
var spy2 = sinon.spy(_ol_VectorTile_.prototype, var spy2 = sinon.spy(VectorTile.prototype,
'setReplayGroup'); 'setReplayGroup');
map.renderSync(); map.renderSync();
expect(spy1.callCount).to.be(4); expect(spy1.callCount).to.be(4);
@@ -245,7 +245,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
transition: 0 transition: 0
}) })
}); });
var sourceTile = new _ol_VectorTile_([0, 0, 0], 2); var sourceTile = new VectorTile([0, 0, 0], 2);
sourceTile.setProjection(getProjection('EPSG:3857')); sourceTile.setProjection(getProjection('EPSG:3857'));
sourceTile.features_ = []; sourceTile.features_ = [];
sourceTile.getImage = function() { sourceTile.getImage = function() {
@@ -293,7 +293,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
var TileClass = function() { var TileClass = function() {
VectorImageTile.apply(this, arguments); VectorImageTile.apply(this, arguments);
this.setState('loaded'); this.setState('loaded');
var sourceTile = new _ol_VectorTile_([0, 0, 0]); var sourceTile = new VectorTile([0, 0, 0]);
sourceTile.setProjection(getProjection('EPSG:3857')); sourceTile.setProjection(getProjection('EPSG:3857'));
sourceTile.getReplayGroup = function() { sourceTile.getReplayGroup = function() {
return replayGroup; return replayGroup;
+3 -3
View File
@@ -1,7 +1,7 @@
import Map from '../../../../src/ol/Map.js'; import Map from '../../../../src/ol/Map.js';
import _ol_View_ from '../../../../src/ol/View.js'; import _ol_View_ from '../../../../src/ol/View.js';
import VectorImageTile from '../../../../src/ol/VectorImageTile.js'; import VectorImageTile from '../../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../../src/ol/VectorTile.js'; import VectorTile from '../../../../src/ol/VectorTile.js';
import MVT from '../../../../src/ol/format/MVT.js'; import MVT from '../../../../src/ol/format/MVT.js';
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
import {get as getProjection} from '../../../../src/ol/proj.js'; import {get as getProjection} from '../../../../src/ol/proj.js';
@@ -25,7 +25,7 @@ describe('ol.source.VectorTile', function() {
}); });
it('uses ol.VectorTile as default tileClass', function() { it('uses ol.VectorTile as default tileClass', function() {
expect(source.tileClass).to.equal(_ol_VectorTile_); expect(source.tileClass).to.equal(VectorTile);
}); });
it('creates a 512 XYZ tilegrid by default', function() { it('creates a 512 XYZ tilegrid by default', function() {
@@ -65,7 +65,7 @@ describe('ol.source.VectorTile', function() {
}); });
source.on('tileloadend', function(e) { source.on('tileloadend', function(e) {
expect(started).to.be(true); expect(started).to.be(true);
expect(e.tile).to.be.a(_ol_VectorTile_); expect(e.tile).to.be.a(VectorTile);
expect(e.tile.getFeatures().length).to.be(1327); expect(e.tile.getFeatures().length).to.be(1327);
done(); done();
}); });
+8 -8
View File
@@ -1,6 +1,6 @@
import TileState from '../../../src/ol/TileState.js'; import TileState from '../../../src/ol/TileState.js';
import VectorImageTile from '../../../src/ol/VectorImageTile.js'; import VectorImageTile from '../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../src/ol/VectorTile.js'; import VectorTile from '../../../src/ol/VectorTile.js';
import _ol_events_ from '../../../src/ol/events.js'; import _ol_events_ from '../../../src/ol/events.js';
import GeoJSON from '../../../src/ol/format/GeoJSON.js'; import GeoJSON from '../../../src/ol/format/GeoJSON.js';
import {get as getProjection} from '../../../src/ol/proj.js'; import {get as getProjection} from '../../../src/ol/proj.js';
@@ -17,7 +17,7 @@ describe('ol.VectorImageTile', function() {
VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {
return url; return url;
}, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {},
1, getProjection('EPSG:3857'), _ol_VectorTile_, function() {}); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
var sourceTile = tile.getTile(tile.tileKeys[0]); var sourceTile = tile.getTile(tile.tileKeys[0]);
@@ -41,7 +41,7 @@ describe('ol.VectorImageTile', function() {
}, [0, 0, -1], function() { }, [0, 0, -1], function() {
return url; return url;
}, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {},
1, getProjection('EPSG:3857'), _ol_VectorTile_, function() {}); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
var calls = 0; var calls = 0;
@@ -65,7 +65,7 @@ describe('ol.VectorImageTile', function() {
VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {
return url; return url;
}, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {},
1, getProjection('EPSG:3857'), _ol_VectorTile_, function() {}); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
@@ -81,7 +81,7 @@ describe('ol.VectorImageTile', function() {
var tile = new VectorImageTile([0, 0, -1], 0, url, format, var tile = new VectorImageTile([0, 0, -1], 0, url, format,
VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {}, VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {},
_ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {}, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ(), {},
1, getProjection('EPSG:3857'), _ol_VectorTile_, function() {}); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
@@ -105,7 +105,7 @@ describe('ol.VectorImageTile', function() {
return url; return url;
}, tileGrid, }, tileGrid,
_ol_tilegrid_.createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}), _ol_tilegrid_.createXYZ({extent: [-180, -90, 180, 90], tileSize: 512}),
sourceTiles, 1, getProjection('EPSG:4326'), _ol_VectorTile_, function() {}); sourceTiles, 1, getProjection('EPSG:4326'), VectorTile, function() {});
tile.load(); tile.load();
expect(tile.tileKeys.length).to.be(1); expect(tile.tileKeys.length).to.be(1);
expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, -10]); expect(tile.getTile(tile.tileKeys[0]).tileCoord).to.eql([0, 16, -10]);
@@ -118,7 +118,7 @@ describe('ol.VectorImageTile', function() {
VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {
return url; return url;
}, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ({tileSize: 512}), {}, }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ({tileSize: 512}), {},
1, getProjection('EPSG:3857'), _ol_VectorTile_, function() {}); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
expect(tile.loadListenerKeys_.length).to.be(4); expect(tile.loadListenerKeys_.length).to.be(4);
@@ -138,7 +138,7 @@ describe('ol.VectorImageTile', function() {
VectorImageTile.defaultLoadFunction, [0, 0, -1], function() { VectorImageTile.defaultLoadFunction, [0, 0, -1], function() {
return url; return url;
}, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ({tileSize: 512}), {}, }, _ol_tilegrid_.createXYZ(), _ol_tilegrid_.createXYZ({tileSize: 512}), {},
1, getProjection('EPSG:3857'), _ol_VectorTile_, function() {}); 1, getProjection('EPSG:3857'), VectorTile, function() {});
tile.load(); tile.load();
_ol_events_.listenOnce(tile, 'change', function() { _ol_events_.listenOnce(tile, 'change', function() {
+2 -2
View File
@@ -1,6 +1,6 @@
import _ol_Feature_ from '../../../src/ol/Feature.js'; import _ol_Feature_ from '../../../src/ol/Feature.js';
import VectorImageTile from '../../../src/ol/VectorImageTile.js'; import VectorImageTile from '../../../src/ol/VectorImageTile.js';
import _ol_VectorTile_ from '../../../src/ol/VectorTile.js'; import VectorTile from '../../../src/ol/VectorTile.js';
import _ol_events_ from '../../../src/ol/events.js'; import _ol_events_ from '../../../src/ol/events.js';
import TextFeature from '../../../src/ol/format/TextFeature.js'; import TextFeature from '../../../src/ol/format/TextFeature.js';
import {get as getProjection} from '../../../src/ol/proj.js'; import {get as getProjection} from '../../../src/ol/proj.js';
@@ -22,7 +22,7 @@ describe('ol.VectorTile', function() {
return [new _ol_Feature_()]; return [new _ol_Feature_()];
}; };
var tile = new _ol_VectorTile_([0, 0, 0], null, null, format); var tile = new VectorTile([0, 0, 0], null, null, format);
var url = 'spec/ol/data/point.json'; var url = 'spec/ol/data/point.json';
VectorImageTile.defaultLoadFunction(tile, url); VectorImageTile.defaultLoadFunction(tile, url);