Fix raster layers
This commit is contained in:
parent
e24f43d685
commit
39051c7004
3 changed files with 79 additions and 80 deletions
|
@ -44,17 +44,17 @@ public class SettingsRasterMapsActivity extends SettingsBaseActivity {
|
|||
cat.addPreference(createCheckBoxPreference(settings.USE_INTERNET_TO_DOWNLOAD_TILES,
|
||||
R.string.use_internet, R.string.use_internet_to_download_tile));
|
||||
|
||||
int startZoom = 1;
|
||||
int endZoom = 18;
|
||||
String[] entries = new String[endZoom - startZoom + 1];
|
||||
Integer[] intValues = new Integer[endZoom - startZoom + 1];
|
||||
for (int i = startZoom; i <= endZoom; i++) {
|
||||
entries[i - startZoom] = i + ""; //$NON-NLS-1$
|
||||
intValues[i - startZoom] = i ;
|
||||
}
|
||||
ListPreference lp = createListPreference(settings.LEVEL_TO_SWITCH_VECTOR_RASTER,
|
||||
entries, intValues, R.string.level_to_switch_vector_raster, R.string.level_to_switch_vector_raster_descr);
|
||||
cat.addPreference(lp);
|
||||
// int startZoom = 1;
|
||||
// int endZoom = 18;
|
||||
// String[] entries = new String[endZoom - startZoom + 1];
|
||||
// Integer[] intValues = new Integer[endZoom - startZoom + 1];
|
||||
// for (int i = startZoom; i <= endZoom; i++) {
|
||||
// entries[i - startZoom] = i + ""; //$NON-NLS-1$
|
||||
// intValues[i - startZoom] = i ;
|
||||
// }
|
||||
// ListPreference lp = createListPreference(settings.LEVEL_TO_SWITCH_VECTOR_RASTER,
|
||||
// entries, intValues, R.string.level_to_switch_vector_raster, R.string.level_to_switch_vector_raster_descr);
|
||||
// cat.addPreference(lp);
|
||||
|
||||
// present on configure map
|
||||
// addOverlayPrefs(grp, listener);
|
||||
|
|
|
@ -94,75 +94,76 @@ public class MapVectorLayer extends BaseMapLayer {
|
|||
if (!visible) {
|
||||
return;
|
||||
}
|
||||
if (!isVectorDataVisible() && tileLayer != null) {
|
||||
tileLayer.drawTileMap(canvas, tilesRect);
|
||||
resourceManager.getRenderer().interruptLoadingMap();
|
||||
} else {
|
||||
final MapRendererView mapRenderer = view.getMapRenderer();
|
||||
if (mapRenderer != null && !oldRender) {
|
||||
NativeCoreContext.getMapRendererContext().setNightMode(drawSettings.isNightMode());
|
||||
OsmandSettings st = view.getApplication().getSettings();
|
||||
if (!Algorithms.objectEquals(st.MAP_UNDERLAY.get(), cachedUnderlay)) {
|
||||
cachedUnderlay = st.MAP_UNDERLAY.get();
|
||||
ITileSource tileSource = st.getTileSourceByName(cachedUnderlay, false);
|
||||
if (tileSource != null) {
|
||||
TileSourceProxyProvider prov = new TileSourceProxyProvider(view.getApplication(), tileSource);
|
||||
mapRenderer.setMapLayerProvider(-1, prov.instantiateProxy(true));
|
||||
prov.swigReleaseOwnership();
|
||||
// mapRenderer.setMapLayerProvider(-1, net.osmand.core.jni.OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"));
|
||||
} else {
|
||||
mapRenderer.resetMapLayerProvider(-1);
|
||||
}
|
||||
// if (!isVectorDataVisible() && tileLayer != null) {
|
||||
// tileLayer.drawTileMap(canvas, tilesRect);
|
||||
// resourceManager.getRenderer().interruptLoadingMap();
|
||||
// } else {
|
||||
final MapRendererView mapRenderer = view.getMapRenderer();
|
||||
if (mapRenderer != null && !oldRender) {
|
||||
NativeCoreContext.getMapRendererContext().setNightMode(drawSettings.isNightMode());
|
||||
OsmandSettings st = view.getApplication().getSettings();
|
||||
if (!Algorithms.objectEquals(st.MAP_UNDERLAY.get(), cachedUnderlay)) {
|
||||
cachedUnderlay = st.MAP_UNDERLAY.get();
|
||||
ITileSource tileSource = st.getTileSourceByName(cachedUnderlay, false);
|
||||
if (tileSource != null) {
|
||||
TileSourceProxyProvider prov = new TileSourceProxyProvider(view.getApplication(), tileSource);
|
||||
mapRenderer.setMapLayerProvider(-1, prov.instantiateProxy(true));
|
||||
prov.swigReleaseOwnership();
|
||||
// mapRenderer.setMapLayerProvider(-1,
|
||||
// net.osmand.core.jni.OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"));
|
||||
} else {
|
||||
mapRenderer.resetMapLayerProvider(-1);
|
||||
}
|
||||
if (!Algorithms.objectEquals(st.MAP_TRANSPARENCY.get(), cachedMapTransparency)) {
|
||||
cachedMapTransparency = st.MAP_TRANSPARENCY.get();
|
||||
MapLayerConfiguration mapLayerConfiguration = new MapLayerConfiguration();
|
||||
mapLayerConfiguration.setOpacityFactor(((float)cachedMapTransparency) / 255.0f);
|
||||
mapRenderer.setMapLayerConfiguration(0, mapLayerConfiguration);
|
||||
}
|
||||
if (!Algorithms.objectEquals(st.MAP_OVERLAY.get(), cachedOverlay)) {
|
||||
cachedOverlay = st.MAP_OVERLAY.get();
|
||||
ITileSource tileSource = st.getTileSourceByName(cachedOverlay, false);
|
||||
if (tileSource != null) {
|
||||
TileSourceProxyProvider prov = new TileSourceProxyProvider(view.getApplication(), tileSource);
|
||||
mapRenderer.setMapLayerProvider(1, prov.instantiateProxy(true));
|
||||
prov.swigReleaseOwnership();
|
||||
// mapRenderer.setMapLayerProvider(1, net.osmand.core.jni.OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"));
|
||||
} else {
|
||||
mapRenderer.resetMapLayerProvider(1);
|
||||
}
|
||||
}
|
||||
if (!Algorithms.objectEquals(st.MAP_OVERLAY_TRANSPARENCY.get(), cachedOverlayTransparency)) {
|
||||
cachedOverlayTransparency = st.MAP_OVERLAY_TRANSPARENCY.get();
|
||||
MapLayerConfiguration mapLayerConfiguration = new MapLayerConfiguration();
|
||||
mapLayerConfiguration.setOpacityFactor(((float)cachedOverlayTransparency) / 255.0f);
|
||||
mapRenderer.setMapLayerConfiguration(1, mapLayerConfiguration);
|
||||
}
|
||||
// opengl renderer
|
||||
LatLon ll = tilesRect.getLatLonFromPixel(tilesRect.getPixWidth() / 2, tilesRect.getPixHeight() / 2);
|
||||
mapRenderer.setTarget(new PointI(MapUtils.get31TileNumberX(ll.getLongitude()),
|
||||
MapUtils.get31TileNumberY(ll.getLatitude())));
|
||||
mapRenderer.setAzimuth(-tilesRect.getRotate());
|
||||
mapRenderer.setZoom((float) (tilesRect.getZoom() + tilesRect
|
||||
.getZoomAnimation() + tilesRect.getZoomFloatPart()));
|
||||
float zoomMagnifier = st.MAP_DENSITY.get();
|
||||
mapRenderer.setVisualZoomShift(zoomMagnifier - 1.0f);
|
||||
} else {
|
||||
if (!view.isZooming()) {
|
||||
if (resourceManager.updateRenderedMapNeeded(tilesRect, drawSettings)) {
|
||||
// pixRect.set(-view.getWidth(), -view.getHeight() / 2, 2 * view.getWidth(), 3 *
|
||||
// view.getHeight() / 2);
|
||||
final RotatedTileBox copy = tilesRect.copy();
|
||||
copy.increasePixelDimensions(copy.getPixWidth() / 3, copy.getPixHeight() / 4);
|
||||
resourceManager.updateRendererMap(copy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MapRenderRepositories renderer = resourceManager.getRenderer();
|
||||
drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation(), tilesRect);
|
||||
drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation(), tilesRect);
|
||||
}
|
||||
if (!Algorithms.objectEquals(st.MAP_TRANSPARENCY.get(), cachedMapTransparency)) {
|
||||
cachedMapTransparency = st.MAP_TRANSPARENCY.get();
|
||||
MapLayerConfiguration mapLayerConfiguration = new MapLayerConfiguration();
|
||||
mapLayerConfiguration.setOpacityFactor(((float) cachedMapTransparency) / 255.0f);
|
||||
mapRenderer.setMapLayerConfiguration(0, mapLayerConfiguration);
|
||||
}
|
||||
if (!Algorithms.objectEquals(st.MAP_OVERLAY.get(), cachedOverlay)) {
|
||||
cachedOverlay = st.MAP_OVERLAY.get();
|
||||
ITileSource tileSource = st.getTileSourceByName(cachedOverlay, false);
|
||||
if (tileSource != null) {
|
||||
TileSourceProxyProvider prov = new TileSourceProxyProvider(view.getApplication(), tileSource);
|
||||
mapRenderer.setMapLayerProvider(1, prov.instantiateProxy(true));
|
||||
prov.swigReleaseOwnership();
|
||||
// mapRenderer.setMapLayerProvider(1,
|
||||
// net.osmand.core.jni.OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"));
|
||||
} else {
|
||||
mapRenderer.resetMapLayerProvider(1);
|
||||
}
|
||||
}
|
||||
if (!Algorithms.objectEquals(st.MAP_OVERLAY_TRANSPARENCY.get(), cachedOverlayTransparency)) {
|
||||
cachedOverlayTransparency = st.MAP_OVERLAY_TRANSPARENCY.get();
|
||||
MapLayerConfiguration mapLayerConfiguration = new MapLayerConfiguration();
|
||||
mapLayerConfiguration.setOpacityFactor(((float) cachedOverlayTransparency) / 255.0f);
|
||||
mapRenderer.setMapLayerConfiguration(1, mapLayerConfiguration);
|
||||
}
|
||||
// opengl renderer
|
||||
LatLon ll = tilesRect.getLatLonFromPixel(tilesRect.getPixWidth() / 2, tilesRect.getPixHeight() / 2);
|
||||
mapRenderer.setTarget(new PointI(MapUtils.get31TileNumberX(ll.getLongitude()), MapUtils.get31TileNumberY(ll
|
||||
.getLatitude())));
|
||||
mapRenderer.setAzimuth(-tilesRect.getRotate());
|
||||
mapRenderer.setZoom((float) (tilesRect.getZoom() + tilesRect.getZoomAnimation() + tilesRect
|
||||
.getZoomFloatPart()));
|
||||
float zoomMagnifier = st.MAP_DENSITY.get();
|
||||
mapRenderer.setVisualZoomShift(zoomMagnifier - 1.0f);
|
||||
} else {
|
||||
if (!view.isZooming()) {
|
||||
if (resourceManager.updateRenderedMapNeeded(tilesRect, drawSettings)) {
|
||||
// pixRect.set(-view.getWidth(), -view.getHeight() / 2, 2 * view.getWidth(), 3 *
|
||||
// view.getHeight() / 2);
|
||||
final RotatedTileBox copy = tilesRect.copy();
|
||||
copy.increasePixelDimensions(copy.getPixWidth() / 3, copy.getPixHeight() / 4);
|
||||
resourceManager.updateRendererMap(copy);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MapRenderRepositories renderer = resourceManager.getRenderer();
|
||||
drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation(), tilesRect);
|
||||
drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation(), tilesRect);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,7 +274,6 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
// TODO clear map cache
|
||||
setMapTileAdapter(null);
|
||||
}
|
||||
|
||||
|
@ -284,7 +283,6 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
// TODO clear map cache
|
||||
}
|
||||
|
||||
public ITileSource getMap() {
|
||||
|
|
Loading…
Reference in a new issue