8b3ceed3 by chiangbt

update 3.29

1 parent 07d77721
...@@ -17,7 +17,11 @@ ...@@ -17,7 +17,11 @@
17 android:supportsRtl="true" 17 android:supportsRtl="true"
18 android:theme="@style/AppTheme"> 18 android:theme="@style/AppTheme">
19 <activity android:name=".BootActivity"> 19 <activity android:name=".BootActivity">
20 <intent-filter>
21 <action android:name="android.intent.action.MAIN" />
20 22
23 <category android:name="android.intent.category.LAUNCHER" />
24 </intent-filter>
21 </activity> 25 </activity>
22 <activity 26 <activity
23 android:name=".MainActivity" 27 android:name=".MainActivity"
...@@ -26,11 +30,7 @@ ...@@ -26,11 +30,7 @@
26 android:theme="@style/AppTheme.NoActionBar"> <!-- 禁止屏幕旋转 --> 30 android:theme="@style/AppTheme.NoActionBar"> <!-- 禁止屏幕旋转 -->
27 </activity> 31 </activity>
28 <activity android:name=".GoogleMapActivity"> 32 <activity android:name=".GoogleMapActivity">
29 <intent-filter>
30 <action android:name="android.intent.action.MAIN" />
31 33
32 <category android:name="android.intent.category.LAUNCHER" />
33 </intent-filter>
34 </activity> 34 </activity>
35 </application> 35 </application>
36 36
......
...@@ -28,15 +28,17 @@ public class GoogleMapActivity extends AppCompatActivity { ...@@ -28,15 +28,17 @@ public class GoogleMapActivity extends AppCompatActivity {
28 super.onCreate(savedInstanceState); 28 super.onCreate(savedInstanceState);
29 setContentView(R.layout.activity_google_map); 29 setContentView(R.layout.activity_google_map);
30 30
31 AppInfo.Settings();
32
31 ArcGISRuntime.setClientId("1eFHW78avlnRUPHm"); 33 ArcGISRuntime.setClientId("1eFHW78avlnRUPHm");
32 mapView = (MapView) findViewById(R.id.map); 34 mapView = (MapView) findViewById(R.id.map);
33 mapView.setEsriLogoVisible(false); 35 mapView.setEsriLogoVisible(false);
34 mapView.enableWrapAround(false); 36 mapView.enableWrapAround(false);
35 37
36 GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.VECTOR_GOOGLE_MAP); 38 // GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.VECTOR_GOOGLE_MAP);
37 // GoogleMapsTiledServiceLayer GOOGLE_TER_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP); 39 // GoogleMapsTiledServiceLayer GOOGLE_TER_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP);
38 // GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP); 40 GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP);
39 mapView.addLayer(GOOGLE_VECTOR_Layer); 41 mapView.addLayer(GOOGLE_IMAGE_Layer);
40 // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP); 42 // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP);
41 // mapView.addLayer(GOOGLE_ANNO_Layer); 43 // mapView.addLayer(GOOGLE_ANNO_Layer);
42 44
......
1 package com.pashanhoo.landsurvey; 1 package com.pashanhoo.landsurvey;
2 2
3 import android.annotation.SuppressLint;
4 import android.location.Location; 3 import android.location.Location;
5 import android.location.LocationListener; 4 import android.location.LocationListener;
6 import android.os.Bundle; 5 import android.os.Bundle;
...@@ -30,7 +29,7 @@ import com.esri.core.symbol.PictureMarkerSymbol; ...@@ -30,7 +29,7 @@ import com.esri.core.symbol.PictureMarkerSymbol;
30 import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo; 29 import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo;
31 import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuLocalTiledMapServiceLayer; 30 import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuLocalTiledMapServiceLayer;
32 import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceLayer; 31 import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceLayer;
33 import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuTiledMapServiceType; 32 import com.pashanhoo.landsurvey.layers.tianditu.TianDiTuLayerTypes;
34 import com.pashanhoo.landsurvey.search.POISuggestion; 33 import com.pashanhoo.landsurvey.search.POISuggestion;
35 import com.pashanhoo.landsurvey.utils.AppInfo; 34 import com.pashanhoo.landsurvey.utils.AppInfo;
36 35
...@@ -129,7 +128,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -129,7 +128,7 @@ public class MainActivity extends AppCompatActivity {
129 locationDisplayManager.stop(); 128 locationDisplayManager.stop();
130 } else { 129 } else {
131 locationDisplayManager.start(); 130 locationDisplayManager.start();
132 mapView.zoomToResolution(locationDisplayManager.getPoint(), TDTTileinfo.getRes4490()[18]); 131 mapView.zoomToResolution(locationDisplayManager.getPoint(), t_vec.getRes()[18]);
133 } 132 }
134 } 133 }
135 }); 134 });
...@@ -154,18 +153,18 @@ public class MainActivity extends AppCompatActivity { ...@@ -154,18 +153,18 @@ public class MainActivity extends AppCompatActivity {
154 mapView.setEsriLogoVisible(false); 153 mapView.setEsriLogoVisible(false);
155 mapView.enableWrapAround(false); 154 mapView.enableWrapAround(false);
156 // 添加地图图层 155 // 添加地图图层
157 t_vec = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.VEC_C); 156 t_vec = new TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes.VEC_C);
158 mapView.addLayer(t_vec); 157 mapView.addLayer(t_vec);
159 t_cva = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CVA_C); 158 t_cva = new TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes.CVA_C);
160 mapView.addLayer(t_cva); 159 mapView.addLayer(t_cva);
161 // 一个本地sqlite数据库,注意其只有8-9级数据,因此在数据层中予以了显示控制 160 // 一个本地sqlite数据库,注意其只有8-9级数据,因此在数据层中予以了显示控制
162 t_local = new TianDiTuLocalTiledMapServiceLayer("my.db", "IMG_C"); 161 t_local = new TianDiTuLocalTiledMapServiceLayer("my.db", "IMG_C");
163 mapView.addLayer(t_local); 162 mapView.addLayer(t_local);
164 // 添加地图图层 163 // 添加地图图层
165 t_img = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.IMG_C); 164 t_img = new TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes.IMG_C);
166 t_img.setVisible(false); 165 t_img.setVisible(false);
167 mapView.addLayer(t_img); 166 mapView.addLayer(t_img);
168 t_cia = new TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType.CIA_C); 167 t_cia = new TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes.CIA_C);
169 t_cia.setVisible(false); 168 t_cia.setVisible(false);
170 mapView.addLayer(t_cia); 169 mapView.addLayer(t_cia);
171 mapType = "VEC"; 170 mapType = "VEC";
...@@ -173,8 +172,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -173,8 +172,8 @@ public class MainActivity extends AppCompatActivity {
173 graphicsLayer = new GraphicsLayer(); 172 graphicsLayer = new GraphicsLayer();
174 mapView.addLayer(graphicsLayer); 173 mapView.addLayer(graphicsLayer);
175 // 设置地图的最小和最大分辨率 174 // 设置地图的最小和最大分辨率
176 mapView.setMaxResolution(TDTTileinfo.getRes4490()[1]); 175 mapView.setMaxResolution(t_vec.getRes()[1]);
177 mapView.setMinResolution(TDTTileinfo.getRes4490()[19]); 176 mapView.setMinResolution(t_vec.getRes()[19]);
178 // 监听地图状态变化事件 177 // 监听地图状态变化事件
179 mapView.setOnStatusChangedListener(new OnStatusChangedListener() { 178 mapView.setOnStatusChangedListener(new OnStatusChangedListener() {
180 private static final long serialVersionUID = 1L; 179 private static final long serialVersionUID = 1L;
...@@ -215,7 +214,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -215,7 +214,7 @@ public class MainActivity extends AppCompatActivity {
215 locationDisplayManager.setLocationListener(new LocationListener() { 214 locationDisplayManager.setLocationListener(new LocationListener() {
216 @Override 215 @Override
217 public void onLocationChanged(Location location) { 216 public void onLocationChanged(Location location) {
218 mapView.zoomToResolution(new Point(location.getLongitude(), location.getLatitude()), TDTTileinfo.getRes4490()[18]); 217 mapView.zoomToResolution(new Point(location.getLongitude(), location.getLatitude()), t_vec.getRes()[18]);
219 mapinfoView.setText("当前地图级别为:18"); 218 mapinfoView.setText("当前地图级别为:18");
220 } 219 }
221 220
...@@ -240,7 +239,7 @@ public class MainActivity extends AppCompatActivity { ...@@ -240,7 +239,7 @@ public class MainActivity extends AppCompatActivity {
240 239
241 POISuggestion colorSuggestion = (POISuggestion) searchSuggestion; 240 POISuggestion colorSuggestion = (POISuggestion) searchSuggestion;
242 Point poipt = new Point(colorSuggestion.getLng(), colorSuggestion.getLat()); 241 Point poipt = new Point(colorSuggestion.getLng(), colorSuggestion.getLat());
243 mapView.zoomToResolution(poipt, TDTTileinfo.getRes4490()[19]); 242 mapView.zoomToResolution(poipt, t_vec.getRes()[19]);
244 graphicsLayer.addGraphic(new Graphic(poipt, 243 graphicsLayer.addGraphic(new Graphic(poipt,
245 new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16))); 244 new PictureMarkerSymbol(getResources().getDrawable(R.mipmap.locator)).setOffsetY(16)));
246 // floatingSearchView.clearSuggestions(); 245 // floatingSearchView.clearSuggestions();
......
1 package com.pashanhoo.landsurvey.layers.google; 1 package com.pashanhoo.landsurvey.layers.google;
2 2
3 import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType;
4
3 /** 5 /**
4 * Created by jiangbotao on 2018/3/28. 6 * Created by jiangbotao on 2018/3/28.
5 */ 7 */
6 8
7 public interface GoogleMapLayerTypes { 9 public enum GoogleMapLayerTypes implements BaseTiledMapServiceType {
8 10
9 /** * Google vector map service by city map*/ 11 /** * Google vector map service by city map*/
10 final int VECTOR_GOOGLE_MAP = 1; 12 VECTOR_GOOGLE_MAP,
11 /** * Google image map service by satellite map */ 13 /** * Google image map service by satellite map */
12 final int IMAGE_GOOGLE_MAP = 2; 14 IMAGE_GOOGLE_MAP,
13 /** * Google topographic map service ======= topographic map */ 15 /** * Google topographic map service ======= topographic map */
14 final int TERRAIN_GOOGLE_MAP = 3; 16 TERRAIN_GOOGLE_MAP,
15 /** * Google road POI map service = = = = net road map */ 17 /** * Google road POI map service = = = = net road map */
16 final int ANNOTATION_GOOGLE_MAP = 4; 18 ANNOTATION_GOOGLE_MAP;
19
20 @Override
21 public String getName()
22 {
23 return this.name().toString();
24 }
17 } 25 }
......
1 package com.pashanhoo.landsurvey.layers.google; 1 package com.pashanhoo.landsurvey.layers.google;
2 2
3 import com.esri.android.map.TiledServiceLayer;
4
5 import java.util.concurrent.RejectedExecutionException; 3 import java.util.concurrent.RejectedExecutionException;
6 4
7 import android.annotation.SuppressLint; 5 import android.annotation.SuppressLint;
6 import android.content.ContentValues;
7 import android.database.Cursor;
8 import android.util.Log; 8 import android.util.Log;
9 9
10 import com.esri.android.map.TiledServiceLayer;
10 import com.esri.android.map.event.OnStatusChangedListener; 11 import com.esri.android.map.event.OnStatusChangedListener;
11 import com.esri.core.geometry.Envelope; 12 import com.esri.core.geometry.Envelope;
12 import com.esri.core.geometry.Point; 13 import com.esri.core.geometry.Point;
...@@ -14,6 +15,8 @@ import com.esri.core.geometry.SpatialReference; ...@@ -14,6 +15,8 @@ import com.esri.core.geometry.SpatialReference;
14 import com.esri.core.internal.io.handler.ResponseListener; 15 import com.esri.core.internal.io.handler.ResponseListener;
15 import com.esri.core.internal.io.handler.a; 16 import com.esri.core.internal.io.handler.a;
16 import com.esri.core.io.UserCredentials; 17 import com.esri.core.io.UserCredentials;
18 import com.pashanhoo.landsurvey.utils.AppInfo;
19 import com.pashanhoo.landsurvey.utils.GADBHelper;
17 import com.pashanhoo.landsurvey.utils.GISHelper; 20 import com.pashanhoo.landsurvey.utils.GISHelper;
18 21
19 /** 22 /**
...@@ -28,27 +31,61 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -28,27 +31,61 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
28 31
29 private static final double XMin = 110.35992000000005; 32 private static final double XMin = 110.35992000000005;
30 private static final double YMin = 31.382360000000062; 33 private static final double YMin = 31.382360000000062;
31
32 private static final double XMax = 116.65036000000009; 34 private static final double XMax = 116.65036000000009;
33 private static final double YMax = 36.36647000000005; 35 private static final double YMax = 36.36647000000005;
34 36
35 private static final double[] res = {156543.03392800014, 78271.516963999937, 39135.758482000092, 19567.879240999919, 9783.9396204999593, 4891.9698102499797, 2445.9849051249898, 37 private static final double[] res = {156543.03392800014,
36 1222.9924525624949, 611.49622628138, 305.748113140558, 152.874056570411, 76.4370282850732, 38.2185141425366, 19.1092570712683, 9.55462853563415, 4.7773142679493699, 2.3886571339746849, 38 78271.516963999937,
37 1.1943285668550503 , 0.59716428355981721, 0.29858214164761665 }; 39 39135.758482000092,
38 40 19567.879240999919,
39 private static final double[] scale = {591657527.591555, 295828763.79577702, 147914381.89788899, 73957190.948944002, 36978595.474472001, 18489297.737236001, 9244648.8686180003, 41 9783.9396204999593,
40 4622324.4343090001, 2311162.217155, 1155581.108577, 577790.554289, 288895.277144, 144447.638572, 72223.819286, 6111.909643, 18055.954822, 9027.9774109999998, 4513.9887049999998 42 4891.9698102499797,
41 ,2256.994353, 1128.4971760000001 }; 43 2445.9849051249898,
44 1222.9924525624949,
45 611.49622628138,
46 305.748113140558,
47 152.874056570411,
48 76.4370282850732,
49 38.2185141425366,
50 19.1092570712683,
51 9.55462853563415,
52 4.7773142679493699,
53 2.3886571339746849,
54 1.1943285668550503,
55 0.59716428355981721,
56 0.29858214164761665};
57
58 private static final double[] scale = {591657527.591555,
59 295828763.79577702,
60 147914381.89788899,
61 73957190.948944002,
62 36978595.474472001,
63 18489297.737236001,
64 9244648.8686180003,
65 4622324.4343090001,
66 2311162.217155,
67 1155581.108577,
68 577790.554289,
69 288895.277144,
70 144447.638572,
71 72223.819286, 6111.909643,
72 18055.954822,
73 9027.9774109999998,
74 4513.9887049999998
75 , 2256.994353,
76 1128.4971760000001};
42 77
43 private static String URL = "http://maps.iwxlh.com"; 78 private static String URL = "http://maps.iwxlh.com";
44 private ResponseListener responseListener; 79 private ResponseListener responseListener;
45 private static Point origin = new Point(-20037508.342787, 20037508.342787); 80 private static Point origin = new Point(-20037508.342787, 20037508.342787);
46 81
47 private int GoogleMapLayerType; 82 private GoogleMapLayerTypes googleMapLayerType;
48 83
49 public GoogleMapsTiledServiceLayer(int layerType) { 84 public GoogleMapsTiledServiceLayer(GoogleMapLayerTypes layerType) {
50 this(true); 85 this(true);
51 this.GoogleMapLayerType = layerType; 86 this.googleMapLayerType = layerType;
87 // 新建数据表,主要在Activity中必须有AppInfo.Settings()初始数据库
88 GADBHelper.createTable(AppInfo.mapcachedb, this.googleMapLayerType.getName());
52 } 89 }
53 90
54 public GoogleMapsTiledServiceLayer(boolean initLayer) { 91 public GoogleMapsTiledServiceLayer(boolean initLayer) {
...@@ -77,22 +114,15 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -77,22 +114,15 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
77 this.nativeHandle = create(); 114 this.nativeHandle = create();
78 } 115 }
79 if (getID() == 0L) { 116 if (getID() == 0L) {
80 changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000)); 117 this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1000));
81 } else { 118 } else {
82 try { 119 try {
83 setDefaultSpatialReference(SpatialReference.create(102100)); 120 this.setDefaultSpatialReference(SpatialReference.create(102100));
84 121 this.setFullExtent(new Envelope(xmin, ymin, xmax, ymax));
85 GISHelper.lonLat2Mercator(new Point(XMin, YMin)); 122 this.setTileInfo(new TiledServiceLayer.TileInfo(origin, scale, res, scale.length, 96, 256, 256));
86 GISHelper.lonLat2Mercator(new Point(XMax, YMax));
87
88 setFullExtent(new Envelope(xmin, ymin, xmax, ymax));
89 // setFullExtent(new Envelope(minMercatorPoint.getX(),
90 // minMercatorPoint.getY(), maxMercatorPoint.getX(),
91 // maxMercatorPoint.getY()));
92 setTileInfo(new TiledServiceLayer.TileInfo(origin, scale, res, scale.length, 96, 256, 256));
93 super.initLayer(); 123 super.initLayer();
94 } catch (Exception localException) { 124 } catch (Exception localException) {
95 changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005)); 125 this.changeStatus(OnStatusChangedListener.STATUS.fromInt(-1005));
96 Log.e("ArcGIS", "Bing map url =" + getUrl(), localException); 126 Log.e("ArcGIS", "Bing map url =" + getUrl(), localException);
97 } 127 }
98 } 128 }
...@@ -100,25 +130,40 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -100,25 +130,40 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
100 130
101 @SuppressLint("DefaultLocale") 131 @SuppressLint("DefaultLocale")
102 protected byte[] getTile(int level, int col, int row) throws Exception { 132 protected byte[] getTile(int level, int col, int row) throws Exception {
133 byte[] result = null;
134
103 String url = ""; 135 String url = "";
104 String s = "Galil"; 136 String s = "Galil";
105 137 switch (googleMapLayerType) {
106 switch (GoogleMapLayerType) { 138 case IMAGE_GOOGLE_MAP:
107 case GoogleMapLayerTypes.IMAGE_GOOGLE_MAP:
108 url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=s&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s; 139 url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=s&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
109 break; 140 break;
110 case GoogleMapLayerTypes.VECTOR_GOOGLE_MAP: 141 case VECTOR_GOOGLE_MAP:
111 url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=m@161000000&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s; 142 url = "http://mt" + (col % 4) + ".google.cn/vt/lyrs=m@161000000&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
112 break; 143 break;
113 case GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP: 144 case TERRAIN_GOOGLE_MAP:
114 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; 145 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;
115 break; 146 break;
116 case GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP: 147 case ANNOTATION_GOOGLE_MAP:
117 // 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; 148 // 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;
118 url = "http://webst02.is.autonavi.com/appmaptile?style=8&x="+ col +"&y="+ row +"&z="+level; 149 url = "http://webst02.is.autonavi.com/appmaptile?style=8&x=" + col + "&y=" + row + "&z=" + level;
119 break; 150 break;
120 } 151 }
121 return a.a(url, null, null, this.responseListener); 152
153 try {
154 // 首先从离线数据库中读取
155 result = getOfflineCacheDB(level, col, row);
156 // 如果没有就直接从web上读取
157 if (result == null) {
158 result = a.a(url, null, null, this.responseListener);
159 // 将读取的数据存入mbtiles中
160 AddOfflineCacheDB(level, col, row, result);
161 }
162 } catch (Exception ex) {
163 ex.printStackTrace();
164 }
165
166 return result;
122 } 167 }
123 168
124 public void refresh() { 169 public void refresh() {
...@@ -145,4 +190,38 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -145,4 +190,38 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
145 public void reinitializeLayer(String appID) { 190 public void reinitializeLayer(String appID) {
146 super.reinitializeLayer(null); 191 super.reinitializeLayer(null);
147 } 192 }
193
194 private byte[] getOfflineCacheDB(int level, int col, int row) throws Exception {
195
196 byte[] result = null;
197 String sql = "select * from " + this.googleMapLayerType.getName() + " where TILELEVEL = " + level + " and TILECOL = " + col + " and TILEROW = " + row;
198 Cursor mCursor = AppInfo.mapcachedb.rawQuery(sql, null);
199 boolean hasData = false;
200
201 while (mCursor.moveToNext()) {//判断是否存在数据
202 hasData = true;
203 }
204 if (hasData) {//数据库中有数据
205 try {
206 if (mCursor.moveToFirst()) {
207 result = mCursor.getBlob(mCursor.getColumnIndex("TILEDATA"));
208 }
209 mCursor.close();
210 } catch (Exception e) {
211 e.printStackTrace();
212 result = null;
213 }
214 }
215 return result;
216 }
217
218 private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) {
219 ContentValues values = new ContentValues();
220 values.put("TILELEVEL", level);
221 values.put("TILECOL", col);
222 values.put("TILEROW", row);
223 values.put("TILEDATA", bytes);
224
225 AppInfo.mapcachedb.insert(this.googleMapLayerType.getName(), null, values);
226 }
148 } 227 }
......
1 package com.pashanhoo.landsurvey.layers.tianditu;
2
3 import java.util.Random;
4
5 /**
6 * Created by jiangbotao on 2018/3/23.
7 */
8
9 public class TDTUrl {
10
11 private TianDiTuTiledMapServiceType _tiandituMapServiceType;
12 private int _level;
13 private int _col;
14 private int _row;
15
16 public TDTUrl(int level, int col, int row, TianDiTuTiledMapServiceType tiandituMapServiceType) {
17 this._level = level;
18 this._col = col;
19 this._row = row;
20 this._tiandituMapServiceType = tiandituMapServiceType;
21 }
22
23 public String generatUrl() {
24
25 StringBuilder url = new StringBuilder("http://t");
26 Random random = new Random();
27 int subdomain = (random.nextInt(6) + 1);
28 url.append(subdomain);
29 switch (this._tiandituMapServiceType) {
30 case VEC_C:
31 url.append(".tianditu.com/DataServer?T=vec_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
32 break;
33 case CVA_C:
34 url.append(".tianditu.com/DataServer?T=cva_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
35 break;
36 case CIA_C:
37 url.append(".tianditu.com/DataServer?T=cia_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
38 break;
39 case IMG_C:
40 url.append(".tianditu.com/DataServer?T=img_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
41 break;
42 case VEC_W:
43 url.append(".tianditu.com/DataServer?T=vec_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
44 break;
45 case CVA_W:
46 url.append(".tianditu.com/DataServer?T=cva_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
47 break;
48 case CIA_W:
49 url.append(".tianditu.com/DataServer?T=cia_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
50 break;
51 case IMG_W:
52 url.append(".tianditu.com/DataServer?T=img_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
53 break;
54 default:
55 return null;
56 }
57 return url.toString();
58 }
59 }
...@@ -6,7 +6,7 @@ import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType; ...@@ -6,7 +6,7 @@ import com.pashanhoo.landsurvey.layers.BaseTiledMapServiceType;
6 * Created by jiangbotao on 2018/3/23. 6 * Created by jiangbotao on 2018/3/23.
7 */ 7 */
8 8
9 public enum TianDiTuTiledMapServiceType implements BaseTiledMapServiceType { 9 public enum TianDiTuLayerTypes implements BaseTiledMapServiceType {
10 10
11 /** 11 /**
12 * 矢量数据,CGCS2000 12 * 矢量数据,CGCS2000
......
...@@ -8,6 +8,8 @@ import com.esri.android.map.TiledServiceLayer; ...@@ -8,6 +8,8 @@ import com.esri.android.map.TiledServiceLayer;
8 import com.esri.core.geometry.Envelope; 8 import com.esri.core.geometry.Envelope;
9 import com.esri.core.geometry.Point; 9 import com.esri.core.geometry.Point;
10 import com.esri.core.geometry.SpatialReference; 10 import com.esri.core.geometry.SpatialReference;
11 import com.esri.core.internal.io.handler.ResponseListener;
12 import com.esri.core.internal.io.handler.a;
11 import com.esri.core.io.UserCredentials; 13 import com.esri.core.io.UserCredentials;
12 import com.pashanhoo.landsurvey.utils.AppInfo; 14 import com.pashanhoo.landsurvey.utils.AppInfo;
13 import com.pashanhoo.landsurvey.utils.GADBHelper; 15 import com.pashanhoo.landsurvey.utils.GADBHelper;
...@@ -16,6 +18,7 @@ import java.io.BufferedInputStream; ...@@ -16,6 +18,7 @@ import java.io.BufferedInputStream;
16 import java.io.ByteArrayOutputStream; 18 import java.io.ByteArrayOutputStream;
17 import java.net.HttpURLConnection; 19 import java.net.HttpURLConnection;
18 import java.net.URL; 20 import java.net.URL;
21 import java.util.Random;
19 import java.util.concurrent.RejectedExecutionException; 22 import java.util.concurrent.RejectedExecutionException;
20 23
21 /** 24 /**
...@@ -24,23 +27,78 @@ import java.util.concurrent.RejectedExecutionException; ...@@ -24,23 +27,78 @@ import java.util.concurrent.RejectedExecutionException;
24 27
25 public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer { 28 public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
26 29
27 private TianDiTuTiledMapServiceType _mapType; 30 private static final Point originalPoint = new Point(-180, 90);
31
32 private static final double[] res = {
33 1.40625,
34 0.703125,
35 0.3515625,
36 0.17578125,
37 0.087890625,
38 0.0439453125,
39 0.02197265625,
40 0.010986328125,
41 0.0054931640625,
42 0.00274658203125,
43 0.001373291015625,
44 0.0006866455078125,
45 0.00034332275390625,
46 0.000171661376953125,
47 8.58306884765629E-05,
48 4.29153442382814E-05,
49 2.14576721191407E-05,
50 1.07288360595703E-05,
51 5.36441802978515E-06,
52 2.68220901489258E-06,
53 1.34110450744629E-06
54 };
55 private static final double[] scale = {
56 400000000,
57 295497598.5708346,
58 147748799.285417,
59 73874399.6427087,
60 36937199.8213544,
61 18468599.9106772,
62 9234299.95533859,
63 4617149.97766929,
64 2308574.98883465,
65 1154287.49441732,
66 577143.747208662,
67 288571.873604331,
68 144285.936802165,
69 72142.9684010827,
70 36071.4842005414,
71 18035.7421002707,
72 9017.87105013534,
73 4508.93552506767,
74 2254.467762533835,
75 1127.2338812669175,
76 563.616940
77 };
78 private static final int levels = 21;
79 private static final int dpi = 96;
80 private static final int tileWidth = 256;
81 private static final int tileHeight = 256;
82
83 private ResponseListener responseListener;
84
85 private TianDiTuLayerTypes _mapType;
28 private TileInfo tiandituTileInfo; 86 private TileInfo tiandituTileInfo;
29 87
30 public TianDiTuTiledMapServiceLayer() { 88 public TianDiTuTiledMapServiceLayer() {
31 this(null, null, true); 89 this(null, null, true);
32 } 90 }
33 91
34 public TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType mapType) { 92 public TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes mapType) {
35 this(mapType, null, true); 93 this(mapType, null, true);
36 GADBHelper.createTable(AppInfo.mapcachedb, _mapType.getName()); 94 GADBHelper.createTable(AppInfo.mapcachedb, _mapType.getName());
37 } 95 }
38 96
39 public TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType mapType, UserCredentials usercredentials) { 97 public TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes mapType, UserCredentials usercredentials) {
40 this(mapType, usercredentials, true); 98 this(mapType, usercredentials, true);
41 } 99 }
42 100
43 public TianDiTuTiledMapServiceLayer(TianDiTuTiledMapServiceType mapType, UserCredentials usercredentials, boolean flag) { 101 public TianDiTuTiledMapServiceLayer(TianDiTuLayerTypes mapType, UserCredentials usercredentials, boolean flag) {
44 super(""); 102 super("");
45 this._mapType = mapType; 103 this._mapType = mapType;
46 setCredentials(usercredentials); 104 setCredentials(usercredentials);
...@@ -54,6 +112,7 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer { ...@@ -54,6 +112,7 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
54 } 112 }
55 113
56 final TianDiTuTiledMapServiceLayer a; 114 final TianDiTuTiledMapServiceLayer a;
115
57 { 116 {
58 a = TianDiTuTiledMapServiceLayer.this; 117 a = TianDiTuTiledMapServiceLayer.this;
59 //super(); 118 //super();
...@@ -64,13 +123,17 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer { ...@@ -64,13 +123,17 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
64 } 123 }
65 } 124 }
66 125
126 public static double[] getRes() {
127 return res;
128 }
67 129
68 public TianDiTuTiledMapServiceType getMapType() { 130 public TianDiTuLayerTypes getMapType() {
69 return this._mapType; 131 return this._mapType;
70 } 132 }
71 133
72 protected void initLayer() { 134 protected void initLayer() {
73 this.buildTileInfo(); 135 this.tiandituTileInfo = new com.esri.android.map.TiledServiceLayer.TileInfo(originalPoint, scale, res, levels, dpi, tileWidth, tileHeight);
136 this.setTileInfo(this.tiandituTileInfo);
74 this.setFullExtent(new Envelope(-180, -90, 180, 90)); 137 this.setFullExtent(new Envelope(-180, -90, 180, 90));
75 this.setDefaultSpatialReference(SpatialReference.create(4490)); //CGCS2000 138 this.setDefaultSpatialReference(SpatialReference.create(4490)); //CGCS2000
76 //this.setDefaultSpatialReference(SpatialReference.create(4326)); 139 //this.setDefaultSpatialReference(SpatialReference.create(4326));
...@@ -114,35 +177,34 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer { ...@@ -114,35 +177,34 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
114 @Override 177 @Override
115 protected byte[] getTile(int level, int col, int row) throws Exception { 178 protected byte[] getTile(int level, int col, int row) throws Exception {
116 byte[] result = null; 179 byte[] result = null;
180
181 StringBuilder url = new StringBuilder("http://t");
182 Random random = new Random();
183 int subdomain = (random.nextInt(6) + 1);
184 url.append(subdomain);
185 switch (this._mapType) {
186 case VEC_C:
187 url.append(".tianditu.com/DataServer?T=vec_c&X=").append(col).append("&Y=").append(row).append("&L=").append(level);
188 break;
189 case CVA_C:
190 url.append(".tianditu.com/DataServer?T=cva_c&X=").append(col).append("&Y=").append(row).append("&L=").append(level);
191 break;
192 case CIA_C:
193 url.append(".tianditu.com/DataServer?T=cia_c&X=").append(col).append("&Y=").append(row).append("&L=").append(level);
194 break;
195 case IMG_C:
196 url.append(".tianditu.com/DataServer?T=img_c&X=").append(col).append("&Y=").append(row).append("&L=").append(level);
197 break;
198 default:
199 return null;
200 }
201
117 try { 202 try {
118 // 首先从离线数据库中读取 203 // 首先从离线数据库中读取
119 result = getOfflineCacheDB(level, col, row); 204 result = getOfflineCacheDB(level, col, row);
120 // 如果没有就直接从web上读取 205 // 如果没有就直接从web上读取
121 if (result == null) { 206 if (result == null) {
122 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 207 result = com.esri.core.internal.io.handler.a.a(url.toString(), null, null, this.responseListener);
123
124 URL sjwurl = new URL(this.getTianDiMapUrl(level, col, row));
125 HttpURLConnection httpUrl = null;
126 BufferedInputStream bis = null;
127 byte[] buf = new byte[1024];
128
129 httpUrl = (HttpURLConnection) sjwurl.openConnection();
130 httpUrl.connect();
131 bis = new BufferedInputStream(httpUrl.getInputStream());
132
133 while (true) {
134 int bytes_read = bis.read(buf);
135 if (bytes_read > 0) {
136 bos.write(buf, 0, bytes_read);
137 } else {
138 break;
139 }
140 }
141 ;
142 bis.close();
143 httpUrl.disconnect();
144
145 result = bos.toByteArray();
146 // 将读取的数据存入mbtiles中 208 // 将读取的数据存入mbtiles中
147 AddOfflineCacheDB(level, col, row, result); 209 AddOfflineCacheDB(level, col, row, result);
148 } 210 }
...@@ -153,7 +215,7 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer { ...@@ -153,7 +215,7 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
153 return result; 215 return result;
154 } 216 }
155 217
156 private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes){ 218 private void AddOfflineCacheDB(int level, int col, int row, byte[] bytes) {
157 ContentValues values = new ContentValues(); 219 ContentValues values = new ContentValues();
158 values.put("TILELEVEL", level); 220 values.put("TILELEVEL", level);
159 values.put("TILECOL", col); 221 values.put("TILECOL", col);
...@@ -193,68 +255,5 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer { ...@@ -193,68 +255,5 @@ public class TianDiTuTiledMapServiceLayer extends TiledServiceLayer {
193 return this.tiandituTileInfo; 255 return this.tiandituTileInfo;
194 } 256 }
195 257
196 /**
197 *
198 * */
199 private String getTianDiMapUrl(int level, int col, int row) {
200 String url = new TDTUrl(level, col, row, this._mapType).generatUrl();
201 return url;
202 }
203 258
204 private void buildTileInfo() {
205 Point originalPoint = new Point(-180, 90);
206
207 double[] res = {
208 1.40625,
209 0.703125,
210 0.3515625,
211 0.17578125,
212 0.087890625,
213 0.0439453125,
214 0.02197265625,
215 0.010986328125,
216 0.0054931640625,
217 0.00274658203125,
218 0.001373291015625,
219 0.0006866455078125,
220 0.00034332275390625,
221 0.000171661376953125,
222 8.58306884765629E-05,
223 4.29153442382814E-05,
224 2.14576721191407E-05,
225 1.07288360595703E-05,
226 5.36441802978515E-06,
227 2.68220901489258E-06,
228 1.34110450744629E-06
229 };
230 double[] scale = {
231 400000000,
232 295497598.5708346,
233 147748799.285417,
234 73874399.6427087,
235 36937199.8213544,
236 18468599.9106772,
237 9234299.95533859,
238 4617149.97766929,
239 2308574.98883465,
240 1154287.49441732,
241 577143.747208662,
242 288571.873604331,
243 144285.936802165,
244 72142.9684010827,
245 36071.4842005414,
246 18035.7421002707,
247 9017.87105013534,
248 4508.93552506767,
249 2254.467762533835,
250 1127.2338812669175,
251 563.616940
252 };
253 int levels = 21;
254 int dpi = 96;
255 int tileWidth = 256;
256 int tileHeight = 256;
257 this.tiandituTileInfo = new com.esri.android.map.TiledServiceLayer.TileInfo(originalPoint, scale, res, levels, dpi, tileWidth, tileHeight);
258 this.setTileInfo(this.tiandituTileInfo);
259 }
260 } 259 }
......
...@@ -21,8 +21,8 @@ public class AppInfo { ...@@ -21,8 +21,8 @@ public class AppInfo {
21 21
22 public static Point initPoint = new Point(121.56, 29.862149); 22 public static Point initPoint = new Point(121.56, 29.862149);
23 23
24 // public static double initRes = TDTTileinfo.getRes4490()[6]; 24 public static double initRes = TDTTileinfo.getRes4490()[6];
25 public static double initRes = TDTTileinfo.getRes4326()[6]; 25 // public static double initRes = TDTTileinfo.getRes4326()[6];
26 26
27 27
28 public static void Settings(){ 28 public static void Settings(){
......
...@@ -55,8 +55,7 @@ public class GADBHelper extends SQLiteOpenHelper { ...@@ -55,8 +55,7 @@ public class GADBHelper extends SQLiteOpenHelper {
55 "(TILELEVEL INT," + 55 "(TILELEVEL INT," +
56 "TILECOL INT," + 56 "TILECOL INT," +
57 "TILEROW INT," + 57 "TILEROW INT," +
58 "TILEDATA BLOB," + 58 "TILEDATA BLOB)");
59 "TILETIME TEXT)");
60 59
61 db.setTransactionSuccessful(); 60 db.setTransactionSuccessful();
62 db.endTransaction(); 61 db.endTransaction();
......
1 package com.pashanhoo.landsurvey.utils;
2
3 import com.esri.core.geometry.Point;
4
5 /**
6 * Created by jiangbotao on 2018/3/28.
7 */
8
9 public class JZLocationConverter {
10
11 private static final double LAT_OFFSET_0(double x, double y) {
12 return -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
13 }
14
15 private static final double LAT_OFFSET_1(double x, double y) {
16 return (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
17 }
18
19 private static final double LAT_OFFSET_2(double x, double y) {
20 return (20.0 * Math.sin(y * Math.PI) + 40.0 * Math.sin(y / 3.0 * Math.PI)) * 2.0 / 3.0;
21 }
22
23 private static final double LAT_OFFSET_3(double x, double y) {
24 return (160.0 * Math.sin(y / 12.0 * Math.PI) + 320 * Math.sin(y * Math.PI / 30.0)) * 2.0 / 3.0;
25 }
26
27 private static final double LON_OFFSET_0(double x, double y) {
28 return 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
29 }
30
31 private static final double LON_OFFSET_1(double x, double y) {
32 return (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0;
33 }
34
35 private static final double LON_OFFSET_2(double x, double y) {
36 return (20.0 * Math.sin(x * Math.PI) + 40.0 * Math.sin(x / 3.0 * Math.PI)) * 2.0 / 3.0;
37 }
38
39 private static final double LON_OFFSET_3(double x, double y) {
40 return (150.0 * Math.sin(x / 12.0 * Math.PI) + 300.0 * Math.sin(x / 30.0 * Math.PI)) * 2.0 / 3.0;
41 }
42
43 private static double RANGE_LON_MAX = 137.8347;
44 private static double RANGE_LON_MIN = 72.004;
45 private static double RANGE_LAT_MAX = 55.8271;
46 private static double RANGE_LAT_MIN = 0.8293;
47
48 private static double jzA = 6378245.0;
49 private static double jzEE = 0.00669342162296594323;
50
51 public static double transformLat(double x, double y) {
52 double ret = LAT_OFFSET_0(x, y);
53 ret += LAT_OFFSET_1(x, y);
54 ret += LAT_OFFSET_2(x, y);
55 ret += LAT_OFFSET_3(x, y);
56 return ret;
57 }
58
59 public static double transformLon(double x, double y) {
60 double ret = LON_OFFSET_0(x, y);
61 ret += LON_OFFSET_1(x, y);
62 ret += LON_OFFSET_2(x, y);
63 ret += LON_OFFSET_3(x, y);
64 return ret;
65 }
66
67 public static boolean outOfChina(double lat, double lon) {
68 if (lon < RANGE_LON_MIN || lon > RANGE_LON_MAX)
69 return true;
70 if (lat < RANGE_LAT_MIN || lat > RANGE_LAT_MAX)
71 return true;
72 return false;
73 }
74
75 public static Point gcj02Encrypt(double ggLat, double ggLon) {
76 Point resPoint = new Point();
77 double mgLat;
78 double mgLon;
79 if (outOfChina(ggLat, ggLon)) {
80 resPoint.setY(ggLat);
81 resPoint.setX(ggLon);
82 return resPoint;
83 }
84 double dLat = transformLat(ggLon - 105.0, ggLat - 35.0);
85 double dLon = transformLon(ggLon - 105.0, ggLat - 35.0);
86 double radLat = ggLat / 180.0 * Math.PI;
87 double magic = Math.sin(radLat);
88 magic = 1 - jzEE * magic * magic;
89 double sqrtMagic = Math.sqrt(magic);
90 dLat = (dLat * 180.0) / ((jzA * (1 - jzEE)) / (magic * sqrtMagic) * Math.PI);
91 dLon = (dLon * 180.0) / (jzA / sqrtMagic * Math.cos(radLat) * Math.PI);
92 mgLat = ggLat + dLat;
93 mgLon = ggLon + dLon;
94
95 resPoint.setY(mgLat);
96 resPoint.setX(mgLon);
97 return resPoint;
98 }
99
100 public static Point gcj02Decrypt(double gjLat, double gjLon) {
101 Point gPt = gcj02Encrypt(gjLat, gjLon);
102 double dLon = gPt.getX() - gjLon;
103 double dLat = gPt.getY() - gjLat;
104 Point pt = new Point();
105 pt.setY(gjLat - dLat);
106 pt.setX(gjLon - dLon);
107 return pt;
108 }
109
110 public static Point bd09Decrypt(double bdLat, double bdLon) {
111 Point gcjPt = new Point();
112 double x = bdLon - 0.0065, y = bdLat - 0.006;
113 double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * Math.PI);
114 double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * Math.PI);
115 gcjPt.setX(z * Math.cos(theta));
116 gcjPt.setY(z * Math.sin(theta));
117 return gcjPt;
118 }
119
120 public static Point bd09Encrypt(double ggLat, double ggLon) {
121 Point bdPt = new Point();
122 double x = ggLon, y = ggLat;
123 double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * Math.PI);
124 double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * Math.PI);
125 bdPt.setX(z * Math.cos(theta) + 0.0065);
126 bdPt.setY(z * Math.sin(theta) + 0.006);
127 return bdPt;
128 }
129
130 /**
131 * @param location 世界标准地理坐标(WGS-84)
132 * @return 中国国测局地理坐标(GCJ-02)<火星坐标>
133 * @brief 世界标准地理坐标(WGS-84) 转换成 中国国测局地理坐标(GCJ-02)<火星坐标>
134 *
135 * ####只在中国大陆的范围的坐标有效,以外直接返回世界标准坐标
136 */
137 public static Point wgs84ToGcj02(Point location) {
138 return gcj02Encrypt(location.getY(), location.getX());
139 }
140
141 /**
142 * @param location 中国国测局地理坐标(GCJ-02)
143 * @return 世界标准地理坐标(WGS-84)
144 * @brief 中国国测局地理坐标(GCJ-02) 转换成 世界标准地理坐标(WGS-84)
145 *
146 * ####此接口有1-2米左右的误差,需要精确定位情景慎用
147 */
148 public static Point gcj02ToWgs84(Point location) {
149 return gcj02Decrypt(location.getY(), location.getX());
150 }
151
152 /**
153 * @param location 世界标准地理坐标(WGS-84)
154 * @return 百度地理坐标(BD-09)
155 * @brief 世界标准地理坐标(WGS-84) 转换成 百度地理坐标(BD-09)
156 */
157 public static Point wgs84ToBd09(Point location) {
158 Point gcj02Pt = gcj02Encrypt(location.getY(), location.getX());
159 return bd09Encrypt(gcj02Pt.getY(), gcj02Pt.getX());
160 }
161
162 /**
163 * @param location 中国国测局地理坐标(GCJ-02)<火星坐标>
164 * @return 百度地理坐标(BD-09)
165 * @brief 中国国测局地理坐标(GCJ-02)<火星坐标> 转换成 百度地理坐标(BD-09)
166 */
167 public static Point gcj02ToBd09(Point location) {
168 return bd09Encrypt(location.getY(), location.getX());
169 }
170
171 /**
172 * @param location 百度地理坐标(BD-09)
173 * @return 中国国测局地理坐标(GCJ-02)<火星坐标>
174 * @brief 百度地理坐标(BD-09) 转换成 中国国测局地理坐标(GCJ-02)<火星坐标>
175 */
176 public static Point bd09ToGcj02(Point location) {
177 return bd09Decrypt(location.getY(), location.getX());
178 }
179
180 /**
181 * @param location 百度地理坐标(BD-09)
182 * @return 世界标准地理坐标(WGS-84)
183 * @brief 百度地理坐标(BD-09) 转换成 世界标准地理坐标(WGS-84)
184 *
185 * ####此接口有1-2米左右的误差,需要精确定位情景慎用
186 */
187 public static Point bd09ToWgs84(Point location) {
188 Point gcj02 = bd09ToGcj02(location);
189 return gcj02Decrypt(gcj02.getY(), gcj02.getX());
190 }
191
192 }
...@@ -28,4 +28,5 @@ ...@@ -28,4 +28,5 @@
28 android:layout_marginLeft="0dp" 28 android:layout_marginLeft="0dp"
29 app:srcCompat="@mipmap/ic_my_location_white_48dp" /> 29 app:srcCompat="@mipmap/ic_my_location_white_48dp" />
30 </android.support.v7.widget.LinearLayoutCompat> 30 </android.support.v7.widget.LinearLayoutCompat>
31
31 </android.support.constraint.ConstraintLayout> 32 </android.support.constraint.ConstraintLayout>
......