|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package net.osmand.core.android;
|
|
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -10,13 +9,13 @@ import net.osmand.core.jni.IObfsCollection;
|
|
|
|
|
import net.osmand.core.jni.IRasterMapLayerProvider;
|
|
|
|
|
import net.osmand.core.jni.MapObjectsSymbolsProvider;
|
|
|
|
|
import net.osmand.core.jni.MapPresentationEnvironment;
|
|
|
|
|
import net.osmand.core.jni.MapPresentationEnvironment.LanguagePreference;
|
|
|
|
|
import net.osmand.core.jni.MapPrimitivesProvider;
|
|
|
|
|
import net.osmand.core.jni.MapPrimitiviser;
|
|
|
|
|
import net.osmand.core.jni.MapRasterLayerProvider_Software;
|
|
|
|
|
import net.osmand.core.jni.MapStylesCollection;
|
|
|
|
|
import net.osmand.core.jni.ObfMapObjectsProvider;
|
|
|
|
|
import net.osmand.core.jni.QStringStringHash;
|
|
|
|
|
import net.osmand.core.jni.MapPresentationEnvironment.LanguagePreference;
|
|
|
|
|
import net.osmand.core.jni.ResolvedMapStyle;
|
|
|
|
|
import net.osmand.plus.OsmandApplication;
|
|
|
|
|
import net.osmand.plus.OsmandSettings;
|
|
|
|
@ -28,7 +27,6 @@ import net.osmand.util.Algorithms;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Context container and utility class for MapRendererView and derivatives.
|
|
|
|
|
*
|
|
|
|
|
* @author Alexey Pelykh
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
@ -37,58 +35,27 @@ public class MapRendererContext {
|
|
|
|
|
private static final int OBF_RASTER_LAYER = 0;
|
|
|
|
|
private OsmandApplication app;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cached map styles per name
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, ResolvedMapStyle> mapStyles = new HashMap<String, ResolvedMapStyle>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to OBF map symbols provider (if used)
|
|
|
|
|
*/
|
|
|
|
|
private IMapTiledSymbolsProvider obfMapSymbolsProvider;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map styles collection
|
|
|
|
|
*/
|
|
|
|
|
// input parameters
|
|
|
|
|
private MapStylesCollection mapStylesCollection;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to map presentation environment (if used)
|
|
|
|
|
*/
|
|
|
|
|
private MapPresentationEnvironment mapPresentationEnvironment;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to OBFs collection (if present)
|
|
|
|
|
*/
|
|
|
|
|
private IObfsCollection obfsCollection;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to map renderer view that is currently managed by this
|
|
|
|
|
* context
|
|
|
|
|
*/
|
|
|
|
|
private boolean nightMode;
|
|
|
|
|
private final float density;
|
|
|
|
|
|
|
|
|
|
// ached objects
|
|
|
|
|
private Map<String, ResolvedMapStyle> mapStyles = new HashMap<String, ResolvedMapStyle>();
|
|
|
|
|
private CachedMapPresentation presentationObjectParams;
|
|
|
|
|
private MapPresentationEnvironment mapPresentationEnvironment;
|
|
|
|
|
|
|
|
|
|
private IMapTiledSymbolsProvider obfMapSymbolsProvider;
|
|
|
|
|
private IRasterMapLayerProvider obfMapRasterLayerProvider;
|
|
|
|
|
private MapRendererView mapRendererView;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Display density factor
|
|
|
|
|
*/
|
|
|
|
|
private float displayDensityFactor = 1;
|
|
|
|
|
private float cachedReferenceTileSize;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference tile size on screen in pixels
|
|
|
|
|
*/
|
|
|
|
|
private float referenceTileSizef = 256;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Raster tile size in texels
|
|
|
|
|
*/
|
|
|
|
|
private int rasterTileSize = 256;
|
|
|
|
|
|
|
|
|
|
private CachedMapPresentation presentationObjectParams;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MapRendererContext(OsmandApplication app) {
|
|
|
|
|
public MapRendererContext(OsmandApplication app, float density) {
|
|
|
|
|
this.app = app;
|
|
|
|
|
this.density = density;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -102,7 +69,157 @@ public class MapRendererContext {
|
|
|
|
|
}
|
|
|
|
|
this.mapRendererView = mapRendererView;
|
|
|
|
|
if (mapRendererView != null) {
|
|
|
|
|
apply();
|
|
|
|
|
applyCurrentContextToView();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isNightMode() {
|
|
|
|
|
return nightMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNightMode(boolean nightMode) {
|
|
|
|
|
this.nightMode = nightMode;
|
|
|
|
|
updateMapSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateMapSettings() {
|
|
|
|
|
if (mapRendererView instanceof AtlasMapRendererView && cachedReferenceTileSize != getReferenceTileSize()) {
|
|
|
|
|
((AtlasMapRendererView) mapRendererView).setReferenceTileSizeOnScreenInPixels(getReferenceTileSize());
|
|
|
|
|
}
|
|
|
|
|
if(mapPresentationEnvironment != null) {
|
|
|
|
|
updateMapPresentationEnvironment();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Setup OBF map on layer 0 with symbols
|
|
|
|
|
* @param obfsCollection OBFs collection
|
|
|
|
|
*/
|
|
|
|
|
public void setupObfMap(MapStylesCollection mapStylesCollection, IObfsCollection obfsCollection) {
|
|
|
|
|
this.obfsCollection = obfsCollection;
|
|
|
|
|
this.mapStylesCollection = mapStylesCollection;
|
|
|
|
|
updateMapPresentationEnvironment();
|
|
|
|
|
recreateRasterAndSymbolsProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected float getDisplayDensityFactor() {
|
|
|
|
|
return (float) Math.pow(2, Math.sqrt((app.getSettings().getSettingsZoomScale() + density)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected int getRasterTileSize() {
|
|
|
|
|
return Integer.highestOneBit((int) getReferenceTileSize() - 1) * 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private float getReferenceTileSize() {
|
|
|
|
|
return 256 * getDisplayDensityFactor();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update map presentation environment and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateMapPresentationEnvironment() {
|
|
|
|
|
float displayDensityFactor = getDisplayDensityFactor();
|
|
|
|
|
// Create new map presentation environment
|
|
|
|
|
String langId = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
|
|
|
|
// TODO make setting
|
|
|
|
|
LanguagePreference langPref = LanguagePreference.LocalizedOrNative;
|
|
|
|
|
String rendName = app.getSettings().RENDERER.get();
|
|
|
|
|
if (rendName.length() == 0 || rendName.equals(RendererRegistry.DEFAULT_RENDER)) {
|
|
|
|
|
rendName = "default";
|
|
|
|
|
}
|
|
|
|
|
if (!mapStyles.containsKey(rendName)) {
|
|
|
|
|
mapStyles.put(rendName, mapStylesCollection.getResolvedStyleByName(rendName));
|
|
|
|
|
}
|
|
|
|
|
ResolvedMapStyle mapStyle = mapStyles.get(rendName);
|
|
|
|
|
CachedMapPresentation pres = new CachedMapPresentation(langId, langPref, mapStyle, displayDensityFactor);
|
|
|
|
|
if (this.presentationObjectParams == null || !this.presentationObjectParams.equalsFields(pres)) {
|
|
|
|
|
this.presentationObjectParams = pres;
|
|
|
|
|
mapPresentationEnvironment = new MapPresentationEnvironment(mapStyle, displayDensityFactor, langId,
|
|
|
|
|
langPref);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringStringHash convertedStyleSettings = getMapStyleSettings();
|
|
|
|
|
mapPresentationEnvironment.setSettings(convertedStyleSettings);
|
|
|
|
|
|
|
|
|
|
if (obfMapRasterLayerProvider != null || obfMapSymbolsProvider != null) {
|
|
|
|
|
recreateRasterAndSymbolsProvider();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected QStringStringHash getMapStyleSettings() {
|
|
|
|
|
// Apply map style settings
|
|
|
|
|
OsmandSettings prefs = app.getSettings();
|
|
|
|
|
RenderingRulesStorage storage = app.getRendererRegistry().getCurrentSelectedRenderer();
|
|
|
|
|
Map<String, String> props = new HashMap<String, String>();
|
|
|
|
|
for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
|
|
|
|
|
if (customProp.isBoolean()) {
|
|
|
|
|
CommonPreference<Boolean> pref = prefs.getCustomRenderBooleanProperty(customProp.getAttrName());
|
|
|
|
|
props.put(customProp.getAttrName(), pref.get() + "");
|
|
|
|
|
} else {
|
|
|
|
|
CommonPreference<String> settings = prefs.getCustomRenderProperty(customProp.getAttrName());
|
|
|
|
|
String res = settings.get();
|
|
|
|
|
if (!Algorithms.isEmpty(res)) {
|
|
|
|
|
props.put(customProp.getAttrName(), res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringStringHash convertedStyleSettings = new QStringStringHash();
|
|
|
|
|
for (Iterator<Map.Entry<String, String>> itSetting = props.entrySet().iterator(); itSetting.hasNext();) {
|
|
|
|
|
Map.Entry<String, String> setting = itSetting.next();
|
|
|
|
|
convertedStyleSettings.set(setting.getKey(), setting.getValue());
|
|
|
|
|
}
|
|
|
|
|
if (nightMode) {
|
|
|
|
|
convertedStyleSettings.set("nightMode", "true");
|
|
|
|
|
}
|
|
|
|
|
return convertedStyleSettings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void recreateRasterAndSymbolsProvider() {
|
|
|
|
|
// Create new map primitiviser
|
|
|
|
|
MapPrimitiviser mapPrimitiviser = new MapPrimitiviser(mapPresentationEnvironment);
|
|
|
|
|
ObfMapObjectsProvider obfMapObjectsProvider = new ObfMapObjectsProvider(obfsCollection);
|
|
|
|
|
// Create new map primitives provider
|
|
|
|
|
MapPrimitivesProvider mapPrimitivesProvider = new MapPrimitivesProvider(obfMapObjectsProvider, mapPrimitiviser,
|
|
|
|
|
getRasterTileSize());
|
|
|
|
|
updateObfMapRasterLayerProvider(mapPrimitivesProvider);
|
|
|
|
|
updateObfMapSymbolsProvider(mapPrimitivesProvider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateObfMapRasterLayerProvider(MapPrimitivesProvider mapPrimitivesProvider) {
|
|
|
|
|
// Create new OBF map raster layer provider
|
|
|
|
|
obfMapRasterLayerProvider = new MapRasterLayerProvider_Software(mapPrimitivesProvider);
|
|
|
|
|
// In case there's bound view and configured layer, perform setup
|
|
|
|
|
if (mapRendererView != null) {
|
|
|
|
|
mapRendererView.setMapLayerProvider(OBF_RASTER_LAYER, obfMapRasterLayerProvider);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateObfMapSymbolsProvider(MapPrimitivesProvider mapPrimitivesProvider) {
|
|
|
|
|
// If there's current provider and bound view, remove it
|
|
|
|
|
if (obfMapSymbolsProvider != null && mapRendererView != null) {
|
|
|
|
|
mapRendererView.removeSymbolsProvider(obfMapSymbolsProvider);
|
|
|
|
|
}
|
|
|
|
|
// Create new OBF map symbols provider
|
|
|
|
|
obfMapSymbolsProvider = new MapObjectsSymbolsProvider(mapPrimitivesProvider, getReferenceTileSize());
|
|
|
|
|
// If there's bound view, add new provider
|
|
|
|
|
if (mapRendererView != null) {
|
|
|
|
|
mapRendererView.addSymbolsProvider(obfMapSymbolsProvider);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void applyCurrentContextToView() {
|
|
|
|
|
if (mapRendererView instanceof AtlasMapRendererView) {
|
|
|
|
|
cachedReferenceTileSize = getReferenceTileSize();
|
|
|
|
|
((AtlasMapRendererView)mapRendererView).setReferenceTileSizeOnScreenInPixels(cachedReferenceTileSize);
|
|
|
|
|
}
|
|
|
|
|
// Layers
|
|
|
|
|
if (obfMapRasterLayerProvider != null) {
|
|
|
|
|
mapRendererView.setMapLayerProvider(OBF_RASTER_LAYER, obfMapRasterLayerProvider);
|
|
|
|
|
}
|
|
|
|
|
// Symbols
|
|
|
|
|
if (obfMapSymbolsProvider != null) {
|
|
|
|
|
mapRendererView.addSymbolsProvider(obfMapSymbolsProvider);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -143,232 +260,5 @@ public class MapRendererContext {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set display density factor and update context (if needed)
|
|
|
|
|
* @param displayDensityFactor New display density factor
|
|
|
|
|
*/
|
|
|
|
|
public void setDisplayDensityFactor(float displayDensityFactor) {
|
|
|
|
|
this.displayDensityFactor = displayDensityFactor;
|
|
|
|
|
referenceTileSizef = 256.0f * displayDensityFactor;
|
|
|
|
|
rasterTileSize = Integer.highestOneBit((int) referenceTileSizef - 1) * 2;
|
|
|
|
|
|
|
|
|
|
if (mapRendererView instanceof AtlasMapRendererView)
|
|
|
|
|
((AtlasMapRendererView) mapRendererView)
|
|
|
|
|
.setReferenceTileSizeOnScreenInPixels(referenceTileSizef);
|
|
|
|
|
if (mapPresentationEnvironment != null)
|
|
|
|
|
updateMapPresentationEnvironment();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update map presentation environment and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateMapPresentationEnvironment() {
|
|
|
|
|
// Create new map presentation environment
|
|
|
|
|
String langId = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
|
|
|
|
// TODO make setting
|
|
|
|
|
LanguagePreference langPref = LanguagePreference.LocalizedOrNative;
|
|
|
|
|
String rendName = app.getSettings().RENDERER.get();
|
|
|
|
|
if(rendName.length() == 0 || rendName.equals(RendererRegistry.DEFAULT_RENDER)) {
|
|
|
|
|
rendName = "default";
|
|
|
|
|
}
|
|
|
|
|
if(!mapStyles.containsKey(rendName)) {
|
|
|
|
|
mapStyles.put(rendName, mapStylesCollection.getResolvedStyleByName(rendName));
|
|
|
|
|
}
|
|
|
|
|
ResolvedMapStyle mapStyle = mapStyles.get(rendName);
|
|
|
|
|
CachedMapPresentation pres = new CachedMapPresentation(langId, langPref, mapStyle, displayDensityFactor);
|
|
|
|
|
if (this.presentationObjectParams == null
|
|
|
|
|
|| !this.presentationObjectParams.equalsFields(pres)) {
|
|
|
|
|
this.presentationObjectParams = pres;
|
|
|
|
|
mapPresentationEnvironment = new MapPresentationEnvironment(
|
|
|
|
|
mapStyle, displayDensityFactor, langId, langPref);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Apply map style settings
|
|
|
|
|
OsmandSettings prefs = app.getSettings();
|
|
|
|
|
RenderingRulesStorage storage = app.getRendererRegistry()
|
|
|
|
|
.getCurrentSelectedRenderer();
|
|
|
|
|
Map<String, String> props = new HashMap<String, String>();
|
|
|
|
|
for (RenderingRuleProperty customProp : storage.PROPS.getCustomRules()) {
|
|
|
|
|
if (customProp.isBoolean()) {
|
|
|
|
|
CommonPreference<Boolean> pref = prefs
|
|
|
|
|
.getCustomRenderBooleanProperty(customProp
|
|
|
|
|
.getAttrName());
|
|
|
|
|
props.put(customProp.getAttrName(), pref.get() + "");
|
|
|
|
|
} else {
|
|
|
|
|
CommonPreference<String> settings = prefs
|
|
|
|
|
.getCustomRenderProperty(customProp.getAttrName());
|
|
|
|
|
String res = settings.get();
|
|
|
|
|
if (!Algorithms.isEmpty(res)) {
|
|
|
|
|
props.put(customProp.getAttrName(), res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringStringHash convertedStyleSettings = new QStringStringHash();
|
|
|
|
|
for (Iterator<Map.Entry<String, String>> itSetting = props.entrySet()
|
|
|
|
|
.iterator(); itSetting.hasNext();) {
|
|
|
|
|
Map.Entry<String, String> setting = itSetting.next();
|
|
|
|
|
convertedStyleSettings.set(setting.getKey(), setting.getValue());
|
|
|
|
|
}
|
|
|
|
|
if(nightMode) {
|
|
|
|
|
convertedStyleSettings.set("nightMode", "true");
|
|
|
|
|
}
|
|
|
|
|
mapPresentationEnvironment.setSettings(convertedStyleSettings);
|
|
|
|
|
|
|
|
|
|
// Update all dependencies
|
|
|
|
|
if (mapPrimitiviser != null) {
|
|
|
|
|
updateMapPrimitiviser();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to map primitiviser (if used)
|
|
|
|
|
*/
|
|
|
|
|
private MapPrimitiviser mapPrimitiviser;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update map primitiviser and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateMapPrimitiviser() {
|
|
|
|
|
// Create new map primitiviser
|
|
|
|
|
mapPrimitiviser = new MapPrimitiviser(mapPresentationEnvironment);
|
|
|
|
|
|
|
|
|
|
// Update all dependencies
|
|
|
|
|
if (mapPrimitivesProvider != null)
|
|
|
|
|
updateMapPrimitivesProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to OBF map objects provider (if used)
|
|
|
|
|
*/
|
|
|
|
|
private ObfMapObjectsProvider _obfMapObjectsProvider;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update OBF map objects provider and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateObfMapObjectsProvider() {
|
|
|
|
|
_obfMapObjectsProvider = new ObfMapObjectsProvider(
|
|
|
|
|
obfsCollection);
|
|
|
|
|
|
|
|
|
|
// Update all dependencies
|
|
|
|
|
if (mapPrimitivesProvider != null)
|
|
|
|
|
updateMapPrimitivesProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to map primitives provider (if used)
|
|
|
|
|
*/
|
|
|
|
|
private MapPrimitivesProvider mapPrimitivesProvider;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update map primitives provider and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateMapPrimitivesProvider() {
|
|
|
|
|
// Create new map primitives provider
|
|
|
|
|
mapPrimitivesProvider = new MapPrimitivesProvider(
|
|
|
|
|
_obfMapObjectsProvider,
|
|
|
|
|
mapPrimitiviser,
|
|
|
|
|
rasterTileSize);
|
|
|
|
|
|
|
|
|
|
// Update all dependencies
|
|
|
|
|
if (obfMapRasterLayerProvider != null)
|
|
|
|
|
updateObfMapRasterLayerProvider();
|
|
|
|
|
if (obfMapSymbolsProvider != null)
|
|
|
|
|
updateObfMapSymbolsProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reference to OBF map raster layer provider (if used)
|
|
|
|
|
*/
|
|
|
|
|
private IRasterMapLayerProvider obfMapRasterLayerProvider;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Index of OBF map raster layer in bound map renderer view (if set)
|
|
|
|
|
*/
|
|
|
|
|
private Integer obfMapRasterLayer;
|
|
|
|
|
private boolean nightMode;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update OBF map raster layer provider and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateObfMapRasterLayerProvider() {
|
|
|
|
|
// Create new OBF map raster layer provider
|
|
|
|
|
obfMapRasterLayerProvider = new MapRasterLayerProvider_Software(
|
|
|
|
|
mapPrimitivesProvider);
|
|
|
|
|
|
|
|
|
|
// In case there's bound view and configured layer, perform setup
|
|
|
|
|
if(mapRendererView != null && obfMapRasterLayer != null)
|
|
|
|
|
mapRendererView.setMapLayerProvider(obfMapRasterLayer, obfMapRasterLayerProvider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update OBF map symbols provider and everything that depends on it
|
|
|
|
|
*/
|
|
|
|
|
private void updateObfMapSymbolsProvider() {
|
|
|
|
|
// If there's current provider and bound view, remove it
|
|
|
|
|
if (obfMapSymbolsProvider != null && mapRendererView != null)
|
|
|
|
|
mapRendererView.removeSymbolsProvider(obfMapSymbolsProvider);
|
|
|
|
|
|
|
|
|
|
// Create new OBF map symbols provider
|
|
|
|
|
obfMapSymbolsProvider = new MapObjectsSymbolsProvider(
|
|
|
|
|
mapPrimitivesProvider,
|
|
|
|
|
referenceTileSizef);
|
|
|
|
|
|
|
|
|
|
// If there's bound view, add new provider
|
|
|
|
|
if (mapRendererView != null)
|
|
|
|
|
mapRendererView.addSymbolsProvider(obfMapSymbolsProvider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Apply current context to view
|
|
|
|
|
*/
|
|
|
|
|
private void apply() {
|
|
|
|
|
if (mapRendererView instanceof AtlasMapRendererView)
|
|
|
|
|
((AtlasMapRendererView)mapRendererView).setReferenceTileSizeOnScreenInPixels(referenceTileSizef);
|
|
|
|
|
|
|
|
|
|
// Layers
|
|
|
|
|
if (obfMapRasterLayer != null && obfMapRasterLayerProvider != null)
|
|
|
|
|
mapRendererView.setMapLayerProvider(obfMapRasterLayer, obfMapRasterLayerProvider);
|
|
|
|
|
|
|
|
|
|
// Symbols
|
|
|
|
|
if (obfMapSymbolsProvider != null)
|
|
|
|
|
mapRendererView.addSymbolsProvider(obfMapSymbolsProvider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Setup OBF map on layer 0 with symbols
|
|
|
|
|
* @param obfsCollection OBFs collection
|
|
|
|
|
*/
|
|
|
|
|
public void setupObfMap(MapStylesCollection mapStylesCollection, IObfsCollection obfsCollection) {
|
|
|
|
|
this.obfsCollection = obfsCollection;
|
|
|
|
|
this.mapStylesCollection = mapStylesCollection;
|
|
|
|
|
this.obfMapRasterLayer = OBF_RASTER_LAYER;
|
|
|
|
|
updateMapPresentationEnvironment();
|
|
|
|
|
updateMapPrimitiviser();
|
|
|
|
|
updateMapPrimitivesProvider();
|
|
|
|
|
updateObfMapObjectsProvider();
|
|
|
|
|
updateObfMapRasterLayerProvider();
|
|
|
|
|
updateObfMapSymbolsProvider();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateMapSettings() {
|
|
|
|
|
if (mapPresentationEnvironment != null) {
|
|
|
|
|
updateMapPresentationEnvironment();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isNightMode() {
|
|
|
|
|
return nightMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setNightMode(boolean nightMode) {
|
|
|
|
|
this.nightMode = nightMode;
|
|
|
|
|
updateMapSettings();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|