Scale factor for short vertices improvements, fix #537
This commit is contained in:
parent
34023cdc95
commit
12cb34146c
@ -31,7 +31,6 @@ import org.oscim.core.Tile;
|
|||||||
import org.oscim.gdx.AndroidGL;
|
import org.oscim.gdx.AndroidGL;
|
||||||
import org.oscim.gdx.GdxAssets;
|
import org.oscim.gdx.GdxAssets;
|
||||||
import org.oscim.gdx.GdxMap;
|
import org.oscim.gdx.GdxMap;
|
||||||
import org.oscim.renderer.MapRenderer;
|
|
||||||
import org.oscim.tiling.TileSource;
|
import org.oscim.tiling.TileSource;
|
||||||
import org.oscim.tiling.source.OkHttpEngine;
|
import org.oscim.tiling.source.OkHttpEngine;
|
||||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||||
@ -49,7 +48,6 @@ public class GdxActivity extends AndroidApplication {
|
|||||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||||
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
|
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
|
||||||
Tile.SIZE = Tile.calculateTileSize();
|
Tile.SIZE = Tile.calculateTileSize();
|
||||||
MapRenderer.COORD_SCALE = MapRenderer.calculateCoordScale();
|
|
||||||
|
|
||||||
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
|
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
|
||||||
cfg.stencil = 8;
|
cfg.stencil = 8;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.oscim.android;
|
package org.oscim.android;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
@ -66,6 +65,8 @@ public class MapView extends GLSurfaceView {
|
|||||||
protected GestureDetector mGestureDetector;
|
protected GestureDetector mGestureDetector;
|
||||||
protected AndroidMotionEvent mMotionEvent;
|
protected AndroidMotionEvent mMotionEvent;
|
||||||
|
|
||||||
|
private final Point mScreenSize = new Point();
|
||||||
|
|
||||||
public MapView(Context context) {
|
public MapView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
@ -93,8 +94,20 @@ public class MapView extends GLSurfaceView {
|
|||||||
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
|
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
|
||||||
if (!Parameters.CUSTOM_TILE_SIZE)
|
if (!Parameters.CUSTOM_TILE_SIZE)
|
||||||
Tile.SIZE = Tile.calculateTileSize();
|
Tile.SIZE = Tile.calculateTileSize();
|
||||||
if (!Parameters.CUSTOM_COORD_SCALE)
|
|
||||||
MapRenderer.COORD_SCALE = MapRenderer.calculateCoordScale();
|
WindowManager windowManager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
Display display = windowManager.getDefaultDisplay();
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
||||||
|
display.getSize(mScreenSize);
|
||||||
|
else {
|
||||||
|
mScreenSize.x = display.getWidth();
|
||||||
|
mScreenSize.y = display.getHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Parameters.CUSTOM_COORD_SCALE) {
|
||||||
|
if (Math.min(mScreenSize.x, mScreenSize.y) > 1080)
|
||||||
|
MapRenderer.COORD_SCALE = 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
/* Initialize the Map */
|
/* Initialize the Map */
|
||||||
mMap = new AndroidMap(this);
|
mMap = new AndroidMap(this);
|
||||||
@ -175,8 +188,6 @@ public class MapView extends GLSurfaceView {
|
|||||||
private boolean mRenderWait;
|
private boolean mRenderWait;
|
||||||
private boolean mPausing;
|
private boolean mPausing;
|
||||||
|
|
||||||
private final Point mScreenSize = new Point();
|
|
||||||
|
|
||||||
public AndroidMap(MapView mapView) {
|
public AndroidMap(MapView mapView) {
|
||||||
super();
|
super();
|
||||||
mMapView = mapView;
|
mMapView = mapView;
|
||||||
@ -195,25 +206,12 @@ public class MapView extends GLSurfaceView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getScreenWidth() {
|
public int getScreenWidth() {
|
||||||
return getScreenSize().x;
|
return mMapView.mScreenSize.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getScreenHeight() {
|
public int getScreenHeight() {
|
||||||
return getScreenSize().y;
|
return mMapView.mScreenSize.y;
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
|
|
||||||
private Point getScreenSize() {
|
|
||||||
Display display = mWindowManager.getDefaultDisplay();
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
|
|
||||||
display.getSize(mScreenSize);
|
|
||||||
else {
|
|
||||||
mScreenSize.x = display.getWidth();
|
|
||||||
mScreenSize.y = display.getHeight();
|
|
||||||
}
|
|
||||||
return mScreenSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Runnable mRedrawCb = new Runnable() {
|
private final Runnable mRedrawCb = new Runnable() {
|
||||||
|
@ -68,6 +68,11 @@ public abstract class GdxMap implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
if (!Parameters.CUSTOM_COORD_SCALE) {
|
||||||
|
if (Math.min(Gdx.graphics.getDisplayMode().width, Gdx.graphics.getDisplayMode().height) > 1080)
|
||||||
|
MapRenderer.COORD_SCALE = 4.0f;
|
||||||
|
}
|
||||||
|
|
||||||
mMap = new MapAdapter();
|
mMap = new MapAdapter();
|
||||||
mMapRenderer = new MapRenderer(mMap);
|
mMapRenderer = new MapRenderer(mMap);
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.renderer;
|
package org.oscim.renderer;
|
||||||
|
|
||||||
import org.oscim.backend.CanvasAdapter;
|
|
||||||
import org.oscim.backend.GL;
|
import org.oscim.backend.GL;
|
||||||
import org.oscim.backend.GLAdapter;
|
import org.oscim.backend.GLAdapter;
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
@ -77,17 +76,6 @@ public class MapRenderer {
|
|||||||
setBackgroundColor(Color.DKGRAY);
|
setBackgroundColor(Color.DKGRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate scale factor for short vertices.
|
|
||||||
* <p>
|
|
||||||
* CanvasAdapter.dpi must be set before!
|
|
||||||
*/
|
|
||||||
public static float calculateCoordScale() {
|
|
||||||
if (CanvasAdapter.dpi > 420)
|
|
||||||
return 4.0f;
|
|
||||||
return 8.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setBackgroundColor(int color) {
|
public static void setBackgroundColor(int color) {
|
||||||
mClearColor = GLUtils.colorToFloat(color);
|
mClearColor = GLUtils.colorToFloat(color);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user