use of net.osmand.core.jni.QStringStringHash in project Osmand by osmandapp.
the class MapRendererContext method 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)) {
Log.d(TAG, "Style '" + rendName + "' not in cache");
if (mapStylesCollection.getStyleByName(rendName) == null) {
Log.d(TAG, "Unknown '" + rendName + "' style, need to load");
// Ensure parents are loaded (this may also trigger load)
app.getRendererRegistry().getRenderer(rendName);
if (mapStylesCollection.getStyleByName(rendName) == null) {
try {
loadStyleFromStream(rendName, app.getRendererRegistry().getInputStream(rendName));
} catch (IOException e) {
Log.e(TAG, "Failed to load '" + rendName + "'", e);
}
}
}
ResolvedMapStyle mapStyle = mapStylesCollection.getResolvedStyleByName(rendName);
if (mapStyle != null) {
mapStyles.put(rendName, mapStyle);
} else {
Log.d(TAG, "Failed to resolve '" + rendName + "', will use 'default'");
rendName = "default";
}
}
ResolvedMapStyle mapStyle = mapStyles.get(rendName);
CachedMapPresentation pres = new CachedMapPresentation(langId, langPref, mapStyle, density, app.getSettings().MAP_DENSITY.get(), app.getSettings().TEXT_SCALE.get());
if (this.presentationObjectParams == null || !this.presentationObjectParams.equalsFields(pres)) {
this.presentationObjectParams = pres;
mapPresentationEnvironment = new MapPresentationEnvironment(mapStyle, density, app.getSettings().MAP_DENSITY.get(), app.getSettings().TEXT_SCALE.get(), langId, langPref);
}
QStringStringHash convertedStyleSettings = getMapStyleSettings();
mapPresentationEnvironment.setSettings(convertedStyleSettings);
if (obfMapRasterLayerProvider != null || obfMapSymbolsProvider != null) {
recreateRasterAndSymbolsProvider();
}
}
use of net.osmand.core.jni.QStringStringHash in project Osmand by osmandapp.
the class MapRendererContext method getMapStyleSettings.
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 (RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN.equals(customProp.getCategory())) {
continue;
} else 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 (Map.Entry<String, String> setting : props.entrySet()) {
convertedStyleSettings.set(setting.getKey(), setting.getValue());
}
if (nightMode) {
convertedStyleSettings.set("nightMode", "true");
}
return convertedStyleSettings;
}
Aggregations