Location renderer: add scaling support #317
This commit is contained in:
parent
2872ce94a3
commit
8d2aba9c65
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2013 Ahmad Saleem
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016-2017 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.oscim.layers;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.core.MercatorProjection;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.renderer.LocationRenderer;
|
||||
@ -24,9 +25,13 @@ public class LocationLayer extends Layer {
|
||||
public final LocationRenderer locationRenderer;
|
||||
|
||||
public LocationLayer(Map map) {
|
||||
this(map, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI);
|
||||
}
|
||||
|
||||
public LocationLayer(Map map, float scale) {
|
||||
super(map);
|
||||
|
||||
mRenderer = locationRenderer = new LocationRenderer(mMap, this);
|
||||
mRenderer = locationRenderer = new LocationRenderer(mMap, this, scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.oscim.renderer;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.GL;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.Box;
|
||||
@ -35,12 +36,13 @@ public class LocationRenderer extends LayerRenderer {
|
||||
private static final long ANIM_RATE = 50;
|
||||
private static final long INTERVAL = 2000;
|
||||
|
||||
private static final float CIRCLE_SIZE = 60;
|
||||
private static final float CIRCLE_SIZE = 40;
|
||||
private static final int COLOR = 0xff3333cc;
|
||||
private static final int SHOW_ACCURACY_ZOOM = 16;
|
||||
|
||||
private final Map mMap;
|
||||
private final Layer mLayer;
|
||||
private final float mScale;
|
||||
|
||||
private String mShaderFile;
|
||||
private int mShaderProgram;
|
||||
@ -71,8 +73,13 @@ public class LocationRenderer extends LayerRenderer {
|
||||
private int mShowAccuracyZoom = SHOW_ACCURACY_ZOOM;
|
||||
|
||||
public LocationRenderer(Map map, Layer layer) {
|
||||
this(map, layer, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI);
|
||||
}
|
||||
|
||||
public LocationRenderer(Map map, Layer layer, float scale) {
|
||||
mMap = map;
|
||||
mLayer = layer;
|
||||
mScale = scale;
|
||||
|
||||
float a = Color.aToFloat(COLOR);
|
||||
mColors[0] = a * Color.rToFloat(COLOR);
|
||||
@ -212,7 +219,7 @@ public class LocationRenderer extends LayerRenderer {
|
||||
GLState.enableVertexArrays(hVertexPosition, -1);
|
||||
MapRenderer.bindQuadVertexVBO(hVertexPosition/*, true*/);
|
||||
|
||||
float radius = CIRCLE_SIZE;
|
||||
float radius = CIRCLE_SIZE * mScale;
|
||||
|
||||
animate(true);
|
||||
boolean viewShed = false;
|
||||
@ -221,7 +228,7 @@ public class LocationRenderer extends LayerRenderer {
|
||||
} else {
|
||||
if (v.pos.zoomLevel >= mShowAccuracyZoom)
|
||||
radius = (float) (mRadius * v.pos.scale);
|
||||
radius = Math.max(CIRCLE_SIZE, radius);
|
||||
radius = Math.max(CIRCLE_SIZE * mScale, radius);
|
||||
|
||||
viewShed = true;
|
||||
//animate(false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user