cleanups
This commit is contained in:
parent
b0c02e0c56
commit
f440920a4b
@ -51,11 +51,9 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
new Byte((byte) 4), new GeoPoint(53.11, 8.85),
|
new Byte((byte) 4), new GeoPoint(53.11, 8.85),
|
||||||
null, 0, 0, 0, "de", "comment", "author", null);
|
null, 0, 0, 0, "de", "comment", "author", null);
|
||||||
|
|
||||||
|
|
||||||
private static final String CACHE_DIRECTORY = "/Android/data/org.oscim.app/cache/";
|
private static final String CACHE_DIRECTORY = "/Android/data/org.oscim.app/cache/";
|
||||||
private static final String CACHE_FILE = "%d-%d-%d.tile";
|
private static final String CACHE_FILE = "%d-%d-%d.tile";
|
||||||
|
|
||||||
|
|
||||||
private final static float REF_TILE_SIZE = 4096.0f;
|
private final static float REF_TILE_SIZE = 4096.0f;
|
||||||
|
|
||||||
// 'open' state
|
// 'open' state
|
||||||
@ -89,7 +87,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
File f = null;
|
File f = null;
|
||||||
|
|
||||||
if (USE_CACHE) {
|
if (USE_CACHE) {
|
||||||
f = new File(cacheDir, String.format(CACHE_FILE,
|
f = new File(cacheDir, String.format(CACHE_FILE,
|
||||||
Integer.valueOf(tile.zoomLevel),
|
Integer.valueOf(tile.zoomLevel),
|
||||||
Integer.valueOf(tile.tileX),
|
Integer.valueOf(tile.tileX),
|
||||||
Integer.valueOf(tile.tileY)));
|
Integer.valueOf(tile.tileY)));
|
||||||
@ -158,7 +156,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
|
|
||||||
lwHttp = new LwHttp();
|
lwHttp = new LwHttp();
|
||||||
|
|
||||||
if (!lwHttp.setServer(options.get("url"))){
|
if (!lwHttp.setServer(options.get("url"))) {
|
||||||
return new OpenResult("invalid url: " + options.get("url"));
|
return new OpenResult("invalid url: " + options.get("url"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,20 +209,9 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
// /////////////// hand sewed tile protocol buffers decoder ///////////////
|
// /////////////// hand sewed tile protocol buffers decoder ///////////////
|
||||||
private final int MAX_WAY_COORDS = 16384;
|
private final int MAX_WAY_COORDS = 16384;
|
||||||
|
|
||||||
//private final byte[] mReadBuffer = new byte[BUFFER_SIZE];
|
|
||||||
|
|
||||||
// position in buffer
|
|
||||||
// private int mBufferPos;
|
|
||||||
|
|
||||||
// bytes available in buffer
|
|
||||||
// private int mBufferFill;
|
|
||||||
|
|
||||||
// overall bytes of content processed
|
// overall bytes of content processed
|
||||||
private int mBytesProcessed;
|
private int mBytesProcessed;
|
||||||
|
|
||||||
// overall bytes of content read
|
|
||||||
// private int mReadPos;
|
|
||||||
|
|
||||||
private static final int TAG_TILE_NUM_TAGS = 1;
|
private static final int TAG_TILE_NUM_TAGS = 1;
|
||||||
private static final int TAG_TILE_TAG_KEYS = 2;
|
private static final int TAG_TILE_TAG_KEYS = 2;
|
||||||
private static final int TAG_TILE_TAG_VALUES = 3;
|
private static final int TAG_TILE_TAG_VALUES = 3;
|
||||||
@ -360,19 +347,16 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_ELEM_INDEX:
|
case TAG_ELEM_INDEX:
|
||||||
index = decodeShortArray(indexCnt, mIndices);
|
mIndices = index = decodeShortArray(indexCnt, mIndices);
|
||||||
if (index != null) {
|
|
||||||
mIndices = index;
|
|
||||||
|
|
||||||
for (int i = 0; i < indexCnt; i++) {
|
for (int i = 0; i < indexCnt; i++) {
|
||||||
int len = index[i] * 2;
|
int len = index[i] * 2;
|
||||||
coordCnt += len;
|
coordCnt += len;
|
||||||
index[i] = (short) len;
|
index[i] = (short) len;
|
||||||
}
|
|
||||||
// set end marker
|
|
||||||
if (indexCnt < index.length)
|
|
||||||
index[indexCnt] = -1;
|
|
||||||
}
|
}
|
||||||
|
// set end marker
|
||||||
|
if (indexCnt < index.length)
|
||||||
|
index[indexCnt] = -1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAG_ELEM_COORDS:
|
case TAG_ELEM_COORDS:
|
||||||
@ -436,19 +420,17 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
|
|
||||||
if (tagNum < 0) {
|
if (tagNum < 0) {
|
||||||
Log.d(TAG, "NULL TAG: " + mTile + " invalid tag:" + tagNum + " " + cnt);
|
Log.d(TAG, "NULL TAG: " + mTile + " invalid tag:" + tagNum + " " + cnt);
|
||||||
|
} else if (tagNum < Tags.MAX) {
|
||||||
|
tmp[cnt++] = Tags.tags[tagNum];
|
||||||
} else {
|
} else {
|
||||||
if (tagNum < Tags.MAX)
|
tagNum -= Tags.LIMIT;
|
||||||
tmp[cnt++] = Tags.tags[tagNum];
|
|
||||||
else {
|
|
||||||
tagNum -= Tags.LIMIT;
|
|
||||||
|
|
||||||
if (tagNum >= 0 && tagNum < max) {
|
if (tagNum >= 0 && tagNum < max) {
|
||||||
// Log.d(TAG, "variable tag: " + curTags[tagNum]);
|
// Log.d(TAG, "variable tag: " + curTags[tagNum]);
|
||||||
tmp[cnt++] = curTags[tagNum];
|
tmp[cnt++] = curTags[tagNum];
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "NULL TAG: " + mTile + " could find tag:"
|
Log.d(TAG, "NULL TAG: " + mTile + " could not find tag:"
|
||||||
+ tagNum + " " + cnt);
|
+ tagNum + " " + cnt);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -554,10 +536,8 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
private short[] decodeShortArray(int num, short[] array) throws IOException {
|
private short[] decodeShortArray(int num, short[] array) throws IOException {
|
||||||
int bytes = decodeVarint32();
|
int bytes = decodeVarint32();
|
||||||
|
|
||||||
short[] index = array;
|
if (array.length < num)
|
||||||
if (index.length < num) {
|
array = new short[num];
|
||||||
index = new short[num];
|
|
||||||
}
|
|
||||||
|
|
||||||
lwHttp.readBuffer(bytes);
|
lwHttp.readBuffer(bytes);
|
||||||
|
|
||||||
@ -605,13 +585,13 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
index[cnt++] = (short) result;
|
array[cnt++] = (short) result;
|
||||||
}
|
}
|
||||||
|
|
||||||
lwHttp.bufferPos = pos;
|
lwHttp.bufferPos = pos;
|
||||||
mBytesProcessed += bytes;
|
mBytesProcessed += bytes;
|
||||||
|
|
||||||
return index;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int decodeVarint32() throws IOException {
|
private int decodeVarint32() throws IOException {
|
||||||
@ -622,7 +602,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
pos = lwHttp.bufferPos;
|
pos = lwHttp.bufferPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] buf =lwHttp.buffer;
|
byte[] buf = lwHttp.buffer;
|
||||||
|
|
||||||
if (buf[pos] >= 0) {
|
if (buf[pos] >= 0) {
|
||||||
lwHttp.bufferPos += 1;
|
lwHttp.bufferPos += 1;
|
||||||
|
@ -162,12 +162,6 @@ public final class LineLayer extends Layer {
|
|||||||
ux = -vy;
|
ux = -vy;
|
||||||
uy = vx;
|
uy = vx;
|
||||||
|
|
||||||
if (opos == VertexPoolItem.SIZE) {
|
|
||||||
si = si.next = VertexPool.get();
|
|
||||||
v = si.vertices;
|
|
||||||
opos = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ddx, ddy;
|
int ddx, ddy;
|
||||||
|
|
||||||
// vertex point coordinate
|
// vertex point coordinate
|
||||||
|
@ -30,7 +30,7 @@ public final class TextLayer extends TextureLayer {
|
|||||||
private final static int LBIT_MASK = 0xfffffffe;
|
private final static int LBIT_MASK = 0xfffffffe;
|
||||||
|
|
||||||
private static int mFontPadX = 1;
|
private static int mFontPadX = 1;
|
||||||
private static int mFontPadY = 1;
|
//private static int mFontPadY = 1;
|
||||||
|
|
||||||
public TextItem labels;
|
public TextItem labels;
|
||||||
private final Canvas mCanvas;
|
private final Canvas mCanvas;
|
||||||
|
@ -55,7 +55,7 @@ import android.opengl.GLES20;
|
|||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
||||||
public class TextOverlay extends BasicOverlay {
|
public class TextOverlay extends BasicOverlay {
|
||||||
private final static String TAG = TextOverlay.class.getName();
|
//private final static String TAG = TextOverlay.class.getName();
|
||||||
|
|
||||||
private final MapViewPosition mMapViewPosition;
|
private final MapViewPosition mMapViewPosition;
|
||||||
private TileSet mTileSet;
|
private TileSet mTileSet;
|
||||||
@ -247,9 +247,8 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
private final static float[] mDebugPoints = new float[4];
|
private final static float[] mDebugPoints = new float[4];
|
||||||
//private final Matrix4 mMVP = new Matrix4();
|
//private final Matrix4 mMVP = new Matrix4();
|
||||||
|
|
||||||
void addTile(MapTile t) {
|
//void addTile(MapTile t) {
|
||||||
|
//}
|
||||||
}
|
|
||||||
|
|
||||||
private Label addToPool(Label l) {
|
private Label addToPool(Label l) {
|
||||||
TextItem.release(l.item);
|
TextItem.release(l.item);
|
||||||
|
@ -28,7 +28,7 @@ import android.graphics.Color;
|
|||||||
* A RenderTheme defines how ways and nodes are drawn.
|
* A RenderTheme defines how ways and nodes are drawn.
|
||||||
*/
|
*/
|
||||||
public class RenderTheme {
|
public class RenderTheme {
|
||||||
private final static String TAG = RenderTheme.class.getName();
|
//private final static String TAG = RenderTheme.class.getName();
|
||||||
|
|
||||||
private static final int MATCHING_CACHE_SIZE = 512;
|
private static final int MATCHING_CACHE_SIZE = 512;
|
||||||
private static final int RENDER_THEME_VERSION = 1;
|
private static final int RENDER_THEME_VERSION = 1;
|
||||||
@ -88,13 +88,13 @@ public class RenderTheme {
|
|||||||
private final LRUCache<MatchingCacheKey, RenderInstructionItem> mWayCache;
|
private final LRUCache<MatchingCacheKey, RenderInstructionItem> mWayCache;
|
||||||
private final LRUCache<MatchingCacheKey, RenderInstructionItem> mAreaCache;
|
private final LRUCache<MatchingCacheKey, RenderInstructionItem> mAreaCache;
|
||||||
|
|
||||||
private MatchingCacheKey mAreaCacheKey = new MatchingCacheKey();
|
private final MatchingCacheKey mAreaCacheKey = new MatchingCacheKey();
|
||||||
private MatchingCacheKey mWayCacheKey = new MatchingCacheKey();
|
private final MatchingCacheKey mWayCacheKey = new MatchingCacheKey();
|
||||||
private MatchingCacheKey mNodeCacheKey = new MatchingCacheKey();
|
private final MatchingCacheKey mNodeCacheKey = new MatchingCacheKey();
|
||||||
|
|
||||||
private ArrayList<RenderInstruction> mWayInstructionList = new ArrayList<RenderInstruction>(4);
|
private final ArrayList<RenderInstruction> mWayInstructionList = new ArrayList<RenderInstruction>(4);
|
||||||
private ArrayList<RenderInstruction> mAreaInstructionList = new ArrayList<RenderInstruction>(4);
|
private final ArrayList<RenderInstruction> mAreaInstructionList = new ArrayList<RenderInstruction>(4);
|
||||||
private ArrayList<RenderInstruction> mNodeInstructionList = new ArrayList<RenderInstruction>(4);
|
private final ArrayList<RenderInstruction> mNodeInstructionList = new ArrayList<RenderInstruction>(4);
|
||||||
|
|
||||||
private RenderInstructionItem mPrevAreaItem;
|
private RenderInstructionItem mPrevAreaItem;
|
||||||
private RenderInstructionItem mPrevWayItem;
|
private RenderInstructionItem mPrevWayItem;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user