diff --git a/docs/Changelog.md b/docs/Changelog.md
index 1b8c3c2e..56458353 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -12,6 +12,7 @@
- Mapsforge fix artifacts zoom > 17 [#231](https://github.com/mapsforge/vtm/issues/231)
- PolyLabel default disabled [#402](https://github.com/mapsforge/vtm/issues/402)
- vtm-theme-comparator module [#387](https://github.com/mapsforge/vtm/issues/387)
+- Feature parameters [#403](https://github.com/mapsforge/vtm/issues/403)
- Internal render themes various improvements [#41](https://github.com/mapsforge/vtm/issues/41)
- Many other minor improvements and bug fixes
- [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.9.0)
diff --git a/vtm-android-example/src/org/oscim/android/test/AtlasThemeActivity.java b/vtm-android-example/src/org/oscim/android/test/AtlasThemeActivity.java
index c2a22a4d..d0dcb1dd 100644
--- a/vtm-android-example/src/org/oscim/android/test/AtlasThemeActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/AtlasThemeActivity.java
@@ -17,13 +17,13 @@ package org.oscim.android.test;
import android.os.Bundle;
-import org.oscim.theme.ThemeLoader;
+import org.oscim.utils.Parameters;
public class AtlasThemeActivity extends SimpleMapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
- ThemeLoader.USE_ATLAS = true;
+ Parameters.TEXTURE_ATLAS = true;
super.onCreate(savedInstanceState);
}
diff --git a/vtm-android-example/src/org/oscim/android/test/MapsforgePolyLabelActivity.java b/vtm-android-example/src/org/oscim/android/test/MapsforgePolyLabelActivity.java
index 40f73196..8c2ac434 100644
--- a/vtm-android-example/src/org/oscim/android/test/MapsforgePolyLabelActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/MapsforgePolyLabelActivity.java
@@ -16,13 +16,13 @@ package org.oscim.android.test;
import android.os.Bundle;
-import org.oscim.layers.tile.vector.labeling.LabelLayer;
+import org.oscim.utils.Parameters;
public class MapsforgePolyLabelActivity extends MapsforgeMapActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
- LabelLayer.POLY_LABEL = true;
+ Parameters.POLY_LABEL = true;
super.onCreate(savedInstanceState);
}
diff --git a/vtm-android-example/src/org/oscim/android/test/NewGesturesActivity.java b/vtm-android-example/src/org/oscim/android/test/NewGesturesActivity.java
index b058f8ad..2045c040 100644
--- a/vtm-android-example/src/org/oscim/android/test/NewGesturesActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/NewGesturesActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 devemux86
+ * Copyright 2016-2017 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -14,13 +14,13 @@
*/
package org.oscim.android.test;
-import org.oscim.map.Map;
+import org.oscim.utils.Parameters;
public class NewGesturesActivity extends MarkerOverlayActivity {
public NewGesturesActivity() {
super();
- Map.NEW_GESTURES = true;
+ Parameters.MAP_EVENT_LAYER2 = true;
}
@Override
@@ -28,6 +28,6 @@ public class NewGesturesActivity extends MarkerOverlayActivity {
super.onDestroy();
// Revert gestures for other activities
- Map.NEW_GESTURES = false;
+ Parameters.MAP_EVENT_LAYER2 = false;
}
}
diff --git a/vtm-android-example/src/org/oscim/android/test/POTTextureActivity.java b/vtm-android-example/src/org/oscim/android/test/POTTextureActivity.java
index 4e3354d5..bef12fc1 100644
--- a/vtm-android-example/src/org/oscim/android/test/POTTextureActivity.java
+++ b/vtm-android-example/src/org/oscim/android/test/POTTextureActivity.java
@@ -16,13 +16,13 @@ package org.oscim.android.test;
import android.os.Bundle;
-import org.oscim.theme.ThemeLoader;
+import org.oscim.utils.Parameters;
public class POTTextureActivity extends SimpleMapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
- ThemeLoader.POT_TEXTURES = true;
+ Parameters.POT_TEXTURES = true;
super.onCreate(savedInstanceState);
}
diff --git a/vtm-android/src/org/oscim/android/MapView.java b/vtm-android/src/org/oscim/android/MapView.java
index 6958b7af..933b0211 100644
--- a/vtm-android/src/org/oscim/android/MapView.java
+++ b/vtm-android/src/org/oscim/android/MapView.java
@@ -33,6 +33,7 @@ import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.GLAdapter;
import org.oscim.core.Tile;
import org.oscim.map.Map;
+import org.oscim.utils.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -102,7 +103,7 @@ public class MapView extends GLSurfaceView {
mMap.clearMap();
mMap.updateMap(false);
- if (!Map.NEW_GESTURES) {
+ if (!Parameters.MAP_EVENT_LAYER2) {
GestureHandler gestureHandler = new GestureHandler(mMap);
mGestureDetector = new GestureDetector(context, gestureHandler);
mGestureDetector.setOnDoubleTapListener(gestureHandler);
diff --git a/vtm-gdx/src/org/oscim/gdx/GdxMap.java b/vtm-gdx/src/org/oscim/gdx/GdxMap.java
index 6487c225..ac64b676 100644
--- a/vtm-gdx/src/org/oscim/gdx/GdxMap.java
+++ b/vtm-gdx/src/org/oscim/gdx/GdxMap.java
@@ -34,6 +34,7 @@ import org.oscim.map.Map;
import org.oscim.renderer.MapRenderer;
import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource;
+import org.oscim.utils.Parameters;
public abstract class GdxMap implements ApplicationListener {
@@ -85,7 +86,7 @@ public abstract class GdxMap implements ApplicationListener {
mMapRenderer.onSurfaceChanged(w, h);
InputMultiplexer mux = new InputMultiplexer();
- if (!Map.NEW_GESTURES) {
+ if (!Parameters.MAP_EVENT_LAYER2) {
mGestureDetector = new GestureDetector(new GestureHandlerImpl(mMap));
mux.addProcessor(mGestureDetector);
}
diff --git a/vtm-ios-example/src/org/oscim/ios/test/ExampleLauncher.java b/vtm-ios-example/src/org/oscim/ios/test/ExampleLauncher.java
index 558f7c2a..5fa392f3 100644
--- a/vtm-ios-example/src/org/oscim/ios/test/ExampleLauncher.java
+++ b/vtm-ios-example/src/org/oscim/ios/test/ExampleLauncher.java
@@ -1,6 +1,6 @@
/*
* Copyright 2016-2017 Longri
- * Copyright 2016 devemux86
+ * Copyright 2016-2017 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -19,7 +19,7 @@ import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
import org.oscim.backend.CanvasAdapter;
-import org.oscim.theme.ThemeLoader;
+import org.oscim.utils.Parameters;
import org.robovm.apple.foundation.NSAutoreleasePool;
import org.robovm.apple.glkit.GLKViewDrawableStencilFormat;
import org.robovm.apple.uikit.UIApplication;
@@ -38,12 +38,12 @@ public class ExampleLauncher extends IOSApplication.Delegate {
float scale = (float) (getIosVersion() >= 8 ? UIScreen.getMainScreen().getNativeScale() : UIScreen.getMainScreen().getScale());
CanvasAdapter.dpi *= scale;
- IOSMapApp iosMapApp = new IOSMapApp();
+ IOSMapApp iosMapApp = new IOSMapApp();
// IOSLineTexTest iosMapApp = new IOSLineTexTest();
// IOSMapAppCluster iosMapApp = new IOSMapAppCluster();
- ThemeLoader.POT_TEXTURES = true;
+ Parameters.POT_TEXTURES = true;
iosMapApp.init();
return new IOSApplication(iosMapApp, config);
diff --git a/vtm-playground/src/org/oscim/test/AtlasThemeMapTest.java b/vtm-playground/src/org/oscim/test/AtlasThemeMapTest.java
index 3e5597cf..d6c7c409 100644
--- a/vtm-playground/src/org/oscim/test/AtlasThemeMapTest.java
+++ b/vtm-playground/src/org/oscim/test/AtlasThemeMapTest.java
@@ -16,12 +16,12 @@
package org.oscim.test;
import org.oscim.gdx.GdxMapApp;
-import org.oscim.theme.ThemeLoader;
+import org.oscim.utils.Parameters;
public class AtlasThemeMapTest extends MapTest {
private AtlasThemeMapTest() {
- ThemeLoader.USE_ATLAS = true;
+ Parameters.TEXTURE_ATLAS = true;
}
public static void main(String[] args) {
diff --git a/vtm-playground/src/org/oscim/test/MapsforgePolyLabelTest.java b/vtm-playground/src/org/oscim/test/MapsforgePolyLabelTest.java
index 6bfbfbb7..254b0a05 100644
--- a/vtm-playground/src/org/oscim/test/MapsforgePolyLabelTest.java
+++ b/vtm-playground/src/org/oscim/test/MapsforgePolyLabelTest.java
@@ -15,7 +15,7 @@
package org.oscim.test;
import org.oscim.gdx.GdxMapApp;
-import org.oscim.layers.tile.vector.labeling.LabelLayer;
+import org.oscim.utils.Parameters;
import java.io.File;
@@ -24,7 +24,7 @@ public class MapsforgePolyLabelTest extends MapsforgeTest {
private MapsforgePolyLabelTest(File mapFile) {
super(mapFile);
- LabelLayer.POLY_LABEL = true;
+ Parameters.POLY_LABEL = true;
}
public static void main(String[] args) {
diff --git a/vtm-playground/src/org/oscim/test/NewGesturesTest.java b/vtm-playground/src/org/oscim/test/NewGesturesTest.java
index e0f3c0b4..58128113 100644
--- a/vtm-playground/src/org/oscim/test/NewGesturesTest.java
+++ b/vtm-playground/src/org/oscim/test/NewGesturesTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 devemux86
+ * Copyright 2016-2017 devemux86
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
@@ -15,12 +15,12 @@
package org.oscim.test;
import org.oscim.gdx.GdxMapApp;
-import org.oscim.map.Map;
+import org.oscim.utils.Parameters;
public class NewGesturesTest extends MarkerLayerTest {
public static void main(String[] args) {
- Map.NEW_GESTURES = true;
+ Parameters.MAP_EVENT_LAYER2 = true;
GdxMapApp.init();
GdxMapApp.run(new NewGesturesTest());
diff --git a/vtm-playground/src/org/oscim/test/POTTextureTest.java b/vtm-playground/src/org/oscim/test/POTTextureTest.java
index f0c3aa09..fb5a1088 100644
--- a/vtm-playground/src/org/oscim/test/POTTextureTest.java
+++ b/vtm-playground/src/org/oscim/test/POTTextureTest.java
@@ -18,12 +18,12 @@
package org.oscim.test;
import org.oscim.gdx.GdxMapApp;
-import org.oscim.theme.ThemeLoader;
+import org.oscim.utils.Parameters;
public class POTTextureTest extends MapTest {
private POTTextureTest() {
- ThemeLoader.POT_TEXTURES = true;
+ Parameters.POT_TEXTURES = true;
}
public static void main(String[] args) {
diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelLayer.java b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelLayer.java
index f44e55b2..25d58796 100644
--- a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelLayer.java
+++ b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelLayer.java
@@ -38,8 +38,6 @@ public class LabelLayer extends Layer implements Map.UpdateListener, TileManager
private static final long MAX_RELABEL_DELAY = 100;
- public static boolean POLY_LABEL;
-
private final LabelPlacement mLabelPlacer;
private final Worker mWorker;
diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelTileLoaderHook.java b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelTileLoaderHook.java
index 15bd28c3..dd9b8b8d 100644
--- a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelTileLoaderHook.java
+++ b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelTileLoaderHook.java
@@ -29,6 +29,7 @@ import org.oscim.renderer.bucket.TextItem;
import org.oscim.theme.styles.RenderStyle;
import org.oscim.theme.styles.SymbolStyle;
import org.oscim.theme.styles.TextStyle;
+import org.oscim.utils.Parameters;
import org.oscim.utils.geom.PolyLabel;
import static org.oscim.core.GeometryBuffer.GeometryType.LINE;
@@ -93,7 +94,7 @@ public class LabelTileLoaderHook implements TileLoaderThemeHook {
float x = 0;
float y = 0;
if (label == null) {
- if (LabelLayer.POLY_LABEL) {
+ if (Parameters.POLY_LABEL) {
label = PolyLabel.get(element);
x = label.x;
y = label.y;
diff --git a/vtm/src/org/oscim/map/Map.java b/vtm/src/org/oscim/map/Map.java
index 9177a305..d5279ab3 100644
--- a/vtm/src/org/oscim/map/Map.java
+++ b/vtm/src/org/oscim/map/Map.java
@@ -2,7 +2,7 @@
* Copyright 2013 Hannes Janetzek
* Copyright 2016 Andrey Novikov
* Copyright 2016 Stephan Leuschner
- * Copyright 2016 devemux86
+ * Copyright 2016-2017 devemux86
* Copyright 2016 Longri
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -40,6 +40,7 @@ import org.oscim.theme.IRenderTheme;
import org.oscim.theme.ThemeFile;
import org.oscim.theme.ThemeLoader;
import org.oscim.tiling.TileSource;
+import org.oscim.utils.Parameters;
import org.oscim.utils.ThreadUtils;
import org.oscim.utils.async.AsyncExecutor;
import org.oscim.utils.async.TaskQueue;
@@ -50,11 +51,6 @@ public abstract class Map implements TaskQueue {
private static final Logger log = LoggerFactory.getLogger(Map.class);
- /**
- * If true the {@link MapEventLayer2} will be used instead of default {@link MapEventLayer}.
- */
- public static boolean NEW_GESTURES = false;
-
/**
* Listener interface for map update notifications.
* Layers implementing this interface they will be automatically register
@@ -157,7 +153,7 @@ public abstract class Map implements TaskQueue {
mAsyncExecutor = new AsyncExecutor(4, this);
mMapPosition = new MapPosition();
- if (NEW_GESTURES)
+ if (Parameters.MAP_EVENT_LAYER2)
mEventLayer = new MapEventLayer2(this);
else
mEventLayer = new MapEventLayer(this);
diff --git a/vtm/src/org/oscim/theme/ThemeLoader.java b/vtm/src/org/oscim/theme/ThemeLoader.java
index 16c4bdeb..620115ce 100644
--- a/vtm/src/org/oscim/theme/ThemeLoader.java
+++ b/vtm/src/org/oscim/theme/ThemeLoader.java
@@ -20,12 +20,10 @@ package org.oscim.theme;
import org.oscim.backend.CanvasAdapter;
import org.oscim.theme.IRenderTheme.ThemeException;
+import org.oscim.utils.Parameters;
public class ThemeLoader {
- public static boolean USE_ATLAS;
- public static boolean POT_TEXTURES;
-
public static IRenderTheme load(String renderThemePath) throws ThemeException {
return load(new ExternalRenderTheme(renderThemePath));
}
@@ -49,9 +47,9 @@ public class ThemeLoader {
public static IRenderTheme load(ThemeFile theme, ThemeCallback themeCallback) throws ThemeException {
IRenderTheme t;
if (ThemeUtils.isMapsforgeTheme(theme))
- t = USE_ATLAS ? XmlMapsforgeAtlasThemeBuilder.read(theme, themeCallback) : XmlMapsforgeThemeBuilder.read(theme, themeCallback);
+ t = Parameters.TEXTURE_ATLAS ? XmlMapsforgeAtlasThemeBuilder.read(theme, themeCallback) : XmlMapsforgeThemeBuilder.read(theme, themeCallback);
else
- t = USE_ATLAS ? XmlAtlasThemeBuilder.read(theme, themeCallback) : XmlThemeBuilder.read(theme, themeCallback);
+ t = Parameters.TEXTURE_ATLAS ? XmlAtlasThemeBuilder.read(theme, themeCallback) : XmlThemeBuilder.read(theme, themeCallback);
if (t != null)
t.scaleTextSize(CanvasAdapter.getScale() * CanvasAdapter.textScale);
return t;
diff --git a/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java b/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java
index 26f3ff70..688cf429 100644
--- a/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java
+++ b/vtm/src/org/oscim/tiling/source/mapfile/MapDatabase.java
@@ -32,6 +32,7 @@ import org.oscim.layers.tile.MapTile;
import org.oscim.tiling.ITileDataSink;
import org.oscim.tiling.ITileDataSource;
import org.oscim.tiling.source.mapfile.header.SubFileParameter;
+import org.oscim.utils.Parameters;
import org.oscim.utils.geom.TileClipper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -532,7 +533,7 @@ public class MapDatabase implements ITileDataSource {
} else if (blockSize == 0) {
/* the current block is empty, continue with the next block */
continue;
- } else if (blockSize > ReadBuffer.MAXIMUM_BUFFER_SIZE) {
+ } else if (blockSize > Parameters.MAXIMUM_BUFFER_SIZE) {
/* the current block is too large, continue with the next
* block */
log.warn("current block size too large: " + blockSize);
diff --git a/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java b/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java
index 18d2a2f3..e5392d74 100644
--- a/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java
+++ b/vtm/src/org/oscim/tiling/source/mapfile/ReadBuffer.java
@@ -1,5 +1,6 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
+ * Copyright 2017 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -18,6 +19,7 @@ package org.oscim.tiling.source.mapfile;
import org.oscim.core.Tag;
import org.oscim.core.TagSet;
+import org.oscim.utils.Parameters;
import java.io.IOException;
import java.io.RandomAccessFile;
@@ -31,11 +33,6 @@ public class ReadBuffer {
private static final String CHARSET_UTF8 = "UTF-8";
private static final Logger LOG = Logger.getLogger(ReadBuffer.class.getName());
- /**
- * Maximum buffer size which is supported by this implementation.
- */
- static final int MAXIMUM_BUFFER_SIZE = 8000000;
-
private byte[] mBufferData;
private int mBufferPosition;
private final RandomAccessFile mInputFile;
@@ -67,7 +64,7 @@ public class ReadBuffer {
// ensure that the read buffer is large enough
if (mBufferData == null || mBufferData.length < length) {
// ensure that the read buffer is not too large
- if (length > MAXIMUM_BUFFER_SIZE) {
+ if (length > Parameters.MAXIMUM_BUFFER_SIZE) {
LOG.warning("invalid read length: " + length);
return false;
}
diff --git a/vtm/src/org/oscim/utils/Parameters.java b/vtm/src/org/oscim/utils/Parameters.java
new file mode 100644
index 00000000..1dff9ba8
--- /dev/null
+++ b/vtm/src/org/oscim/utils/Parameters.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2017 devemux86
+ *
+ * This program is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with
+ * this program. If not, see .
+ */
+package org.oscim.utils;
+
+public final class Parameters {
+
+ /**
+ * If true the MapEventLayer2
will be used instead of default MapEventLayer
.
+ */
+ public static boolean MAP_EVENT_LAYER2 = false;
+
+ /**
+ * Maximum buffer size for map files.
+ */
+ public static int MAXIMUM_BUFFER_SIZE = 8000000;
+
+ /**
+ * Optimal placement of text labels on polygons.
+ */
+ public static boolean POLY_LABEL = false;
+
+ /**
+ * POT textures in themes.
+ */
+ public static boolean POT_TEXTURES = false;
+
+ /**
+ * Texture atlas in themes.
+ */
+ public static boolean TEXTURE_ATLAS = false;
+
+ private Parameters() {
+ throw new IllegalStateException();
+ }
+}
diff --git a/vtm/src/org/oscim/utils/Utils.java b/vtm/src/org/oscim/utils/Utils.java
index caccd9f2..702c4af6 100644
--- a/vtm/src/org/oscim/utils/Utils.java
+++ b/vtm/src/org/oscim/utils/Utils.java
@@ -19,7 +19,6 @@ import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.renderer.bucket.TextureItem;
-import org.oscim.theme.ThemeLoader;
import org.oscim.utils.math.MathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,7 +46,7 @@ public final class Utils {
if (bitmap != null) {
log.debug("loading {}", src);
- if (ThemeLoader.POT_TEXTURES) {
+ if (Parameters.POT_TEXTURES) {
int potWidth = MathUtils.nextPowerOfTwo(bitmap.getWidth());
int potHeight = MathUtils.nextPowerOfTwo(bitmap.getHeight());
if (potWidth != bitmap.getWidth() || potHeight != bitmap.getHeight()) {