Skip to content

Commit 0057d8b

Browse files
committed
Website updates
1 parent 7d68f81 commit 0057d8b

File tree

8 files changed

+30
-8
lines changed

8 files changed

+30
-8
lines changed

dist/en/main/apidoc/module-ol_source_UTFGrid-UTFGrid.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ <h4 class="name">
161161

162162
<div class="tag-source">
163163
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js">source/UTFGrid.js</a>,
164-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js#L273">line 273</a>
164+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js#L275">line 275</a>
165165
</div>
166166

167167
</div>
@@ -804,7 +804,7 @@ <h4 class="name">
804804

805805
<div class="tag-source">
806806
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js">source/UTFGrid.js</a>,
807-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js#L382">line 382</a>
807+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js#L390">line 390</a>
808808
</div>
809809

810810
</div>
@@ -1786,7 +1786,7 @@ <h4 class="name">
17861786

17871787
<div class="tag-source">
17881788
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js">source/UTFGrid.js</a>,
1789-
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js#L367">line 367</a>
1789+
<a href="https://github.com/openlayers/openlayers/blob/main/src/ol/source/UTFGrid.js#L375">line 375</a>
17901790
</div>
17911791

17921792
</div>

dist/en/main/examples/utfgrid.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/examples/utfgrid.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/dist/ol.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/dist/ol.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/source/UTFGrid.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ declare class UTFGrid extends TileSource<Tile> {
194194
* @type {boolean}
195195
*/
196196
private jsonp_;
197+
/**
198+
* @private
199+
* @type {LRUCache}
200+
*/
201+
private tileCache_;
197202
/**
198203
* @private
199204
* @param {Event} event The load event.

dist/en/main/ol/source/UTFGrid.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/en/main/ol/source/UTFGrid.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {listenOnce} from '../events.js';
99
import {applyTransform, intersects} from '../extent.js';
1010
import {jsonp as requestJSONP} from '../net.js';
1111
import {get as getProjection, getTransformFromProjections} from '../proj.js';
12+
import LRUCache from '../structs/LRUCache.js';
13+
import {getKeyZXY} from '../tilecoord.js';
1214
import {createXYZ, extentFromProjection} from '../tilegrid.js';
1315
import {createFromTemplates, nullTileUrlFunction} from '../tileurlfunction.js';
1416
import TileSource from './Tile.js';
@@ -307,6 +309,12 @@ class UTFGrid extends TileSource {
307309
*/
308310
this.jsonp_ = options.jsonp || false;
309311

312+
/**
313+
* @private
314+
* @type {LRUCache}
315+
*/
316+
this.tileCache_ = new LRUCache(512);
317+
310318
if (options.url) {
311319
if (this.jsonp_) {
312320
requestJSONP(
@@ -392,6 +400,9 @@ class UTFGrid extends TileSource {
392400
this.getProjection(),
393401
)
394402
);
403+
if (tile.getState() == TileState.IDLE) {
404+
tile.load();
405+
}
395406
tile.forDataAtCoordinate(coordinate, callback, request);
396407
} else {
397408
if (request === true) {
@@ -478,6 +489,11 @@ class UTFGrid extends TileSource {
478489
projection,
479490
);
480491
const tileUrl = this.tileUrlFunction_(urlTileCoord, pixelRatio, projection);
492+
const tileKey = `${this.getKey()},${getKeyZXY(z, x, y)}`;
493+
if (this.tileCache_.containsKey(tileKey)) {
494+
return this.tileCache_.get(tileKey);
495+
}
496+
this.tileCache_.expireCache();
481497
const tile = new CustomTile(
482498
tileCoord,
483499
tileUrl !== undefined ? TileState.IDLE : TileState.EMPTY,
@@ -486,6 +502,7 @@ class UTFGrid extends TileSource {
486502
this.preemptive_,
487503
this.jsonp_,
488504
);
505+
this.tileCache_.set(tileKey, tile);
489506
return tile;
490507
}
491508
}

0 commit comments

Comments
 (0)