Skip to content
Permalink
Browse files

Add configuration attribute for activating this optimization

  • Loading branch information
jbo-ads committed Nov 15, 2019
1 parent a55685f commit 30adc48e9e0461f817dc1fc3e3c1cf04455a76f7
Showing with 34 additions and 9 deletions.
  1. +1 −0 include/mapcache.h
  2. +21 −0 lib/configuration_xml.c
  3. +12 −9 lib/tileset.c
@@ -1578,6 +1578,7 @@ MS_DLL_EXPORT apr_array_header_t *mapcache_requested_dimensions_clone(apr_pool_t
struct mapcache_dimension {
mapcache_dimension_type type;
int isTime;
int wms_single_query_minzoom;
char *name;
char *unit;
apr_table_t *metadata;
@@ -63,6 +63,7 @@ void parseMetadata(mapcache_context *ctx, ezxml_t node, apr_table_t *metadata)
void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tileset)
{
ezxml_t dimension_node;
ezxml_t wms_single_query_node;
apr_array_header_t *dimensions = apr_array_make(ctx->pool,1,sizeof(mapcache_dimension*));
for(dimension_node = ezxml_child(node,"dimension"); dimension_node; dimension_node = dimension_node->next) {
char *name = (char*)ezxml_attr(dimension_node,"name");
@@ -120,6 +121,26 @@ void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tile
return;
}

dimension->wms_single_query_minzoom = -1;
wms_single_query_node = ezxml_child(dimension_node,"wms_single_query");
if (wms_single_query_node && wms_single_query_node->txt) {
if (!strcasecmp(wms_single_query_node->txt,"true")) {
const char * minzoom = ezxml_attr(wms_single_query_node,"minzoom");
dimension->wms_single_query_minzoom = 0;
if (minzoom && *minzoom) {
char *endptr;
dimension->wms_single_query_minzoom = strtol(minzoom,&endptr,10);
if (*endptr != 0 || dimension->wms_single_query_minzoom < 0) {
ctx->set_error(ctx, 400, "failed to parse minzoom \"%s\" for <wms_single_query>"
"expecting an integer starting from 0",minzoom);
return;
}
}
} else if (strcasecmp(wms_single_query_node->txt,"false")) {
ctx->set_error(ctx,400,"failed to parse <wms_single_query> (%s), expecting \"true\" or \"false\"",wms_single_query_node->txt);
return;
}
}

dimension->configuration_parse_xml(ctx,dimension,dimension_node);
GC_CHECK_ERROR(ctx);
@@ -221,24 +221,27 @@ void mapcache_tileset_get_map_tiles(mapcache_context *ctx, mapcache_tileset *til
resolution = mapcache_grid_get_resolution(bbox, width, height);
*effectively_used_grid_link = mapcache_grid_get_closest_wms_level(ctx,grid_link,resolution,&level);

// Get dimensions values
/* we don't want to assemble tiles that have already been reassembled from a lower level */
if((*effectively_used_grid_link)->outofzoom_strategy == MAPCACHE_OUTOFZOOM_REASSEMBLE && level > (*effectively_used_grid_link)->max_cached_zoom) {
level = (*effectively_used_grid_link)->max_cached_zoom;
}

// Get dimensions values for whole map if required by <wms_single_query> configuration
if (dimensions)
{
int j;
for (j=0 ; j<dimensions->nelts ; j++)
{
mapcache_requested_dimension *rdim = APR_ARRAY_IDX(dimensions,j,mapcache_requested_dimension*);
rdim->cached_entries_for_value =
mapcache_dimension_get_entries_for_value(ctx,rdim->dimension,rdim->requested_value,
tileset,bbox,(*effectively_used_grid_link)->grid);
mapcache_dimension *dim = rdim->dimension;
if (dim->wms_single_query_minzoom != -1 && level >= dim->wms_single_query_minzoom) {
rdim->cached_entries_for_value =
mapcache_dimension_get_entries_for_value(ctx,rdim->dimension,rdim->requested_value,
tileset,bbox,(*effectively_used_grid_link)->grid);
}
}
}

/* we don't want to assemble tiles that have already been reassembled from a lower level */
if((*effectively_used_grid_link)->outofzoom_strategy == MAPCACHE_OUTOFZOOM_REASSEMBLE && level > (*effectively_used_grid_link)->max_cached_zoom) {
level = (*effectively_used_grid_link)->max_cached_zoom;
}

mapcache_grid_get_xy(ctx,(*effectively_used_grid_link)->grid,bbox->minx,bbox->miny,level,&bl_x,&bl_y);
mapcache_grid_get_xy(ctx,(*effectively_used_grid_link)->grid,bbox->maxx,bbox->maxy,level,&tr_x,&tr_y);
Mx = MAPCACHE_MAX(MAPCACHE_MIN(MAPCACHE_MAX(tr_x,bl_x),(*effectively_used_grid_link)->grid_limits[level].maxx),(*effectively_used_grid_link)->grid_limits[level].minx);

0 comments on commit 30adc48

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