s/store/source/

This commit is contained in:
Tom Payne
2012-09-26 18:48:19 +02:00
parent 228e5a8dbf
commit 290d03e76f
15 changed files with 128 additions and 125 deletions
+1 -1
View File
@@ -21,4 +21,4 @@ var map = new ol.Map(document.getElementById('map'), {
layers: new ol.Collection([layer]), layers: new ol.Collection([layer]),
zoom: 0 zoom: 0
}); });
var zoom = new ol.control.Zoom(map, layer.getStore().getResolutions()); var zoom = new ol.control.Zoom(map, layer.getSource().getResolutions());
+21 -18
View File
@@ -92,7 +92,7 @@ ol.control.Attribution.prototype.addLayer = function(layer) {
layer, ol.Object.getChangedEventType(ol.layer.LayerProperty.VISIBLE), layer, ol.Object.getChangedEventType(ol.layer.LayerProperty.VISIBLE),
this.handleLayerVisibleChanged, false, this); this.handleLayerVisibleChanged, false, this);
if (layer.getStore().isReady()) { if (layer.getSource().isReady()) {
this.createAttributionElementsForLayer_(layer); this.createAttributionElementsForLayer_(layer);
} else { } else {
goog.events.listenOnce(layer, goog.events.EventType.LOAD, goog.events.listenOnce(layer, goog.events.EventType.LOAD,
@@ -109,8 +109,8 @@ ol.control.Attribution.prototype.addLayer = function(layer) {
ol.control.Attribution.prototype.createAttributionElementsForLayer_ = ol.control.Attribution.prototype.createAttributionElementsForLayer_ =
function(layer) { function(layer) {
var store = layer.getStore(); var source = layer.getSource();
var attributions = store.getAttributions(); var attributions = source.getAttributions();
if (goog.isNull(attributions)) { if (goog.isNull(attributions)) {
return; return;
} }
@@ -173,17 +173,17 @@ ol.control.Attribution.prototype.getElement = function() {
ol.control.Attribution.prototype.getLayerAttributionVisiblities_ = ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
function(layer, mapExtent, mapResolution, mapProjection) { function(layer, mapExtent, mapResolution, mapProjection) {
var store = layer.getStore(); var source = layer.getSource();
var attributions = store.getAttributions(); var attributions = source.getAttributions();
if (goog.isNull(attributions)) { if (goog.isNull(attributions)) {
return null; return null;
} }
var mapZ; var mapZ;
if (store instanceof ol.TileStore) { if (source instanceof ol.TileSource) {
var tileStore = /** @type {ol.TileStore} */ store; var tileSource = /** @type {ol.TileSource} */ source;
var tileGrid = tileStore.getTileGrid(); var tileGrid = tileSource.getTileGrid();
mapZ = tileGrid.getZForResolution(mapResolution); mapZ = tileGrid.getZForResolution(mapResolution);
} }
@@ -214,7 +214,7 @@ ol.control.Attribution.prototype.getLayerAttributionVisiblities_ =
} }
if (!goog.isNull(coverageAreas)) { if (!goog.isNull(coverageAreas)) {
if (store instanceof ol.TileStore) { if (source instanceof ol.TileSource) {
attributionVisible = goog.array.some( attributionVisible = goog.array.some(
coverageAreas, coverageAreas,
function(coverageArea, index) { function(coverageArea, index) {
@@ -347,13 +347,16 @@ ol.control.Attribution.prototype.removeLayer = function(layer) {
goog.events.unlistenByKey(this.layerVisibleChangeListenerKeys_[layerKey]); goog.events.unlistenByKey(this.layerVisibleChangeListenerKeys_[layerKey]);
delete this.layerVisibleChangeListenerKeys_[layerKey]; delete this.layerVisibleChangeListenerKeys_[layerKey];
goog.array.forEach(layer.getStore().getAttributions(), function(attribution) { goog.array.forEach(
var attributionKey = goog.getUid(attribution); layer.getSource().getAttributions(),
delete this.coverageAreass_[attributionKey]; function(attribution) {
var attributionElement = this.attributionElements_[attributionKey]; var attributionKey = goog.getUid(attribution);
goog.dom.removeNode(attributionElement); delete this.coverageAreass_[attributionKey];
delete this.attributionElements_[attributionKey]; var attributionElement = this.attributionElements_[attributionKey];
}, this); goog.dom.removeNode(attributionElement);
delete this.attributionElements_[attributionKey];
},
this);
}; };
@@ -379,8 +382,8 @@ ol.control.Attribution.prototype.updateLayerAttributionsVisibility_ =
}, },
this); this);
} else { } else {
var store = layer.getStore(); var source = layer.getSource();
var attributions = store.getAttributions(); var attributions = source.getAttributions();
if (!goog.isNull(attributions)) { if (!goog.isNull(attributions)) {
goog.array.forEach(attributions, function(attribution) { goog.array.forEach(attributions, function(attribution) {
var attributionKey = goog.getUid(attribution); var attributionKey = goog.getUid(attribution);
+12 -12
View File
@@ -1,5 +1,5 @@
goog.provide('ol.layer.BingMaps'); goog.provide('ol.layer.BingMaps');
goog.provide('ol.tilestore.BingMaps'); goog.provide('ol.tilesource.BingMaps');
goog.require('goog.Uri'); goog.require('goog.Uri');
goog.require('goog.events'); goog.require('goog.events');
@@ -7,7 +7,7 @@ goog.require('goog.events.EventType');
goog.require('goog.net.Jsonp'); goog.require('goog.net.Jsonp');
goog.require('ol.TileCoverageArea'); goog.require('ol.TileCoverageArea');
goog.require('ol.TileLayer'); goog.require('ol.TileLayer');
goog.require('ol.TileStore'); goog.require('ol.TileSource');
goog.require('ol.tilegrid.XYZ'); goog.require('ol.tilegrid.XYZ');
@@ -33,11 +33,11 @@ ol.BingMapsStyle = {
* @param {Object.<string, *>=} opt_values Values. * @param {Object.<string, *>=} opt_values Values.
*/ */
ol.layer.BingMaps = function(style, key, opt_culture, opt_values) { ol.layer.BingMaps = function(style, key, opt_culture, opt_values) {
var tileStore = new ol.tilestore.BingMaps(style, key, opt_culture, var tileSource = new ol.tilesource.BingMaps(style, key, opt_culture,
function(tileStore) { function(tileSource) {
this.dispatchEvent(goog.events.EventType.LOAD); this.dispatchEvent(goog.events.EventType.LOAD);
}, this); }, this);
goog.base(this, tileStore, opt_values); goog.base(this, tileSource, opt_values);
}; };
goog.inherits(ol.layer.BingMaps, ol.TileLayer); goog.inherits(ol.layer.BingMaps, ol.TileLayer);
@@ -45,14 +45,14 @@ goog.inherits(ol.layer.BingMaps, ol.TileLayer);
/** /**
* @constructor * @constructor
* @extends {ol.TileStore} * @extends {ol.TileSource}
* @param {ol.BingMapsStyle} style Bing Maps style. * @param {ol.BingMapsStyle} style Bing Maps style.
* @param {string} key Key. * @param {string} key Key.
* @param {string=} opt_culture Culture. * @param {string=} opt_culture Culture.
* @param {?function(ol.tilestore.BingMaps)=} opt_callback Callback. * @param {?function(ol.tilesource.BingMaps)=} opt_callback Callback.
* @param {*=} opt_obj Object. * @param {*=} opt_obj Object.
*/ */
ol.tilestore.BingMaps = ol.tilesource.BingMaps =
function(style, key, opt_culture, opt_callback, opt_obj) { function(style, key, opt_culture, opt_callback, opt_obj) {
/** /**
@@ -69,7 +69,7 @@ ol.tilestore.BingMaps =
/** /**
* @private * @private
* @type {?function(ol.tilestore.BingMaps)} * @type {?function(ol.tilesource.BingMaps)}
*/ */
this.callback_ = opt_callback || null; this.callback_ = opt_callback || null;
@@ -94,13 +94,13 @@ ol.tilestore.BingMaps =
this, projection, null, ol.TileUrlFunction.nullTileUrlFunction, extent); this, projection, null, ol.TileUrlFunction.nullTileUrlFunction, extent);
}; };
goog.inherits(ol.tilestore.BingMaps, ol.TileStore); goog.inherits(ol.tilesource.BingMaps, ol.TileSource);
/** /**
* @param {BingMapsImageryMetadataResponse} response Response. * @param {BingMapsImageryMetadataResponse} response Response.
*/ */
ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse = ol.tilesource.BingMaps.prototype.handleImageryMetadataResponse =
function(response) { function(response) {
goog.asserts.assert( goog.asserts.assert(
@@ -184,6 +184,6 @@ ol.tilestore.BingMaps.prototype.handleImageryMetadataResponse =
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.tilestore.BingMaps.prototype.isReady = function() { ol.tilesource.BingMaps.prototype.isReady = function() {
return this.ready_; return this.ready_;
}; };
+9 -9
View File
@@ -3,7 +3,7 @@ goog.provide('ol.layer.LayerProperty');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol.Object'); goog.require('ol.Object');
goog.require('ol.Store'); goog.require('ol.Source');
/** /**
@@ -23,18 +23,18 @@ ol.layer.LayerProperty = {
/** /**
* @constructor * @constructor
* @extends {ol.Object} * @extends {ol.Object}
* @param {ol.Store} store Store. * @param {ol.Source} source Source.
* @param {Object.<string, *>=} opt_values Values. * @param {Object.<string, *>=} opt_values Values.
*/ */
ol.layer.Layer = function(store, opt_values) { ol.layer.Layer = function(source, opt_values) {
goog.base(this); goog.base(this);
/** /**
* @private * @private
* @type {ol.Store} * @type {ol.Source}
*/ */
this.store_ = store; this.source_ = source;
this.setBrightness(0); this.setBrightness(0);
this.setContrast(0); this.setContrast(0);
@@ -112,10 +112,10 @@ goog.exportProperty(
/** /**
* @return {ol.Store} Store. * @return {ol.Source} Source.
*/ */
ol.layer.Layer.prototype.getStore = function() { ol.layer.Layer.prototype.getSource = function() {
return this.store_; return this.source_;
}; };
@@ -135,7 +135,7 @@ goog.exportProperty(
* @return {boolean} Is ready. * @return {boolean} Is ready.
*/ */
ol.layer.Layer.prototype.isReady = function() { ol.layer.Layer.prototype.isReady = function() {
return this.getStore().isReady(); return this.getSource().isReady();
}; };
+7 -7
View File
@@ -1,9 +1,9 @@
goog.provide('ol.layer.OpenStreetMap'); goog.provide('ol.layer.OpenStreetMap');
goog.provide('ol.store.OpenStreetMap'); goog.provide('ol.source.OpenStreetMap');
goog.require('ol.TileLayer'); goog.require('ol.TileLayer');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.tilestore.XYZ'); goog.require('ol.tilesource.XYZ');
@@ -13,8 +13,8 @@ goog.require('ol.tilestore.XYZ');
* @param {Object.<string, *>=} opt_values Values. * @param {Object.<string, *>=} opt_values Values.
*/ */
ol.layer.OpenStreetMap = function(opt_values) { ol.layer.OpenStreetMap = function(opt_values) {
var tileStore = new ol.store.OpenStreetMap(); var tileSource = new ol.source.OpenStreetMap();
goog.base(this, tileStore, opt_values); goog.base(this, tileSource, opt_values);
}; };
goog.inherits(ol.layer.OpenStreetMap, ol.TileLayer); goog.inherits(ol.layer.OpenStreetMap, ol.TileLayer);
@@ -22,9 +22,9 @@ goog.inherits(ol.layer.OpenStreetMap, ol.TileLayer);
/** /**
* @constructor * @constructor
* @extends {ol.tilestore.XYZ} * @extends {ol.tilesource.XYZ}
*/ */
ol.store.OpenStreetMap = function() { ol.source.OpenStreetMap = function() {
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate( var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(
'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'); 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png');
@@ -37,4 +37,4 @@ ol.store.OpenStreetMap = function() {
goog.base(this, 18, tileUrlFunction, [attribution]); goog.base(this, 18, tileUrlFunction, [attribution]);
}; };
goog.inherits(ol.store.OpenStreetMap, ol.tilestore.XYZ); goog.inherits(ol.source.OpenStreetMap, ol.tilesource.XYZ);
+1 -1
View File
@@ -1,7 +1,7 @@
// FIXME Configure minZoom when supported by TileGrid // FIXME Configure minZoom when supported by TileGrid
goog.provide('ol.layer.Stamen'); goog.provide('ol.layer.Stamen');
goog.provide('ol.store.Stamen'); goog.provide('ol.source.Stamen');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.layer.XYZ'); goog.require('ol.layer.XYZ');
+11 -11
View File
@@ -8,7 +8,7 @@
goog.provide('ol.layer.TileJSON'); goog.provide('ol.layer.TileJSON');
goog.provide('ol.tilejson'); goog.provide('ol.tilejson');
goog.provide('ol.tilestore.TileJSON'); goog.provide('ol.tilesource.TileJSON');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.events.EventType'); goog.require('goog.events.EventType');
@@ -16,7 +16,7 @@ goog.require('goog.net.jsloader');
goog.require('goog.string'); goog.require('goog.string');
goog.require('ol.TileCoverageArea'); goog.require('ol.TileCoverageArea');
goog.require('ol.TileLayer'); goog.require('ol.TileLayer');
goog.require('ol.TileStore'); goog.require('ol.TileSource');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
@@ -45,10 +45,10 @@ goog.exportSymbol('grid', grid);
*/ */
ol.layer.TileJSON = function(url, opt_values) { ol.layer.TileJSON = function(url, opt_values) {
goog.asserts.assert(goog.string.endsWith(url, '.jsonp')); goog.asserts.assert(goog.string.endsWith(url, '.jsonp'));
var tileStore = new ol.tilestore.TileJSON(url, function(tileStore) { var tileSource = new ol.tilesource.TileJSON(url, function(tileSource) {
this.dispatchEvent(goog.events.EventType.LOAD); this.dispatchEvent(goog.events.EventType.LOAD);
}, this); }, this);
goog.base(this, tileStore, opt_values); goog.base(this, tileSource, opt_values);
}; };
goog.inherits(ol.layer.TileJSON, ol.TileLayer); goog.inherits(ol.layer.TileJSON, ol.TileLayer);
@@ -56,12 +56,12 @@ goog.inherits(ol.layer.TileJSON, ol.TileLayer);
/** /**
* @constructor * @constructor
* @extends {ol.TileStore} * @extends {ol.TileSource}
* @param {string} uri URI. * @param {string} uri URI.
* @param {?function(ol.tilestore.TileJSON)=} opt_callback Callback. * @param {?function(ol.tilesource.TileJSON)=} opt_callback Callback.
* @param {*=} opt_obj Object. * @param {*=} opt_obj Object.
*/ */
ol.tilestore.TileJSON = function(uri, opt_callback, opt_obj) { ol.tilesource.TileJSON = function(uri, opt_callback, opt_obj) {
var projection = ol.Projection.getFromCode('EPSG:3857'); var projection = ol.Projection.getFromCode('EPSG:3857');
@@ -70,7 +70,7 @@ ol.tilestore.TileJSON = function(uri, opt_callback, opt_obj) {
/** /**
* @private * @private
* @type {?function(ol.tilestore.TileJSON)} * @type {?function(ol.tilesource.TileJSON)}
*/ */
this.callback_ = opt_callback || null; this.callback_ = opt_callback || null;
@@ -94,13 +94,13 @@ ol.tilestore.TileJSON = function(uri, opt_callback, opt_obj) {
this.deferred_.addCallback(this.handleTileJSONResponse, this); this.deferred_.addCallback(this.handleTileJSONResponse, this);
}; };
goog.inherits(ol.tilestore.TileJSON, ol.TileStore); goog.inherits(ol.tilesource.TileJSON, ol.TileSource);
/** /**
* @protected * @protected
*/ */
ol.tilestore.TileJSON.prototype.handleTileJSONResponse = function() { ol.tilesource.TileJSON.prototype.handleTileJSONResponse = function() {
var tileJSON = ol.tilejson.grids_.pop(); var tileJSON = ol.tilejson.grids_.pop();
@@ -176,6 +176,6 @@ ol.tilestore.TileJSON.prototype.handleTileJSONResponse = function() {
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.tilestore.TileJSON.prototype.isReady = function() { ol.tilesource.TileJSON.prototype.isReady = function() {
return this.ready_; return this.ready_;
}; };
+7 -7
View File
@@ -1,6 +1,6 @@
goog.provide('ol.layer.XYZ'); goog.provide('ol.layer.XYZ');
goog.provide('ol.tilegrid.XYZ'); goog.provide('ol.tilegrid.XYZ');
goog.provide('ol.tilestore.XYZ'); goog.provide('ol.tilesource.XYZ');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
@@ -10,7 +10,7 @@ goog.require('ol.Size');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileGrid'); goog.require('ol.TileGrid');
goog.require('ol.TileLayer'); goog.require('ol.TileLayer');
goog.require('ol.TileStore'); goog.require('ol.TileSource');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
@@ -76,9 +76,9 @@ ol.tilegrid.XYZ.prototype.forEachTileCoordParentTileRange =
*/ */
ol.layer.XYZ = function( ol.layer.XYZ = function(
maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin, opt_values) { maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin, opt_values) {
var tileStore = new ol.tilestore.XYZ( var tileSource = new ol.tilesource.XYZ(
maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin); maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin);
goog.base(this, tileStore, opt_values); goog.base(this, tileSource, opt_values);
}; };
goog.inherits(ol.layer.XYZ, ol.TileLayer); goog.inherits(ol.layer.XYZ, ol.TileLayer);
@@ -86,13 +86,13 @@ goog.inherits(ol.layer.XYZ, ol.TileLayer);
/** /**
* @constructor * @constructor
* @extends {ol.TileStore} * @extends {ol.TileSource}
* @param {number} maxZoom Maximum zoom. * @param {number} maxZoom Maximum zoom.
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL function. * @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL function.
* @param {Array.<ol.Attribution>=} opt_attributions Attributions. * @param {Array.<ol.Attribution>=} opt_attributions Attributions.
* @param {string=} opt_crossOrigin Cross origin. * @param {string=} opt_crossOrigin Cross origin.
*/ */
ol.tilestore.XYZ = ol.tilesource.XYZ =
function(maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin) { function(maxZoom, tileUrlFunction, opt_attributions, opt_crossOrigin) {
var projection = ol.Projection.getFromCode('EPSG:3857'); var projection = ol.Projection.getFromCode('EPSG:3857');
@@ -115,4 +115,4 @@ ol.tilestore.XYZ =
opt_attributions, opt_crossOrigin); opt_attributions, opt_crossOrigin);
}; };
goog.inherits(ol.tilestore.XYZ, ol.TileStore); goog.inherits(ol.tilesource.XYZ, ol.TileSource);
+7 -7
View File
@@ -74,8 +74,8 @@ ol.renderer.dom.TileLayer.prototype.getLayer = function() {
*/ */
ol.renderer.dom.TileLayer.prototype.getTileOffset_ = function(z, resolution) { ol.renderer.dom.TileLayer.prototype.getTileOffset_ = function(z, resolution) {
var tileLayer = this.getLayer(); var tileLayer = this.getLayer();
var tileStore = tileLayer.getStore(); var tileSource = tileLayer.getSource();
var tileGrid = tileStore.getTileGrid(); var tileGrid = tileSource.getTileGrid();
var tileOrigin = tileGrid.getOrigin(z); var tileOrigin = tileGrid.getOrigin(z);
var offset = new ol.Coordinate( var offset = new ol.Coordinate(
Math.round((this.origin.x - tileOrigin.x) / resolution), Math.round((this.origin.x - tileOrigin.x) / resolution),
@@ -167,8 +167,8 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
var resolutionChanged = (mapResolution !== this.renderedMapResolution_); var resolutionChanged = (mapResolution !== this.renderedMapResolution_);
var tileLayer = this.getLayer(); var tileLayer = this.getLayer();
var tileStore = tileLayer.getStore(); var tileSource = tileLayer.getSource();
var tileGrid = tileStore.getTileGrid(); var tileGrid = tileSource.getTileGrid();
// z represents the "best" resolution // z represents the "best" resolution
var z = tileGrid.getZForResolution(mapResolution); var z = tileGrid.getZForResolution(mapResolution);
@@ -191,9 +191,9 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
// first pass through the tile range to determine all the tiles needed // first pass through the tile range to determine all the tiles needed
var allTilesLoaded = true; var allTilesLoaded = true;
tileRange.forEachTileCoord(z, function(tileCoord) { tileRange.forEachTileCoord(z, function(tileCoord) {
var tile = tileStore.getTile(tileCoord); var tile = tileSource.getTile(tileCoord);
if (goog.isNull(tile)) { if (goog.isNull(tile)) {
// we're outside the store's extent, continue // we're outside the source's extent, continue
return; return;
} }
@@ -228,7 +228,7 @@ ol.renderer.dom.TileLayer.prototype.render = function() {
if (tilesToDrawByZ[altZ] && tilesToDrawByZ[altZ][tileKey]) { if (tilesToDrawByZ[altZ] && tilesToDrawByZ[altZ][tileKey]) {
return; return;
} }
var altTile = tileStore.getTile(altTileCoord); var altTile = tileSource.getTile(altTileCoord);
if (!goog.isNull(altTile) && if (!goog.isNull(altTile) &&
altTile.getState() == ol.TileState.LOADED) { altTile.getState() == ol.TileState.LOADED) {
if (!(altZ in tilesToDrawByZ)) { if (!(altZ in tilesToDrawByZ)) {
+3 -3
View File
@@ -169,7 +169,7 @@ ol.renderer.webgl.Map = function(container, map) {
goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST, goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.LOST,
this.handleWebGLContextLost, false, this); this.handleWebGLContextLost, false, this);
goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.RESTORED, goog.events.listen(this.canvas_, ol.webgl.WebGLContextEventType.RESTORED,
this.handleWebGLContextRestored, false, this); this.handleWebGLContextResourced, false, this);
/** /**
* @private * @private
@@ -493,9 +493,9 @@ ol.renderer.webgl.Map.prototype.handleWebGLContextLost = function(event) {
/** /**
* @protected * @protected
*/ */
ol.renderer.webgl.Map.prototype.handleWebGLContextRestored = function() { ol.renderer.webgl.Map.prototype.handleWebGLContextResourced = function() {
if (goog.DEBUG) { if (goog.DEBUG) {
this.logger.info('WebGLContextRestored'); this.logger.info('WebGLContextResourced');
} }
this.initializeGL_(); this.initializeGL_();
this.getMap().render(); this.getMap().render();
+5 -5
View File
@@ -316,8 +316,8 @@ ol.renderer.webgl.TileLayer.prototype.render = function() {
var mapRotation = map.getRotation(); var mapRotation = map.getRotation();
var tileLayer = this.getLayer(); var tileLayer = this.getLayer();
var tileStore = tileLayer.getStore(); var tileSource = tileLayer.getSource();
var tileGrid = tileStore.getTileGrid(); var tileGrid = tileSource.getTileGrid();
var z = tileGrid.getZForResolution(mapResolution); var z = tileGrid.getZForResolution(mapResolution);
var tileResolution = tileGrid.getResolution(z); var tileResolution = tileGrid.getResolution(z);
var tileRange = tileGrid.getTileRangeForExtentAndResolution( var tileRange = tileGrid.getTileRangeForExtentAndResolution(
@@ -406,10 +406,10 @@ ol.renderer.webgl.TileLayer.prototype.render = function() {
tilesToDrawByZ[z] = {}; tilesToDrawByZ[z] = {};
tileRange.forEachTileCoord(z, function(tileCoord) { tileRange.forEachTileCoord(z, function(tileCoord) {
var tile = tileStore.getTile(tileCoord); var tile = tileSource.getTile(tileCoord);
if (goog.isNull(tile)) { if (goog.isNull(tile)) {
// FIXME - consider returning here as this is outside the store's extent // FIXME consider returning here as this is outside the source's extent
} else if (tile.getState() == ol.TileState.LOADED) { } else if (tile.getState() == ol.TileState.LOADED) {
if (mapRenderer.isImageTextureLoaded(tile.getImage())) { if (mapRenderer.isImageTextureLoaded(tile.getImage())) {
tilesToDrawByZ[z][tileCoord.toString()] = tile; tilesToDrawByZ[z][tileCoord.toString()] = tile;
@@ -439,7 +439,7 @@ ol.renderer.webgl.TileLayer.prototype.render = function() {
if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) { if (tilesToDrawByZ[z] && tilesToDrawByZ[z][tileCoordKey]) {
return; return;
} }
var tile = tileStore.getTile(tileCoord); var tile = tileSource.getTile(tileCoord);
if (!goog.isNull(tile) && if (!goog.isNull(tile) &&
tile.getState() == ol.TileState.LOADED) { tile.getState() == ol.TileState.LOADED) {
if (!tilesToDrawByZ[z]) { if (!tilesToDrawByZ[z]) {
+10 -10
View File
@@ -1,4 +1,4 @@
goog.provide('ol.Store'); goog.provide('ol.Source');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
@@ -13,7 +13,7 @@ goog.require('ol.Projection');
* @param {ol.Extent=} opt_extent Extent. * @param {ol.Extent=} opt_extent Extent.
* @param {Array.<ol.Attribution>=} opt_attributions Attributions. * @param {Array.<ol.Attribution>=} opt_attributions Attributions.
*/ */
ol.Store = function(projection, opt_extent, opt_attributions) { ol.Source = function(projection, opt_extent, opt_attributions) {
/** /**
* @private * @private
@@ -39,7 +39,7 @@ ol.Store = function(projection, opt_extent, opt_attributions) {
/** /**
* @return {Array.<ol.Attribution>} Attributions. * @return {Array.<ol.Attribution>} Attributions.
*/ */
ol.Store.prototype.getAttributions = function() { ol.Source.prototype.getAttributions = function() {
return this.attributions_; return this.attributions_;
}; };
@@ -47,7 +47,7 @@ ol.Store.prototype.getAttributions = function() {
/** /**
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
*/ */
ol.Store.prototype.getExtent = function() { ol.Source.prototype.getExtent = function() {
return this.extent_; return this.extent_;
}; };
@@ -55,7 +55,7 @@ ol.Store.prototype.getExtent = function() {
/** /**
* @return {ol.Projection} Projection. * @return {ol.Projection} Projection.
*/ */
ol.Store.prototype.getProjection = function() { ol.Source.prototype.getProjection = function() {
return this.projection_; return this.projection_;
}; };
@@ -63,19 +63,19 @@ ol.Store.prototype.getProjection = function() {
/** /**
* @return {Array.<number>|undefined} Resolutions. * @return {Array.<number>|undefined} Resolutions.
*/ */
ol.Store.prototype.getResolutions = goog.abstractMethod; ol.Source.prototype.getResolutions = goog.abstractMethod;
/** /**
* @return {boolean} Is ready. * @return {boolean} Is ready.
*/ */
ol.Store.prototype.isReady = goog.functions.TRUE; ol.Source.prototype.isReady = goog.functions.TRUE;
/** /**
* @param {Array.<ol.Attribution>} attributions Attributions. * @param {Array.<ol.Attribution>} attributions Attributions.
*/ */
ol.Store.prototype.setAttributions = function(attributions) { ol.Source.prototype.setAttributions = function(attributions) {
this.attributions_ = attributions; this.attributions_ = attributions;
}; };
@@ -83,7 +83,7 @@ ol.Store.prototype.setAttributions = function(attributions) {
/** /**
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
*/ */
ol.Store.prototype.setExtent = function(extent) { ol.Source.prototype.setExtent = function(extent) {
this.extent_ = extent; this.extent_ = extent;
}; };
@@ -91,6 +91,6 @@ ol.Store.prototype.setExtent = function(extent) {
/** /**
* @param {ol.Projection} projection Projetion. * @param {ol.Projection} projection Projetion.
*/ */
ol.Store.prototype.setProjection = function(projection) { ol.Source.prototype.setProjection = function(projection) {
this.projection_ = projection; this.projection_ = projection;
}; };
+7 -7
View File
@@ -1,6 +1,6 @@
goog.provide('ol.TileLayer'); goog.provide('ol.TileLayer');
goog.require('ol.TileStore'); goog.require('ol.TileSource');
goog.require('ol.layer.Layer'); goog.require('ol.layer.Layer');
@@ -8,19 +8,19 @@ goog.require('ol.layer.Layer');
/** /**
* @constructor * @constructor
* @extends {ol.layer.Layer} * @extends {ol.layer.Layer}
* @param {ol.TileStore} tileStore Tile store. * @param {ol.TileSource} tileSource Tile source.
* @param {Object.<string, *>=} opt_values Values. * @param {Object.<string, *>=} opt_values Values.
*/ */
ol.TileLayer = function(tileStore, opt_values) { ol.TileLayer = function(tileSource, opt_values) {
goog.base(this, tileStore, opt_values); goog.base(this, tileSource, opt_values);
}; };
goog.inherits(ol.TileLayer, ol.layer.Layer); goog.inherits(ol.TileLayer, ol.layer.Layer);
/** /**
* @inheritDoc * @inheritDoc
* @return {ol.TileStore} Store. * @return {ol.TileSource} Source.
*/ */
ol.TileLayer.prototype.getStore = function() { ol.TileLayer.prototype.getSource = function() {
return /** @type {ol.TileStore} */ goog.base(this, 'getStore'); return /** @type {ol.TileSource} */ goog.base(this, 'getSource');
}; };
+9 -9
View File
@@ -1,7 +1,7 @@
goog.provide('ol.TileStore'); goog.provide('ol.TileSource');
goog.require('ol.Attribution'); goog.require('ol.Attribution');
goog.require('ol.Store'); goog.require('ol.Source');
goog.require('ol.Tile'); goog.require('ol.Tile');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileGrid'); goog.require('ol.TileGrid');
@@ -11,7 +11,7 @@ goog.require('ol.TileUrlFunctionType');
/** /**
* @constructor * @constructor
* @extends {ol.Store} * @extends {ol.Source}
* @param {ol.Projection} projection Projection. * @param {ol.Projection} projection Projection.
* @param {ol.TileGrid} tileGrid Tile grid. * @param {ol.TileGrid} tileGrid Tile grid.
* @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL. * @param {ol.TileUrlFunctionType} tileUrlFunction Tile URL.
@@ -19,7 +19,7 @@ goog.require('ol.TileUrlFunctionType');
* @param {Array.<string>=} opt_attributions Attributions. * @param {Array.<string>=} opt_attributions Attributions.
* @param {?string=} opt_crossOrigin Cross origin. * @param {?string=} opt_crossOrigin Cross origin.
*/ */
ol.TileStore = function(projection, tileGrid, tileUrlFunction, opt_extent, ol.TileSource = function(projection, tileGrid, tileUrlFunction, opt_extent,
opt_attributions, opt_crossOrigin) { opt_attributions, opt_crossOrigin) {
goog.base(this, projection, opt_extent, opt_attributions); goog.base(this, projection, opt_extent, opt_attributions);
@@ -51,13 +51,13 @@ ol.TileStore = function(projection, tileGrid, tileUrlFunction, opt_extent,
this.tileCache_ = {}; this.tileCache_ = {};
}; };
goog.inherits(ol.TileStore, ol.Store); goog.inherits(ol.TileSource, ol.Source);
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.TileStore.prototype.getResolutions = function() { ol.TileSource.prototype.getResolutions = function() {
return this.tileGrid.getResolutions(); return this.tileGrid.getResolutions();
}; };
@@ -66,7 +66,7 @@ ol.TileStore.prototype.getResolutions = function() {
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @return {ol.Tile} Tile. * @return {ol.Tile} Tile.
*/ */
ol.TileStore.prototype.getTile = function(tileCoord) { ol.TileSource.prototype.getTile = function(tileCoord) {
var key = tileCoord.toString(); var key = tileCoord.toString();
if (goog.object.containsKey(this.tileCache_, key)) { if (goog.object.containsKey(this.tileCache_, key)) {
return this.tileCache_[key]; return this.tileCache_[key];
@@ -88,7 +88,7 @@ ol.TileStore.prototype.getTile = function(tileCoord) {
* @param {ol.TileCoord} tileCoord Tile coordinate. * @param {ol.TileCoord} tileCoord Tile coordinate.
* @return {string|undefined} Tile URL. * @return {string|undefined} Tile URL.
*/ */
ol.TileStore.prototype.getTileCoordUrl = function(tileCoord) { ol.TileSource.prototype.getTileCoordUrl = function(tileCoord) {
return this.tileUrlFunction(tileCoord); return this.tileUrlFunction(tileCoord);
}; };
@@ -96,6 +96,6 @@ ol.TileStore.prototype.getTileCoordUrl = function(tileCoord) {
/** /**
* @return {ol.TileGrid} Tile grid. * @return {ol.TileGrid} Tile grid.
*/ */
ol.TileStore.prototype.getTileGrid = function() { ol.TileSource.prototype.getTileGrid = function() {
return this.tileGrid; return this.tileGrid;
}; };
+18 -18
View File
@@ -1,70 +1,70 @@
describe('ol.tilestore.XYZ', function() { describe('ol.tilesource.XYZ', function() {
describe('getTileCoordUrl', function() { describe('getTileCoordUrl', function() {
var xyzTileStore, tileGrid; var xyzTileSource, tileGrid;
beforeEach(function() { beforeEach(function() {
xyzTileStore = new ol.tilestore.XYZ( xyzTileSource = new ol.tilesource.XYZ(
6, ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}')); 6, ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}'));
tileGrid = xyzTileStore.getTileGrid(); tileGrid = xyzTileSource.getTileGrid();
}); });
it('return the expected URL', function() { it('return the expected URL', function() {
var coordinate = new ol.Coordinate(829330.2064098881, 5933916.615134273); var coordinate = new ol.Coordinate(829330.2064098881, 5933916.615134273);
var tileUrl; var tileUrl;
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 0)); tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
expect(tileUrl).toEqual('0/0/0'); expect(tileUrl).toEqual('0/0/0');
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 1)); tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
expect(tileUrl).toEqual('1/1/0'); expect(tileUrl).toEqual('1/1/0');
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 2)); tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
expect(tileUrl).toEqual('2/2/1'); expect(tileUrl).toEqual('2/2/1');
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 3)); tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
expect(tileUrl).toEqual('3/4/2'); expect(tileUrl).toEqual('3/4/2');
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 4)); tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
expect(tileUrl).toEqual('4/8/5'); expect(tileUrl).toEqual('4/8/5');
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 5)); tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
expect(tileUrl).toEqual('5/16/11'); expect(tileUrl).toEqual('5/16/11');
tileUrl = xyzTileStore.getTileCoordUrl( tileUrl = xyzTileSource.getTileCoordUrl(
tileGrid.getTileCoordForCoordAndZ(coordinate, 6)); tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).toEqual('6/33/22');
}); });
describe('wrap x', function() { describe('wrap x', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
tileUrl = xyzTileStore.getTileCoordUrl(new ol.TileCoord(6, -31, -23)); tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, -31, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).toEqual('6/33/22');
tileUrl = xyzTileStore.getTileCoordUrl(new ol.TileCoord(6, 33, -23)); tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).toEqual('6/33/22');
tileUrl = xyzTileStore.getTileCoordUrl(new ol.TileCoord(6, 97, -23)); tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 97, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).toEqual('6/33/22');
}); });
}); });
describe('crop y', function() { describe('crop y', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
tileUrl = xyzTileStore.getTileCoordUrl(new ol.TileCoord(6, 33, -87)); tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, -87));
expect(tileUrl).toBeUndefined(); expect(tileUrl).toBeUndefined();
tileUrl = xyzTileStore.getTileCoordUrl(new ol.TileCoord(6, 33, -23)); tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).toEqual('6/33/22');
tileUrl = xyzTileStore.getTileCoordUrl(new ol.TileCoord(6, 33, 41)); tileUrl = xyzTileSource.getTileCoordUrl(new ol.TileCoord(6, 33, 41));
expect(tileUrl).toBeUndefined(); expect(tileUrl).toBeUndefined();
}); });
}); });
@@ -124,4 +124,4 @@ describe('ol.tilestore.XYZ', function() {
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.tilestore.XYZ'); goog.require('ol.tilesource.XYZ');