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

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