Online maps usage added for new render

This commit is contained in:
Denis_Bars 2014-09-29 15:58:04 +03:00
parent b6d92031e6
commit d1e07eeaab
2 changed files with 15 additions and 27 deletions

View file

@ -94,7 +94,7 @@ public class CoreResourcesFromAndroidAssets extends ICoreResourcesProvider {
// } // }
final ResourceData resourceData = new ResourceData(); final ResourceData resourceData = new ResourceData();
resourceData.offset = 0; resourceData.offset = 0;
resourceData.path = ((OsmandApplication) _context.getApplicationContext()).getAppPath("OsmAndCore_ResourcesBundle/" + resourceInBundle); resourceData.path = ((OsmandApplication) _context.getApplicationContext()).getAppPath("OsmAndCore_ResourcesBundle/" + resourceInBundle + ".qz");
resourceData.size = resourceData.path.length(); resourceData.size = resourceData.path.length();
// Get resource entry for this resource // Get resource entry for this resource
@ -164,7 +164,7 @@ public class CoreResourcesFromAndroidAssets extends ICoreResourcesProvider {
Log.d(TAG, "Using ddf=" + resourceDataEntry.getKey() + " while looking for " + displayDensityFactor + " of '" + name + "'"); Log.d(TAG, "Using ddf=" + resourceDataEntry.getKey() + " while looking for " + displayDensityFactor + " of '" + name + "'");
System.out.println(resourceData.path.getAbsolutePath()); System.out.println(resourceData.path.getAbsolutePath());
final SWIGTYPE_p_QByteArray data = SwigUtilities.qDecompress(SwigUtilities.readEntireFile( final SWIGTYPE_p_QByteArray data = SwigUtilities.qDecompress(SwigUtilities.readEntireFile(
resourceData.path.getAbsolutePath()+".qz")); resourceData.path.getAbsolutePath()));
if (data == null) { if (data == null) {
Log.e(TAG, "Failed to load data of '" + name + "'"); Log.e(TAG, "Failed to load data of '" + name + "'");
if (ok != null) if (ok != null)
@ -197,7 +197,7 @@ public class CoreResourcesFromAndroidAssets extends ICoreResourcesProvider {
} }
System.out.println(resourceEntry.defaultVariant.path.getAbsolutePath()); System.out.println(resourceEntry.defaultVariant.path.getAbsolutePath());
SWIGTYPE_p_QByteArray bt = SwigUtilities.readEntireFile( SWIGTYPE_p_QByteArray bt = SwigUtilities.readEntireFile(
resourceEntry.defaultVariant.path.getAbsolutePath() + ".qz"); resourceEntry.defaultVariant.path.getAbsolutePath());
final SWIGTYPE_p_QByteArray data = SwigUtilities.qDecompress(bt); final SWIGTYPE_p_QByteArray data = SwigUtilities.qDecompress(bt);
if (data == null) { if (data == null) {
Log.e(TAG, "Failed to load data of '" + name + "'"); Log.e(TAG, "Failed to load data of '" + name + "'");

View file

@ -8,27 +8,7 @@ import javax.microedition.khronos.egl.EGLSurface;
import javax.microedition.khronos.opengles.GL10; import javax.microedition.khronos.opengles.GL10;
import net.osmand.core.android.CoreResourcesFromAndroidAssets; import net.osmand.core.android.CoreResourcesFromAndroidAssets;
import net.osmand.core.jni.AreaI; import net.osmand.core.jni.*;
import net.osmand.core.jni.AtlasMapRendererConfiguration;
import net.osmand.core.jni.BinaryMapDataProvider;
import net.osmand.core.jni.BinaryMapPrimitivesProvider;
import net.osmand.core.jni.BinaryMapRasterBitmapTileProvider;
import net.osmand.core.jni.BinaryMapRasterBitmapTileProvider_Software;
import net.osmand.core.jni.BinaryMapStaticSymbolsProvider;
import net.osmand.core.jni.IMapRenderer;
import net.osmand.core.jni.IMapStylesCollection;
import net.osmand.core.jni.Logger;
import net.osmand.core.jni.MapPresentationEnvironment;
import net.osmand.core.jni.MapRendererClass;
import net.osmand.core.jni.MapRendererSetupOptions;
import net.osmand.core.jni.ResolvedMapStyle;
import net.osmand.core.jni.MapStylesCollection;
import net.osmand.core.jni.ObfsCollection;
import net.osmand.core.jni.OsmAndCore;
import net.osmand.core.jni.PointI;
import net.osmand.core.jni.Primitiviser;
import net.osmand.core.jni.QIODeviceLogSink;
import net.osmand.core.jni.RasterMapLayerId;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -53,6 +33,8 @@ import android.view.MotionEvent;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import java.io.File;
public class GLActivity extends Activity { public class GLActivity extends Activity {
static { static {
@ -78,6 +60,7 @@ public class GLActivity extends Activity {
private BinaryMapPrimitivesProvider _binaryMapPrimitivesProvider; private BinaryMapPrimitivesProvider _binaryMapPrimitivesProvider;
private BinaryMapStaticSymbolsProvider _binaryMapStaticSymbolsProvider; private BinaryMapStaticSymbolsProvider _binaryMapStaticSymbolsProvider;
private BinaryMapRasterBitmapTileProvider _binaryMapRasterBitmapTileProvider; private BinaryMapRasterBitmapTileProvider _binaryMapRasterBitmapTileProvider;
private OnlineRasterMapTileProvider _onlineMapRasterBitmapTileProvider;
private IMapRenderer _mapRenderer; private IMapRenderer _mapRenderer;
private GpuWorkerThreadPrologue _gpuWorkerThreadPrologue; private GpuWorkerThreadPrologue _gpuWorkerThreadPrologue;
private GpuWorkerThreadEpilogue _gpuWorkerThreadEpilogue; private GpuWorkerThreadEpilogue _gpuWorkerThreadEpilogue;
@ -201,8 +184,11 @@ public class GLActivity extends Activity {
Log.i(TAG, "Going to prepare OBFs collection"); Log.i(TAG, "Going to prepare OBFs collection");
_obfsCollection = new ObfsCollection(); _obfsCollection = new ObfsCollection();
Log.i(TAG, "Will load OBFs from " + Environment.getExternalStorageDirectory() + "/osmand"); Log.i(TAG, "Will load OBFs from " + Environment.getExternalStorageDirectory() + "/osmand");
_obfsCollection.addDirectory(Environment.getExternalStorageDirectory() + "/osmand", false); File directory =getApp().getAppPath("");
Log.i(TAG, "Will load OBFs from " + directory.getAbsolutePath());
_obfsCollection.addDirectory(directory.getAbsolutePath(), false);
Log.i(TAG, "Going to prepare all resources for renderer"); Log.i(TAG, "Going to prepare all resources for renderer");
_mapPresentationEnvironment = new MapPresentationEnvironment( _mapPresentationEnvironment = new MapPresentationEnvironment(
@ -224,6 +210,8 @@ public class GLActivity extends Activity {
_binaryMapRasterBitmapTileProvider = new BinaryMapRasterBitmapTileProvider_Software( _binaryMapRasterBitmapTileProvider = new BinaryMapRasterBitmapTileProvider_Software(
_binaryMapPrimitivesProvider); _binaryMapPrimitivesProvider);
_onlineMapRasterBitmapTileProvider = OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)");
Log.i(TAG, "Going to create renderer"); Log.i(TAG, "Going to create renderer");
_mapRenderer = OsmAndCore.createMapRenderer(MapRendererClass.AtlasMapRenderer_OpenGLES2); _mapRenderer = OsmAndCore.createMapRenderer(MapRendererClass.AtlasMapRenderer_OpenGLES2);
if (_mapRenderer == null) if (_mapRenderer == null)
@ -243,7 +231,7 @@ public class GLActivity extends Activity {
if (mapnik == null) if (mapnik == null)
Log.e(TAG, "Failed to create mapnik"); Log.e(TAG, "Failed to create mapnik");
*/ */
_mapRenderer.setRasterLayerProvider(RasterMapLayerId.BaseLayer, _binaryMapRasterBitmapTileProvider); _mapRenderer.setRasterLayerProvider(RasterMapLayerId.BaseLayer, _onlineMapRasterBitmapTileProvider);
_glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView); _glSurfaceView = (GLSurfaceView) findViewById(R.id.glSurfaceView);
//TODO:_glSurfaceView.setPreserveEGLContextOnPause(true); //TODO:_glSurfaceView.setPreserveEGLContextOnPause(true);