Scale factor for short vertices improvements, fix #537

This commit is contained in:
Emux 2018-05-11 13:14:43 +03:00
parent 34023cdc95
commit 12cb34146c
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
4 changed files with 23 additions and 34 deletions

View File

@ -31,7 +31,6 @@ import org.oscim.core.Tile;
import org.oscim.gdx.AndroidGL;
import org.oscim.gdx.GdxAssets;
import org.oscim.gdx.GdxMap;
import org.oscim.renderer.MapRenderer;
import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.OkHttpEngine;
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
@ -49,7 +48,6 @@ public class GdxActivity extends AndroidApplication {
DisplayMetrics metrics = getResources().getDisplayMetrics();
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
Tile.SIZE = Tile.calculateTileSize();
MapRenderer.COORD_SCALE = MapRenderer.calculateCoordScale();
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.stencil = 8;

View File

@ -19,7 +19,6 @@
package org.oscim.android;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Point;
import android.opengl.GLSurfaceView;
@ -66,6 +65,8 @@ public class MapView extends GLSurfaceView {
protected GestureDetector mGestureDetector;
protected AndroidMotionEvent mMotionEvent;
private final Point mScreenSize = new Point();
public MapView(Context context) {
this(context, null);
}
@ -93,8 +94,20 @@ public class MapView extends GLSurfaceView {
CanvasAdapter.dpi = (int) (metrics.scaledDensity * CanvasAdapter.DEFAULT_DPI);
if (!Parameters.CUSTOM_TILE_SIZE)
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 */
mMap = new AndroidMap(this);
@ -175,8 +188,6 @@ public class MapView extends GLSurfaceView {
private boolean mRenderWait;
private boolean mPausing;
private final Point mScreenSize = new Point();
public AndroidMap(MapView mapView) {
super();
mMapView = mapView;
@ -195,25 +206,12 @@ public class MapView extends GLSurfaceView {
@Override
public int getScreenWidth() {
return getScreenSize().x;
return mMapView.mScreenSize.x;
}
@Override
public int getScreenHeight() {
return getScreenSize().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;
return mMapView.mScreenSize.y;
}
private final Runnable mRedrawCb = new Runnable() {

View File

@ -68,6 +68,11 @@ public abstract class GdxMap implements ApplicationListener {
@Override
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();
mMapRenderer = new MapRenderer(mMap);

View File

@ -18,7 +18,6 @@
*/
package org.oscim.renderer;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.GL;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.canvas.Color;
@ -77,17 +76,6 @@ public class MapRenderer {
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) {
mClearColor = GLUtils.colorToFloat(color);
}