make VectorTileLoader extendable
This commit is contained in:
parent
5c2eaf961f
commit
99cfdd6e14
@ -53,36 +53,36 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
|
|
||||||
static final Logger log = LoggerFactory.getLogger(VectorTileLoader.class);
|
static final Logger log = LoggerFactory.getLogger(VectorTileLoader.class);
|
||||||
|
|
||||||
private static final double STROKE_INCREASE = Math.sqrt(2.5);
|
protected static final double STROKE_INCREASE = Math.sqrt(2.5);
|
||||||
private static final byte LAYERS = 11;
|
protected static final byte LAYERS = 11;
|
||||||
|
|
||||||
public static final byte STROKE_MIN_ZOOM = 12;
|
public static final byte STROKE_MIN_ZOOM = 12;
|
||||||
public static final byte STROKE_MAX_ZOOM = 17;
|
public static final byte STROKE_MAX_ZOOM = 17;
|
||||||
|
|
||||||
private IRenderTheme renderTheme;
|
protected IRenderTheme renderTheme;
|
||||||
private int renderLevels;
|
protected int renderLevels;
|
||||||
|
|
||||||
/** current TileDataSource used by this MapTileLoader */
|
/** current TileDataSource used by this MapTileLoader */
|
||||||
private ITileDataSource mTileDataSource;
|
protected ITileDataSource mTileDataSource;
|
||||||
|
|
||||||
/** currently processed tile */
|
/** currently processed tile */
|
||||||
private MapTile mTile;
|
protected MapTile mTile;
|
||||||
|
|
||||||
/** currently processed MapElement */
|
/** currently processed MapElement */
|
||||||
private MapElement mElement;
|
protected MapElement mElement;
|
||||||
|
|
||||||
/** current line layer (will be used for outline layers) */
|
/** current line layer (will be used for outline layers) */
|
||||||
private LineLayer mCurLineLayer;
|
protected LineLayer mCurLineLayer;
|
||||||
|
|
||||||
/** Current layer for adding elements */
|
/** Current layer for adding elements */
|
||||||
private int mCurLayer;
|
protected int mCurLayer;
|
||||||
|
|
||||||
/** Line-scale-factor depending on zoom and latitude */
|
/** Line-scale-factor depending on zoom and latitude */
|
||||||
private float mLineScale = 1.0f;
|
protected float mLineScale = 1.0f;
|
||||||
|
|
||||||
private final LineClipper mClipper;
|
protected final LineClipper mClipper;
|
||||||
|
|
||||||
private final TagSet mFilteredTags;
|
protected final TagSet mFilteredTags;
|
||||||
|
|
||||||
public void setRenderTheme(IRenderTheme theme) {
|
public void setRenderTheme(IRenderTheme theme) {
|
||||||
renderTheme = theme;
|
renderTheme = theme;
|
||||||
@ -137,7 +137,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getValidLayer(int layer) {
|
protected static int getValidLayer(int layer) {
|
||||||
if (layer < 0) {
|
if (layer < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (layer >= LAYERS) {
|
} else if (layer >= LAYERS) {
|
||||||
@ -164,37 +164,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
Tag tag;
|
Tag tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace tags that should only be matched by key in RenderTheme
|
protected boolean filterTags(TagSet tagSet) {
|
||||||
// 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)
|
|
||||||
};
|
|
||||||
|
|
||||||
private 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +201,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
mElement = null;
|
mElement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void debugUnmatched(boolean closed, TagSet tags) {
|
//protected void debugUnmatched(boolean closed, TagSet tags) {
|
||||||
// log.debug("DBG way not matched: " + closed + " "
|
// log.debug("DBG way not matched: " + closed + " "
|
||||||
// + Arrays.deepToString(tags));
|
// + Arrays.deepToString(tags));
|
||||||
//
|
//
|
||||||
@ -243,7 +213,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
// renderWay(ri);
|
// renderWay(ri);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private void renderWay(RenderStyle[] ri) {
|
protected void renderWay(RenderStyle[] ri) {
|
||||||
if (ri == null)
|
if (ri == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -251,7 +221,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
ri[i].renderWay(this);
|
ri[i].renderWay(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderNode(RenderStyle[] ri) {
|
protected void renderNode(RenderStyle[] ri) {
|
||||||
if (ri == null)
|
if (ri == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -259,7 +229,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
ri[i].renderNode(this);
|
ri[i].renderNode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearState() {
|
protected void clearState() {
|
||||||
mCurLineLayer = null;
|
mCurLineLayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +289,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static boolean USE_MESH_POLY = false;
|
protected final static boolean USE_MESH_POLY = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderArea(Area area, int level) {
|
public void renderArea(Area area, int level) {
|
||||||
|
@ -59,36 +59,36 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
|
|
||||||
static final Logger log = LoggerFactory.getLogger(VectorTileLoader.class);
|
static final Logger log = LoggerFactory.getLogger(VectorTileLoader.class);
|
||||||
|
|
||||||
private static final double STROKE_INCREASE = Math.sqrt(2.5);
|
protected static final double STROKE_INCREASE = Math.sqrt(2.5);
|
||||||
private static final byte LAYERS = 11;
|
protected static final byte LAYERS = 11;
|
||||||
|
|
||||||
public static final byte STROKE_MIN_ZOOM = 12;
|
public static final byte STROKE_MIN_ZOOM = 12;
|
||||||
public static final byte STROKE_MAX_ZOOM = 17;
|
public static final byte STROKE_MAX_ZOOM = 17;
|
||||||
|
|
||||||
private IRenderTheme renderTheme;
|
protected IRenderTheme renderTheme;
|
||||||
private int renderLevels;
|
protected int renderLevels;
|
||||||
|
|
||||||
/** current TileDataSource used by this MapTileLoader */
|
/** current TileDataSource used by this MapTileLoader */
|
||||||
private ITileDataSource mTileDataSource;
|
protected ITileDataSource mTileDataSource;
|
||||||
|
|
||||||
/** currently processed tile */
|
/** currently processed tile */
|
||||||
private MapTile mTile;
|
protected MapTile mTile;
|
||||||
|
|
||||||
/** currently processed MapElement */
|
/** currently processed MapElement */
|
||||||
private MapElement mElement;
|
protected MapElement mElement;
|
||||||
|
|
||||||
/** current line layer (will be used for outline layers) */
|
/** current line layer (will be used for outline layers) */
|
||||||
private LineLayer mCurLineLayer;
|
protected LineLayer mCurLineLayer;
|
||||||
|
|
||||||
/** Current layer for adding elements */
|
/** Current layer for adding elements */
|
||||||
private int mCurLayer;
|
protected int mCurLayer;
|
||||||
|
|
||||||
/** Line-scale-factor depending on zoom and latitude */
|
/** Line-scale-factor depending on zoom and latitude */
|
||||||
private float mLineScale = 1.0f;
|
protected float mLineScale = 1.0f;
|
||||||
|
|
||||||
private final LineClipper mClipper;
|
protected final LineClipper mClipper;
|
||||||
|
|
||||||
private final TagSet mFilteredTags;
|
protected final TagSet mFilteredTags;
|
||||||
|
|
||||||
public void setRenderTheme(IRenderTheme theme) {
|
public void setRenderTheme(IRenderTheme theme) {
|
||||||
renderTheme = theme;
|
renderTheme = theme;
|
||||||
@ -148,7 +148,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
return (result == QueryResult.SUCCESS);
|
return (result == QueryResult.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getValidLayer(int layer) {
|
protected static int getValidLayer(int layer) {
|
||||||
if (layer < 0) {
|
if (layer < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (layer >= LAYERS) {
|
} else if (layer >= LAYERS) {
|
||||||
@ -180,7 +180,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
// only with different name.
|
// only with different name.
|
||||||
// Maybe this should be done within RenderTheme, also allowing
|
// Maybe this should be done within RenderTheme, also allowing
|
||||||
// to set these replacement rules in theme file.
|
// to set these replacement rules in theme file.
|
||||||
private static final TagReplacement[] mTagReplacement = {
|
protected static final TagReplacement[] mTagReplacement = {
|
||||||
new TagReplacement(Tag.KEY_NAME),
|
new TagReplacement(Tag.KEY_NAME),
|
||||||
new TagReplacement(Tag.KEY_HOUSE_NUMBER),
|
new TagReplacement(Tag.KEY_HOUSE_NUMBER),
|
||||||
new TagReplacement(Tag.KEY_REF),
|
new TagReplacement(Tag.KEY_REF),
|
||||||
@ -188,7 +188,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
new TagReplacement(Tag.KEY_MIN_HEIGHT)
|
new TagReplacement(Tag.KEY_MIN_HEIGHT)
|
||||||
};
|
};
|
||||||
|
|
||||||
private boolean filterTags(TagSet tagSet) {
|
protected boolean filterTags(TagSet tagSet) {
|
||||||
Tag[] tags = tagSet.tags;
|
Tag[] tags = tagSet.tags;
|
||||||
|
|
||||||
mFilteredTags.clear();
|
mFilteredTags.clear();
|
||||||
@ -243,7 +243,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
mElement = null;
|
mElement = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private void debugUnmatched(boolean closed, TagSet tags) {
|
//protected void debugUnmatched(boolean closed, TagSet tags) {
|
||||||
// log.debug("DBG way not matched: " + closed + " "
|
// log.debug("DBG way not matched: " + closed + " "
|
||||||
// + Arrays.deepToString(tags));
|
// + Arrays.deepToString(tags));
|
||||||
//
|
//
|
||||||
@ -255,7 +255,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
// renderWay(ri);
|
// renderWay(ri);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private void renderWay(RenderStyle[] style) {
|
protected void renderWay(RenderStyle[] style) {
|
||||||
if (style == null)
|
if (style == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
style[i].renderWay(this);
|
style[i].renderWay(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderNode(RenderStyle[] style) {
|
protected void renderNode(RenderStyle[] style) {
|
||||||
if (style == null)
|
if (style == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
style[i].renderNode(this);
|
style[i].renderNode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearState() {
|
protected void clearState() {
|
||||||
mCurLineLayer = null;
|
mCurLineLayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
|
|
||||||
// slower to load (requires tesselation) and uses
|
// slower to load (requires tesselation) and uses
|
||||||
// more memory but should be faster to render
|
// more memory but should be faster to render
|
||||||
private final static boolean USE_MESH_POLY = false;
|
protected final static boolean USE_MESH_POLY = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderArea(Area area, int level) {
|
public void renderArea(Area area, int level) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user