- improve tile locking (use ref counter instead of boolean)
- flip over date line (inserting placeholder tiles in renderer) - make view coordinates consistent with tile coordinates (flip on y-axis)
This commit is contained in:
@@ -65,8 +65,8 @@ public class MapDatabase implements IMapDatabase {
|
||||
private static final String CACHE_FILE = "%d-%d-%d.tile";
|
||||
|
||||
private static final String SERVER_ADDR = "city.informatik.uni-bremen.de";
|
||||
private static final String URL = "/osci/map-live/";
|
||||
// private static final String URL = "/osci/oscim/";
|
||||
// private static final String URL = "/osci/map-live/";
|
||||
private static final String URL = "/osci/oscim/";
|
||||
|
||||
private final static float REF_TILE_SIZE = 4096.0f;
|
||||
|
||||
|
||||
@@ -91,10 +91,13 @@ public class MapDatabase implements IMapDatabase {
|
||||
private static final String CACHE_FILE = "%d-%d-%d.tile";
|
||||
|
||||
private static final String SERVER_ADDR = "city.informatik.uni-bremen.de";
|
||||
// private static final String URL = "http://city.informatik.uni-bremen.de:8020/test/%d/%d/%d.osmtile";
|
||||
// private static final String URL =
|
||||
// "http://city.informatik.uni-bremen.de:8020/test/%d/%d/%d.osmtile";
|
||||
private static final String URL = "http://city.informatik.uni-bremen.de/osmstache/test/%d/%d/%d.osmtile";
|
||||
// private static final String URL = "http://city.informatik.uni-bremen.de/tiles/tiles.py///test/%d/%d/%d.osmtile";
|
||||
// private static final String URL = "http://city.informatik.uni-bremen.de/osmstache/gis2/%d/%d/%d.osmtile";
|
||||
// private static final String URL =
|
||||
// "http://city.informatik.uni-bremen.de/tiles/tiles.py///test/%d/%d/%d.osmtile";
|
||||
// private static final String URL =
|
||||
// "http://city.informatik.uni-bremen.de/osmstache/gis2/%d/%d/%d.osmtile";
|
||||
|
||||
private final static float REF_TILE_SIZE = 4096.0f;
|
||||
|
||||
@@ -360,7 +363,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
return file;
|
||||
}
|
||||
|
||||
// /////////////// hand sewed tile protocol buffers decoder ///////////////////
|
||||
// /////////////// hand sewed tile protocol buffers decoder ////////////////
|
||||
private static final int BUFFER_SIZE = 65536;
|
||||
|
||||
private final byte[] mReadBuffer = new byte[BUFFER_SIZE];
|
||||
@@ -604,7 +607,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
lastY = lat + lastY;
|
||||
|
||||
mMapGenerator.renderPointOfInterest(layer,
|
||||
tags, lastY / scale, lastX / scale);
|
||||
tags, Tile.TILE_SIZE - lastY / scale, lastX / scale);
|
||||
cnt += 2;
|
||||
}
|
||||
return cnt;
|
||||
@@ -800,7 +803,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
} else {
|
||||
y = ((result >>> 1) ^ -(result & 1));
|
||||
lastY = lastY + y;
|
||||
coords[cnt++] = lastY / scale;
|
||||
coords[cnt++] = Tile.TILE_SIZE - lastY / scale;
|
||||
even = true;
|
||||
}
|
||||
}
|
||||
@@ -940,7 +943,8 @@ public class MapDatabase implements IMapDatabase {
|
||||
return result;
|
||||
}
|
||||
|
||||
// ///////////////////////// Lightweight HttpClient ///////////////////////////////////////
|
||||
// ///////////////////////// Lightweight HttpClient
|
||||
// ///////////////////////////////////////
|
||||
// would have written simple tcp server/client for this...
|
||||
|
||||
private int mMaxReq = 0;
|
||||
@@ -1080,7 +1084,8 @@ public class MapDatabase implements IMapDatabase {
|
||||
len += pos;
|
||||
|
||||
// this does the same but with a few more allocations:
|
||||
// byte[] request = String.format(REQUEST, Integer.valueOf(tile.zoomLevel),
|
||||
// byte[] request = String.format(REQUEST,
|
||||
// Integer.valueOf(tile.zoomLevel),
|
||||
// Integer.valueOf(tile.tileX), Integer.valueOf(tile.tileY)).getBytes();
|
||||
|
||||
try {
|
||||
@@ -1138,7 +1143,7 @@ public class MapDatabase implements IMapDatabase {
|
||||
|
||||
}
|
||||
|
||||
// //////////////////////////// Tile cache ////////////////////////////////////
|
||||
// //////////////////////////// Tile cache ///////////////////////////////
|
||||
|
||||
private boolean cacheRead(Tile tile, File f) {
|
||||
if (f.exists() && f.length() > 0) {
|
||||
@@ -1212,7 +1217,10 @@ public class MapDatabase implements IMapDatabase {
|
||||
mCacheFile = null;
|
||||
}
|
||||
|
||||
/* All code below is taken from or based on Google's Protocol Buffers implementation: */
|
||||
/*
|
||||
* All code below is taken from or based on Google's Protocol Buffers
|
||||
* implementation:
|
||||
*/
|
||||
|
||||
// Protocol Buffers - Google's data interchange format
|
||||
// Copyright 2008 Google Inc. All rights reserved.
|
||||
|
||||
@@ -38,6 +38,8 @@ public class MapDatabase implements IMapDatabase {
|
||||
// private Tag[] mTags = { new Tag("boundary", "administrative"), new
|
||||
// Tag("admin_level", "2") };
|
||||
private Tag[] mTags = { new Tag("natural", "water") };
|
||||
private Tag[] mTagsWay = { new Tag("highway", "primary"), new Tag("name", "Highway Rd") };
|
||||
|
||||
private Tag[] mNameTags;
|
||||
|
||||
private final MapInfo mMapInfo =
|
||||
@@ -50,10 +52,12 @@ public class MapDatabase implements IMapDatabase {
|
||||
@Override
|
||||
public QueryResult executeQuery(JobTile tile, IMapDatabaseCallback mapDatabaseCallback) {
|
||||
|
||||
float lat1 = -0.5f;
|
||||
float lon1 = -0.5f;
|
||||
float lat2 = Tile.TILE_SIZE + 0.5f;
|
||||
float lon2 = Tile.TILE_SIZE + 0.5f;
|
||||
int size = Tile.TILE_SIZE;
|
||||
|
||||
float lat1 = -1;
|
||||
float lon1 = -1;
|
||||
float lat2 = size + 1;
|
||||
float lon2 = size + 1;
|
||||
|
||||
mCoords[0] = lon1;
|
||||
mCoords[1] = lat1;
|
||||
@@ -70,13 +74,13 @@ public class MapDatabase implements IMapDatabase {
|
||||
mCoords[8] = lon1;
|
||||
mCoords[9] = lat1;
|
||||
|
||||
mIndex[0] = 8;
|
||||
mIndex[1] = 2;
|
||||
mIndex[0] = 10;
|
||||
mIndex[1] = 0;
|
||||
|
||||
lon1 = 40;
|
||||
lon2 = Tile.TILE_SIZE - 40;
|
||||
lon2 = size - 40;
|
||||
lat1 = 40;
|
||||
lat2 = Tile.TILE_SIZE - 40;
|
||||
lat2 = size - 40;
|
||||
|
||||
mCoords[10] = lon1;
|
||||
mCoords[11] = lat1;
|
||||
@@ -93,19 +97,84 @@ public class MapDatabase implements IMapDatabase {
|
||||
mCoords[18] = lon1;
|
||||
mCoords[19] = lat1;
|
||||
|
||||
mIndex[2] = 8;
|
||||
mIndex[3] = 2;
|
||||
mIndex[2] = 10;
|
||||
mIndex[3] = 0;
|
||||
|
||||
mapDatabaseCallback.renderWay((byte) 0, mTags, mCoords, mIndex, true);
|
||||
|
||||
lon1 = Tile.TILE_SIZE / 2;
|
||||
lat1 = Tile.TILE_SIZE / 2;
|
||||
mIndex[0] = 4;
|
||||
mIndex[1] = -1;
|
||||
|
||||
mNameTags = new Tag[2];
|
||||
mNameTags[0] = new Tag("place", "city");
|
||||
mNameTags[1] = new Tag("name", tile.toString());
|
||||
mapDatabaseCallback.renderPointOfInterest((byte) 0, mNameTags, (int) lat1,
|
||||
(int) lon1);
|
||||
// middle horizontal
|
||||
mCoords[0] = 0;
|
||||
mCoords[1] = size / 2;
|
||||
mCoords[2] = size;
|
||||
mCoords[3] = size / 2;
|
||||
Tag[] tags = new Tag[2];
|
||||
tags[0] = mTagsWay[0];
|
||||
tags[1] = mTagsWay[1];
|
||||
mapDatabaseCallback.renderWay((byte) 0, tags, mCoords, mIndex, false);
|
||||
|
||||
// center up
|
||||
mCoords[0] = size / 2;
|
||||
mCoords[1] = -size / 2;
|
||||
mCoords[2] = size / 2;
|
||||
mCoords[3] = size / 2;
|
||||
tags = new Tag[2];
|
||||
tags[0] = mTagsWay[0];
|
||||
tags[1] = mTagsWay[1];
|
||||
mapDatabaseCallback.renderWay((byte) 0, tags, mCoords, mIndex,
|
||||
false);
|
||||
|
||||
// center down
|
||||
mCoords[0] = size / 2;
|
||||
mCoords[1] = size / 2;
|
||||
mCoords[2] = size / 2;
|
||||
mCoords[3] = size / 2 + size;
|
||||
tags = new Tag[2];
|
||||
tags[0] = mTagsWay[0];
|
||||
tags[1] = mTagsWay[1];
|
||||
mapDatabaseCallback.renderWay((byte) 0, tags, mCoords, mIndex, false);
|
||||
|
||||
// left-top to center
|
||||
mCoords[0] = size / 2;
|
||||
mCoords[1] = size / 2;
|
||||
mCoords[2] = 10;
|
||||
mCoords[3] = 10;
|
||||
tags = new Tag[2];
|
||||
tags[0] = mTagsWay[0];
|
||||
tags[1] = mTagsWay[1];
|
||||
mapDatabaseCallback.renderWay((byte) 1, tags, mCoords, mIndex, false);
|
||||
|
||||
// middle horizontal
|
||||
mCoords[0] = 0;
|
||||
mCoords[1] = 10;
|
||||
mCoords[2] = size;
|
||||
mCoords[3] = 10;
|
||||
tags = new Tag[2];
|
||||
tags[0] = mTagsWay[0];
|
||||
tags[1] = mTagsWay[1];
|
||||
mapDatabaseCallback.renderWay((byte) 1, tags, mCoords, mIndex, false);
|
||||
|
||||
// middle horizontal
|
||||
mCoords[0] = 10;
|
||||
mCoords[1] = 0;
|
||||
mCoords[2] = 10;
|
||||
mCoords[3] = size;
|
||||
tags = new Tag[2];
|
||||
tags[0] = mTagsWay[0];
|
||||
tags[1] = mTagsWay[1];
|
||||
mapDatabaseCallback.renderWay((byte) 1, tags, mCoords, mIndex, false);
|
||||
|
||||
// lon1 = size / 2;
|
||||
// lat1 = size / 2;
|
||||
|
||||
// mNameTags = new Tag[2];
|
||||
// mNameTags[0] = new Tag("place", "city");
|
||||
// mNameTags[1] = new Tag("name", tile.toString());
|
||||
// mapDatabaseCallback.renderPointOfInterest((byte) 0, mNameTags, (int)
|
||||
// lat1,
|
||||
// (int) lon1);
|
||||
|
||||
return QueryResult.SUCCESS;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user