From e24bba1e57340f4e0ff4471c5d34dbb5b165d012 Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Wed, 24 Apr 2013 15:41:45 +0200 Subject: [PATCH] use 'max zoom level' from TileSource --- src/org/oscim/layers/tile/BitmapTileLayer.java | 2 +- src/org/oscim/layers/tile/TileLayer.java | 7 ++++++- src/org/oscim/layers/tile/TileManager.java | 10 ++++++---- src/org/oscim/layers/tile/bitmap/MapQuestAerial.java | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/org/oscim/layers/tile/BitmapTileLayer.java b/src/org/oscim/layers/tile/BitmapTileLayer.java index 0f3d101d..33c724d8 100644 --- a/src/org/oscim/layers/tile/BitmapTileLayer.java +++ b/src/org/oscim/layers/tile/BitmapTileLayer.java @@ -35,7 +35,7 @@ public class BitmapTileLayer extends TileLayer { final TileSource mTileSource; public BitmapTileLayer(MapView mapView, TileSource tileSource) { - super(mapView); + super(mapView, tileSource.getZoomLevelMax()); mTileSource = tileSource; } diff --git a/src/org/oscim/layers/tile/TileLayer.java b/src/org/oscim/layers/tile/TileLayer.java index 2c143d50..bca849c4 100644 --- a/src/org/oscim/layers/tile/TileLayer.java +++ b/src/org/oscim/layers/tile/TileLayer.java @@ -22,6 +22,7 @@ import org.oscim.view.MapView; public abstract class TileLayer extends Layer { //private final static String TAG = TileLayer.class.getName(); + private final static int MAX_ZOOMLEVEL = 17; private boolean mClearMap = true; @@ -33,11 +34,15 @@ public abstract class TileLayer extends Layer { protected final ArrayList mTileLoader; public TileLayer(MapView mapView) { + this(mapView, MAX_ZOOMLEVEL); + } + + public TileLayer(MapView mapView, int maxZoom) { super(mapView); // TileManager responsible for adding visible tiles // to load queue and managing in-memory tile cache. - mTileManager = new TileManager(mapView, this); + mTileManager = new TileManager(mapView, this, maxZoom); mJobQueue = new JobQueue(); diff --git a/src/org/oscim/layers/tile/TileManager.java b/src/org/oscim/layers/tile/TileManager.java index 0f165163..32e3dc1f 100644 --- a/src/org/oscim/layers/tile/TileManager.java +++ b/src/org/oscim/layers/tile/TileManager.java @@ -46,9 +46,10 @@ public class TileManager { private static final int CACHE_TILES_MAX = 250; static final String TAG = TileManager.class.getSimpleName(); - private final static int MAX_ZOOMLEVEL = 17; private final static int MIN_ZOOMLEVEL = 2; + private final int mMaxZoom; + // limit number tiles with new data not uploaded to GL // TODO this should depend on the number of tiles displayed private static final int MAX_TILES_IN_QUEUE = 40; @@ -116,10 +117,11 @@ public class TileManager { private final float[] mBoxCoords = new float[8]; private final TileLayer mTileLayer; - public TileManager(MapView mapView, TileLayer tileLayer) { + + public TileManager(MapView mapView, TileLayer tileLayer, int maxZoom) { mMapView = mapView; mTileLayer = tileLayer; - + mMaxZoom = maxZoom; mMapViewPosition = mapView.getMapViewPosition(); mJobs = new ArrayList(); mTiles = new MapTile[CACHE_TILES_MAX]; @@ -202,7 +204,7 @@ public class TileManager { // load some tiles more than currently visible (* 0.75) double scale = pos.scale * 0.9f; - int tileZoom = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, MAX_ZOOMLEVEL); + int tileZoom = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, mMaxZoom); mMapViewPosition.getMapViewProjection(mBoxCoords); diff --git a/src/org/oscim/layers/tile/bitmap/MapQuestAerial.java b/src/org/oscim/layers/tile/bitmap/MapQuestAerial.java index 78d99ab7..bf96dcf4 100644 --- a/src/org/oscim/layers/tile/bitmap/MapQuestAerial.java +++ b/src/org/oscim/layers/tile/bitmap/MapQuestAerial.java @@ -23,7 +23,7 @@ public class MapQuestAerial extends AbstractTileSource { public static final MapQuestAerial INSTANCE = new MapQuestAerial("otile1.mqcdn.com", 80); private static final int PARALLEL_REQUESTS_LIMIT = 8; private static final String PROTOCOL = "http"; - private static final int ZOOM_LEVEL_MAX = 18; + private static final int ZOOM_LEVEL_MAX = 8; private static final int ZOOM_LEVEL_MIN = 0; public MapQuestAerial(String hostName, int port) {