Rename _ol_source_VectorTile_ to VectorTileSource

This commit is contained in:
Tim Schaub
2018-01-08 16:05:34 -07:00
parent 231c8837ca
commit ecd1343d75
10 changed files with 35 additions and 35 deletions

View File

@@ -3,7 +3,7 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import GeoJSON from '../src/ol/format/GeoJSON.js'; import GeoJSON from '../src/ol/format/GeoJSON.js';
import OSM from '../src/ol/source/OSM.js'; import OSM from '../src/ol/source/OSM.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import VectorTileSource from '../src/ol/source/VectorTile.js';
import TileLayer from '../src/ol/layer/Tile.js'; import TileLayer from '../src/ol/layer/Tile.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import _ol_proj_Projection_ from '../src/ol/proj/Projection.js'; import _ol_proj_Projection_ from '../src/ol/proj/Projection.js';
@@ -74,7 +74,7 @@ fetch(url).then(function(response) {
extent: 4096, extent: 4096,
debug: 1 debug: 1
}); });
var vectorSource = new _ol_source_VectorTile_({ var vectorSource = new VectorTileSource({
format: new GeoJSON(), format: new GeoJSON(),
tileLoadFunction: function(tile) { tileLoadFunction: function(tile) {
var format = tile.getFormat(); var format = tile.getFormat();

View File

@@ -3,7 +3,7 @@ import View from '../src/ol/View.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';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import VectorTileSource from '../src/ol/source/VectorTile.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Icon_ from '../src/ol/style/Icon.js'; import _ol_style_Icon_ from '../src/ol/style/Icon.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
@@ -33,7 +33,7 @@ function tileUrlFunction(tileCoord) {
var map = new Map({ var map = new Map({
layers: [ layers: [
new _ol_layer_VectorTile_({ new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({ source: new VectorTileSource({
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' + attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
'© <a href="https://www.openstreetmap.org/copyright">' + '© <a href="https://www.openstreetmap.org/copyright">' +
'OpenStreetMap contributors</a>', 'OpenStreetMap contributors</a>',

View File

@@ -2,7 +2,7 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.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 _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import VectorTileSource from '../src/ol/source/VectorTile.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Icon_ from '../src/ol/style/Icon.js'; import _ol_style_Icon_ from '../src/ol/style/Icon.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
@@ -16,7 +16,7 @@ var map = new Map({
layers: [ layers: [
new _ol_layer_VectorTile_({ new _ol_layer_VectorTile_({
declutter: true, declutter: true,
source: new _ol_source_VectorTile_({ source: new VectorTileSource({
attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' + attributions: '© <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' +
'© <a href="https://www.openstreetmap.org/copyright">' + '© <a href="https://www.openstreetmap.org/copyright">' +
'OpenStreetMap contributors</a>', 'OpenStreetMap contributors</a>',

View File

@@ -3,7 +3,7 @@ import View from '../src/ol/View.js';
import TopoJSON from '../src/ol/format/TopoJSON.js'; import TopoJSON from '../src/ol/format/TopoJSON.js';
import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../src/ol/layer/VectorTile.js';
import {fromLonLat} from '../src/ol/proj.js'; import {fromLonLat} from '../src/ol/proj.js';
import _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import VectorTileSource from '../src/ol/source/VectorTile.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js'; import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
import _ol_style_Style_ from '../src/ol/style/Style.js'; import _ol_style_Style_ from '../src/ol/style/Style.js';
@@ -61,7 +61,7 @@ var roadStyle = function(feature) {
var map = new Map({ var map = new Map({
layers: [ layers: [
new _ol_layer_VectorTile_({ new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({ source: new VectorTileSource({
attributions: '&copy; OpenStreetMap contributors, Whos On First, ' + attributions: '&copy; OpenStreetMap contributors, Whos On First, ' +
'Natural Earth, and openstreetmapdata.com', 'Natural Earth, and openstreetmapdata.com',
format: new TopoJSON({ format: new TopoJSON({

View File

@@ -2,7 +2,7 @@ import Map from '../src/ol/Map.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.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 _ol_source_VectorTile_ from '../src/ol/source/VectorTile.js'; import VectorTileSource from '../src/ol/source/VectorTile.js';
var map = new Map({ var map = new Map({
target: 'map', target: 'map',
@@ -11,7 +11,7 @@ var map = new Map({
zoom: 2 zoom: 2
}), }),
layers: [new _ol_layer_VectorTile_({ layers: [new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({ source: new VectorTileSource({
format: new MVT(), format: new MVT(),
url: 'https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf' url: 'https://basemaps.arcgis.com/v1/arcgis/rest/services/World_Basemap/VectorTileServer/tile/{z}/{y}/{x}.pbf'
}) })

View File

@@ -26,7 +26,7 @@ import _ol_tilegrid_ from '../tilegrid.js';
* @param {olx.source.VectorTileOptions} options Vector tile options. * @param {olx.source.VectorTileOptions} options Vector tile options.
* @api * @api
*/ */
var _ol_source_VectorTile_ = function(options) { var VectorTileSource = function(options) {
var projection = options.projection || 'EPSG:3857'; var projection = options.projection || 'EPSG:3857';
var extent = options.extent || _ol_tilegrid_.extentFromProjection(projection); var extent = options.extent || _ol_tilegrid_.extentFromProjection(projection);
@@ -87,13 +87,13 @@ var _ol_source_VectorTile_ = function(options) {
}; };
inherits(_ol_source_VectorTile_, UrlTile); inherits(VectorTileSource, UrlTile);
/** /**
* @return {boolean} The source can have overlapping geometries. * @return {boolean} The source can have overlapping geometries.
*/ */
_ol_source_VectorTile_.prototype.getOverlaps = function() { VectorTileSource.prototype.getOverlaps = function() {
return this.overlaps_; return this.overlaps_;
}; };
@@ -101,7 +101,7 @@ _ol_source_VectorTile_.prototype.getOverlaps = function() {
* clear {@link ol.TileCache} and delete all source tiles * clear {@link ol.TileCache} and delete all source tiles
* @api * @api
*/ */
_ol_source_VectorTile_.prototype.clear = function() { VectorTileSource.prototype.clear = function() {
this.tileCache.clear(); this.tileCache.clear();
this.sourceTiles_ = {}; this.sourceTiles_ = {};
}; };
@@ -109,7 +109,7 @@ _ol_source_VectorTile_.prototype.clear = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_source_VectorTile_.prototype.getTile = function(z, x, y, pixelRatio, projection) { VectorTileSource.prototype.getTile = function(z, x, y, pixelRatio, projection) {
var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y); var tileCoordKey = _ol_tilecoord_.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(tileCoordKey)) { if (this.tileCache.containsKey(tileCoordKey)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey)); return /** @type {!ol.Tile} */ (this.tileCache.get(tileCoordKey));
@@ -136,7 +136,7 @@ _ol_source_VectorTile_.prototype.getTile = function(z, x, y, pixelRatio, project
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_source_VectorTile_.prototype.getTileGridForProjection = function(projection) { VectorTileSource.prototype.getTileGridForProjection = function(projection) {
var code = projection.getCode(); var code = projection.getCode();
var tileGrid = this.tileGrids_[code]; var tileGrid = this.tileGrids_[code];
if (!tileGrid) { if (!tileGrid) {
@@ -153,7 +153,7 @@ _ol_source_VectorTile_.prototype.getTileGridForProjection = function(projection)
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_source_VectorTile_.prototype.getTilePixelRatio = function(pixelRatio) { VectorTileSource.prototype.getTilePixelRatio = function(pixelRatio) {
return pixelRatio; return pixelRatio;
}; };
@@ -161,8 +161,8 @@ _ol_source_VectorTile_.prototype.getTilePixelRatio = function(pixelRatio) {
/** /**
* @inheritDoc * @inheritDoc
*/ */
_ol_source_VectorTile_.prototype.getTilePixelSize = function(z, pixelRatio, projection) { VectorTileSource.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
var tileSize = _ol_size_.toSize(this.getTileGridForProjection(projection).getTileSize(z)); var tileSize = _ol_size_.toSize(this.getTileGridForProjection(projection).getTileSize(z));
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)]; return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
}; };
export default _ol_source_VectorTile_; export default VectorTileSource;

View File

@@ -7,7 +7,7 @@ import VectorLayer from '../../../../src/ol/layer/Vector.js';
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
import _ol_obj_ from '../../../../src/ol/obj.js'; import _ol_obj_ from '../../../../src/ol/obj.js';
import VectorSource from '../../../../src/ol/source/Vector.js'; import VectorSource from '../../../../src/ol/source/Vector.js';
import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js'; import VectorTileSource from '../../../../src/ol/source/VectorTile.js';
import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js'; import _ol_style_Circle_ from '../../../../src/ol/style/Circle.js';
import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js'; import _ol_style_Fill_ from '../../../../src/ol/style/Fill.js';
import _ol_style_Style_ from '../../../../src/ol/style/Style.js'; import _ol_style_Style_ from '../../../../src/ol/style/Style.js';
@@ -69,7 +69,7 @@ describe('ol.rendering.layer.VectorTile', function() {
var source; var source;
beforeEach(function() { beforeEach(function() {
source = new _ol_source_VectorTile_({ source = new VectorTileSource({
format: new MVT(), format: new MVT(),
tileGrid: _ol_tilegrid_.createXYZ(), tileGrid: _ol_tilegrid_.createXYZ(),
url: 'rendering/ol/data/tiles/mvt/{z}-{x}-{y}.vector.pbf', url: 'rendering/ol/data/tiles/mvt/{z}-{x}-{y}.vector.pbf',

View File

@@ -1,5 +1,5 @@
import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js'; import _ol_layer_VectorTile_ from '../../../../src/ol/layer/VectorTile.js';
import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js'; import VectorTileSource from '../../../../src/ol/source/VectorTile.js';
describe('ol.layer.VectorTile', function() { describe('ol.layer.VectorTile', function() {
@@ -10,7 +10,7 @@ describe('ol.layer.VectorTile', function() {
beforeEach(function() { beforeEach(function() {
layer = new _ol_layer_VectorTile_({ layer = new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({}) source: new VectorTileSource({})
}); });
}); });
@@ -40,18 +40,18 @@ describe('ol.layer.VectorTile', function() {
it('works with options', function() { it('works with options', function() {
var layer = new _ol_layer_VectorTile_({ var layer = new _ol_layer_VectorTile_({
renderMode: 'vector', renderMode: 'vector',
source: new _ol_source_VectorTile_({}) source: new VectorTileSource({})
}); });
expect(layer.getRenderMode()).to.be('vector'); expect(layer.getRenderMode()).to.be('vector');
layer = new _ol_layer_VectorTile_({ layer = new _ol_layer_VectorTile_({
renderMode: 'image', renderMode: 'image',
source: new _ol_source_VectorTile_({}) source: new VectorTileSource({})
}); });
expect(layer.getRenderMode()).to.be('image'); expect(layer.getRenderMode()).to.be('image');
expect(function() { expect(function() {
layer = new _ol_layer_VectorTile_({ layer = new _ol_layer_VectorTile_({
renderMode: 'foo', renderMode: 'foo',
source: new _ol_source_VectorTile_({}) source: new VectorTileSource({})
}); });
}).to.throwException(); }).to.throwException();
}); });

View File

@@ -15,7 +15,7 @@ import _ol_proj_Projection_ from '../../../../../src/ol/proj/Projection.js';
import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js'; import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js';
import _ol_render_Feature_ from '../../../../../src/ol/render/Feature.js'; import _ol_render_Feature_ from '../../../../../src/ol/render/Feature.js';
import CanvasVectorTileLayerRenderer from '../../../../../src/ol/renderer/canvas/VectorTileLayer.js'; import CanvasVectorTileLayerRenderer from '../../../../../src/ol/renderer/canvas/VectorTileLayer.js';
import _ol_source_VectorTile_ from '../../../../../src/ol/source/VectorTile.js'; import VectorTileSource from '../../../../../src/ol/source/VectorTile.js';
import _ol_style_Style_ from '../../../../../src/ol/style/Style.js'; import _ol_style_Style_ from '../../../../../src/ol/style/Style.js';
import _ol_style_Text_ from '../../../../../src/ol/style/Text.js'; import _ol_style_Text_ from '../../../../../src/ol/style/Text.js';
import _ol_tilegrid_ from '../../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../../src/ol/tilegrid.js';
@@ -67,13 +67,13 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
tileCallback(this); tileCallback(this);
}; };
inherits(TileClass, VectorTile); inherits(TileClass, VectorTile);
source = new _ol_source_VectorTile_({ source = new VectorTileSource({
format: new MVT(), format: new MVT(),
tileClass: TileClass, tileClass: TileClass,
tileGrid: _ol_tilegrid_.createXYZ() tileGrid: _ol_tilegrid_.createXYZ()
}); });
source.getTile = function() { source.getTile = function() {
var tile = _ol_source_VectorTile_.prototype.getTile.apply(source, arguments); var tile = VectorTileSource.prototype.getTile.apply(source, arguments);
tile.setState(TileState.LOADED); tile.setState(TileState.LOADED);
return tile; return tile;
}; };
@@ -240,7 +240,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
describe('#prepareFrame', function() { describe('#prepareFrame', function() {
it('re-renders when layer changed', function() { it('re-renders when layer changed', function() {
var layer = new _ol_layer_VectorTile_({ var layer = new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({ source: new VectorTileSource({
tileGrid: _ol_tilegrid_.createXYZ(), tileGrid: _ol_tilegrid_.createXYZ(),
transition: 0 transition: 0
}) })
@@ -309,7 +309,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
beforeEach(function() { beforeEach(function() {
replayGroup = {}; replayGroup = {};
layer = new _ol_layer_VectorTile_({ layer = new _ol_layer_VectorTile_({
source: new _ol_source_VectorTile_({ source: new VectorTileSource({
tileClass: TileClass, tileClass: TileClass,
tileGrid: _ol_tilegrid_.createXYZ() tileGrid: _ol_tilegrid_.createXYZ()
}) })
@@ -349,7 +349,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
target.style.height = '100px'; target.style.height = '100px';
document.body.appendChild(target); document.body.appendChild(target);
var extent = [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608]; var extent = [1824704.739223726, 6141868.096770482, 1827150.7241288517, 6144314.081675608];
var source = new _ol_source_VectorTile_({ var source = new VectorTileSource({
format: new MVT(), format: new MVT(),
url: 'spec/ol/data/14-8938-5680.vector.pbf', url: 'spec/ol/data/14-8938-5680.vector.pbf',
minZoom: 14, minZoom: 14,

View File

@@ -5,14 +5,14 @@ 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';
import _ol_source_VectorTile_ from '../../../../src/ol/source/VectorTile.js'; import VectorTileSource from '../../../../src/ol/source/VectorTile.js';
import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js'; import _ol_tilegrid_ from '../../../../src/ol/tilegrid.js';
import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js'; import TileGrid from '../../../../src/ol/tilegrid/TileGrid.js';
describe('ol.source.VectorTile', function() { describe('ol.source.VectorTile', function() {
var format = new MVT(); var format = new MVT();
var source = new _ol_source_VectorTile_({ var source = new VectorTileSource({
format: format, format: format,
tilePixelRatio: 8, tilePixelRatio: 8,
url: 'spec/ol/data/{z}-{x}-{y}.vector.pbf' url: 'spec/ol/data/{z}-{x}-{y}.vector.pbf'
@@ -96,7 +96,7 @@ describe('ol.source.VectorTile', function() {
var extent = [665584.2026596286, 7033250.839875697, 667162.0221431496, 7035280.378636755]; var extent = [665584.2026596286, 7033250.839875697, 667162.0221431496, 7035280.378636755];
source = new _ol_source_VectorTile_({ source = new VectorTileSource({
tileGrid: new TileGrid({ tileGrid: new TileGrid({
origin: [218128, 6126002], origin: [218128, 6126002],
resolutions: [4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5] resolutions: [4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5]