f878e201 by chiangbt

update2

1 parent 2c22ae85
......@@ -24,7 +24,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -95,8 +95,8 @@ public class MainActivity extends AppCompatActivity {
t_cva = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CVA_C);
mapView.addLayer(t_cva);
// t_local = new TianDiTuLocalTiledMapServiceLayer("my.mbtiles");
// mapView.addLayer(t_local);
t_local = new TianDiTuLocalTiledMapServiceLayer("my.db", "IMG_C");
mapView.addLayer(t_local);
t_img = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.IMG_C);
t_img.setVisible(false);
......
package com.pashanhoo.landsurvey.layers.tianditu;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Environment;
import android.util.Log;
......@@ -9,6 +13,7 @@ import com.esri.android.map.TiledServiceLayer;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.pashanhoo.landsurvey.R;
import com.pashanhoo.landsurvey.utils.AppInfo;
import java.util.concurrent.RejectedExecutionException;
......@@ -21,10 +26,12 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer {
String sqlitedb = "";
private TileInfo tiandituTileInfo;
private String layername = "";
public TianDiTuLocalTiledMapServiceLayer(String url) {
public TianDiTuLocalTiledMapServiceLayer(String url, String layername) {
super(url);
this.sqlitedb = url;
this.layername = layername;
try {
getServiceExecutor().submit(new Runnable() {
......@@ -72,11 +79,8 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer {
byte[] result = null;
Log.i("local", level + ":"+ col + ":" + row);
Log.i("local", String.valueOf(Math.pow(2, level)));
row = (int) (Math.pow(2, level) - col - row);
Log.i("local", level + ":"+ col + ":" + row);
Log.i("local","---------------------");
String sql = "select * from tiles where zoom_level = " + level + " and tile_column = " + col + " and tile_row = " + row;
// row = (int) (Math.pow(2, level) - col - row);
String sql = "select * from " + this.layername + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row;
Cursor mCursor =
SQLiteDatabase.openOrCreateDatabase(Environment.getExternalStorageDirectory()+"/keymapinfo/" + this.sqlitedb, null)
......@@ -89,7 +93,7 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer {
if (hasData) {//数据库中有数据
try {
if (mCursor.moveToFirst()) {
result = mCursor.getBlob(mCursor.getColumnIndex("tile_data"));
result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA"));
}
mCursor.close();
} catch (Exception e) {
......
......@@ -21,7 +21,7 @@ public class AppInfo {
public static Point initPoint = new Point(121.56, 29.862149);
public static double initRes = TDTTileinfo.getRes4490()[12];
public static double initRes = TDTTileinfo.getRes4490()[6];
public static void Settings(){
// 新建地图缓存数据库,不要试图新建多级目录,切记切记,如keymapinfo/cache
......