Feature parameters, fix #403

This commit is contained in:
Emux 2017-09-16 16:21:00 +03:00
parent 4903a4b5f4
commit 607cdeb5db
20 changed files with 89 additions and 49 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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;
@ -43,7 +43,7 @@ public class ExampleLauncher extends IOSApplication.Delegate {
// IOSMapAppCluster iosMapApp = new IOSMapAppCluster();
ThemeLoader.POT_TEXTURES = true;
Parameters.POT_TEXTURES = true;
iosMapApp.init();
return new IOSApplication(iosMapApp, config);

View File

@ -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) {

View File

@ -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) {

View File

@ -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());

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
package org.oscim.utils;
public final class Parameters {
/**
* If true the <code>MapEventLayer2</code> will be used instead of default <code>MapEventLayer</code>.
*/
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();
}
}

View File

@ -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()) {