Tile size based on scale factor, closes #183

This commit is contained in:
Emux
2016-09-25 18:56:04 +03:00
parent aa3aec0218
commit c991666d97
2 changed files with 26 additions and 4 deletions

View File

@@ -7,19 +7,20 @@
- Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60) - Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60)
- Mapsforge multilingual maps [#34](https://github.com/mapsforge/vtm/issues/34) - Mapsforge multilingual maps [#34](https://github.com/mapsforge/vtm/issues/34)
- Render theme styles [#93](https://github.com/mapsforge/vtm/issues/93) - Render theme styles [#93](https://github.com/mapsforge/vtm/issues/93)
- vtm-ios update module [#29](https://github.com/mapsforge/vtm/issues/29) - vtm-ios module update [#29](https://github.com/mapsforge/vtm/issues/29)
- Native libraries for all platforms [#14](https://github.com/mapsforge/vtm/issues/14) - Native libraries for all platforms [#14](https://github.com/mapsforge/vtm/issues/14)
- Line stipple and texture rendering [#105](https://github.com/mapsforge/vtm/issues/105) - Line stipple and texture rendering [#105](https://github.com/mapsforge/vtm/issues/105)
- Layer groups [#99](https://github.com/mapsforge/vtm/issues/99) [#103](https://github.com/mapsforge/vtm/issues/103) - Layer groups [#99](https://github.com/mapsforge/vtm/issues/99) [#103](https://github.com/mapsforge/vtm/issues/103)
- Location renderer [#171](https://github.com/mapsforge/vtm/issues/171) - Location renderer [#171](https://github.com/mapsforge/vtm/issues/171)
- Map scale bar [#84](https://github.com/mapsforge/vtm/issues/84) - Map scale bar [#84](https://github.com/mapsforge/vtm/issues/84)
- Tile size based on scale factor [#183](https://github.com/mapsforge/vtm/issues/183)
- libGDX layer gestures [#151](https://github.com/mapsforge/vtm/issues/151) - libGDX layer gestures [#151](https://github.com/mapsforge/vtm/issues/151)
- LWJGL desktop libGDX backend [#129](https://github.com/mapsforge/vtm/issues/129)
- Render theme area tessellation option [#37](https://github.com/mapsforge/vtm/issues/37) - Render theme area tessellation option [#37](https://github.com/mapsforge/vtm/issues/37)
- Graphics API platform enhancements [#92](https://github.com/mapsforge/vtm/issues/92) - Graphics API platform enhancements [#92](https://github.com/mapsforge/vtm/issues/92)
- vtm-jts module [#53](https://github.com/mapsforge/vtm/issues/53) - vtm-jts module [#53](https://github.com/mapsforge/vtm/issues/53)
- vtm-http module [#140](https://github.com/mapsforge/vtm/issues/140) - vtm-http module [#140](https://github.com/mapsforge/vtm/issues/140)
- Internal render themes various enhancements [#41](https://github.com/mapsforge/vtm/issues/41) - Internal render themes various enhancements [#41](https://github.com/mapsforge/vtm/issues/41)
- LWJGL desktop libGDX backend [#129](https://github.com/mapsforge/vtm/issues/129)
- SNAPSHOT builds publish to Sonatype OSSRH [#165](https://github.com/mapsforge/vtm/issues/165) - SNAPSHOT builds publish to Sonatype OSSRH [#165](https://github.com/mapsforge/vtm/issues/165)
- Many other minor improvements and bug fixes - Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.6.0) - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.6.0)

View File

@@ -1,6 +1,7 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@@ -25,9 +26,19 @@ package org.oscim.core;
public class Tile { public class Tile {
/** /**
* Width and height of a map tile in pixel. * Default tile size in pixels.
*/ */
public static int SIZE = 400; private static final int DEFAULT_TILE_SIZE = 256;
/**
* Width and height of a map tile in pixels.
*/
public static int SIZE = 512;
/**
* Tile size multiple in pixels.
*/
public static int TILE_SIZE_MULTIPLE = 64;
/** /**
* The X number of this tile. * The X number of this tile.
@@ -98,4 +109,14 @@ public class Tile {
} }
return mHash; return mHash;
} }
/**
* Calculate tile size (256px) with a scale factor.
* Clamp tile size to a preset multiple, e.g. 64px.
*/
public static int calculateTileSize(float scaleFactor) {
float scaled = DEFAULT_TILE_SIZE * scaleFactor;
return Math.max(TILE_SIZE_MULTIPLE,
Math.round(scaled / TILE_SIZE_MULTIPLE) * TILE_SIZE_MULTIPLE);
}
} }