From c991666d97ce327629d6913997b4e0cffa47a0ae Mon Sep 17 00:00:00 2001 From: Emux Date: Sun, 25 Sep 2016 18:56:04 +0300 Subject: [PATCH] Tile size based on scale factor, closes #183 --- docs/Changelog.md | 5 +++-- vtm/src/org/oscim/core/Tile.java | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index d0041026..d2bb9287 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -7,19 +7,20 @@ - Render theme SVG resources [#60](https://github.com/mapsforge/vtm/issues/60) - Mapsforge multilingual maps [#34](https://github.com/mapsforge/vtm/issues/34) - 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) - 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) - Location renderer [#171](https://github.com/mapsforge/vtm/issues/171) - 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) -- 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) - Graphics API platform enhancements [#92](https://github.com/mapsforge/vtm/issues/92) - vtm-jts module [#53](https://github.com/mapsforge/vtm/issues/53) - vtm-http module [#140](https://github.com/mapsforge/vtm/issues/140) - 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) - Many other minor improvements and bug fixes - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aissue+is%3Aclosed+milestone%3A0.6.0) diff --git a/vtm/src/org/oscim/core/Tile.java b/vtm/src/org/oscim/core/Tile.java index cfbc1bee..b1097490 100644 --- a/vtm/src/org/oscim/core/Tile.java +++ b/vtm/src/org/oscim/core/Tile.java @@ -1,6 +1,7 @@ /* * Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2013 Hannes Janetzek + * Copyright 2016 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -25,9 +26,19 @@ package org.oscim.core; 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. @@ -98,4 +109,14 @@ public class Tile { } 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); + } }