From b42973662edf1f3f2cfe048aa52f12e9e3bbc8c4 Mon Sep 17 00:00:00 2001 From: Emux Date: Sat, 20 Jan 2018 15:39:30 +0200 Subject: [PATCH] Map fractional zoom, fix #487 --- docs/Changelog.md | 1 + vtm/src/org/oscim/core/MapPosition.java | 28 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 5dbb5927..9bcd2804 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -6,6 +6,7 @@ - vtm-mvt module with MVT tile decoder [#481](https://github.com/mapsforge/vtm/pull/481) - OpenMapTiles MVT vector tiles [#482](https://github.com/mapsforge/vtm/issues/482) - Improved theme styles [#479](https://github.com/mapsforge/vtm/pull/479) +- Map fractional zoom [#487](https://github.com/mapsforge/vtm/issues/487) - Render theme fallback internal resources [#477](https://github.com/mapsforge/vtm/issues/477) - Fix libGDX flickering [#148](https://github.com/mapsforge/vtm/issues/148) [#149](https://github.com/mapsforge/vtm/issues/149) - JTS (LocationTech) [#484](https://github.com/mapsforge/vtm/issues/484) diff --git a/vtm/src/org/oscim/core/MapPosition.java b/vtm/src/org/oscim/core/MapPosition.java index c98e17bd..8131b181 100644 --- a/vtm/src/org/oscim/core/MapPosition.java +++ b/vtm/src/org/oscim/core/MapPosition.java @@ -1,6 +1,6 @@ /* * Copyright 2012 Hannes Janetzek - * Copyright 2016 devemux86 + * Copyright 2016-2018 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -107,6 +107,26 @@ public class MapPosition { return scale; } + public MapPosition setScale(double scale) { + this.zoomLevel = FastMath.log2((int) scale); + this.scale = scale; + return this; + } + + /** + * @return the fractional zoom. + */ + public double getZoom() { + return Math.log(scale) / Math.log(2); + } + + /** + * Sets the fractional zoom. + */ + public void setZoom(double zoom) { + setScale(Math.pow(2, zoom)); + } + public int getZoomLevel() { return zoomLevel; } @@ -117,12 +137,6 @@ public class MapPosition { return this; } - public MapPosition setScale(double scale) { - this.zoomLevel = FastMath.log2((int) scale); - this.scale = scale; - return this; - } - public void setPosition(GeoPoint geoPoint) { setPosition(geoPoint.getLatitude(), geoPoint.getLongitude()); }