[core] use stale sprite data
This is a naïve implementation that essentially merges updated data into existing data. It will *not* remove icons from the stale sprite if they aren't present in the fresh sprite (we aren't tracking the source of a sprite, and the user could have changed it as well). Similarly, it will not update icons that have changed in dimension. This is a rare edge case and probably not worth implementing.
This commit is contained in:
10
test/fixtures/stale/sprite.json
vendored
Normal file
10
test/fixtures/stale/sprite.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"noise": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"width": 32,
|
||||
"height": 32,
|
||||
"pixelRatio": 1,
|
||||
"sdf": false
|
||||
}
|
||||
}
|
||||
BIN
test/fixtures/stale/sprite.png
vendored
Normal file
BIN
test/fixtures/stale/sprite.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.3 KiB |
BIN
test/fixtures/stale/stale_style_and_sprite/expected.png
vendored
Normal file
BIN
test/fixtures/stale/stale_style_and_sprite/expected.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
26
test/fixtures/stale/style_and_sprite.json
vendored
Normal file
26
test/fixtures/stale/style_and_sprite.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"version": 8,
|
||||
"name": "Water",
|
||||
"sources": {
|
||||
"mapbox": {
|
||||
"type": "vector",
|
||||
"url": "asset://test/fixtures/stale/streets.json"
|
||||
}
|
||||
},
|
||||
"sprite": "http://127.0.0.1:3000/stale/sprite",
|
||||
"layers": [{
|
||||
"id": "background",
|
||||
"type": "background",
|
||||
"paint": {
|
||||
"background-color": "red"
|
||||
}
|
||||
}, {
|
||||
"id": "water",
|
||||
"type": "fill",
|
||||
"source": "mapbox",
|
||||
"source-layer": "water",
|
||||
"paint": {
|
||||
"fill-pattern": "noise"
|
||||
}
|
||||
}]
|
||||
}
|
||||
@@ -72,3 +72,31 @@ TEST_F(Storage, CacheStaleStyleAndTileJSON) {
|
||||
|
||||
checkRendering(map, "stale_style_and_tilejson", 1000ms);
|
||||
}
|
||||
|
||||
TEST_F(Storage, CacheStaleStyleAndSprite) {
|
||||
HeadlessView view(display, 1);
|
||||
|
||||
auto cache = SQLiteCache::getShared(":memory:");
|
||||
|
||||
// Rig the cache with an expired stylesheet.
|
||||
const std::string stylePath = "stale/style_and_sprite.json";
|
||||
const Resource styleResource{ Resource::Kind::Style, prefix + "/" + stylePath };
|
||||
cache->put(styleResource, expiredItem(stylePath));
|
||||
|
||||
// Rig the cache with an expired sprite JSON.
|
||||
const std::string spritejsonPath = "stale/sprite.json";
|
||||
const Resource spritejsonResource{ Resource::Kind::SpriteJSON, prefix + "/" + spritejsonPath };
|
||||
cache->put(spritejsonResource, expiredItem(spritejsonPath));
|
||||
|
||||
// Rig the cache with an expired sprite JSON.
|
||||
const std::string spriteimagePath = "stale/sprite.png";
|
||||
const Resource spriteimageResource{ Resource::Kind::SpriteImage, prefix + "/" + spriteimagePath };
|
||||
cache->put(spriteimageResource, expiredItem(spriteimagePath));
|
||||
|
||||
DefaultFileSource fileSource(":memory:", ".");
|
||||
|
||||
Map map(view, fileSource, MapMode::Still);
|
||||
map.setStyleURL(styleResource.url);
|
||||
|
||||
checkRendering(map, "stale_style_and_sprite", 1000ms);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user