This commit is contained in:
Hannes Janetzek 2012-09-26 21:43:01 +02:00
parent dae474922a
commit fbc39c65cb
4 changed files with 36 additions and 32 deletions

View File

@ -98,6 +98,7 @@ public class MapViewPosition {
mapPosition.angle = mRotation; mapPosition.angle = mRotation;
mapPosition.zoomLevel = mZoomLevel; mapPosition.zoomLevel = mZoomLevel;
mapPosition.scale = mScale; mapPosition.scale = mScale;
byte z = mZoomLevel; byte z = mZoomLevel;
mapPosition.x = MercatorProjection.longitudeToPixelX(mLongitude, z); mapPosition.x = MercatorProjection.longitudeToPixelX(mLongitude, z);
mapPosition.y = MercatorProjection.latitudeToPixelY(mLatitude, z); mapPosition.y = MercatorProjection.latitudeToPixelY(mLatitude, z);
@ -114,7 +115,7 @@ public class MapViewPosition {
// updateMatrix(); // updateMatrix();
// not so sure about this, but works... // not so sure about this, but works...
float tilt = FloatMath.sin((float) Math.toRadians(mTilt)) * 4; float tilt = (float) Math.sin(Math.toRadians(mTilt)) * 4;
unproject(-1, 1, tilt, coords, 0); // top-left unproject(-1, 1, tilt, coords, 0); // top-left
unproject(1, 1, tilt, coords, 2); // top-right unproject(1, 1, tilt, coords, 2); // top-right
@ -365,6 +366,21 @@ public class MapViewPosition {
updateMatrix(); updateMatrix();
} }
public boolean tilt(float move) {
float tilt = mTilt + move;
if (tilt > MAX_ANGLE)
tilt = MAX_ANGLE;
else if (tilt < 0)
tilt = 0;
if (mTilt == tilt)
return false;
mTilt = tilt;
updateMatrix();
return true;
}
public void setTilt(float f) { public void setTilt(float f) {
mTilt = f; mTilt = f;
updateMatrix(); updateMatrix();
@ -433,16 +449,4 @@ public class MapViewPosition {
return true; return true;
} }
public boolean tilt(float moveX) {
float tilt = mTilt + moveX;
if (tilt > MAX_ANGLE)
tilt = MAX_ANGLE;
else if (tilt < 0)
tilt = 0;
if (mTilt == tilt)
return false;
mTilt = tilt;
return true;
}
} }

View File

@ -417,8 +417,7 @@ public class TouchHandler
if (mTimeEnd - mTimeStart > 150 || mSumScale > 1.1 || mSumScale < 0.9) { if (mTimeEnd - mTimeStart > 150 || mSumScale > 1.1 || mSumScale < 0.9) {
mBeginScale = true; mBeginScale = true;
scale = mSumScale; scale = mSumScale;
} } else
else
return true; return true;
} }

View File

@ -61,7 +61,7 @@ public class ScanBox {
static Edge bc = new Edge(); static Edge bc = new Edge();
static Edge ca = new Edge(); static Edge ca = new Edge();
static void scanSpans(Edge e0, Edge e1, float ymin, float ymax) { static void scanSpans(Edge e0, Edge e1) {
// sort edge by x-coordinate // sort edge by x-coordinate
if (e0.x0 == e1.x0 && e0.y0 == e1.y0) { if (e0.x0 == e1.x0 && e0.y0 == e1.y0) {
@ -86,8 +86,8 @@ public class ScanBox {
float x0, x1; float x0, x1;
int y = (int) Math.max(ymin, FloatMath.floor(e1.y0)); int y = (int) Math.max(0, FloatMath.floor(e1.y0));
int bottom = (int) Math.min(ymax, FloatMath.ceil(e1.y1)); int bottom = (int) Math.min(mMax, FloatMath.ceil(e1.y1));
for (; y < bottom; y++) { for (; y < bottom; y++) {
// float x0 = (m0 * Math.min(e0.dy, y + d0 - e0.y0) + e0.x0); // float x0 = (m0 * Math.min(e0.dy, y + d0 - e0.y0) + e0.x0);
@ -97,7 +97,7 @@ public class ScanBox {
if (e0.dy < x0) if (e0.dy < x0)
x0 = e0.dy; x0 = e0.dy;
x0 = m0 * x0 + e0.x0; x0 = e0.x0 + m0 * x0;
if (x0 < 0) if (x0 < 0)
x0 = 0; x0 = 0;
@ -108,7 +108,7 @@ public class ScanBox {
if (e1.dy < x1) if (e1.dy < x1)
x1 = e1.dy; x1 = e1.dy;
x1 = m1 * x1 + e1.x0; x1 = e1.x0 + m1 * x1;
if (x1 < 0) if (x1 < 0)
x1 = 0; x1 = 0;
@ -121,7 +121,7 @@ public class ScanBox {
} }
} }
static void scanTriangle(float ymin, float ymax) { static void scanTriangle() {
if (ab.dy > bc.dy) { if (ab.dy > bc.dy) {
Edge t = ab; Edge t = ab;
@ -140,25 +140,28 @@ public class ScanBox {
} }
if (ab.dy != 0) if (ab.dy != 0)
scanSpans(ca, ab, ymin, ymax); scanSpans(ca, ab);
if (bc.dy != 0) if (bc.dy != 0)
scanSpans(ca, bc, ymin, ymax); scanSpans(ca, bc);
} }
private static int mMax;
public static void scan(float[] coords, TilesData tiles, int max) { public static void scan(float[] coords, TilesData tiles, int max) {
sTiles = tiles; sTiles = tiles;
cntDoubles = 0; cntDoubles = 0;
mMax = max;
ab.set(coords[0], coords[1], coords[2], coords[3]); ab.set(coords[0], coords[1], coords[2], coords[3]);
bc.set(coords[2], coords[3], coords[4], coords[5]); bc.set(coords[2], coords[3], coords[4], coords[5]);
ca.set(coords[4], coords[5], coords[0], coords[1]); ca.set(coords[4], coords[5], coords[0], coords[1]);
scanTriangle();
scanTriangle(0, max);
// Log.d("..", ">doubles " + cntDoubles);
ab.set(coords[4], coords[5], coords[6], coords[7]); ab.set(coords[4], coords[5], coords[6], coords[7]);
bc.set(coords[6], coords[7], coords[0], coords[1]); bc.set(coords[6], coords[7], coords[0], coords[1]);
ca.set(coords[0], coords[1], coords[4], coords[5]); ca.set(coords[0], coords[1], coords[4], coords[5]);
scanTriangle();
scanTriangle(0, max);
// Log.d("..", "<doubles " + cntDoubles); // Log.d("..", "<doubles " + cntDoubles);
} }

View File

@ -247,8 +247,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
@Override @Override
public void renderPointOfInterestCaption(Caption caption) { public void renderPointOfInterestCaption(Caption caption) {
// Log.d(TAG, "renderPointOfInterestCaption: " + mPoiX + " " + mPoiY + // Log.d(TAG, "renderPointOfInterestCaption: " + mPoiX + " " + mPoiY +
// " " // " " + mTagName);
// + mTagName);
if (mTagName == null) if (mTagName == null)
return; return;
@ -430,8 +429,8 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
mDebugDrawPolygons = !debugSettings.mDisablePolygons; mDebugDrawPolygons = !debugSettings.mDisablePolygons;
mDebugDrawUnmatched = debugSettings.mDrawUnmatchted; mDebugDrawUnmatched = debugSettings.mDrawUnmatchted;
// fixed now....
if (tile.newData || tile.isReady) { if (tile.newData || tile.isReady) {
// fixed now....
Log.d(TAG, "XXX tile already loaded " Log.d(TAG, "XXX tile already loaded "
+ tile + " " + tile + " "
+ tile.newData + " " + tile.newData + " "
@ -468,8 +467,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
} }
if (debugSettings.mDrawTileFrames) { if (debugSettings.mDrawTileFrames) {
mTagName = new Tag("name", countLines + " " + countNodes + " " mTagName = new Tag("name", tile.toString(), false);
+ tile.toString(), false);
mPoiX = Tile.TILE_SIZE >> 1; mPoiX = Tile.TILE_SIZE >> 1;
mPoiY = 10; mPoiY = 10;
TileGenerator.renderTheme.matchNode(this, debugTagWay, (byte) 0); TileGenerator.renderTheme.matchNode(this, debugTagWay, (byte) 0);