diff --git a/vtm/src/org/oscim/layers/tile/MapTile.java b/vtm/src/org/oscim/layers/tile/MapTile.java index b353ef7a..c918679c 100644 --- a/vtm/src/org/oscim/layers/tile/MapTile.java +++ b/vtm/src/org/oscim/layers/tile/MapTile.java @@ -17,12 +17,12 @@ package org.oscim.layers.tile; import org.oscim.core.Tile; +import org.oscim.layers.tile.vector.VectorTileLoader; +import org.oscim.layers.tile.vector.labeling.LabelTileLoaderHook; import org.oscim.renderer.elements.ElementLayers; -import org.oscim.renderer.elements.SymbolItem; -import org.oscim.renderer.elements.TextItem; import org.oscim.utils.pool.Inlist; -import org.oscim.utils.pool.Inlist.List; import org.oscim.utils.quadtree.Node; +import org.oscim.utils.quadtree.QuadTree; /** * Extends Tile class to hold state and data for concurrent use in @@ -65,6 +65,8 @@ public class MapTile extends Tile { } public static abstract class TileData extends Inlist { + Object id; + protected abstract void dispose(); } @@ -85,6 +87,13 @@ public class MapTile extends Tile { return state; } + /** + * List of TileData for rendering. ElementLayers is always at first + * position (for VectorTileLayer). TileLoaderHooks may add additional + * data. See e.g. {@link LabelTileLoaderHook}. + */ + public TileData data; + /** * absolute tile coordinates: tileX,Y / Math.pow(2, zoomLevel) */ @@ -104,8 +113,6 @@ public class MapTile extends Tile { public final List symbols = new List(); public final List labels = new List(); - public TileData data; - /** * Tile is in view region. Set by TileRenderer. */ @@ -122,6 +129,7 @@ public class MapTile extends Tile { */ int lastDraw = 0; + public final static int PROXY_CHILD1 = 1 << 0; public final static int PROXY_CHILD2 = 1 << 1; public final static int PROXY_CHILD3 = 1 << 2; @@ -236,10 +244,32 @@ public class MapTile extends Tile { state = State.NONE; } + /** + * Get the default ElementLayers which are added + * by {@link VectorTileLoader} + */ public ElementLayers getLayers() { if (!(data instanceof ElementLayers)) return null; return (ElementLayers) data; } + + public TileData getData(Object id) { + for (TileData d = data; d != null; d = d.next) + if (d.id == id) + return d; + return null; + } + + public void addData(Object id, TileData td) { + // keeping ElementLayers at position 0! + td.id = id; + if (data != null) { + td.next = data.next; + data.next = td; + } else { + data = td; + } + } } diff --git a/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLayer.java b/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLayer.java index c6daf19d..fad8fd50 100644 --- a/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLayer.java +++ b/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLayer.java @@ -100,6 +100,6 @@ public class BitmapTileLayer extends TileLayer { @Override protected TileLoader createLoader() { - return new BitmapTileLoader(this.getManager(), mTileSource); + return new BitmapTileLoader(this, mTileSource); } } diff --git a/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLoader.java b/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLoader.java index c5fd9c5e..742e3f9b 100644 --- a/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLoader.java +++ b/vtm/src/org/oscim/layers/tile/bitmap/BitmapTileLoader.java @@ -23,8 +23,8 @@ import java.util.concurrent.CancellationException; import org.oscim.backend.canvas.Bitmap; import org.oscim.core.Tile; import org.oscim.layers.tile.MapTile; +import org.oscim.layers.tile.TileLayer; import org.oscim.layers.tile.TileLoader; -import org.oscim.layers.tile.TileManager; import org.oscim.renderer.elements.BitmapLayer; import org.oscim.renderer.elements.ElementLayers; import org.oscim.tiling.ITileDataSource; @@ -38,8 +38,8 @@ public class BitmapTileLoader extends TileLoader { private final ITileDataSource mTileDataSource; - public BitmapTileLoader(TileManager tileManager, TileSource tileSource) { - super(tileManager); + public BitmapTileLoader(TileLayer tileLayer, TileSource tileSource) { + super(tileLayer.getManager()); mTileDataSource = tileSource.getDataSource(); } diff --git a/vtm/src/org/oscim/layers/tile/example/TestTileLayer.java b/vtm/src/org/oscim/layers/tile/example/TestTileLayer.java index 00a3d359..a20ebc6b 100644 --- a/vtm/src/org/oscim/layers/tile/example/TestTileLayer.java +++ b/vtm/src/org/oscim/layers/tile/example/TestTileLayer.java @@ -47,6 +47,7 @@ public class TestTileLayer extends TileLayer { } static class TestTileLoader extends TileLoader { + public TestTileLoader(TileLayer tileLayer) { super(tileLayer.getManager()); } diff --git a/vtm/src/org/oscim/renderer/elements/ElementLayers.java b/vtm/src/org/oscim/renderer/elements/ElementLayers.java index cdcbe9ca..9179ef49 100644 --- a/vtm/src/org/oscim/renderer/elements/ElementLayers.java +++ b/vtm/src/org/oscim/renderer/elements/ElementLayers.java @@ -1,5 +1,5 @@ /* - * Copyright 2012, 2013 Hannes Janetzek + * Copyright 2012-2014 Hannes Janetzek * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -37,6 +37,7 @@ import org.slf4j.LoggerFactory; * (and limitations) probably wont make sense in different contexts. */ public class ElementLayers extends TileData { + static final Logger log = LoggerFactory.getLogger(ElementLayers.class); public static void initRenderer(GL20 gl) { @@ -58,6 +59,10 @@ public class ElementLayers extends TileData { /** Text- and SymbolLayer */ private RenderElement textureLayers; + /** + * FIXME this is somewhat out-of-place, as it is not + * compiled with the other layers + */ private RenderElement extrusionLayers; /**