Blah Blah
This commit is contained in:
parent
92e3572a57
commit
9ac36c3d68
5 changed files with 108 additions and 26 deletions
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.map;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface ITileSource {
|
||||
|
||||
|
@ -11,6 +12,8 @@ public interface ITileSource {
|
|||
|
||||
public String getUrlToLoad(int x, int y, int zoom);
|
||||
|
||||
public byte[] getBytes(int x, int y, int zoom) throws IOException;
|
||||
|
||||
public int getMinimumZoomSupported();
|
||||
|
||||
public String getTileFormat();
|
||||
|
|
|
@ -239,8 +239,8 @@ public class CoreResourcesFromAndroidAssetsCustom extends interface_ICoreResourc
|
|||
}
|
||||
System.out.println(resourceEntry.defaultVariant.path.getAbsolutePath());
|
||||
final SWIGTYPE_p_QByteArray bt;
|
||||
if (resourceEntry.defaultVariant.offset == 0 &&
|
||||
resourceEntry.defaultVariant.size == resourceEntry.defaultVariant.path.length()) {
|
||||
if (resourceEntry.defaultVariant.offset == 0
|
||||
&& resourceEntry.defaultVariant.size == resourceEntry.defaultVariant.path.length()) {
|
||||
bt = SwigUtilities.readEntireFile(resourceEntry.defaultVariant.path.getAbsolutePath());
|
||||
} else {
|
||||
bt = SwigUtilities.readPartOfFile(resourceEntry.defaultVariant.path.getAbsolutePath(),
|
||||
|
|
57
OsmAnd/src/net/osmand/core/android/TileSourceProxyProvider.java
Executable file
57
OsmAnd/src/net/osmand/core/android/TileSourceProxyProvider.java
Executable file
|
@ -0,0 +1,57 @@
|
|||
package net.osmand.core.android;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.osmand.core.jni.AlphaChannelPresence;
|
||||
import net.osmand.core.jni.SWIGTYPE_p_QByteArray;
|
||||
import net.osmand.core.jni.SwigUtilities;
|
||||
import net.osmand.core.jni.TileId;
|
||||
import net.osmand.core.jni.ZoomLevel;
|
||||
import net.osmand.core.jni.interface_ImageMapLayerProvider;
|
||||
import net.osmand.map.ITileSource;
|
||||
|
||||
public class TileSourceProxyProvider extends interface_ImageMapLayerProvider {
|
||||
|
||||
private final ITileSource tileSource;
|
||||
|
||||
public TileSourceProxyProvider(ITileSource tileSource) {
|
||||
this.tileSource = tileSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZoomLevel getMinZoom() {
|
||||
return ZoomLevel.swigToEnum(tileSource.getMinimumZoomSupported());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZoomLevel getMaxZoom() {
|
||||
return ZoomLevel.swigToEnum(tileSource.getMaximumZoomSupported());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SWIGTYPE_p_QByteArray obtainImage(TileId tileId, ZoomLevel zoom) {
|
||||
byte[] image;
|
||||
try {
|
||||
image = tileSource.getBytes(tileId.getX(), tileId.getY(), zoom.swigValue());
|
||||
} catch(IOException e) {
|
||||
return SwigUtilities.emptyQByteArray();
|
||||
}
|
||||
|
||||
return SwigUtilities.createQByteArrayAsCopyOf(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTileSize() {
|
||||
return tileSource.getTileSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTileDensityFactor() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlphaChannelPresence getAlphaChannelPresence() {
|
||||
return AlphaChannelPresence.Unknown;
|
||||
}
|
||||
}
|
|
@ -262,7 +262,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
return db.isDbLockedByOtherThreads();
|
||||
}
|
||||
|
||||
public Bitmap getImage(int x, int y, int zoom, long[] timeHolder) {
|
||||
public byte[] getBytes(int x, int y, int zoom, long[] timeHolder) throws IOException {
|
||||
SQLiteConnection db = getDatabase();
|
||||
if(db == null){
|
||||
return null;
|
||||
|
@ -283,6 +283,33 @@ public class SQLiteTileSource implements ITileSource {
|
|||
}
|
||||
}
|
||||
cursor.close();
|
||||
return blob;
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug("Load tile " + x + "/" + y + "/" + zoom + " for " + (System.currentTimeMillis() - ts)
|
||||
+ " ms ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getBytes(int x, int y, int zoom) throws IOException {
|
||||
return getBytes(x, y, zoom, null);
|
||||
}
|
||||
|
||||
public Bitmap getImage(int x, int y, int zoom, long[] timeHolder) {
|
||||
SQLiteConnection db = getDatabase();
|
||||
if(db == null){
|
||||
return null;
|
||||
}
|
||||
String[] params = new String[] { x + "", y + "", getFileZoom(zoom) + "" };
|
||||
byte[] blob;
|
||||
try {
|
||||
blob = getBytes(x, y, zoom, timeHolder);
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
if (blob != null) {
|
||||
Bitmap bmp = null;
|
||||
bmp = BitmapFactory.decodeByteArray(blob, 0, blob.length);
|
||||
|
@ -292,14 +319,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
}
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} finally {
|
||||
if(log.isDebugEnabled()) {
|
||||
log.debug("Load tile " + x + "/" + y + "/" + zoom + " for " + (System.currentTimeMillis() - ts)
|
||||
+ " ms ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ITileSource getBase() {
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
|
@ -110,6 +111,7 @@ public class MapTileLayer extends BaseMapLayer {
|
|||
return mapTileAdapter;
|
||||
}
|
||||
|
||||
@SuppressLint("WrongCall")
|
||||
@Override
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox,
|
||||
DrawSettings drawSettings) {
|
||||
|
|
Loading…
Reference in a new issue