added MapLensOverlay
This commit is contained in:
parent
eac8047527
commit
a6a729244f
@ -21,7 +21,10 @@ public class MapPosition {
|
|||||||
public double lon;
|
public double lon;
|
||||||
public double lat;
|
public double lat;
|
||||||
|
|
||||||
public int zoomLevel;
|
public double absX;
|
||||||
|
public double absY;
|
||||||
|
public double absScale;
|
||||||
|
|
||||||
public float scale;
|
public float scale;
|
||||||
public float angle;
|
public float angle;
|
||||||
public float tilt;
|
public float tilt;
|
||||||
@ -29,6 +32,7 @@ public class MapPosition {
|
|||||||
// map center in tile coordinates of current zoom-level
|
// map center in tile coordinates of current zoom-level
|
||||||
public double x;
|
public double x;
|
||||||
public double y;
|
public double y;
|
||||||
|
public int zoomLevel;
|
||||||
|
|
||||||
public MapPosition() {
|
public MapPosition() {
|
||||||
this.zoomLevel = (byte) 1;
|
this.zoomLevel = (byte) 1;
|
||||||
|
|||||||
@ -294,7 +294,7 @@ public final class PolygonRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawOver(Matrices m) {
|
public static void drawOver(Matrices m, boolean drawColor, int color) {
|
||||||
if (GLState.useProgram(polygonProgram)) {
|
if (GLState.useProgram(polygonProgram)) {
|
||||||
|
|
||||||
GLState.enableVertexArrays(hPolygonVertexPosition, -1);
|
GLState.enableVertexArrays(hPolygonVertexPosition, -1);
|
||||||
@ -310,9 +310,13 @@ public final class PolygonRenderer {
|
|||||||
* a quad with func 'always' and op 'zero'
|
* a quad with func 'always' and op 'zero'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// disable drawing to framebuffer (will be re-enabled in fill)
|
if (drawColor) {
|
||||||
glColorMask(false, false, false, false);
|
GlUtils.setColor(hPolygonColor, color, 1);
|
||||||
|
GLState.blend(true);
|
||||||
|
} else {
|
||||||
|
// disable drawing to framebuffer (will be re-enabled in fill)
|
||||||
|
glColorMask(false, false, false, false);
|
||||||
|
}
|
||||||
// always pass stencil test:
|
// always pass stencil test:
|
||||||
glStencilFunc(GL_ALWAYS, 0x00, 0x00);
|
glStencilFunc(GL_ALWAYS, 0x00, 0x00);
|
||||||
// write to all bits
|
// write to all bits
|
||||||
@ -321,7 +325,9 @@ public final class PolygonRenderer {
|
|||||||
glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_ZERO);
|
glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_ZERO);
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
glColorMask(true, true, true, true);
|
|
||||||
|
if (!drawColor)
|
||||||
|
glColorMask(true, true, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float[] debugFillColor = { 0.3f, 0.0f, 0.0f, 0.3f };
|
private static float[] debugFillColor = { 0.3f, 0.0f, 0.0f, 0.3f };
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import org.oscim.core.MapPosition;
|
|||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
import org.oscim.renderer.layer.Layer;
|
import org.oscim.renderer.layer.Layer;
|
||||||
import org.oscim.utils.FastMath;
|
import org.oscim.utils.FastMath;
|
||||||
|
import org.oscim.utils.Matrix4;
|
||||||
|
|
||||||
import android.opengl.GLES20;
|
import android.opengl.GLES20;
|
||||||
|
|
||||||
@ -44,10 +45,17 @@ public class TileRenderer {
|
|||||||
|
|
||||||
private static Matrices mMatrices;
|
private static Matrices mMatrices;
|
||||||
|
|
||||||
|
private static final Matrix4 mProjMatrix = new Matrix4();
|
||||||
|
|
||||||
static void draw(MapTile[] tiles, int tileCnt, MapPosition pos, Matrices m) {
|
static void draw(MapTile[] tiles, int tileCnt, MapPosition pos, Matrices m) {
|
||||||
mDrawCnt = 0;
|
mDrawCnt = 0;
|
||||||
mMatrices = m;
|
mMatrices = m;
|
||||||
|
|
||||||
|
mProjMatrix.copy(m.viewproj);
|
||||||
|
// discard z projection from tilt
|
||||||
|
mProjMatrix.setValue(10, 0);
|
||||||
|
mProjMatrix.setValue(14, 0);
|
||||||
|
|
||||||
GLES20.glDepthFunc(GLES20.GL_LESS);
|
GLES20.glDepthFunc(GLES20.GL_LESS);
|
||||||
|
|
||||||
// load texture for line caps
|
// load texture for line caps
|
||||||
@ -116,11 +124,11 @@ public class TileRenderer {
|
|||||||
Matrices m = mMatrices;
|
Matrices m = mMatrices;
|
||||||
m.mvp.setTransScale(x * scale, y * scale, scale / GLRenderer.COORD_SCALE);
|
m.mvp.setTransScale(x * scale, y * scale, scale / GLRenderer.COORD_SCALE);
|
||||||
|
|
||||||
m.mvp.multiplyMM(m.viewproj, m.mvp);
|
m.mvp.multiplyMM(mProjMatrix, m.mvp);
|
||||||
|
|
||||||
// set depth offset (used for clipping to tile boundaries)
|
// set depth offset (used for clipping to tile boundaries)
|
||||||
GLES20.glPolygonOffset(1, mDrawCnt++);
|
GLES20.glPolygonOffset(1, mDrawCnt++);
|
||||||
if (mDrawCnt > 20)
|
if (mDrawCnt == 100)
|
||||||
mDrawCnt = 0;
|
mDrawCnt = 0;
|
||||||
|
|
||||||
// simple line shader does not take forward shortening into account
|
// simple line shader does not take forward shortening into account
|
||||||
@ -160,7 +168,7 @@ public class TileRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// clear clip-region and could also draw 'fade-effect'
|
// clear clip-region and could also draw 'fade-effect'
|
||||||
PolygonRenderer.drawOver(m);
|
PolygonRenderer.drawOver(m, true, 0x22000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int drawProxyChild(MapTile tile, MapPosition pos) {
|
private static int drawProxyChild(MapTile tile, MapPosition pos) {
|
||||||
|
|||||||
@ -38,14 +38,13 @@ import org.oscim.generator.JobTile;
|
|||||||
import org.oscim.generator.MapWorker;
|
import org.oscim.generator.MapWorker;
|
||||||
import org.oscim.generator.TileGenerator;
|
import org.oscim.generator.TileGenerator;
|
||||||
import org.oscim.overlay.BuildingOverlay;
|
import org.oscim.overlay.BuildingOverlay;
|
||||||
import org.oscim.overlay.GenericOverlay;
|
|
||||||
import org.oscim.overlay.LabelingOverlay;
|
import org.oscim.overlay.LabelingOverlay;
|
||||||
|
import org.oscim.overlay.MapLensOverlay;
|
||||||
import org.oscim.overlay.Overlay;
|
import org.oscim.overlay.Overlay;
|
||||||
import org.oscim.overlay.OverlayManager;
|
import org.oscim.overlay.OverlayManager;
|
||||||
import org.oscim.renderer.GLRenderer;
|
import org.oscim.renderer.GLRenderer;
|
||||||
import org.oscim.renderer.GLView;
|
import org.oscim.renderer.GLView;
|
||||||
import org.oscim.renderer.TileManager;
|
import org.oscim.renderer.TileManager;
|
||||||
import org.oscim.renderer.overlays.TileOverlay;
|
|
||||||
import org.oscim.theme.ExternalRenderTheme;
|
import org.oscim.theme.ExternalRenderTheme;
|
||||||
import org.oscim.theme.InternalRenderTheme;
|
import org.oscim.theme.InternalRenderTheme;
|
||||||
import org.oscim.theme.RenderTheme;
|
import org.oscim.theme.RenderTheme;
|
||||||
@ -197,8 +196,8 @@ public class MapView extends RelativeLayout {
|
|||||||
mOverlayManager.add(new LabelingOverlay(this));
|
mOverlayManager.add(new LabelingOverlay(this));
|
||||||
|
|
||||||
|
|
||||||
mOverlayManager.add(new GenericOverlay(this, new TileOverlay(this)));
|
//mOverlayManager.add(new GenericOverlay(this, new TileOverlay(this)));
|
||||||
|
mOverlayManager.add(new MapLensOverlay(this));
|
||||||
|
|
||||||
//mOverlayManager.add(new GenericOverlay(this, new CustomOverlay(this)));
|
//mOverlayManager.add(new GenericOverlay(this, new CustomOverlay(this)));
|
||||||
|
|
||||||
|
|||||||
@ -157,6 +157,10 @@ public class MapViewPosition {
|
|||||||
pos.angle = mRotation;
|
pos.angle = mRotation;
|
||||||
pos.tilt = mTilt;
|
pos.tilt = mTilt;
|
||||||
|
|
||||||
|
pos.absX = mAbsX;
|
||||||
|
pos.absY = mAbsY;
|
||||||
|
pos.absScale = mAbsScale;
|
||||||
|
|
||||||
// for tiling
|
// for tiling
|
||||||
pos.scale = scale;
|
pos.scale = scale;
|
||||||
pos.zoomLevel = (byte) z;
|
pos.zoomLevel = (byte) z;
|
||||||
@ -312,28 +316,33 @@ public class MapViewPosition {
|
|||||||
return bbox;
|
return bbox;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * For x, y in screen coordinates set Point to map-tile
|
* For x, y in screen coordinates set Point to map-tile
|
||||||
// * coordinates at returned scale.
|
* coordinates at returned scale.
|
||||||
// *
|
*
|
||||||
// * @param x screen coordinate
|
* @param x screen coordinate
|
||||||
// * @param y screen coordinate
|
* @param y screen coordinate
|
||||||
// * @param out Point coords will be set
|
* @param out Point coords will be set
|
||||||
// * @return current map scale
|
*/
|
||||||
// */
|
public synchronized void getScreenPointOnMap(float x, float y, double scale, PointD out) {
|
||||||
// public synchronized float getScreenPointOnMap(float x, float y, PointD out) {
|
|
||||||
//
|
// scale to -1..1
|
||||||
// // scale to -1..1
|
float mx = 1 - (x / mWidth * 2);
|
||||||
// float mx = 1 - (x / mWidth * 2);
|
float my = 1 - (y / mHeight * 2);
|
||||||
// float my = 1 - (y / mHeight * 2);
|
|
||||||
//
|
unproject(-mx, my, getZ(-my), mu, 0);
|
||||||
// unproject(-mx, my, getZ(-my), mu, 0);
|
|
||||||
//
|
//out.x = mCurX + mu[0];
|
||||||
// out.x = mCurX + mu[0];
|
//out.y = mCurY + mu[1];
|
||||||
// out.y = mCurY + mu[1];
|
|
||||||
//
|
out.x = mu[0];
|
||||||
// return (float) mAbsScale;
|
out.y = mu[1];
|
||||||
// }
|
|
||||||
|
if (scale != 0) {
|
||||||
|
out.x *= scale / mAbsScale;
|
||||||
|
out.y *= scale / mAbsScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the GeoPoint for x,y in screen coordinates.
|
* Get the GeoPoint for x,y in screen coordinates.
|
||||||
@ -729,23 +738,23 @@ public class MapViewPosition {
|
|||||||
mHandler.start(mDuration);
|
mHandler.start(mDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized boolean fling(float adv) {
|
||||||
|
|
||||||
synchronized boolean fling(float adv){
|
//float delta = (mDuration - millisLeft) / mDuration;
|
||||||
|
adv = (float) Math.sqrt(adv);
|
||||||
|
float dx = mVelocityX * adv;
|
||||||
|
float dy = mVelocityY * adv;
|
||||||
|
|
||||||
//float delta = (mDuration - millisLeft) / mDuration;
|
if (dx != 0 || dy != 0) {
|
||||||
adv = (float)Math.sqrt(adv);
|
moveMap((float) (dx - mScrollX), (float) (dy - mScrollY));
|
||||||
float dx = mVelocityX * adv;
|
|
||||||
float dy = mVelocityY * adv;
|
|
||||||
|
|
||||||
if (dx != 0 || dy != 0){
|
mMapView.redrawMap(true);
|
||||||
moveMap((float)(dx - mScrollX), (float)(dy - mScrollY));
|
mScrollX = dx;
|
||||||
|
mScrollY = dy;
|
||||||
mMapView.redrawMap(true);
|
}
|
||||||
mScrollX = dx;
|
return true;
|
||||||
mScrollY = dy;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private float mVelocityX;
|
private float mVelocityX;
|
||||||
private float mVelocityY;
|
private float mVelocityY;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user