Merge pull request #4805 from fredj/cacheSize

Add new cacheSize option to ol.source
This commit is contained in:
Frédéric Junod
2016-03-01 10:46:00 +01:00
16 changed files with 138 additions and 13 deletions

View File

@@ -1,5 +1,19 @@
## Upgrade notes
### v3.15.0
#### Removal of `ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK`
The `ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK` define has been removed. The size of the cache can now be defined on every tile based `ol.source`:
```js
new ol.layer.Tile({
source: new ol.source.OSM({
cacheSize: 128
})
})
```
The default cache size is `2048`.
### v3.14.0
#### Internet Explorer 9 support

View File

@@ -3904,7 +3904,8 @@ olx.source;
/**
* @typedef {{culture: (string|undefined),
* @typedef {{cacheSize: (number|undefined),
* culture: (string|undefined),
* key: string,
* imagerySet: string,
* maxZoom: (number|undefined),
@@ -3916,6 +3917,14 @@ olx.source;
olx.source.BingMapsOptions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.BingMapsOptions.prototype.cacheSize;
/**
* Culture code. Default is `en-us`.
* @type {string|undefined}
@@ -4107,6 +4116,7 @@ olx.source.TileUTFGridOptions.prototype.url;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (null|string|undefined),
* logo: (string|olx.LogoOptions|undefined),
* opaque: (boolean|undefined),
@@ -4136,6 +4146,14 @@ olx.source.TileImageOptions;
olx.source.TileImageOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.TileImageOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -4270,6 +4288,7 @@ olx.source.TileImageOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* format: (ol.format.Feature|undefined),
* logo: (string|olx.LogoOptions|undefined),
* opaque: (boolean|undefined),
@@ -4298,6 +4317,15 @@ olx.source.VectorTileOptions;
olx.source.VectorTileOptions.prototype.attributions;
/**
* Cache size. Default is `128`.
* @type {number|undefined}
* @api
*/
olx.source.VectorTileOptions.prototype.cacheSize;
/**
* Feature format for tiles. Used and required by the default
* `tileLoadFunction`.
@@ -4518,7 +4546,8 @@ olx.source.ImageMapGuideOptions.prototype.params;
/**
* @typedef {{layer: string,
* @typedef {{cacheSize: (number|undefined),
* layer: string,
* reprojectionErrorThreshold: (number|undefined),
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
* url: (string|undefined)}}
@@ -4527,6 +4556,14 @@ olx.source.ImageMapGuideOptions.prototype.params;
olx.source.MapQuestOptions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.MapQuestOptions.prototype.cacheSize;
/**
* Layer. Possible values are `osm`, `sat`, and `hyb`.
* @type {string}
@@ -4600,6 +4637,7 @@ olx.source.TileDebugOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (null|string|undefined),
* maxZoom: (number|undefined),
* opaque: (boolean|undefined),
@@ -4620,6 +4658,14 @@ olx.source.OSMOptions;
olx.source.OSMOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.OSMOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5016,7 +5062,8 @@ olx.source.ImageWMSOptions.prototype.url;
/**
* @typedef {{layer: string,
* @typedef {{cacheSize: (number|undefined),
* layer: string,
* minZoom: (number|undefined),
* maxZoom: (number|undefined),
* opaque: (boolean|undefined),
@@ -5028,6 +5075,13 @@ olx.source.ImageWMSOptions.prototype.url;
olx.source.StamenOptions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.StamenOptions.prototype.cacheSize;
/**
* Layer.
* @type {string}
@@ -5176,6 +5230,7 @@ olx.source.ImageStaticOptions.prototype.url;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (null|string|undefined),
* params: (Object.<string, *>|undefined),
* logo: (string|olx.LogoOptions|undefined),
@@ -5199,6 +5254,14 @@ olx.source.TileArcGISRestOptions;
olx.source.TileArcGISRestOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.TileArcGISRestOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5303,6 +5366,7 @@ olx.source.TileArcGISRestOptions.prototype.urls;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (null|string|undefined),
* jsonp: (boolean|undefined),
* reprojectionErrorThreshold: (number|undefined),
@@ -5324,6 +5388,14 @@ olx.source.TileJSONOptions;
olx.source.TileJSONOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.TileJSONOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5385,6 +5457,7 @@ olx.source.TileJSONOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* params: Object.<string,*>,
* crossOrigin: (null|string|undefined),
* gutter: (number|undefined),
@@ -5412,6 +5485,14 @@ olx.source.TileWMSOptions;
olx.source.TileWMSOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.TileWMSOptions.prototype.cacheSize;
/**
* WMS request parameters. At least a `LAYERS` param is required. `STYLES` is
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
@@ -5675,6 +5756,7 @@ olx.source.VectorOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (string|null|undefined),
* logo: (string|olx.LogoOptions|undefined),
* tileGrid: ol.tilegrid.WMTS,
@@ -5709,6 +5791,14 @@ olx.source.WMTSOptions;
olx.source.WMTSOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.WMTSOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5882,6 +5972,7 @@ olx.source.WMTSOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (null|string|undefined),
* logo: (string|olx.LogoOptions|undefined),
* opaque: (boolean|undefined),
@@ -5910,6 +6001,14 @@ olx.source.XYZOptions;
olx.source.XYZOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.XYZOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -6048,6 +6147,7 @@ olx.source.XYZOptions.prototype.wrapX;
/**
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
* cacheSize: (number|undefined),
* crossOrigin: (null|string|undefined),
* logo: (string|olx.LogoOptions|undefined),
* reprojectionErrorThreshold: (number|undefined),
@@ -6067,6 +6167,14 @@ olx.source.ZoomifyOptions;
olx.source.ZoomifyOptions.prototype.attributions;
/**
* Cache size. Default is `2048`.
* @type {number|undefined}
* @api
*/
olx.source.ZoomifyOptions.prototype.cacheSize;
/**
* The `crossOrigin` attribute for loaded images. Note that you must provide a
* `crossOrigin` value if you are using the WebGL renderer or if you want to

View File

@@ -35,12 +35,6 @@ ol.DEFAULT_MIN_ZOOM = 0;
ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5;
/**
* @define {number} Default high water mark.
*/
ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
/**
* @define {number} Default tile size.
*/

View File

@@ -24,6 +24,7 @@ goog.require('ol.tilecoord');
ol.source.BingMaps = function(options) {
goog.base(this, {
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
opaque: true,
projection: ol.proj.get('EPSG:3857'),

View File

@@ -36,6 +36,7 @@ ol.source.MapQuest = function(opt_options) {
goog.base(this, {
attributions: layerConfig.attributions,
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
logo: 'https://developer.mapquest.com/content/osm/mq_logo.png',
maxZoom: layerConfig.maxZoom,

View File

@@ -32,6 +32,7 @@ ol.source.OSM = function(opt_options) {
goog.base(this, {
attributions: attributions,
cacheSize: options.cacheSize,
crossOrigin: crossOrigin,
opaque: options.opaque !== undefined ? options.opaque : true,
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,

View File

@@ -103,6 +103,7 @@ ol.source.Stamen = function(options) {
goog.base(this, {
attributions: ol.source.Stamen.ATTRIBUTIONS,
cacheSize: options.cacheSize,
crossOrigin: 'anonymous',
maxZoom: providerConfig.maxZoom,
// FIXME uncomment the following when tilegrid supports minZoom

View File

@@ -33,6 +33,7 @@ ol.source.TileArcGISRest = function(opt_options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
logo: options.logo,
projection: options.projection,

View File

@@ -25,6 +25,7 @@ ol.source.TileImage = function(options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
extent: options.extent,
logo: options.logo,
opaque: options.opaque,

View File

@@ -31,6 +31,7 @@ ol.source.TileJSON = function(options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
projection: ol.proj.get('EPSG:3857'),
reprojectionErrorThreshold: options.reprojectionErrorThreshold,

View File

@@ -39,6 +39,7 @@ ol.source.TileWMS = function(opt_options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
logo: options.logo,
opaque: !transparent,

View File

@@ -28,7 +28,7 @@ ol.source.VectorTile = function(options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK / 16,
cacheSize: options.cacheSize !== undefined ? options.cacheSize : 128,
extent: options.extent,
logo: options.logo,
opaque: options.opaque,

View File

@@ -174,6 +174,7 @@ ol.source.WMTS = function(options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
logo: options.logo,
projection: options.projection,

View File

@@ -38,6 +38,7 @@ ol.source.XYZ = function(options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
logo: options.logo,
opaque: options.opaque,

View File

@@ -121,6 +121,7 @@ ol.source.Zoomify = function(opt_options) {
goog.base(this, {
attributions: options.attributions,
cacheSize: options.cacheSize,
crossOrigin: options.crossOrigin,
logo: options.logo,
reprojectionErrorThreshold: options.reprojectionErrorThreshold,

View File

@@ -1,6 +1,5 @@
goog.provide('ol.TileCache');
goog.require('ol');
goog.require('ol.TileRange');
goog.require('ol.structs.LRUCache');
goog.require('ol.tilecoord');
@@ -20,8 +19,7 @@ ol.TileCache = function(opt_highWaterMark) {
* @private
* @type {number}
*/
this.highWaterMark_ = opt_highWaterMark !== undefined ?
opt_highWaterMark : ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK;
this.highWaterMark_ = opt_highWaterMark !== undefined ? opt_highWaterMark : 2048;
};
goog.inherits(ol.TileCache, ol.structs.LRUCache);