Skip to content

Commit fbbbcf5

Browse files
committed
Merge pull request #4805 from fredj/cacheSize
Add new cacheSize option to ol.source
2 parents 9fe2970 + 9819aa3 commit fbbbcf5

16 files changed

+138
-13
lines changed

changelog/upgrade-notes.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
## Upgrade notes
22

3+
### v3.15.0
4+
5+
#### Removal of `ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK`
6+
7+
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`:
8+
```js
9+
new ol.layer.Tile({
10+
source: new ol.source.OSM({
11+
cacheSize: 128
12+
})
13+
})
14+
```
15+
The default cache size is `2048`.
16+
317
### v3.14.0
418

519
#### Internet Explorer 9 support

externs/olx.js

+111-3
Original file line numberDiff line numberDiff line change
@@ -3904,7 +3904,8 @@ olx.source;
39043904

39053905

39063906
/**
3907-
* @typedef {{culture: (string|undefined),
3907+
* @typedef {{cacheSize: (number|undefined),
3908+
* culture: (string|undefined),
39083909
* key: string,
39093910
* imagerySet: string,
39103911
* maxZoom: (number|undefined),
@@ -3916,6 +3917,14 @@ olx.source;
39163917
olx.source.BingMapsOptions;
39173918

39183919

3920+
/**
3921+
* Cache size. Default is `2048`.
3922+
* @type {number|undefined}
3923+
* @api
3924+
*/
3925+
olx.source.BingMapsOptions.prototype.cacheSize;
3926+
3927+
39193928
/**
39203929
* Culture code. Default is `en-us`.
39213930
* @type {string|undefined}
@@ -4107,6 +4116,7 @@ olx.source.TileUTFGridOptions.prototype.url;
41074116

41084117
/**
41094118
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
4119+
* cacheSize: (number|undefined),
41104120
* crossOrigin: (null|string|undefined),
41114121
* logo: (string|olx.LogoOptions|undefined),
41124122
* opaque: (boolean|undefined),
@@ -4136,6 +4146,14 @@ olx.source.TileImageOptions;
41364146
olx.source.TileImageOptions.prototype.attributions;
41374147

41384148

4149+
/**
4150+
* Cache size. Default is `2048`.
4151+
* @type {number|undefined}
4152+
* @api
4153+
*/
4154+
olx.source.TileImageOptions.prototype.cacheSize;
4155+
4156+
41394157
/**
41404158
* The `crossOrigin` attribute for loaded images. Note that you must provide a
41414159
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -4270,6 +4288,7 @@ olx.source.TileImageOptions.prototype.wrapX;
42704288

42714289
/**
42724290
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
4291+
* cacheSize: (number|undefined),
42734292
* format: (ol.format.Feature|undefined),
42744293
* logo: (string|olx.LogoOptions|undefined),
42754294
* opaque: (boolean|undefined),
@@ -4298,6 +4317,15 @@ olx.source.VectorTileOptions;
42984317
olx.source.VectorTileOptions.prototype.attributions;
42994318

43004319

4320+
4321+
/**
4322+
* Cache size. Default is `128`.
4323+
* @type {number|undefined}
4324+
* @api
4325+
*/
4326+
olx.source.VectorTileOptions.prototype.cacheSize;
4327+
4328+
43014329
/**
43024330
* Feature format for tiles. Used and required by the default
43034331
* `tileLoadFunction`.
@@ -4518,7 +4546,8 @@ olx.source.ImageMapGuideOptions.prototype.params;
45184546

45194547

45204548
/**
4521-
* @typedef {{layer: string,
4549+
* @typedef {{cacheSize: (number|undefined),
4550+
* layer: string,
45224551
* reprojectionErrorThreshold: (number|undefined),
45234552
* tileLoadFunction: (ol.TileLoadFunctionType|undefined),
45244553
* url: (string|undefined)}}
@@ -4527,6 +4556,14 @@ olx.source.ImageMapGuideOptions.prototype.params;
45274556
olx.source.MapQuestOptions;
45284557

45294558

4559+
/**
4560+
* Cache size. Default is `2048`.
4561+
* @type {number|undefined}
4562+
* @api
4563+
*/
4564+
olx.source.MapQuestOptions.prototype.cacheSize;
4565+
4566+
45304567
/**
45314568
* Layer. Possible values are `osm`, `sat`, and `hyb`.
45324569
* @type {string}
@@ -4600,6 +4637,7 @@ olx.source.TileDebugOptions.prototype.wrapX;
46004637

46014638
/**
46024639
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
4640+
* cacheSize: (number|undefined),
46034641
* crossOrigin: (null|string|undefined),
46044642
* maxZoom: (number|undefined),
46054643
* opaque: (boolean|undefined),
@@ -4620,6 +4658,14 @@ olx.source.OSMOptions;
46204658
olx.source.OSMOptions.prototype.attributions;
46214659

46224660

4661+
/**
4662+
* Cache size. Default is `2048`.
4663+
* @type {number|undefined}
4664+
* @api
4665+
*/
4666+
olx.source.OSMOptions.prototype.cacheSize;
4667+
4668+
46234669
/**
46244670
* The `crossOrigin` attribute for loaded images. Note that you must provide a
46254671
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5016,7 +5062,8 @@ olx.source.ImageWMSOptions.prototype.url;
50165062

50175063

50185064
/**
5019-
* @typedef {{layer: string,
5065+
* @typedef {{cacheSize: (number|undefined),
5066+
* layer: string,
50205067
* minZoom: (number|undefined),
50215068
* maxZoom: (number|undefined),
50225069
* opaque: (boolean|undefined),
@@ -5028,6 +5075,13 @@ olx.source.ImageWMSOptions.prototype.url;
50285075
olx.source.StamenOptions;
50295076

50305077

5078+
/**
5079+
* Cache size. Default is `2048`.
5080+
* @type {number|undefined}
5081+
* @api
5082+
*/
5083+
olx.source.StamenOptions.prototype.cacheSize;
5084+
50315085
/**
50325086
* Layer.
50335087
* @type {string}
@@ -5176,6 +5230,7 @@ olx.source.ImageStaticOptions.prototype.url;
51765230

51775231
/**
51785232
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
5233+
* cacheSize: (number|undefined),
51795234
* crossOrigin: (null|string|undefined),
51805235
* params: (Object.<string, *>|undefined),
51815236
* logo: (string|olx.LogoOptions|undefined),
@@ -5199,6 +5254,14 @@ olx.source.TileArcGISRestOptions;
51995254
olx.source.TileArcGISRestOptions.prototype.attributions;
52005255

52015256

5257+
/**
5258+
* Cache size. Default is `2048`.
5259+
* @type {number|undefined}
5260+
* @api
5261+
*/
5262+
olx.source.TileArcGISRestOptions.prototype.cacheSize;
5263+
5264+
52025265
/**
52035266
* The `crossOrigin` attribute for loaded images. Note that you must provide a
52045267
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5303,6 +5366,7 @@ olx.source.TileArcGISRestOptions.prototype.urls;
53035366

53045367
/**
53055368
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
5369+
* cacheSize: (number|undefined),
53065370
* crossOrigin: (null|string|undefined),
53075371
* jsonp: (boolean|undefined),
53085372
* reprojectionErrorThreshold: (number|undefined),
@@ -5324,6 +5388,14 @@ olx.source.TileJSONOptions;
53245388
olx.source.TileJSONOptions.prototype.attributions;
53255389

53265390

5391+
/**
5392+
* Cache size. Default is `2048`.
5393+
* @type {number|undefined}
5394+
* @api
5395+
*/
5396+
olx.source.TileJSONOptions.prototype.cacheSize;
5397+
5398+
53275399
/**
53285400
* The `crossOrigin` attribute for loaded images. Note that you must provide a
53295401
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5385,6 +5457,7 @@ olx.source.TileJSONOptions.prototype.wrapX;
53855457

53865458
/**
53875459
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
5460+
* cacheSize: (number|undefined),
53885461
* params: Object.<string,*>,
53895462
* crossOrigin: (null|string|undefined),
53905463
* gutter: (number|undefined),
@@ -5412,6 +5485,14 @@ olx.source.TileWMSOptions;
54125485
olx.source.TileWMSOptions.prototype.attributions;
54135486

54145487

5488+
/**
5489+
* Cache size. Default is `2048`.
5490+
* @type {number|undefined}
5491+
* @api
5492+
*/
5493+
olx.source.TileWMSOptions.prototype.cacheSize;
5494+
5495+
54155496
/**
54165497
* WMS request parameters. At least a `LAYERS` param is required. `STYLES` is
54175498
* `''` by default. `VERSION` is `1.3.0` by default. `WIDTH`, `HEIGHT`, `BBOX`
@@ -5675,6 +5756,7 @@ olx.source.VectorOptions.prototype.wrapX;
56755756

56765757
/**
56775758
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
5759+
* cacheSize: (number|undefined),
56785760
* crossOrigin: (string|null|undefined),
56795761
* logo: (string|olx.LogoOptions|undefined),
56805762
* tileGrid: ol.tilegrid.WMTS,
@@ -5709,6 +5791,14 @@ olx.source.WMTSOptions;
57095791
olx.source.WMTSOptions.prototype.attributions;
57105792

57115793

5794+
/**
5795+
* Cache size. Default is `2048`.
5796+
* @type {number|undefined}
5797+
* @api
5798+
*/
5799+
olx.source.WMTSOptions.prototype.cacheSize;
5800+
5801+
57125802
/**
57135803
* The `crossOrigin` attribute for loaded images. Note that you must provide a
57145804
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -5882,6 +5972,7 @@ olx.source.WMTSOptions.prototype.wrapX;
58825972

58835973
/**
58845974
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
5975+
* cacheSize: (number|undefined),
58855976
* crossOrigin: (null|string|undefined),
58865977
* logo: (string|olx.LogoOptions|undefined),
58875978
* opaque: (boolean|undefined),
@@ -5910,6 +6001,14 @@ olx.source.XYZOptions;
59106001
olx.source.XYZOptions.prototype.attributions;
59116002

59126003

6004+
/**
6005+
* Cache size. Default is `2048`.
6006+
* @type {number|undefined}
6007+
* @api
6008+
*/
6009+
olx.source.XYZOptions.prototype.cacheSize;
6010+
6011+
59136012
/**
59146013
* The `crossOrigin` attribute for loaded images. Note that you must provide a
59156014
* `crossOrigin` value if you are using the WebGL renderer or if you want to
@@ -6048,6 +6147,7 @@ olx.source.XYZOptions.prototype.wrapX;
60486147

60496148
/**
60506149
* @typedef {{attributions: (Array.<ol.Attribution>|undefined),
6150+
* cacheSize: (number|undefined),
60516151
* crossOrigin: (null|string|undefined),
60526152
* logo: (string|olx.LogoOptions|undefined),
60536153
* reprojectionErrorThreshold: (number|undefined),
@@ -6067,6 +6167,14 @@ olx.source.ZoomifyOptions;
60676167
olx.source.ZoomifyOptions.prototype.attributions;
60686168

60696169

6170+
/**
6171+
* Cache size. Default is `2048`.
6172+
* @type {number|undefined}
6173+
* @api
6174+
*/
6175+
olx.source.ZoomifyOptions.prototype.cacheSize;
6176+
6177+
60706178
/**
60716179
* The `crossOrigin` attribute for loaded images. Note that you must provide a
60726180
* `crossOrigin` value if you are using the WebGL renderer or if you want to

src/ol/ol.js

-6
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ ol.DEFAULT_MIN_ZOOM = 0;
3535
ol.DEFAULT_RASTER_REPROJECTION_ERROR_THRESHOLD = 0.5;
3636

3737

38-
/**
39-
* @define {number} Default high water mark.
40-
*/
41-
ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
42-
43-
4438
/**
4539
* @define {number} Default tile size.
4640
*/

src/ol/source/bingmapssource.js

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ goog.require('ol.tilecoord');
2424
ol.source.BingMaps = function(options) {
2525

2626
goog.base(this, {
27+
cacheSize: options.cacheSize,
2728
crossOrigin: 'anonymous',
2829
opaque: true,
2930
projection: ol.proj.get('EPSG:3857'),

src/ol/source/mapquestsource.js

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ ol.source.MapQuest = function(opt_options) {
3636

3737
goog.base(this, {
3838
attributions: layerConfig.attributions,
39+
cacheSize: options.cacheSize,
3940
crossOrigin: 'anonymous',
4041
logo: 'https://developer.mapquest.com/content/osm/mq_logo.png',
4142
maxZoom: layerConfig.maxZoom,

src/ol/source/osmsource.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ol.source.OSM = function(opt_options) {
3232

3333
goog.base(this, {
3434
attributions: attributions,
35+
cacheSize: options.cacheSize,
3536
crossOrigin: crossOrigin,
3637
opaque: options.opaque !== undefined ? options.opaque : true,
3738
maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,

src/ol/source/stamensource.js

+1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ ol.source.Stamen = function(options) {
103103

104104
goog.base(this, {
105105
attributions: ol.source.Stamen.ATTRIBUTIONS,
106+
cacheSize: options.cacheSize,
106107
crossOrigin: 'anonymous',
107108
maxZoom: providerConfig.maxZoom,
108109
// FIXME uncomment the following when tilegrid supports minZoom

src/ol/source/tilearcgisrestsource.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ ol.source.TileArcGISRest = function(opt_options) {
3333

3434
goog.base(this, {
3535
attributions: options.attributions,
36+
cacheSize: options.cacheSize,
3637
crossOrigin: options.crossOrigin,
3738
logo: options.logo,
3839
projection: options.projection,

src/ol/source/tileimagesource.js

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ ol.source.TileImage = function(options) {
2525

2626
goog.base(this, {
2727
attributions: options.attributions,
28+
cacheSize: options.cacheSize,
2829
extent: options.extent,
2930
logo: options.logo,
3031
opaque: options.opaque,

src/ol/source/tilejsonsource.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ol.source.TileJSON = function(options) {
3131

3232
goog.base(this, {
3333
attributions: options.attributions,
34+
cacheSize: options.cacheSize,
3435
crossOrigin: options.crossOrigin,
3536
projection: ol.proj.get('EPSG:3857'),
3637
reprojectionErrorThreshold: options.reprojectionErrorThreshold,

src/ol/source/tilewmssource.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ ol.source.TileWMS = function(opt_options) {
3939

4040
goog.base(this, {
4141
attributions: options.attributions,
42+
cacheSize: options.cacheSize,
4243
crossOrigin: options.crossOrigin,
4344
logo: options.logo,
4445
opaque: !transparent,

src/ol/source/vectortilesource.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ol.source.VectorTile = function(options) {
2828

2929
goog.base(this, {
3030
attributions: options.attributions,
31-
cacheSize: ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK / 16,
31+
cacheSize: options.cacheSize !== undefined ? options.cacheSize : 128,
3232
extent: options.extent,
3333
logo: options.logo,
3434
opaque: options.opaque,

src/ol/source/wmtssource.js

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ ol.source.WMTS = function(options) {
174174

175175
goog.base(this, {
176176
attributions: options.attributions,
177+
cacheSize: options.cacheSize,
177178
crossOrigin: options.crossOrigin,
178179
logo: options.logo,
179180
projection: options.projection,

0 commit comments

Comments
 (0)