Skip to content

Commit 6c7fafa

Browse files
committed
Add <assembly_threaded_fetching> configuration tag for fetching subtiles using multiple threads
1 parent 9b0309e commit 6c7fafa

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

include/mapcache.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,12 @@ struct mapcache_tileset {
11421142

11431143
mapcache_dimension_assembly_type dimension_assembly_type;
11441144

1145+
/**
1146+
* Maximum zoom level for activating multithreaded subtile retrieval
1147+
* -1 means 'not activated'
1148+
*/
1149+
int assembly_threaded_fetching_maxzoom;
1150+
11451151
/**
11461152
* image to be used as a watermark
11471153
*/

lib/configuration_xml.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,32 @@ void parseDimensions(mapcache_context *ctx, ezxml_t node, mapcache_tileset *tile
158158
}
159159
}
160160

161+
dimension_node = ezxml_child(node,"assembly_threaded_fetching");
162+
if (dimension_node) {
163+
if (dimension_node && dimension_node->txt) {
164+
if (!strcmp(dimension_node->txt,"false")) {
165+
int maxzoom = INT_MAX;
166+
char * smaxzoom = (char*)ezxml_attr(dimension_node,"maxzoom");;
167+
if (smaxzoom && *smaxzoom) {
168+
char *endptr;
169+
maxzoom = (int)strtol(smaxzoom,&endptr,10);
170+
if(*endptr != 0 || maxzoom < 0) {
171+
ctx->set_error(ctx, 400, "failed to parse assembly_threaded_fetching"
172+
" maxzoom %s (expecting a positive integer)", smaxzoom);
173+
return;
174+
}
175+
}
176+
tileset->assembly_threaded_fetching_maxzoom = maxzoom;
177+
} else if (strcmp(dimension_node->txt,"true")) {
178+
ctx->set_error(ctx,400,"failed to parse <assembly_threaded_fetching>"
179+
" (%s), expecting \"true\" or \"false\"",dimension_node->txt);
180+
return;
181+
}
182+
} else {
183+
tileset->assembly_threaded_fetching_maxzoom = -1;
184+
}
185+
}
186+
161187
/* should we create subdimensions from source if not found in cache.
162188
e.g. if dimension=mosaic returns dimension=val1,val2,val3 should we
163189
query the wms source with dimension=val1 , dimension=val2 and/or

lib/tileset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,8 @@ void mapcache_tileset_tile_set_get_with_subdimensions(mapcache_context *ctx, map
906906
/* our subtiles array now contains a list of tiles with subdimensions split up, we now need to fetch them from the cache */
907907
/* note that subtiles[0].tile == tile */
908908
#if APR_HAS_THREADS
909-
{
909+
if (tile->tileset->assembly_threaded_fetching_maxzoom != -1
910+
&& tile->z <= tile->tileset->assembly_threaded_fetching_maxzoom) {
910911
apr_thread_t **threads;
911912
apr_threadattr_t *thread_attrs;
912913
int nthreads;

0 commit comments

Comments
 (0)