a03b6542 by chiangbt

update 3.28

1 parent 4c1f987a
......@@ -17,11 +17,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".BootActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
......@@ -30,7 +26,11 @@
android:theme="@style/AppTheme.NoActionBar"> <!-- 禁止屏幕旋转 -->
</activity>
<activity android:name=".GoogleMapActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
......
......@@ -11,6 +11,10 @@ import com.esri.android.map.LocationDisplayManager;
import com.esri.android.map.MapView;
import com.esri.android.runtime.ArcGISRuntime;
import com.esri.core.geometry.Point;
import com.pashanhoo.landsurvey.layers.Geoq.GeoQMapLayerTypes;
import com.pashanhoo.landsurvey.layers.Geoq.GeoQMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.gaode.GaodeMapLayerTypes;
import com.pashanhoo.landsurvey.layers.gaode.GaodeMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes;
import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer;
import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo;
......@@ -37,11 +41,17 @@ public class GoogleMapActivity extends AppCompatActivity {
// GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.VECTOR_GOOGLE_MAP);
// GoogleMapsTiledServiceLayer GOOGLE_TER_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP);
GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP);
mapView.addLayer(GOOGLE_IMAGE_Layer);
// GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP);
// GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP);
// mapView.addLayer(GOOGLE_IMAGE_Layer);
// GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_ANNO_GOOGLE_MAP);
// mapView.addLayer(GOOGLE_ANNO_Layer);
// GaodeMapsTiledServiceLayer gaodeMapsTiledServiceLayer = new GaodeMapsTiledServiceLayer(GaodeMapLayerTypes.VECTOR_Gaode_MAP);
// mapView.addLayer(gaodeMapsTiledServiceLayer);
GeoQMapsTiledServiceLayer geoQMapsTiledServiceLayer = new GeoQMapsTiledServiceLayer(GeoQMapLayerTypes.ChinaOnlineCommunity_Mobile);
mapView.addLayer(geoQMapsTiledServiceLayer);
mapView.setMaxResolution(156543.03392800014);
mapView.setMinResolution(0.29858214164761665);
......
package com.pashanhoo.landsurvey.layers.Geoq;
import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType;
public enum GeoQMapLayerTypes implements BaseTiledMapServiceType {
/** * Google vector map service by city map*/
ChinaOnlineCommunity,
/** * Google image map service by satellite map */
ChinaOnlineCommunity_Mobile,
/** * Google topographic map service ======= topographic map */
ChinaOnlineCommunityENG,
ChinaOnlineStreetGray,
ChinaOnlineStreetPurplishBlue,
ChinaOnlineStreetWarm;
@Override
public String getName()
{
return this.name().toString();
}
}
package com.pashanhoo.landsurvey.layers.Geoq;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;
import android.util.Log;
import com.esri.android.map.TiledServiceLayer;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.io.handler.ResponseListener;
import com.esri.core.internal.io.handler.a;
import com.esri.core.io.UserCredentials;
import com.pashanhoo.landsurvey.layers.gaode.GaodeMapLayerTypes;
import com.pashanhoo.landsurvey.utils.AppInfo;
import com.pashanhoo.landsurvey.utils.GADBHelper;
import java.util.concurrent.RejectedExecutionException;
/**
* Created by jiangbotao on 2018/3/28.
*/
public class GeoQMapsTiledServiceLayer extends TiledServiceLayer {
private static final double xmin = -22041257.773878;
private static final double ymin = -32673939.6727517;
private static final double xmax = 22041257.773878;
private static final double ymax = 20851350.0432886;
private static final double XMin = 110.35992000000005;
private static final double YMin = 31.382360000000062;
private static final double XMax = 116.65036000000009;
private static final double YMax = 36.36647000000005;
private static final double[] res = {156543.03392800014,
78271.516963999937,
39135.758482000092,
19567.879240999919,
9783.9396204999593,
4891.9698102499797,
2445.9849051249898,
1222.9924525624949,
611.49622628138,
305.748113140558,
152.874056570411,
76.4370282850732,
38.2185141425366,
19.1092570712683,
9.55462853563415,
4.7773142679493699,
2.3886571339746849,
1.1943285668550503,
0.59716428355981721,
0.29858214164761665};
private static final double[] scale = {591657527.591555,
295828763.79577702,
147914381.89788899,
73957190.948944002,
36978595.474472001,
18489297.737236001,
9244648.8686180003,
4622324.4343090001,
2311162.217155,
1155581.108577,
577790.554289,
288895.277144,
144447.638572,
72223.819286, 6111.909643,
18055.954822,
9027.9774109999998,
4513.9887049999998
, 2256.994353,
1128.4971760000001};
private static String URL = "http://maps.iwxlh.com";
private ResponseListener responseListener;
private static Point origin = new Point(-20037508.342787, 20037508.342787);
private GeoQMapLayerTypes geoQMapLayerTypes;
public GeoQMapsTiledServiceLayer(GeoQMapLayerTypes layerType) {
this(true);
this.geoQMapLayerTypes = layerType;
// 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库
GADBHelper.createTable(AppInfo.mapcachedb, this.geoQMapLayerTypes.getName());
}
public GeoQMapsTiledServiceLayer(boolean initLayer) {
super(URL);
this.isBingMap = true;
if (!(initLayer))
return;
try {
getServiceExecutor().submit(new Runnable() {
public void run() {
GeoQMapsTiledServiceLayer.this.initLayer();
}
});
} catch (RejectedExecutionException localRejectedExecutionException) {
Log.e("ArcGIS", "initialization of the layer failed.", localRejectedExecutionException);
}
}
public static double[] getRes() {
return res;
}
protected void initLayer() {
if (getID() == 0L) {
this.nativeHandle = create();
}
if (getID() == 0L) {
this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000));
} else {
try {
this.setDefaultSpatialReference(SpatialReference.create(102100));
this.setFullExtent(new Envelope(xmin, ymin, xmax, ymax));
this.setTileInfo(new TileInfo(origin, scale, res, scale.length, 96, 256, 256));
super.initLayer();
} catch (Exception localException) {
this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005));
Log.e("ArcGIS", "Bing map url =" + getUrl(), localException);
}
}
}
@SuppressLint("DefaultLocale")
protected byte[] getTile(int level, int col, int row) throws Exception {
byte[] result = null;
String url = "";
String s = "Galil";
switch (geoQMapLayerTypes) {
case ChinaOnlineCommunity:
url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/"+level+"/"+row+"/"+col;
break;
case ChinaOnlineCommunity_Mobile:
url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity_Mobile/MapServer/tile/"+level+"/"+row+"/"+col;
break;
case ChinaOnlineCommunityENG:
url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunityENG/MapServer/tile/"+level+"/"+row+"/"+col;
break;
case ChinaOnlineStreetGray:
url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetGray/MapServer/tile/"+level+"/"+row+"/"+col;
break;
case ChinaOnlineStreetPurplishBlue:
url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/"+level+"/"+row+"/"+col;
break;
case ChinaOnlineStreetWarm:
url= "http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer/tile/"+level+"/"+row+"/"+col;
break;
}
try {
// 首先从离线数据库中读取
result = getOfflineCacheDB(level, col, row);
// 如果没有就直接从web上读取
if (result == null) {
result = a.a(url, null, null, this.responseListener);
// 将读取的数据存入mbtiles中
AddOfflineCacheDB(level, col, row, result);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
public void refresh() {
try {
getServiceExecutor().submit(new Runnable() {
public void run() {
if (!(GeoQMapsTiledServiceLayer.this.isInitialized()))
return;
try {
GeoQMapsTiledServiceLayer.this.clearTiles();
} catch (Exception localException) {
Log.e("ArcGIS", "Re-initialization of the layer failed.", localException);
}
}
});
} catch (RejectedExecutionException localRejectedExecutionException) {
return;
}
}
public void reinitializeLayer(UserCredentials usercredentials) {
}
public void reinitializeLayer(String appID) {
super.reinitializeLayer(null);
}
private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception {
byte[] result = null;
String sql = "select * from " + this.geoQMapLayerTypes.getName() + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row;
Cursor mCursor = AppInfo.mapcachedb.rawQuery(sql, null);
boolean hasData = false;
while (mCursor.moveToNext()) {//判断是否存在数据
hasData = true;
}
if (hasData) {//数据库中有数据
try {
if (mCursor.moveToFirst()) {
result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA"));
}
mCursor.close();
} catch (Exception e) {
e.printStackTrace();
result = null;
}
}
return result;
}
private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) {
ContentValues values = new ContentValues();
values.put("TILELEVEL", level);
values.put("TILECOL", col);
values.put("TILEROW", row);
values.put("TILEDATA", bytes);
AppInfo.mapcachedb.insert(this.geoQMapLayerTypes.getName(), null, values);
}
}
package com.pashanhoo.landsurvey.layers.gaode;
import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType;
public enum GaodeMapLayerTypes implements BaseTiledMapServiceType {
/** * Google vector map service by city map*/
VECTOR_Gaode_MAP,
/** * Google image map service by satellite map */
IMAGE_Gaode_MAP,
Anno_Gaode_Map;
/** * Google topographic map service ======= topographic map */
/** * Google road POI map service = = = = net road map */
@Override
public String getName()
{
return this.name().toString();
}
}
package com.pashanhoo.landsurvey.layers.gaode;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.database.Cursor;
import android.util.Log;
import com.esri.android.map.TiledServiceLayer;
import com.esri.android.map.event.OnStatusChangedListener;
import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.io.handler.ResponseListener;
import com.esri.core.internal.io.handler.a;
import com.esri.core.io.UserCredentials;
import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes;
import com.pashanhoo.landsurvey.utils.AppInfo;
import com.pashanhoo.landsurvey.utils.GADBHelper;
import java.util.concurrent.RejectedExecutionException;
/**
* Created by jiangbotao on 2018/3/28.
*/
public class GaodeMapsTiledServiceLayer extends TiledServiceLayer {
private static final double xmin = -22041257.773878;
private static final double ymin = -32673939.6727517;
private static final double xmax = 22041257.773878;
private static final double ymax = 20851350.0432886;
private static final double XMin = 110.35992000000005;
private static final double YMin = 31.382360000000062;
private static final double XMax = 116.65036000000009;
private static final double YMax = 36.36647000000005;
private static final double[] res = {156543.03392800014,
78271.516963999937,
39135.758482000092,
19567.879240999919,
9783.9396204999593,
4891.9698102499797,
2445.9849051249898,
1222.9924525624949,
611.49622628138,
305.748113140558,
152.874056570411,
76.4370282850732,
38.2185141425366,
19.1092570712683,
9.55462853563415,
4.7773142679493699,
2.3886571339746849,
1.1943285668550503,
0.59716428355981721,
0.29858214164761665};
private static final double[] scale = {591657527.591555,
295828763.79577702,
147914381.89788899,
73957190.948944002,
36978595.474472001,
18489297.737236001,
9244648.8686180003,
4622324.4343090001,
2311162.217155,
1155581.108577,
577790.554289,
288895.277144,
144447.638572,
72223.819286, 6111.909643,
18055.954822,
9027.9774109999998,
4513.9887049999998
, 2256.994353,
1128.4971760000001};
private static String URL = "http://maps.iwxlh.com";
private ResponseListener responseListener;
private static Point origin = new Point(-20037508.342787, 20037508.342787);
private GaodeMapLayerTypes gaodeMapLayerTypes;
public GaodeMapsTiledServiceLayer(GaodeMapLayerTypes layerType) {
this(true);
this.gaodeMapLayerTypes = layerType;
// 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库
GADBHelper.createTable(AppInfo.mapcachedb, this.gaodeMapLayerTypes.getName());
}
public GaodeMapsTiledServiceLayer(boolean initLayer) {
super(URL);
this.isBingMap = true;
if (!(initLayer))
return;
try {
getServiceExecutor().submit(new Runnable() {
public void run() {
GaodeMapsTiledServiceLayer.this.initLayer();
}
});
} catch (RejectedExecutionException localRejectedExecutionException) {
Log.e("ArcGIS", "initialization of the layer failed.", localRejectedExecutionException);
}
}
public static double[] getRes() {
return res;
}
protected void initLayer() {
if (getID() == 0L) {
this.nativeHandle = create();
}
if (getID() == 0L) {
this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000));
} else {
try {
this.setDefaultSpatialReference(SpatialReference.create(102100));
this.setFullExtent(new Envelope(xmin, ymin, xmax, ymax));
this.setTileInfo(new TileInfo(origin, scale, res, scale.length, 96, 256, 256));
super.initLayer();
} catch (Exception localException) {
this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005));
Log.e("ArcGIS", "Bing map url =" + getUrl(), localException);
}
}
}
@SuppressLint("DefaultLocale")
protected byte[] getTile(int level, int col, int row) throws Exception {
byte[] result = null;
String url = "";
String s = "Galil";
switch (gaodeMapLayerTypes) {
case VECTOR_Gaode_MAP:
url= "http://webrd01.is.autonavi.com/appmaptile?&x=" + col + "&y=" + row + "&z=" + level + "&lang=zh_cn&size=1&scale=1&style=7";
break;
case IMAGE_Gaode_MAP:
url = "http://webst02.is.autonavi.com/appmaptile?style=6&x="+col+"&y="+row+"&z="+level;
break;
case Anno_Gaode_Map:
url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level;
break;
}
try {
// 首先从离线数据库中读取
result = getOfflineCacheDB(level, col, row);
// 如果没有就直接从web上读取
if (result == null) {
result = a.a(url, null, null, this.responseListener);
// 将读取的数据存入mbtiles中
AddOfflineCacheDB(level, col, row, result);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}
public void refresh() {
try {
getServiceExecutor().submit(new Runnable() {
public void run() {
if (!(GaodeMapsTiledServiceLayer.this.isInitialized()))
return;
try {
GaodeMapsTiledServiceLayer.this.clearTiles();
} catch (Exception localException) {
Log.e("ArcGIS", "Re-initialization of the layer failed.", localException);
}
}
});
} catch (RejectedExecutionException localRejectedExecutionException) {
return;
}
}
public void reinitializeLayer(UserCredentials usercredentials) {
}
public void reinitializeLayer(String appID) {
super.reinitializeLayer(null);
}
private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception {
byte[] result = null;
String sql = "select * from " + this.gaodeMapLayerTypes.getName() + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row;
Cursor mCursor = AppInfo.mapcachedb.rawQuery(sql, null);
boolean hasData = false;
while (mCursor.moveToNext()) {//判断是否存在数据
hasData = true;
}
if (hasData) {//数据库中有数据
try {
if (mCursor.moveToFirst()) {
result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA"));
}
mCursor.close();
} catch (Exception e) {
e.printStackTrace();
result = null;
}
}
return result;
}
private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) {
ContentValues values = new ContentValues();
values.put("TILELEVEL", level);
values.put("TILECOL", col);
values.put("TILEROW", row);
values.put("TILEDATA", bytes);
AppInfo.mapcachedb.insert(this.gaodeMapLayerTypes.getName(), null, values);
}
}
......@@ -15,7 +15,7 @@ public enum GoogleMapLayerTypes implements BaseTiledMapServiceType {
/** * Google topographic map service ======= topographic map */
TERRAIN_GOOGLE_MAP,
/** * Google road POI map service = = = = net road map */
ANNOTATION_GOOGLE_MAP;
IMAGE_ANNO_GOOGLE_MAP;
@Override
public String getName()
......
......@@ -143,9 +143,9 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
case TERRAIN_GOOGLE_MAP:
url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=t@131,r@227000000&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
break;
case ANNOTATION_GOOGLE_MAP:
// url = "http://mt2.google.cn/vt/lyrs=m@161000000&v=w2.114&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s=" + s;
url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level;
case IMAGE_ANNO_GOOGLE_MAP:
url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=s@131,h@209000000&hl=zh-CN&gl=CN&src=app&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
// url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level;
break;
}
......