extract OSM vector-tile specifics to OsmTileLayer
This commit is contained in:
parent
1b232cca84
commit
6a40c3c375
@ -31,10 +31,6 @@ public class VectorTileRenderer extends TileRenderer {
|
||||
|
||||
protected GLMatrix mViewProj = new GLMatrix();
|
||||
|
||||
// public VectorTileRenderer(TileManager tileManager) {
|
||||
// super(tileManager);
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected synchronized void update(GLViewport v) {
|
||||
super.update(v);
|
||||
|
64
vtm/src/org/oscim/layers/tile/vector/OsmTileLayer.java
Normal file
64
vtm/src/org/oscim/layers/tile/vector/OsmTileLayer.java
Normal file
@ -0,0 +1,64 @@
|
||||
package org.oscim.layers.tile.vector;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
import org.oscim.core.TagSet;
|
||||
import org.oscim.layers.tile.TileLoader;
|
||||
import org.oscim.layers.tile.TileManager;
|
||||
import org.oscim.map.Map;
|
||||
|
||||
public class OsmTileLayer extends VectorTileLayer {
|
||||
|
||||
protected final static int MAX_ZOOMLEVEL = 17;
|
||||
protected final static int MIN_ZOOMLEVEL = 2;
|
||||
protected final static int CACHE_LIMIT = 150;
|
||||
|
||||
public OsmTileLayer(Map map) {
|
||||
super(map, MIN_ZOOMLEVEL, MAX_ZOOMLEVEL, CACHE_LIMIT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TileLoader createLoader(TileManager tm) {
|
||||
return new OsmTileLoader(tm);
|
||||
}
|
||||
|
||||
static class OsmTileLoader extends VectorTileLoader {
|
||||
|
||||
public OsmTileLoader(TileManager tileManager) {
|
||||
super(tileManager);
|
||||
}
|
||||
|
||||
/* Replace tags that should only be matched by key in RenderTheme
|
||||
* to avoid caching RenderInstructions for each way of the same type
|
||||
* only with different name.
|
||||
* Maybe this should be done within RenderTheme, also allowing
|
||||
* to set these replacement rules in theme file. */
|
||||
private static final TagReplacement[] mTagReplacement = {
|
||||
new TagReplacement(Tag.KEY_NAME),
|
||||
new TagReplacement(Tag.KEY_HOUSE_NUMBER),
|
||||
new TagReplacement(Tag.KEY_REF),
|
||||
new TagReplacement(Tag.KEY_HEIGHT),
|
||||
new TagReplacement(Tag.KEY_MIN_HEIGHT)
|
||||
};
|
||||
|
||||
protected boolean filterTags(TagSet tagSet) {
|
||||
Tag[] tags = tagSet.tags;
|
||||
|
||||
mFilteredTags.clear();
|
||||
|
||||
O: for (int i = 0, n = tagSet.numTags; i < n; i++) {
|
||||
Tag t = tags[i];
|
||||
|
||||
for (TagReplacement replacement : mTagReplacement) {
|
||||
if (t.key == replacement.key) {
|
||||
mFilteredTags.add(replacement.tag);
|
||||
continue O;
|
||||
}
|
||||
}
|
||||
|
||||
mFilteredTags.add(t);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -32,19 +32,11 @@ import org.slf4j.LoggerFactory;
|
||||
* {@link VectorTileLoader} that load and assemble vector tiles
|
||||
* for rendering.
|
||||
*/
|
||||
public class VectorTileLayer extends TileLayer {
|
||||
public abstract class VectorTileLayer extends TileLayer {
|
||||
static final Logger log = LoggerFactory.getLogger(VectorTileLayer.class);
|
||||
|
||||
protected final static int MAX_ZOOMLEVEL = 17;
|
||||
protected final static int MIN_ZOOMLEVEL = 2;
|
||||
protected final static int CACHE_LIMIT = 150;
|
||||
|
||||
protected TileSource mTileSource;
|
||||
|
||||
public VectorTileLayer(Map map) {
|
||||
this(map, MIN_ZOOMLEVEL, MAX_ZOOMLEVEL, CACHE_LIMIT);
|
||||
}
|
||||
|
||||
public VectorTileLayer(Map map, int minZoom, int maxZoom, int cacheLimit) {
|
||||
super(map, new TileManager(map, minZoom, maxZoom, cacheLimit),
|
||||
new VectorTileRenderer());
|
||||
@ -53,7 +45,7 @@ public class VectorTileLayer extends TileLayer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected VectorTileLoader createLoader(TileManager tm) {
|
||||
protected TileLoader createLoader(TileManager tm) {
|
||||
return new VectorTileLoader(tm);
|
||||
}
|
||||
|
||||
|
@ -51,11 +51,11 @@ import org.oscim.theme.styles.Text;
|
||||
import org.oscim.tiling.ITileDataSink;
|
||||
import org.oscim.tiling.ITileDataSource;
|
||||
import org.oscim.tiling.ITileDataSource.QueryResult;
|
||||
import org.oscim.utils.geom.LineClipper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class VectorTileLoader extends TileLoader implements IRenderTheme.Callback, ITileDataSink {
|
||||
public class VectorTileLoader extends TileLoader implements IRenderTheme.Callback,
|
||||
ITileDataSink {
|
||||
|
||||
static final Logger log = LoggerFactory.getLogger(VectorTileLoader.class);
|
||||
|
||||
@ -86,8 +86,6 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
/** Line-scale-factor depending on zoom and latitude */
|
||||
protected float mLineScale = 1.0f;
|
||||
|
||||
protected final LineClipper mClipper;
|
||||
|
||||
protected final TagSet mFilteredTags;
|
||||
|
||||
public void setRenderTheme(IRenderTheme theme) {
|
||||
@ -98,7 +96,6 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
public VectorTileLoader(TileManager tileManager) {
|
||||
super(tileManager);
|
||||
|
||||
mClipper = new LineClipper(0, 0, Tile.SIZE, Tile.SIZE, true);
|
||||
mFilteredTags = new TagSet();
|
||||
}
|
||||
|
||||
@ -175,37 +172,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
Tag tag;
|
||||
}
|
||||
|
||||
// Replace tags that should only be matched by key in RenderTheme
|
||||
// to avoid caching RenderInstructions for each way of the same type
|
||||
// only with different name.
|
||||
// Maybe this should be done within RenderTheme, also allowing
|
||||
// to set these replacement rules in theme file.
|
||||
protected static final TagReplacement[] mTagReplacement = {
|
||||
new TagReplacement(Tag.KEY_NAME),
|
||||
new TagReplacement(Tag.KEY_HOUSE_NUMBER),
|
||||
new TagReplacement(Tag.KEY_REF),
|
||||
new TagReplacement(Tag.KEY_HEIGHT),
|
||||
new TagReplacement(Tag.KEY_MIN_HEIGHT)
|
||||
};
|
||||
|
||||
protected boolean filterTags(TagSet tagSet) {
|
||||
Tag[] tags = tagSet.tags;
|
||||
|
||||
mFilteredTags.clear();
|
||||
|
||||
O: for (int i = 0, n = tagSet.numTags; i < n; i++) {
|
||||
Tag t = tags[i];
|
||||
|
||||
for (TagReplacement replacement : mTagReplacement) {
|
||||
if (t.key == replacement.key) {
|
||||
mFilteredTags.add(replacement.tag);
|
||||
continue O;
|
||||
}
|
||||
}
|
||||
|
||||
mFilteredTags.add(t);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -389,7 +356,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
||||
if (length < 4)
|
||||
break;
|
||||
|
||||
WayDecorator.renderText(mClipper, mElement.points, value, text,
|
||||
WayDecorator.renderText(null, mElement.points, value, text,
|
||||
offset, length, mTile);
|
||||
offset += length;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import org.oscim.event.GestureDetector;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.layers.MapEventLayer;
|
||||
import org.oscim.layers.tile.BitmapTileLayer;
|
||||
import org.oscim.layers.tile.vector.OsmTileLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.renderer.MapRenderer;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
@ -125,7 +126,7 @@ public abstract class Map {
|
||||
public VectorTileLayer setBaseMap(TileSource tileSource) {
|
||||
// TODO cleanup previous baseLayer here?
|
||||
|
||||
mBaseLayer = new VectorTileLayer(this);
|
||||
mBaseLayer = new OsmTileLayer(this);
|
||||
mBaseLayer.setTileSource(tileSource);
|
||||
mLayers.add(1, mBaseLayer);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user