rename Tile.TILE_SIZE to Tile.SIZE, while I'm at refactoring
This commit is contained in:
parent
8e01dce85e
commit
491e41becc
@ -57,7 +57,7 @@ public final class MercatorProjection {
|
|||||||
*/
|
*/
|
||||||
public static double calculateGroundResolution(double latitude, int zoomLevel) {
|
public static double calculateGroundResolution(double latitude, int zoomLevel) {
|
||||||
return Math.cos(latitude * (Math.PI / 180)) * EARTH_CIRCUMFERENCE
|
return Math.cos(latitude * (Math.PI / 180)) * EARTH_CIRCUMFERENCE
|
||||||
/ ((long) Tile.TILE_SIZE << zoomLevel);
|
/ ((long) Tile.SIZE << zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,7 +130,7 @@ public final class MercatorProjection {
|
|||||||
* @return the longitude value of the pixel X coordinate.
|
* @return the longitude value of the pixel X coordinate.
|
||||||
*/
|
*/
|
||||||
public static double pixelXToLongitude(double pixelX, int zoomLevel) {
|
public static double pixelXToLongitude(double pixelX, int zoomLevel) {
|
||||||
return 360 * ((pixelX / ((long) Tile.TILE_SIZE << zoomLevel)) - 0.5);
|
return 360 * ((pixelX / ((long) Tile.SIZE << zoomLevel)) - 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,7 +144,7 @@ public final class MercatorProjection {
|
|||||||
* @return the pixel X coordinate of the longitude value.
|
* @return the pixel X coordinate of the longitude value.
|
||||||
*/
|
*/
|
||||||
public static double longitudeToPixelX(double longitude, int zoomLevel) {
|
public static double longitudeToPixelX(double longitude, int zoomLevel) {
|
||||||
return (longitude + 180) / 360 * ((long) Tile.TILE_SIZE << zoomLevel);
|
return (longitude + 180) / 360 * ((long) Tile.SIZE << zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +158,7 @@ public final class MercatorProjection {
|
|||||||
* @return the latitude value of the pixel Y coordinate.
|
* @return the latitude value of the pixel Y coordinate.
|
||||||
*/
|
*/
|
||||||
public static double pixelYToLatitude(double pixelY, int zoomLevel) {
|
public static double pixelYToLatitude(double pixelY, int zoomLevel) {
|
||||||
double y = 0.5 - (pixelY / ((long) Tile.TILE_SIZE << zoomLevel));
|
double y = 0.5 - (pixelY / ((long) Tile.SIZE << zoomLevel));
|
||||||
return 90 - 360 * Math.atan(Math.exp(-y * (2 * Math.PI))) / Math.PI;
|
return 90 - 360 * Math.atan(Math.exp(-y * (2 * Math.PI))) / Math.PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ public final class MercatorProjection {
|
|||||||
public static double latitudeToPixelY(double latitude, int zoomLevel) {
|
public static double latitudeToPixelY(double latitude, int zoomLevel) {
|
||||||
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
|
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
|
||||||
return (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI))
|
return (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI))
|
||||||
* ((long) Tile.TILE_SIZE << zoomLevel);
|
* ((long) Tile.SIZE << zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MercatorProjection() {
|
private MercatorProjection() {
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class Tile {
|
|||||||
/**
|
/**
|
||||||
* Width and height of a map tile in pixel.
|
* Width and height of a map tile in pixel.
|
||||||
*/
|
*/
|
||||||
public static int TILE_SIZE = 256;
|
public static int SIZE = 256;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The X number of this tile.
|
* The X number of this tile.
|
||||||
|
|||||||
@ -63,7 +63,7 @@ public class WebMercator {
|
|||||||
* @return ...
|
* @return ...
|
||||||
*/
|
*/
|
||||||
public static double PixelYtoSphericalMercator(long pixelY, byte z) {
|
public static double PixelYtoSphericalMercator(long pixelY, byte z) {
|
||||||
long half = (Tile.TILE_SIZE << z) >> 1;
|
long half = (Tile.SIZE << z) >> 1;
|
||||||
return ((half - pixelY) / (double) half) * f900913;
|
return ((half - pixelY) / (double) half) * f900913;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class WebMercator {
|
|||||||
* @return ...
|
* @return ...
|
||||||
*/
|
*/
|
||||||
public static double PixelXtoSphericalMercator(long pixelX, byte z) {
|
public static double PixelXtoSphericalMercator(long pixelX, byte z) {
|
||||||
long half = (Tile.TILE_SIZE << z) >> 1;
|
long half = (Tile.SIZE << z) >> 1;
|
||||||
return ((pixelX - half) / (double) half) * f900913;
|
return ((pixelX - half) / (double) half) * f900913;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -591,9 +591,9 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
Tag[] tags = null;
|
Tag[] tags = null;
|
||||||
Tag[] curTags;
|
Tag[] curTags;
|
||||||
|
|
||||||
long x = mTile.tileX * Tile.TILE_SIZE;
|
long x = mTile.tileX * Tile.SIZE;
|
||||||
long y = mTile.tileY * Tile.TILE_SIZE + Tile.TILE_SIZE;
|
long y = mTile.tileY * Tile.SIZE + Tile.SIZE;
|
||||||
long z = Tile.TILE_SIZE << mTile.zoomLevel;
|
long z = Tile.SIZE << mTile.zoomLevel;
|
||||||
|
|
||||||
long dx = (x - (z >> 1));
|
long dx = (x - (z >> 1));
|
||||||
long dy = (y - (z >> 1));
|
long dy = (y - (z >> 1));
|
||||||
@ -1055,9 +1055,9 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
|
|
||||||
private boolean projectToTile(float[] coords, short[] indices) {
|
private boolean projectToTile(float[] coords, short[] indices) {
|
||||||
|
|
||||||
long x = mTile.tileX * Tile.TILE_SIZE;
|
long x = mTile.tileX * Tile.SIZE;
|
||||||
long y = mTile.tileY * Tile.TILE_SIZE + Tile.TILE_SIZE;
|
long y = mTile.tileY * Tile.SIZE + Tile.SIZE;
|
||||||
long z = Tile.TILE_SIZE << mTile.zoomLevel;
|
long z = Tile.SIZE << mTile.zoomLevel;
|
||||||
|
|
||||||
double divx, divy = 0;
|
double divx, divy = 0;
|
||||||
long dx = (x - (z >> 1));
|
long dx = (x - (z >> 1));
|
||||||
@ -1081,7 +1081,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
|
|
||||||
lon = (float) ((coords[pos]) / divx - dx);
|
lon = (float) ((coords[pos]) / divx - dx);
|
||||||
double sinLat = Math.sin(coords[pos + 1] * PI180);
|
double sinLat = Math.sin(coords[pos + 1] * PI180);
|
||||||
lat = (float) (Tile.TILE_SIZE - (Math.log((1.0 + sinLat) / (1.0 - sinLat)) * divy + dy));
|
lat = (float) (Tile.SIZE - (Math.log((1.0 + sinLat) / (1.0 - sinLat)) * divy + dy));
|
||||||
|
|
||||||
if (cnt != 0) {
|
if (cnt != 0) {
|
||||||
// drop small distance intermediate nodes
|
// drop small distance intermediate nodes
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class Projection {
|
|||||||
* @return the longitude value of the tile X number.
|
* @return the longitude value of the tile X number.
|
||||||
*/
|
*/
|
||||||
public static double tileXToLongitude(long tileX, int zoomLevel) {
|
public static double tileXToLongitude(long tileX, int zoomLevel) {
|
||||||
return MercatorProjection.pixelXToLongitude(tileX * Tile.TILE_SIZE, zoomLevel);
|
return MercatorProjection.pixelXToLongitude(tileX * Tile.SIZE, zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +45,7 @@ public class Projection {
|
|||||||
* @return the latitude value of the tile Y number.
|
* @return the latitude value of the tile Y number.
|
||||||
*/
|
*/
|
||||||
public static double tileYToLatitude(long tileY, int zoomLevel) {
|
public static double tileYToLatitude(long tileY, int zoomLevel) {
|
||||||
return MercatorProjection.pixelYToLatitude(tileY * Tile.TILE_SIZE, zoomLevel);
|
return MercatorProjection.pixelYToLatitude(tileY * Tile.SIZE, zoomLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +86,7 @@ public class Projection {
|
|||||||
* @return the tile X number.
|
* @return the tile X number.
|
||||||
*/
|
*/
|
||||||
public static int pixelXToTileX(double pixelX, int zoomLevel) {
|
public static int pixelXToTileX(double pixelX, int zoomLevel) {
|
||||||
return (int) Math.min(Math.max(pixelX / Tile.TILE_SIZE, 0),
|
return (int) Math.min(Math.max(pixelX / Tile.SIZE, 0),
|
||||||
Math.pow(2, zoomLevel) - 1);
|
Math.pow(2, zoomLevel) - 1);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -99,7 +99,7 @@ public class Projection {
|
|||||||
* @return the tile Y number.
|
* @return the tile Y number.
|
||||||
*/
|
*/
|
||||||
public static int pixelYToTileY(double pixelY, int zoomLevel) {
|
public static int pixelYToTileY(double pixelY, int zoomLevel) {
|
||||||
return (int) Math.min(Math.max(pixelY / Tile.TILE_SIZE, 0),
|
return (int) Math.min(Math.max(pixelY / Tile.SIZE, 0),
|
||||||
Math.pow(2, zoomLevel) - 1);
|
Math.pow(2, zoomLevel) - 1);
|
||||||
}
|
}
|
||||||
private Projection(){
|
private Projection(){
|
||||||
|
|||||||
@ -205,7 +205,7 @@ final class RequiredFields {
|
|||||||
static OpenResult readTilePixelSize(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) {
|
static OpenResult readTilePixelSize(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) {
|
||||||
// get and check the tile pixel size (2 bytes)
|
// get and check the tile pixel size (2 bytes)
|
||||||
int tilePixelSize = readBuffer.readShort();
|
int tilePixelSize = readBuffer.readShort();
|
||||||
// if (tilePixelSize != Tile.TILE_SIZE) {
|
// if (tilePixelSize != Tile.SIZE) {
|
||||||
// return new FileOpenResult("unsupported tile pixel size: " + tilePixelSize);
|
// return new FileOpenResult("unsupported tile pixel size: " + tilePixelSize);
|
||||||
// }
|
// }
|
||||||
mapFileInfoBuilder.tilePixelSize = tilePixelSize;
|
mapFileInfoBuilder.tilePixelSize = tilePixelSize;
|
||||||
|
|||||||
@ -86,7 +86,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
mMapGenerator = mapDatabaseCallback;
|
mMapGenerator = mapDatabaseCallback;
|
||||||
|
|
||||||
// scale coordinates to tile size
|
// scale coordinates to tile size
|
||||||
mScaleFactor = REF_TILE_SIZE / Tile.TILE_SIZE;
|
mScaleFactor = REF_TILE_SIZE / Tile.SIZE;
|
||||||
|
|
||||||
File f = null;
|
File f = null;
|
||||||
|
|
||||||
|
|||||||
@ -130,7 +130,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
mCurTagCnt = 0;
|
mCurTagCnt = 0;
|
||||||
|
|
||||||
// scale coordinates to tile size
|
// scale coordinates to tile size
|
||||||
mScaleFactor = REF_TILE_SIZE / Tile.TILE_SIZE;
|
mScaleFactor = REF_TILE_SIZE / Tile.SIZE;
|
||||||
|
|
||||||
File f = null;
|
File f = null;
|
||||||
|
|
||||||
@ -532,7 +532,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
lastX = lon + lastX;
|
lastX = lon + lastX;
|
||||||
lastY = lat + lastY;
|
lastY = lat + lastY;
|
||||||
coords[cnt++] = lastX / scale;
|
coords[cnt++] = lastX / scale;
|
||||||
coords[cnt++] = Tile.TILE_SIZE - lastY / scale;
|
coords[cnt++] = Tile.SIZE - lastY / scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGeom.index[0] = (short)numNodes;
|
mGeom.index[0] = (short)numNodes;
|
||||||
@ -722,7 +722,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
} else {
|
} else {
|
||||||
y = ((result >>> 1) ^ -(result & 1));
|
y = ((result >>> 1) ^ -(result & 1));
|
||||||
lastY = lastY + y;
|
lastY = lastY + y;
|
||||||
coords[cnt++] = Tile.TILE_SIZE - lastY / scale;
|
coords[cnt++] = Tile.SIZE - lastY / scale;
|
||||||
even = true;
|
even = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class MapDatabase implements IMapDatabase {
|
|||||||
@Override
|
@Override
|
||||||
public QueryResult executeQuery(JobTile tile, IMapDatabaseCallback mapDatabaseCallback) {
|
public QueryResult executeQuery(JobTile tile, IMapDatabaseCallback mapDatabaseCallback) {
|
||||||
|
|
||||||
int size = Tile.TILE_SIZE;
|
int size = Tile.SIZE;
|
||||||
float[] points = mGeom.points;
|
float[] points = mGeom.points;
|
||||||
short[] index = mGeom.index;
|
short[] index = mGeom.index;
|
||||||
|
|
||||||
|
|||||||
@ -71,14 +71,14 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
private static final Tag[] debugTagArea = { new Tag("debug", "area") };
|
private static final Tag[] debugTagArea = { new Tag("debug", "area") };
|
||||||
|
|
||||||
private final GeometryBuffer mDebugPoint = new GeometryBuffer(
|
private final GeometryBuffer mDebugPoint = new GeometryBuffer(
|
||||||
new float[] { Tile.TILE_SIZE >> 1, 10 },
|
new float[] { Tile.SIZE >> 1, 10 },
|
||||||
new short[] { 2 });
|
new short[] { 2 });
|
||||||
|
|
||||||
private final WayData mDebugWay = new WayData(
|
private final WayData mDebugWay = new WayData(
|
||||||
new GeometryBuffer(
|
new GeometryBuffer(
|
||||||
new float[] { 0, 0, 0, Tile.TILE_SIZE,
|
new float[] { 0, 0, 0, Tile.SIZE,
|
||||||
Tile.TILE_SIZE, Tile.TILE_SIZE,
|
Tile.SIZE, Tile.SIZE,
|
||||||
Tile.TILE_SIZE, 0, 0, 0 },
|
Tile.SIZE, 0, 0, 0 },
|
||||||
new short[] {10}),
|
new short[] {10}),
|
||||||
new Tag[] { new Tag("debug", "box") }
|
new Tag[] { new Tag("debug", "box") }
|
||||||
);
|
);
|
||||||
@ -127,7 +127,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public TileGenerator() {
|
public TileGenerator() {
|
||||||
mClipper = new LineClipper(0, 0, Tile.TILE_SIZE, Tile.TILE_SIZE, true);
|
mClipper = new LineClipper(0, 0, Tile.SIZE, Tile.SIZE, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup() {
|
public void cleanup() {
|
||||||
@ -156,7 +156,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
|||||||
|
|
||||||
mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180))
|
mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180))
|
||||||
* MercatorProjection.EARTH_CIRCUMFERENCE
|
* MercatorProjection.EARTH_CIRCUMFERENCE
|
||||||
/ ((long) Tile.TILE_SIZE << mTile.zoomLevel));
|
/ ((long) Tile.SIZE << mTile.zoomLevel));
|
||||||
|
|
||||||
mTile.layers = new Layers();
|
mTile.layers = new Layers();
|
||||||
|
|
||||||
|
|||||||
@ -31,10 +31,10 @@ public final class WayDecorator {
|
|||||||
|
|
||||||
// calculate the way name length plus some margin of safety
|
// calculate the way name length plus some margin of safety
|
||||||
float wayNameWidth = -1;
|
float wayNameWidth = -1;
|
||||||
float minWidth = Tile.TILE_SIZE / 10;
|
float minWidth = Tile.SIZE / 10;
|
||||||
|
|
||||||
final int min = 0;
|
final int min = 0;
|
||||||
final int max = Tile.TILE_SIZE;
|
final int max = Tile.SIZE;
|
||||||
|
|
||||||
// find way segments long enough to draw the way name on them
|
// find way segments long enough to draw the way name on them
|
||||||
for (int i = pos; i < pos + len - 2; i += 2) {
|
for (int i = pos; i < pos + len - 2; i += 2) {
|
||||||
|
|||||||
@ -105,8 +105,8 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
|||||||
int z = FastMath.log2((int) curPos.scale);
|
int z = FastMath.log2((int) curPos.scale);
|
||||||
int diff = MAX_ZOOM - z;
|
int diff = MAX_ZOOM - z;
|
||||||
|
|
||||||
int mx = (int) (curPos.x * (Tile.TILE_SIZE << z));
|
int mx = (int) (curPos.x * (Tile.SIZE << z));
|
||||||
int my = (int) (curPos.y * (Tile.TILE_SIZE << z));
|
int my = (int) (curPos.y * (Tile.SIZE << z));
|
||||||
|
|
||||||
// limit could be 1 if we update on every position change
|
// limit could be 1 if we update on every position change
|
||||||
float limit = 1.5f;
|
float limit = 1.5f;
|
||||||
|
|||||||
@ -124,8 +124,8 @@ public class PathOverlay extends Overlay {
|
|||||||
//int z = curPos.zoomLevel;
|
//int z = curPos.zoomLevel;
|
||||||
int z = FastMath.log2((int) curPos.scale);
|
int z = FastMath.log2((int) curPos.scale);
|
||||||
int diff = MAX_ZOOM - z;
|
int diff = MAX_ZOOM - z;
|
||||||
int mx = (int) (curPos.x * (Tile.TILE_SIZE << z));
|
int mx = (int) (curPos.x * (Tile.SIZE << z));
|
||||||
int my = (int) (curPos.y * (Tile.TILE_SIZE << z));
|
int my = (int) (curPos.y * (Tile.SIZE << z));
|
||||||
|
|
||||||
for (int j = 0; j < size; j += 2) {
|
for (int j = 0; j < size; j += 2) {
|
||||||
// TODO translate mapPosition and do this after clipping
|
// TODO translate mapPosition and do this after clipping
|
||||||
|
|||||||
@ -190,7 +190,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
|
|
||||||
// tile fill coords
|
// tile fill coords
|
||||||
short min = 0;
|
short min = 0;
|
||||||
short max = (short) ((Tile.TILE_SIZE * COORD_SCALE));
|
short max = (short) ((Tile.SIZE * COORD_SCALE));
|
||||||
mFillCoords = new short[8];
|
mFillCoords = new short[8];
|
||||||
mFillCoords[0] = min;
|
mFillCoords[0] = min;
|
||||||
mFillCoords[1] = max;
|
mFillCoords[1] = max;
|
||||||
@ -318,8 +318,8 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
|
|
||||||
int z = tiles[0].zoomLevel;
|
int z = tiles[0].zoomLevel;
|
||||||
|
|
||||||
double curScale = Tile.TILE_SIZE * pos.scale;
|
double curScale = Tile.SIZE * pos.scale;
|
||||||
double tileScale = Tile.TILE_SIZE * (pos.scale / (1 << z));
|
double tileScale = Tile.SIZE * (pos.scale / (1 << z));
|
||||||
|
|
||||||
for (int i = 0; i < 8; i += 2) {
|
for (int i = 0; i < 8; i += 2) {
|
||||||
coords[i + 0] = (float) ((pos.x * curScale + coords[i + 0]) / tileScale);
|
coords[i + 0] = (float) ((pos.x * curScale + coords[i + 0]) / tileScale);
|
||||||
@ -622,8 +622,8 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
mBufferMemoryUsage = 0;
|
mBufferMemoryUsage = 0;
|
||||||
mDrawTiles = null;
|
mDrawTiles = null;
|
||||||
|
|
||||||
int numTiles = (screenWidth / (Tile.TILE_SIZE / 2) + 2)
|
int numTiles = (screenWidth / (Tile.SIZE / 2) + 2)
|
||||||
* (screenHeight / (Tile.TILE_SIZE / 2) + 2);
|
* (screenHeight / (Tile.SIZE / 2) + 2);
|
||||||
|
|
||||||
// Set up vertex buffer objects
|
// Set up vertex buffer objects
|
||||||
int numVBO = (CACHE_TILES + (numTiles * 2));
|
int numVBO = (CACHE_TILES + (numTiles * 2));
|
||||||
|
|||||||
@ -135,7 +135,7 @@ public class TileManager {
|
|||||||
|
|
||||||
// set up TileSet large enough to hold current tiles
|
// set up TileSet large enough to hold current tiles
|
||||||
int num = Math.max(width, height);
|
int num = Math.max(width, height);
|
||||||
int size = Tile.TILE_SIZE >> 1;
|
int size = Tile.SIZE >> 1;
|
||||||
int numTiles = (num * num) / (size * size) * 4;
|
int numTiles = (num * num) / (size * size) * 4;
|
||||||
mNewTiles = new TileSet(numTiles);
|
mNewTiles = new TileSet(numTiles);
|
||||||
mCurrentTiles = new TileSet(numTiles);
|
mCurrentTiles = new TileSet(numTiles);
|
||||||
@ -166,7 +166,7 @@ public class TileManager {
|
|||||||
// scale and translate projection to tile coordinates
|
// scale and translate projection to tile coordinates
|
||||||
// load some tiles more than currently visible (* 0.75)
|
// load some tiles more than currently visible (* 0.75)
|
||||||
// float scale = mapPosition.scale * 0.75f;
|
// float scale = mapPosition.scale * 0.75f;
|
||||||
// float tileScale = scale * Tile.TILE_SIZE;
|
// float tileScale = scale * Tile.SIZE;
|
||||||
// double px = mapPosition.x * scale;
|
// double px = mapPosition.x * scale;
|
||||||
// double py = mapPosition.y * scale;
|
// double py = mapPosition.y * scale;
|
||||||
//
|
//
|
||||||
@ -180,10 +180,10 @@ public class TileManager {
|
|||||||
// scale and translate projection to tile coordinates
|
// scale and translate projection to tile coordinates
|
||||||
// load some tiles more than currently visible (* 0.75)
|
// load some tiles more than currently visible (* 0.75)
|
||||||
double scale = pos.scale * 0.75f;
|
double scale = pos.scale * 0.75f;
|
||||||
double curScale = Tile.TILE_SIZE * scale;
|
double curScale = Tile.SIZE * scale;
|
||||||
int zoomLevel = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, MAX_ZOOMLEVEL);
|
int zoomLevel = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, MAX_ZOOMLEVEL);
|
||||||
|
|
||||||
double tileScale = Tile.TILE_SIZE * (scale / (1 << zoomLevel));
|
double tileScale = Tile.SIZE * (scale / (1 << zoomLevel));
|
||||||
|
|
||||||
float[] coords = mTileCoords;
|
float[] coords = mTileCoords;
|
||||||
mMapViewPosition.getMapViewProjection(coords);
|
mMapViewPosition.getMapViewProjection(coords);
|
||||||
|
|||||||
@ -125,7 +125,7 @@ public class TileRenderer {
|
|||||||
|
|
||||||
float div = FastMath.pow(z - pos.zoomLevel);
|
float div = FastMath.pow(z - pos.zoomLevel);
|
||||||
|
|
||||||
double curScale = Tile.TILE_SIZE * pos.scale;
|
double curScale = Tile.SIZE * pos.scale;
|
||||||
double scale = (pos.scale / (1 << z));
|
double scale = (pos.scale / (1 << z));
|
||||||
|
|
||||||
float x = (float) ((tile.x - pos.x) * curScale);
|
float x = (float) ((tile.x - pos.x) * curScale);
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class ExtrusionLayer extends Layer {
|
|||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
mIndices[i] = mCurIndices[i] = VertexPool.get();
|
mIndices[i] = mCurIndices[i] = VertexPool.get();
|
||||||
|
|
||||||
mClipper = new LineClipper(0, 0, Tile.TILE_SIZE, Tile.TILE_SIZE);
|
mClipper = new LineClipper(0, 0, Tile.SIZE, Tile.SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBuildings(WayData way) {
|
public void addBuildings(WayData way) {
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public final class LineLayer extends Layer {
|
|||||||
float x, y, nextX, nextY;
|
float x, y, nextX, nextY;
|
||||||
float a, ux, uy, vx, vy, wx, wy;
|
float a, ux, uy, vx, vy, wx, wy;
|
||||||
|
|
||||||
int tmax = Tile.TILE_SIZE + 4;
|
int tmax = Tile.SIZE + 4;
|
||||||
int tmin = -4;
|
int tmin = -4;
|
||||||
|
|
||||||
boolean rounded = false;
|
boolean rounded = false;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ public final class PolygonLayer extends Layer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPolygon(float[] points, short[] index) {
|
public void addPolygon(float[] points, short[] index) {
|
||||||
short center = (short) ((Tile.TILE_SIZE >> 1) * S);
|
short center = (short) ((Tile.SIZE >> 1) * S);
|
||||||
|
|
||||||
VertexPoolItem si = curItem;
|
VertexPoolItem si = curItem;
|
||||||
short[] v = si.vertices;
|
short[] v = si.vertices;
|
||||||
|
|||||||
@ -326,7 +326,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
|||||||
MapTile tile, int delta) {
|
MapTile tile, int delta) {
|
||||||
|
|
||||||
int z = tile.zoomLevel;
|
int z = tile.zoomLevel;
|
||||||
double curScale = Tile.TILE_SIZE * pos.scale;
|
double curScale = Tile.SIZE * pos.scale;
|
||||||
float scale = (float)(pos.scale / (1 << z));
|
float scale = (float)(pos.scale / (1 << z));
|
||||||
|
|
||||||
float x = (float) ((tile.x - pos.x) * curScale);
|
float x = (float) ((tile.x - pos.x) * curScale);
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class GridOverlay extends BasicOverlay {
|
|||||||
public GridOverlay(MapView mapView) {
|
public GridOverlay(MapView mapView) {
|
||||||
super(mapView);
|
super(mapView);
|
||||||
|
|
||||||
int size = Tile.TILE_SIZE;
|
int size = Tile.SIZE;
|
||||||
float[] points = new float[64];
|
float[] points = new float[64];
|
||||||
short[] index = new short[16];
|
short[] index = new short[16];
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public class GridOverlay extends BasicOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addLabels(int x, int y, int z) {
|
private void addLabels(int x, int y, int z) {
|
||||||
int size = Tile.TILE_SIZE;
|
int size = Tile.SIZE;
|
||||||
|
|
||||||
TextLayer tl = new TextLayer();
|
TextLayer tl = new TextLayer();
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@ public abstract class RenderOverlay {
|
|||||||
protected void setMatrix(MapPosition curPos, Matrices m, boolean project) {
|
protected void setMatrix(MapPosition curPos, Matrices m, boolean project) {
|
||||||
MapPosition oPos = mMapPosition;
|
MapPosition oPos = mMapPosition;
|
||||||
|
|
||||||
double tileScale = Tile.TILE_SIZE * curPos.scale;
|
double tileScale = Tile.SIZE * curPos.scale;
|
||||||
|
|
||||||
double x = oPos.x - curPos.x;
|
double x = oPos.x - curPos.x;
|
||||||
double y = oPos.y - curPos.y;
|
double y = oPos.y - curPos.y;
|
||||||
|
|||||||
@ -113,8 +113,8 @@ public class TestOverlay extends BasicOverlay {
|
|||||||
// TextItem ti = new TextItem(0, 0, "check one, check two", t);
|
// TextItem ti = new TextItem(0, 0, "check one, check two", t);
|
||||||
// ti.x1 = 0;
|
// ti.x1 = 0;
|
||||||
// ti.y1 = 0;
|
// ti.y1 = 0;
|
||||||
// ti.x2 = (short) Tile.TILE_SIZE;
|
// ti.x2 = (short) Tile.SIZE;
|
||||||
// ti.y2 = (short) Tile.TILE_SIZE;
|
// ti.y2 = (short) Tile.SIZE;
|
||||||
//
|
//
|
||||||
// tl.addText(ti);
|
// tl.addText(ti);
|
||||||
//
|
//
|
||||||
|
|||||||
@ -306,8 +306,8 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
mMapViewPosition.getMapViewProjection(coords);
|
mMapViewPosition.getMapViewProjection(coords);
|
||||||
//mMapViewPosition.getMatrix(null, null, mMVP);
|
//mMapViewPosition.getMatrix(null, null, mMVP);
|
||||||
}
|
}
|
||||||
int mw = (mMapView.getWidth() + Tile.TILE_SIZE) / 2;
|
int mw = (mMapView.getWidth() + Tile.SIZE) / 2;
|
||||||
int mh = (mMapView.getHeight() + Tile.TILE_SIZE) / 2;
|
int mh = (mMapView.getHeight() + Tile.SIZE) / 2;
|
||||||
mSquareRadius = mw * mw + mh * mh;
|
mSquareRadius = mw * mw + mh * mh;
|
||||||
|
|
||||||
// mTiles might be from another zoomlevel than the current:
|
// mTiles might be from another zoomlevel than the current:
|
||||||
@ -328,7 +328,7 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
float cos = (float) Math.cos(angle);
|
float cos = (float) Math.cos(angle);
|
||||||
float sin = (float) Math.sin(angle);
|
float sin = (float) Math.sin(angle);
|
||||||
|
|
||||||
int maxx = Tile.TILE_SIZE << (pos.zoomLevel - 1);
|
int maxx = Tile.SIZE << (pos.zoomLevel - 1);
|
||||||
|
|
||||||
Label l = null;
|
Label l = null;
|
||||||
|
|
||||||
@ -337,8 +337,8 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
|
|
||||||
mRelabelCnt++;
|
mRelabelCnt++;
|
||||||
|
|
||||||
double tileX = (pos.x * (Tile.TILE_SIZE << pos.zoomLevel));
|
double tileX = (pos.x * (Tile.SIZE << pos.zoomLevel));
|
||||||
double tileY = (pos.y * (Tile.TILE_SIZE << pos.zoomLevel));
|
double tileY = (pos.y * (Tile.SIZE << pos.zoomLevel));
|
||||||
|
|
||||||
for (l = mPrevLabels; l != null;) {
|
for (l = mPrevLabels; l != null;) {
|
||||||
|
|
||||||
@ -355,8 +355,8 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dx = (float) (l.tile.tileX * Tile.TILE_SIZE - tileX * s);
|
float dx = (float) (l.tile.tileX * Tile.SIZE - tileX * s);
|
||||||
float dy = (float) (l.tile.tileY * Tile.TILE_SIZE - tileY * s);
|
float dy = (float) (l.tile.tileY * Tile.SIZE - tileY * s);
|
||||||
|
|
||||||
// flip around date-line
|
// flip around date-line
|
||||||
if (dx > maxx)
|
if (dx > maxx)
|
||||||
@ -412,8 +412,8 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
if (t.state != JobTile.STATE_READY)
|
if (t.state != JobTile.STATE_READY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float dx = (float) (t.tileX * Tile.TILE_SIZE - tileX);
|
float dx = (float) (t.tileX * Tile.SIZE - tileX);
|
||||||
float dy = (float) (t.tileY * Tile.TILE_SIZE - tileY);
|
float dy = (float) (t.tileY * Tile.SIZE - tileY);
|
||||||
|
|
||||||
// flip around date-line
|
// flip around date-line
|
||||||
if (dx > maxx)
|
if (dx > maxx)
|
||||||
@ -479,8 +479,8 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
if (t.state != JobTile.STATE_READY)
|
if (t.state != JobTile.STATE_READY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float dx = (float) (t.tileX * Tile.TILE_SIZE - tileX);
|
float dx = (float) (t.tileX * Tile.SIZE - tileX);
|
||||||
float dy = (float) (t.tileY * Tile.TILE_SIZE - tileY);
|
float dy = (float) (t.tileY * Tile.SIZE - tileY);
|
||||||
|
|
||||||
// flip around date-line
|
// flip around date-line
|
||||||
if (dx > maxx)
|
if (dx > maxx)
|
||||||
@ -726,7 +726,7 @@ public class TextOverlay extends BasicOverlay {
|
|||||||
protected void setMatrix(MapPosition curPos, Matrices m) {
|
protected void setMatrix(MapPosition curPos, Matrices m) {
|
||||||
MapPosition oPos = mMapPosition;
|
MapPosition oPos = mMapPosition;
|
||||||
|
|
||||||
double tileScale = Tile.TILE_SIZE * curPos.scale;
|
double tileScale = Tile.SIZE * curPos.scale;
|
||||||
double scale = (curPos.scale / oPos.scale);
|
double scale = (curPos.scale / oPos.scale);
|
||||||
|
|
||||||
float x = (float) ((oPos.x - curPos.x) * tileScale);
|
float x = (float) ((oPos.x - curPos.x) * tileScale);
|
||||||
|
|||||||
@ -143,7 +143,7 @@ public class MapView extends RelativeLayout {
|
|||||||
dpi = Math.max(metrics.xdpi, metrics.ydpi);
|
dpi = Math.max(metrics.xdpi, metrics.ydpi);
|
||||||
|
|
||||||
// TODO make this dpi dependent
|
// TODO make this dpi dependent
|
||||||
Tile.TILE_SIZE = 400;
|
Tile.SIZE = 400;
|
||||||
|
|
||||||
MapActivity mapActivity = (MapActivity) context;
|
MapActivity mapActivity = (MapActivity) context;
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@ import android.view.animation.AccelerateDecelerateInterpolator;
|
|||||||
public class MapViewPosition {
|
public class MapViewPosition {
|
||||||
private static final String TAG = MapViewPosition.class.getName();
|
private static final String TAG = MapViewPosition.class.getName();
|
||||||
|
|
||||||
// needs to fit for int: 2 * 20 * Tile.TILE_SIZE
|
// needs to fit for int: 2 * 20 * Tile.SIZE
|
||||||
public final static int MAX_ZOOMLEVEL = 20;
|
public final static int MAX_ZOOMLEVEL = 20;
|
||||||
public final static int MIN_ZOOMLEVEL = 2;
|
public final static int MIN_ZOOMLEVEL = 2;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class MapViewPosition {
|
|||||||
private double mAbsX;
|
private double mAbsX;
|
||||||
private double mAbsY;
|
private double mAbsY;
|
||||||
|
|
||||||
// mAbsScale * Tile.TILE_SIZE
|
// mAbsScale * Tile.SIZE
|
||||||
// i.e. size of tile 0/0/0 at current scale in pixel
|
// i.e. size of tile 0/0/0 at current scale in pixel
|
||||||
private double mCurScale;
|
private double mCurScale;
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ public class MapViewPosition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updatePosition() {
|
private void updatePosition() {
|
||||||
mCurScale = mAbsScale * Tile.TILE_SIZE;
|
mCurScale = mAbsScale * Tile.SIZE;
|
||||||
mCurX = mAbsX * mCurScale;
|
mCurX = mAbsX * mCurScale;
|
||||||
mCurY = mAbsY * mCurScale;
|
mCurY = mAbsY * mCurScale;
|
||||||
}
|
}
|
||||||
@ -341,8 +341,8 @@ public class MapViewPosition {
|
|||||||
|
|
||||||
double dx = mCurX + mu[0];
|
double dx = mCurX + mu[0];
|
||||||
double dy = mCurY + mu[1];
|
double dy = mCurY + mu[1];
|
||||||
dx /= mAbsScale * Tile.TILE_SIZE;
|
dx /= mAbsScale * Tile.SIZE;
|
||||||
dy /= mAbsScale * Tile.TILE_SIZE;
|
dy /= mAbsScale * Tile.SIZE;
|
||||||
|
|
||||||
if (dx > 1) {
|
if (dx > 1) {
|
||||||
while (dx > 1)
|
while (dx > 1)
|
||||||
@ -458,7 +458,7 @@ public class MapViewPosition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void moveAbs(double x, double y) {
|
private synchronized void moveAbs(double x, double y) {
|
||||||
double f = Tile.TILE_SIZE << ABS_ZOOMLEVEL;
|
double f = Tile.SIZE << ABS_ZOOMLEVEL;
|
||||||
|
|
||||||
mAbsX = x / f;
|
mAbsX = x / f;
|
||||||
mAbsY = y / f;
|
mAbsY = y / f;
|
||||||
@ -625,7 +625,7 @@ public class MapViewPosition {
|
|||||||
double dy = Math.abs(MercatorProjection.latitudeToY(bbox.getMinLatitude())
|
double dy = Math.abs(MercatorProjection.latitudeToY(bbox.getMinLatitude())
|
||||||
- MercatorProjection.latitudeToY(bbox.getMaxLatitude()));
|
- MercatorProjection.latitudeToY(bbox.getMaxLatitude()));
|
||||||
|
|
||||||
double aspect = (Math.min(mWidth, mHeight) / Tile.TILE_SIZE);
|
double aspect = (Math.min(mWidth, mHeight) / Tile.SIZE);
|
||||||
double z = Math.min(
|
double z = Math.min(
|
||||||
-LOG4 * Math.log(dx) + aspect,
|
-LOG4 * Math.log(dx) + aspect,
|
||||||
-LOG4 * Math.log(dy) + aspect);
|
-LOG4 * Math.log(dy) + aspect);
|
||||||
@ -647,7 +647,7 @@ public class MapViewPosition {
|
|||||||
//mTilt = 0;
|
//mTilt = 0;
|
||||||
//mRotation = 0;
|
//mRotation = 0;
|
||||||
//updateMatrix();
|
//updateMatrix();
|
||||||
double f = Tile.TILE_SIZE << ABS_ZOOMLEVEL;
|
double f = Tile.SIZE << ABS_ZOOMLEVEL;
|
||||||
mStartX = mAbsX * f;
|
mStartX = mAbsX * f;
|
||||||
mStartY = mAbsY * f;
|
mStartY = mAbsY * f;
|
||||||
|
|
||||||
@ -666,7 +666,7 @@ public class MapViewPosition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void animateTo(GeoPoint geoPoint) {
|
public synchronized void animateTo(GeoPoint geoPoint) {
|
||||||
double f = Tile.TILE_SIZE << ABS_ZOOMLEVEL;
|
double f = Tile.SIZE << ABS_ZOOMLEVEL;
|
||||||
|
|
||||||
mStartX = mAbsX * f;
|
mStartX = mAbsX * f;
|
||||||
mStartY = mAbsY * f;
|
mStartY = mAbsY * f;
|
||||||
|
|||||||
@ -382,8 +382,8 @@ final class TouchHandler implements OnGestureListener, OnDoubleTapListener {
|
|||||||
if (mWasMulti)
|
if (mWasMulti)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int w = Tile.TILE_SIZE * 3;
|
int w = Tile.SIZE * 3;
|
||||||
int h = Tile.TILE_SIZE * 3;
|
int h = Tile.SIZE * 3;
|
||||||
|
|
||||||
//if (mMapView.enablePagedFling) {
|
//if (mMapView.enablePagedFling) {
|
||||||
// double a = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
|
// double a = Math.sqrt(velocityX * velocityX + velocityY * velocityY);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user