source: josm/trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java@ 8598

Last change on this file since 8598 was 8598, checked in by wiktorn, 9 years ago

TileSource:

  • added method - getTileId that returns unique identifier for the tile, that should not collide with other tile sources
  • added JavaDocs

JCSCacheManager:

  • moved from object count limit to object size limit
  • fixed bug with unnecessary re-creation of auxilary cache, that could result in cache corruption/loss of current cache data

CachedTileLoaderFactory, WMSCachedTileLoader, TMSCachedTileLoader

  • un-abstract CachedTileLoaderFactory, use reflection to create TileLoaders
  • adjust constructors

TMSCachedTileLoader, AbstractCachedTileSourceLayer:

  • move cache related settings to AbstractCachedTileSourceLayer
  • move cache instation to AbstractCachedTileSourceLayer
  • make "flush tile cache" command clear only one tile source

TMSCachedTileLoaderJob:

  • make "flush tile cache" command clear only one tile source
  • reorder methods

TemplatedWMSTileSource:

  • java docs
  • inline of private methods: getTileXMax, getTileYMax
  • fix sonar issues
  • make WMS layer zoom levels closer to TMS (addresses: #11459)

WMTSTileSource:

  • fix Sonar issues
  • use topLeftCorner in X/Y tile max calculations instead of world bounds (fixes issues with WMTS-es, for which topLeftCorner lies outside projection world bounds)

AbstractTileSourceLayer:

  • draw warning, when min-zoom-level is set, and tiles are not loaded due to too many tiles on screen

TMSLayer, WMSLayer, WMTSLayer:

  • expose access to cache object for ImageryPreferences

CacheContentsPanel:

  • add panel for managing cache regions and tile sources within the regions

CommonSettingsPanel, TMSSettingsPanel:

  • move settings common to all imagery layers from TMSSettingsPanel to CommonSettingsPanel
  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import org.apache.commons.jcs.access.CacheAccess;
7import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader;
8import org.openstreetmap.gui.jmapviewer.interfaces.TileSource;
9import org.openstreetmap.gui.jmapviewer.tilesources.ScanexTileSource;
10import org.openstreetmap.gui.jmapviewer.tilesources.TMSTileSource;
11import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
12import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
13import org.openstreetmap.josm.data.imagery.CachedAttributionBingAerialTileSource;
14import org.openstreetmap.josm.data.imagery.ImageryInfo;
15import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
16import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader;
17import org.openstreetmap.josm.data.preferences.BooleanProperty;
18import org.openstreetmap.josm.data.preferences.IntegerProperty;
19import org.openstreetmap.josm.data.projection.Projection;
20
21/**
22 * Class that displays a slippy map layer.
23 *
24 * @author Frederik Ramm
25 * @author LuVar <lubomir.varga@freemap.sk>
26 * @author Dave Hansen <dave@sr71.net>
27 * @author Upliner <upliner@gmail.com>
28 *
29 */
30public class TMSLayer extends AbstractCachedTileSourceLayer {
31 private static final String CACHE_REGION_NAME = "TMS";
32
33 private static final String PREFERENCE_PREFIX = "imagery.tms";
34
35 /** minimum zoom level for TMS layer */
36 public static final IntegerProperty PROP_MIN_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".min_zoom_lvl",
37 AbstractTileSourceLayer.PROP_MIN_ZOOM_LVL.get());
38 /** maximum zoom level for TMS layer */
39 public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl",
40 AbstractTileSourceLayer.PROP_MAX_ZOOM_LVL.get());
41 /** shall TMS layers be added to download dialog */
42 public static final BooleanProperty PROP_ADD_TO_SLIPPYMAP_CHOOSER = new BooleanProperty(PREFERENCE_PREFIX + ".add_to_slippymap_chooser",
43 true);
44
45 /**
46 * Create a layer based on ImageryInfo
47 * @param info description of the layer
48 */
49 public TMSLayer(ImageryInfo info) {
50 super(info);
51 }
52
53
54 /**
55 * Creates and returns a new TileSource instance depending on the {@link ImageryType}
56 * of the passed ImageryInfo object.
57 *
58 * If no appropriate TileSource is found, null is returned.
59 * Currently supported ImageryType are {@link ImageryType#TMS},
60 * {@link ImageryType#BING}, {@link ImageryType#SCANEX}.
61 *
62 *
63 * @param info imagery info
64 * @return a new TileSource instance or null if no TileSource for the ImageryInfo/ImageryType could be found.
65 * @throws IllegalArgumentException if url from imagery info is null or invalid
66 */
67 @Override
68 protected TileSource getTileSource(ImageryInfo info) throws IllegalArgumentException {
69 return getTileSourceStatic(info);
70 }
71
72 /**
73 * Adds a context menu to the mapView.
74 */
75
76 @Override
77 public final boolean isProjectionSupported(Projection proj) {
78 return "EPSG:3857".equals(proj.toCode()) || "EPSG:4326".equals(proj.toCode());
79 }
80
81 @Override
82 public final String nameSupportedProjections() {
83 return tr("EPSG:4326 and Mercator projection are supported");
84 }
85
86 /**
87 * Creates and returns a new TileSource instance depending on the {@link ImageryType}
88 * of the passed ImageryInfo object.
89 *
90 * If no appropriate TileSource is found, null is returned.
91 * Currently supported ImageryType are {@link ImageryType#TMS},
92 * {@link ImageryType#BING}, {@link ImageryType#SCANEX}.
93 *
94 * @param info imagery info
95 * @return a new TileSource instance or null if no TileSource for the ImageryInfo/ImageryType could be found.
96 * @throws IllegalArgumentException if url from imagery info is null or invalid
97 */
98 public static TileSource getTileSourceStatic(ImageryInfo info) throws IllegalArgumentException {
99 if (info.getImageryType() == ImageryType.TMS) {
100 TemplatedTMSTileSource.checkUrl(info.getUrl());
101 TMSTileSource t = new TemplatedTMSTileSource(info);
102 info.setAttribution(t);
103 return t;
104 } else if (info.getImageryType() == ImageryType.BING)
105 return new CachedAttributionBingAerialTileSource(info);
106 else if (info.getImageryType() == ImageryType.SCANEX) {
107 return new ScanexTileSource(info);
108 }
109 return null;
110 }
111
112 @Override
113 protected Class<? extends TileLoader> getTileLoaderClass() {
114 return TMSCachedTileLoader.class;
115 }
116
117 @Override
118 protected String getCacheName() {
119 return CACHE_REGION_NAME;
120 }
121
122 /**
123 * @return cache for TMS region
124 */
125 public static CacheAccess<String, BufferedImageCacheEntry> getCache() {
126 return AbstractCachedTileSourceLayer.getCache(CACHE_REGION_NAME);
127 }
128
129}
Note: See TracBrowser for help on using the repository browser.