Skip to content
Permalink
Browse files

Copy blank tile to new buffer. Try to reuse blank tile when setting u…

…p rules
  • Loading branch information
tomhel committed May 29, 2016
1 parent 074471e commit 78c4e47a930868e079ac116f1c8f19005c888493
Showing with 20 additions and 9 deletions.
  1. +2 −1 lib/cache.c
  2. +18 −8 lib/configuration_xml.c
@@ -37,7 +37,8 @@ int mapcache_cache_tile_get(mapcache_context *ctx, mapcache_cache *cache, mapcac

/* if tile is outside visible limits, return a blank tile */
if (mapcache_ruleset_is_visible_tile(rule, tile) == MAPCACHE_FALSE) {
tile->encoded_data = rule->hidden_tile;
tile->encoded_data = mapcache_buffer_create(0, ctx->pool);
mapcache_buffer_append(tile->encoded_data, rule->hidden_tile->size, rule->hidden_tile->buf);
return MAPCACHE_SUCCESS;
}

@@ -817,6 +817,9 @@ void parseTileset(mapcache_context *ctx, ezxml_t node, mapcache_cfg *config)

// setup zoom level rules if configured
if(ruleset) {
mapcache_buffer *last_hidden_tile = NULL;
unsigned int last_hidden_color;

// prepare one rule per zoom level. if rule is missing it will be NULL
for(i = 0; i < grid->nlevels; i++) {
mapcache_rule *rule = mapcache_ruleset_rule_find(ruleset->rules, i);
@@ -827,17 +830,24 @@ void parseTileset(mapcache_context *ctx, ezxml_t node, mapcache_cfg *config)
if(rule->visible_extents) {
int j;

// create empty tile in configured format to return when outside visible extent
if(tileset->format) {
rule_clone->hidden_tile = tileset->format->create_empty_image(ctx, tileset->format, grid->tile_sx, grid->tile_sy, rule->hidden_color);
} else {
rule_clone->hidden_tile = config->default_image_format->create_empty_image(ctx, config->default_image_format, grid->tile_sx, grid->tile_sy, rule->hidden_color);
}
// create blank tile in configured format to return when outside visible extent
// try to reuse last tile if possible
if(last_hidden_tile == NULL || last_hidden_color != rule->hidden_color) {
if(tileset->format) {
last_hidden_tile = tileset->format->create_empty_image(ctx, tileset->format, grid->tile_sx, grid->tile_sy, rule->hidden_color);
} else {
last_hidden_tile = config->default_image_format->create_empty_image(ctx, config->default_image_format, grid->tile_sx, grid->tile_sy, rule->hidden_color);
}

if(GC_HAS_ERROR(ctx)) {
return;
if(GC_HAS_ERROR(ctx)) {
return;
}

last_hidden_color = rule->hidden_color;
}

rule_clone->hidden_tile = last_hidden_tile;

// compute limits for extents
for(j = 0; j < rule->visible_extents->nelts; j++) {
mapcache_extent *visible_extent = APR_ARRAY_IDX(rule->visible_extents, j, mapcache_extent*);

0 comments on commit 78c4e47

Please sign in to comment.
You can’t perform that action at this time.