1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.imagery;
|
---|
3 |
|
---|
4 | import org.apache.commons.jcs.access.behavior.ICacheAccess;
|
---|
5 | import org.openstreetmap.gui.jmapviewer.Tile;
|
---|
6 | import org.openstreetmap.gui.jmapviewer.interfaces.TileJob;
|
---|
7 | import org.openstreetmap.gui.jmapviewer.interfaces.TileLoaderListener;
|
---|
8 | import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
|
---|
9 | import org.openstreetmap.josm.data.preferences.IntegerProperty;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Tileloader for WMS based imagery. It is separate to use different ThreadPoolExecutor, as we want
|
---|
13 | * to define number of simultaneous downloads for WMS separately
|
---|
14 | *
|
---|
15 | * @author Wiktor Niesiobędzki
|
---|
16 | * @since 8526
|
---|
17 | */
|
---|
18 | public class WMSCachedTileLoader extends TMSCachedTileLoader {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * overrides the THREAD_LIMIT in superclass, as we want to have separate limit and pool for WMS
|
---|
22 | */
|
---|
23 | public static final IntegerProperty THREAD_LIMIT = new IntegerProperty("imagery.wms.loader.maxjobs", 3);
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Creates a TileLoader with separate WMS download thread pool.
|
---|
27 | *
|
---|
28 | * @param listener that will be notified when tile is loaded
|
---|
29 | * @param cache reference
|
---|
30 | * @param options tile job options
|
---|
31 | */
|
---|
32 | public WMSCachedTileLoader(TileLoaderListener listener, ICacheAccess<String, BufferedImageCacheEntry> cache,
|
---|
33 | TileJobOptions options) {
|
---|
34 |
|
---|
35 | super(listener, cache, options);
|
---|
36 | // use WMS specific maximum number of download threads and use the same value for concurrent downloads per host
|
---|
37 | // for each layer use separate thread pool so the limit set in preferences is per imagery
|
---|
38 | setDownloadExecutor(TMSCachedTileLoader.getNewThreadPoolExecutor("WMS-downloader-%d", THREAD_LIMIT.get(), THREAD_LIMIT.get()));
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Override
|
---|
42 | public TileJob createTileLoaderJob(Tile tile) {
|
---|
43 | return new WMSCachedTileLoaderJob(listener, tile, cache, options, getDownloadExecutor());
|
---|
44 | }
|
---|
45 | }
|
---|