07d77721 by chiangbt

update 3.28

1 parent 85a18886
1 package com.pashanhoo.landsurvey; 1 package com.pashanhoo.landsurvey;
2 2
3 import android.location.Location;
4 import android.location.LocationListener;
5 import android.support.design.widget.FloatingActionButton;
3 import android.support.v7.app.AppCompatActivity; 6 import android.support.v7.app.AppCompatActivity;
4 import android.os.Bundle; 7 import android.os.Bundle;
8 import android.view.View;
5 9
10 import com.esri.android.map.LocationDisplayManager;
6 import com.esri.android.map.MapView; 11 import com.esri.android.map.MapView;
7 import com.esri.android.runtime.ArcGISRuntime; 12 import com.esri.android.runtime.ArcGISRuntime;
8 import com.esri.core.geometry.Point; 13 import com.esri.core.geometry.Point;
9 import com.pashanhoo.landsurvey.R;
10 import com.pashanhoo.landsurvey.layers.google.GoogleMapLayer;
11 import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes; 14 import com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes;
12 import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer; 15 import com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer;
13 import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo; 16 import com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo;
14 import com.pashanhoo.landsurvey.utils.AppInfo; 17 import com.pashanhoo.landsurvey.utils.AppInfo;
15 import com.pashanhoo.landsurvey.utils.GisHolder; 18 import com.pashanhoo.landsurvey.utils.GISHelper;
19 import com.pashanhoo.landsurvey.utils.JZLocationConverter;
16 20
17 public class GoogleMapActivity extends AppCompatActivity { 21 public class GoogleMapActivity extends AppCompatActivity {
18 22
19 private MapView mapView; 23 private MapView mapView;
20 24 // GPS定位器对象
25 private LocationDisplayManager locationDisplayManager;
21 @Override 26 @Override
22 protected void onCreate(Bundle savedInstanceState) { 27 protected void onCreate(Bundle savedInstanceState) {
23 super.onCreate(savedInstanceState); 28 super.onCreate(savedInstanceState);
...@@ -28,14 +33,58 @@ public class GoogleMapActivity extends AppCompatActivity { ...@@ -28,14 +33,58 @@ public class GoogleMapActivity extends AppCompatActivity {
28 mapView.setEsriLogoVisible(false); 33 mapView.setEsriLogoVisible(false);
29 mapView.enableWrapAround(false); 34 mapView.enableWrapAround(false);
30 35
31 GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(); 36 GoogleMapsTiledServiceLayer GOOGLE_VECTOR_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.VECTOR_GOOGLE_MAP);
37 // GoogleMapsTiledServiceLayer GOOGLE_TER_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP);
38 // GoogleMapsTiledServiceLayer GOOGLE_IMAGE_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.IMAGE_GOOGLE_MAP);
32 mapView.addLayer(GOOGLE_VECTOR_Layer); 39 mapView.addLayer(GOOGLE_VECTOR_Layer);
40 // GoogleMapsTiledServiceLayer GOOGLE_ANNO_Layer = new GoogleMapsTiledServiceLayer(GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP);
41 // mapView.addLayer(GOOGLE_ANNO_Layer);
33 42
34 mapView.setMaxResolution(156543.03392800014); 43 mapView.setMaxResolution(156543.03392800014);
35 mapView.setMinResolution(1.1943285668550503); 44 mapView.setMinResolution(0.29858214164761665);
45
46 Point pt = GISHelper.lonLat2Mercator(AppInfo.initPoint);
47 mapView.zoomToResolution(pt, GoogleMapsTiledServiceLayer.getRes()[16]);
48
49 locationDisplayManager = mapView.getLocationDisplayManager();
50 locationDisplayManager.setShowLocation(true);
51 locationDisplayManager.setAutoPanMode(LocationDisplayManager.AutoPanMode.LOCATION);//设置模式
52 locationDisplayManager.setShowPings(true);
53 locationDisplayManager.setLocationListener(new LocationListener() {
54 @Override
55 public void onLocationChanged(Location location) {
56 Point pt = new Point(location.getLongitude(), location.getLatitude());
57 Point gcjPt = JZLocationConverter.wgs84ToGcj02(pt);
58 mapView.zoomToResolution(GISHelper.lonLat2Mercator(gcjPt),
59 GoogleMapsTiledServiceLayer.getRes()[18]);
60 }
61
62 @Override
63 public void onStatusChanged(String s, int i, Bundle bundle) {
64 }
36 65
37 Point pt = GisHolder.lonLat2Mercator(AppInfo.initPoint); 66 @Override
38 mapView.zoomToResolution(pt, 19.1092570712683); 67 public void onProviderEnabled(String s) {
68 }
69
70 @Override
71 public void onProviderDisabled(String s) {
72 }
73 });
39 74
75 FloatingActionButton gps = (FloatingActionButton) findViewById(R.id.gps);
76 gps.setOnClickListener(new View.OnClickListener() {
77 @Override
78 public void onClick(View view) {
79 // 设置GPS功能
80 if (locationDisplayManager.isStarted()) {
81 locationDisplayManager.stop();
82 } else {
83 locationDisplayManager.start();
84 mapView.zoomToResolution(GISHelper.lonLat2Mercator(locationDisplayManager.getPoint()),
85 GoogleMapsTiledServiceLayer.getRes()[18]);
86 }
87 }
88 });
40 } 89 }
41 } 90 }
......
1 package com.pashanhoo.landsurvey.layers.google;
2
3 import android.util.Log;
4
5 import com.esri.android.map.TiledServiceLayer;
6 import com.esri.core.geometry.Envelope;
7 import com.esri.core.geometry.Point;
8 import com.esri.core.geometry.SpatialReference;
9
10 import java.util.Map;
11 import java.util.concurrent.RejectedExecutionException;
12
13 /**
14 * Created by jiangbotao on 2018/3/28.
15 */
16
17 public class GoogleMapLayer extends TiledServiceLayer {
18
19 private int minLevel = 0;
20 private int maxLevel = 19;
21
22 private String[] subDomains = new String[]{"mt1", "mt2", "mt3"};
23
24 private double[] scales = new double[]{591657527.591555,
25 295828763.79577702,
26 147914381.89788899,
27 73957190.948944002,
28 36978595.474472001,
29 18489297.737236001,
30 9244648.8686180003,
31 4622324.4343090001,
32 2311162.217155,
33 1155581.108577,
34 577790.554289,
35 288895.277144,
36 144447.638572,
37 72223.819286,
38 36111.909643,
39 18055.954822,
40 9027.9774109999998,
41 4513.9887049999998,
42 2256.994353,
43 1128.4971760000001};
44
45 private double[] resolutions = new double[]{156543.03392800014,
46 78271.516963999937,
47 39135.758482000092,
48 19567.879240999919,
49 9783.9396204999593,
50 4891.9698102499797,
51 2445.9849051249898,
52 1222.9924525624949,
53 611.49622628138,
54 305.748113140558,
55 152.874056570411,
56 76.4370282850732,
57 38.2185141425366,
58 19.1092570712683,
59 9.55462853563415,
60 4.7773142679493699,
61 2.3886571339746849,
62 1.1943285668550503,
63 0.59716428355981721,
64 0.29858214164761665};
65
66 private Point origin = new Point(-20037508.342787, 20037508.342787);
67
68 private int dpi = 96;
69
70 private int tileWidth = 256;
71 private int tileHeight = 256;
72
73 private int GoogleMapLayerType;
74
75 public GoogleMapLayer(int layerType) {
76 super(true);
77 this.GoogleMapLayerType = layerType;
78 this.init();
79 }
80
81 private void init() {
82 try {
83 getServiceExecutor().submit(new Runnable() {
84 public void run() {
85 GoogleMapLayer.this.initLayer();
86 }
87 });
88 } catch(RejectedExecutionException rejectedexecutionexception) {
89 Log.e("Google Map Layer", "initialization of the layer failed.",
90 rejectedexecutionexception);
91 }
92 }
93
94 protected byte[] getTile(int level, int col, int row) throws Exception {
95 if (level > maxLevel || level <minLevel) {
96 return new byte[0];
97 }
98 String s = "Galileo".substring(0, ((3 * col + row) % 8));
99 String url = "";
100 switch (GoogleMapLayerType) {
101 case GoogleMapLayerTypes.IMAGE_GOOGLE_MAP:
102 url = "http://mt" + (col % 4) + ".google.com/vt/lyrs=s&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
103 break;
104 case GoogleMapLayerTypes.VECTOR_GOOGLE_MAP:
105 url = "http://mt" + (col % 4) + ".google.com/vt/lyrs=m@158000000&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
106 break;
107 case GoogleMapLayerTypes.TERRAIN_GOOGLE_MAP:
108 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;
109 break;
110 case GoogleMapLayerTypes.ANNOTATION_GOOGLE_MAP:
111 url = "http://mt" + (col % 4) + ".google.com/vt/imgtp=png32&lyrs=h@169000000&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + level + "&" + "s=" + s;
112 // url = "http://mt"+ (col % 4) +".google.cn/vt/lyrs=m@256000000&hl=zh-CN&gl=CN&src=app&x=" + col + "&y=" + row + "&z=" + level + "&s=" + s;
113 break;
114 }
115 Log.v(GoogleMapLayer.class.getName(), "url:"+url);
116 Map<String, String> map = null;
117 return com.esri.core.internal.io.handler.a.a(url, map);
118 }
119
120 protected void initLayer() {
121 if (getID() == 0L) {
122 nativeHandle = create();
123 changeStatus(com.esri.android.map.event.OnStatusChangedListener.STATUS .fromInt(-1000));
124 } else {
125 this.setDefaultSpatialReference(SpatialReference.create(102113));
126 this.setFullExtent(new Envelope(-22041257.773878, -32673939.6727517, 22041257.773878, 20851350.0432886));
127 this.setTileInfo(new TileInfo(origin, scales, resolutions, scales.length, dpi, tileWidth, tileHeight));
128 super.initLayer();
129 }
130 }
131 }
1 package com.pashanhoo.landsurvey.layers.google; 1 package com.pashanhoo.landsurvey.layers.google;
2 2
3 import com.esri.android.map.TiledServiceLayer; 3 import com.esri.android.map.TiledServiceLayer;
4
4 import java.util.concurrent.RejectedExecutionException; 5 import java.util.concurrent.RejectedExecutionException;
5 6
6 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
7 import android.util.Log; 8 import android.util.Log;
8 9
9 import com.esri.android.map.TiledServiceLayer;
10 import com.esri.android.map.event.OnStatusChangedListener; 10 import com.esri.android.map.event.OnStatusChangedListener;
11 import com.esri.core.geometry.Envelope; 11 import com.esri.core.geometry.Envelope;
12 import com.esri.core.geometry.Point; 12 import com.esri.core.geometry.Point;
...@@ -14,7 +14,7 @@ import com.esri.core.geometry.SpatialReference; ...@@ -14,7 +14,7 @@ import com.esri.core.geometry.SpatialReference;
14 import com.esri.core.internal.io.handler.ResponseListener; 14 import com.esri.core.internal.io.handler.ResponseListener;
15 import com.esri.core.internal.io.handler.a; 15 import com.esri.core.internal.io.handler.a;
16 import com.esri.core.io.UserCredentials; 16 import com.esri.core.io.UserCredentials;
17 import com.pashanhoo.landsurvey.utils.GisHolder; 17 import com.pashanhoo.landsurvey.utils.GISHelper;
18 18
19 /** 19 /**
20 * Created by jiangbotao on 2018/3/28. 20 * Created by jiangbotao on 2018/3/28.
...@@ -28,23 +28,27 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -28,23 +28,27 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
28 28
29 private static final double XMin = 110.35992000000005; 29 private static final double XMin = 110.35992000000005;
30 private static final double YMin = 31.382360000000062; 30 private static final double YMin = 31.382360000000062;
31
31 private static final double XMax = 116.65036000000009; 32 private static final double XMax = 116.65036000000009;
32 private static final double YMax = 36.36647000000005; 33 private static final double YMax = 36.36647000000005;
33 34
34 private static final double[] res = { 156543.03392800014, 78271.516963999937, 39135.758482000092, 19567.879240999919, 9783.9396204999593, 4891.9698102499797, 2445.9849051249898, 35 private static final double[] res = {156543.03392800014, 78271.516963999937, 39135.758482000092, 19567.879240999919, 9783.9396204999593, 4891.9698102499797, 2445.9849051249898,
35 1222.9924525624949, 611.49622628138, 305.748113140558, 152.874056570411, 76.4370282850732, 38.2185141425366, 19.1092570712683, 9.55462853563415, 4.7773142679493699, 2.3886571339746849, 36 1222.9924525624949, 611.49622628138, 305.748113140558, 152.874056570411, 76.4370282850732, 38.2185141425366, 19.1092570712683, 9.55462853563415, 4.7773142679493699, 2.3886571339746849,
36 1.1943285668550503 /* , 0.59716428355981721, 0.29858214164761665 */}; 37 1.1943285668550503 , 0.59716428355981721, 0.29858214164761665 };
37 38
38 private static final double[] scale = { 591657527.591555, 295828763.79577702, 147914381.89788899, 73957190.948944002, 36978595.474472001, 18489297.737236001, 9244648.8686180003, 39 private static final double[] scale = {591657527.591555, 295828763.79577702, 147914381.89788899, 73957190.948944002, 36978595.474472001, 18489297.737236001, 9244648.8686180003,
39 4622324.4343090001, 2311162.217155, 1155581.108577, 577790.554289, 288895.277144, 144447.638572, 72223.819286, 6111.909643, 18055.954822, 9027.9774109999998, 4513.9887049999998 40 4622324.4343090001, 2311162.217155, 1155581.108577, 577790.554289, 288895.277144, 144447.638572, 72223.819286, 6111.909643, 18055.954822, 9027.9774109999998, 4513.9887049999998
40 /* ,2256.994353, 1128.4971760000001 */}; 41 ,2256.994353, 1128.4971760000001 };
41 42
42 private static String URL = "http://maps.iwxlh.com"; 43 private static String URL = "http://maps.iwxlh.com";
43 private ResponseListener responseListener; 44 private ResponseListener responseListener;
44 private static Point origin = new Point(-20037508.342787, 20037508.342787); 45 private static Point origin = new Point(-20037508.342787, 20037508.342787);
45 46
46 public GoogleMapsTiledServiceLayer() { 47 private int GoogleMapLayerType;
48
49 public GoogleMapsTiledServiceLayer(int layerType) {
47 this(true); 50 this(true);
51 this.GoogleMapLayerType = layerType;
48 } 52 }
49 53
50 public GoogleMapsTiledServiceLayer(boolean initLayer) { 54 public GoogleMapsTiledServiceLayer(boolean initLayer) {
...@@ -64,6 +68,10 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -64,6 +68,10 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
64 } 68 }
65 } 69 }
66 70
71 public static double[] getRes() {
72 return res;
73 }
74
67 protected void initLayer() { 75 protected void initLayer() {
68 if (getID() == 0L) { 76 if (getID() == 0L) {
69 this.nativeHandle = create(); 77 this.nativeHandle = create();
...@@ -74,8 +82,8 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -74,8 +82,8 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
74 try { 82 try {
75 setDefaultSpatialReference(SpatialReference.create(102100)); 83 setDefaultSpatialReference(SpatialReference.create(102100));
76 84
77 GisHolder.lonLat2Mercator(new Point(XMin, YMin)); 85 GISHelper.lonLat2Mercator(new Point(XMin, YMin));
78 GisHolder.lonLat2Mercator(new Point(XMax, YMax)); 86 GISHelper.lonLat2Mercator(new Point(XMax, YMax));
79 87
80 setFullExtent(new Envelope(xmin, ymin, xmax, ymax)); 88 setFullExtent(new Envelope(xmin, ymin, xmax, ymax));
81 // setFullExtent(new Envelope(minMercatorPoint.getX(), 89 // setFullExtent(new Envelope(minMercatorPoint.getX(),
...@@ -90,19 +98,26 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer { ...@@ -90,19 +98,26 @@ public class GoogleMapsTiledServiceLayer extends TiledServiceLayer {
90 } 98 }
91 } 99 }
92 100
93 static final String BASE_URL = "http://mt%d.google.cn/vt/lyrs=m@161000000&v=w2.114&hl=zh-CN&gl=cn&x=%d&y=%d&z=%d&s=Galil";
94 static final String BASE_URL_2 = "http://mt2.google.cn/vt/v=w2.116&hl=zh-CN&gl=cn&x=%d&y=%d&z=%d&s=G";
95
96 String get(int lev, int col, int row) {
97 return "http://mt" + (col % 4) + ".google.cn/vt/lyrs=m@161000000&v=w2.114&hl=zh-CN&gl=cn&" + "x=" + col + "&" + "y=" + row + "&" + "z=" + lev + "&s=Galil"; // 加载Google街道图
98 }
99
100 @SuppressLint("DefaultLocale") 101 @SuppressLint("DefaultLocale")
101 protected byte[] getTile(int lev, int col, int row) throws Exception { 102 protected byte[] getTile(int level, int col, int row) throws Exception {
102 String url = String.format(BASE_URL, col % 4, col, row, lev); // 加载Google街道图 103 String url = "";
103 // String url2 = String.format(BASE_URL_2, col, row, lev); // 加载Google街道图 104 String s = "Galil";
104 // PtaDebug.d("url", url); 105
105 // PtaDebug.e("url2", url2); 106 switch (GoogleMapLayerType) {
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;
109 break;
110 case GoogleMapLayerTypes.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;
112 break;
113 case GoogleMapLayerTypes.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;
115 break;
116 case GoogleMapLayerTypes.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;
118 url = "http://webst02.is.autonavi.com/appmaptile?style=8&x="+ col +"&y="+ row +"&z="+level;
119 break;
120 }
106 return a.a(url, null, null, this.responseListener); 121 return a.a(url, null, null, this.responseListener);
107 } 122 }
108 123
......
...@@ -5,22 +5,14 @@ package com.pashanhoo.landsurvey.utils; ...@@ -5,22 +5,14 @@ package com.pashanhoo.landsurvey.utils;
5 */ 5 */
6 6
7 import java.text.DecimalFormat; 7 import java.text.DecimalFormat;
8 import java.util.ArrayList;
9 import java.util.List;
10 8
11 import android.graphics.Bitmap;
12 import android.util.Log; 9 import android.util.Log;
13 10
14 import com.esri.android.map.GraphicsLayer;
15 import com.esri.android.map.MapView; 11 import com.esri.android.map.MapView;
16 import com.esri.core.geometry.GeometryEngine; 12 import com.esri.core.geometry.GeometryEngine;
17 import com.esri.core.geometry.Line;
18 import com.esri.core.geometry.Point; 13 import com.esri.core.geometry.Point;
19 import com.esri.core.geometry.Polygon; 14 import com.esri.core.geometry.Polygon;
20 import com.esri.core.geometry.Polyline;
21 import com.esri.core.geometry.SpatialReference; 15 import com.esri.core.geometry.SpatialReference;
22 import com.esri.core.map.Graphic;
23 import com.esri.core.symbol.SimpleLineSymbol;
24 16
25 /** 17 /**
26 * GIS相关持有工具类 18 * GIS相关持有工具类
...@@ -28,13 +20,13 @@ import com.esri.core.symbol.SimpleLineSymbol; ...@@ -28,13 +20,13 @@ import com.esri.core.symbol.SimpleLineSymbol;
28 * @author JiangXusheng 20 * @author JiangXusheng
29 * @date 2013-7-6 下午1:16:07 21 * @date 2013-7-6 下午1:16:07
30 */ 22 */
31 public class GisHolder { 23 public class GISHelper {
32 public static final int VALIDATE_X_Y = 999; 24 public static final int VALIDATE_X_Y = 999;
33 25
34 public static final double AX = 0.83; 26 public static final double AX = 0.83;
35 public static final double BX = 1 - AX; 27 public static final double BX = 1 - AX;
36 28
37 static final String TAG = GisHolder.class.getName(); 29 static final String TAG = GISHelper.class.getName();
38 30
39 public enum MarkerSymbolType { 31 public enum MarkerSymbolType {
40 TEXT, IMAGE, SIMPLE, IMAGE_TEXT, SIMPLE_TEXT, SIMPLE_LINE; 32 TEXT, IMAGE, SIMPLE, IMAGE_TEXT, SIMPLE_TEXT, SIMPLE_LINE;
...@@ -42,7 +34,9 @@ public class GisHolder { ...@@ -42,7 +34,9 @@ public class GisHolder {
42 34
43 private static final double EARTH_RADIUS = 6378137.0; 35 private static final double EARTH_RADIUS = 6378137.0;
44 36
45 /** 计算两点间的距离 */ 37 /**
38 * 计算两点间的距离
39 */
46 public static double gps2m(double lat_a, double lng_a, double lat_b, double lng_b) { 40 public static double gps2m(double lat_a, double lng_a, double lat_b, double lng_b) {
47 double radLat1 = (lat_a * Math.PI / 180.0); 41 double radLat1 = (lat_a * Math.PI / 180.0);
48 double radLat2 = (lat_b * Math.PI / 180.0); 42 double radLat2 = (lat_b * Math.PI / 180.0);
...@@ -55,7 +49,10 @@ public class GisHolder { ...@@ -55,7 +49,10 @@ public class GisHolder {
55 } 49 }
56 50
57 // 计算方位角pab。 51 // 计算方位角pab。
58 /** 计算方位角 */ 52
53 /**
54 * 计算方位角
55 */
59 public static double gps2d(double lat_a, double lng_a, double lat_b, double lng_b) { 56 public static double gps2d(double lat_a, double lng_a, double lat_b, double lng_b) {
60 double d = 0; 57 double d = 0;
61 lat_a = lat_a * Math.PI / 180; 58 lat_a = lat_a * Math.PI / 180;
...@@ -94,21 +91,6 @@ public class GisHolder { ...@@ -94,21 +91,6 @@ public class GisHolder {
94 return AX * dN + BX * dPieN_1; 91 return AX * dN + BX * dPieN_1;
95 } 92 }
96 93
97 public static double getScreenM(MapView mapView, Point point1, Point point2, boolean toMocha) {
98
99 point1 = GisHolder.checkGeometryPoint(point1);
100 point2 = GisHolder.checkGeometryPoint(point2);
101
102 if (toMocha) {
103 point1 = GisHolder.lonLat2Mercator(point1);
104 point2 = GisHolder.lonLat2Mercator(point2);
105 }
106
107 Point screenPoint1 = mapView.toScreenPoint(point1);
108 Point screenPoint2 = mapView.toScreenPoint(point2);
109 return Math.sqrt((screenPoint1.getX() - screenPoint2.getX()) * (screenPoint1.getX() - screenPoint2.getX()) + (screenPoint1.getY() - screenPoint2.getY())
110 * (screenPoint1.getY() - screenPoint2.getY()));
111 }
112 94
113 public static boolean isValidateData(Point point) { 95 public static boolean isValidateData(Point point) {
114 boolean rst = false; 96 boolean rst = false;
...@@ -127,28 +109,11 @@ public class GisHolder { ...@@ -127,28 +109,11 @@ public class GisHolder {
127 return (x / 1000000.0); 109 return (x / 1000000.0);
128 } 110 }
129 111
130 public static Point checkGeometryPoint(Point point) {
131 try {
132 if (null == point) {
133 point = new Point();
134 }
135 if (point.isEmpty()) {
136 point.setX(VALIDATE_X_Y);
137 point.setY(VALIDATE_X_Y);
138 }
139 } catch (Exception e) {
140 point.setX(VALIDATE_X_Y);
141 point.setY(VALIDATE_X_Y);
142 }
143 return point;
144 }
145
146
147
148 112
149 private static DecimalFormat format = new DecimalFormat("0.0"); 113 private static DecimalFormat format = new DecimalFormat("0.0");
150 114
151 // 经纬度转墨卡托 115 // 经纬度转墨卡托
116
152 /** 117 /**
153 * SpatialReference.WKID_WGS84(4326) to 118 * SpatialReference.WKID_WGS84(4326) to
154 * SpatialReference.WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE(102100) 119 * SpatialReference.WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE(102100)
...@@ -171,6 +136,7 @@ public class GisHolder { ...@@ -171,6 +136,7 @@ public class GisHolder {
171 } 136 }
172 137
173 // 墨卡托转经纬度 138 // 墨卡托转经纬度
139
174 /** 140 /**
175 * SpatialReference.WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE(102100) to 141 * SpatialReference.WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE(102100) to
176 * SpatialReference.WKID_WGS84(4326) 142 * SpatialReference.WKID_WGS84(4326)
...@@ -189,33 +155,4 @@ public class GisHolder { ...@@ -189,33 +155,4 @@ public class GisHolder {
189 return point; 155 return point;
190 } 156 }
191 157
192 public static Point[] getPoints(Point center, double radius) {
193 Point[] points = new Point[50];
194 double sin;
195 double cos;
196 double x;
197 double y;
198 for (double i = 0; i < 50; i++) {
199 sin = Math.sin(Math.PI * 2 * i / 50);
200 cos = Math.cos(Math.PI * 2 * i / 50);
201 x = center.getX() + radius * 1.2 * sin;
202 y = center.getY() + radius * cos;
203 points[(int) i] = new Point(x, y);
204 }
205 return points;
206 }
207
208 public static void getCircle(Point center, double radius, Polygon circle) {
209 circle.setEmpty();
210 try {
211 Point[] points = getPoints(center, radius);
212 circle.startPath(GisHolder.lonLat2Mercator(points[0]));
213 for (int i = 1; i < points.length; i++) {
214 points[i] = GisHolder.checkGeometryPoint(points[i]);
215 circle.lineTo(GisHolder.lonLat2Mercator(points[i]));
216 }
217 } catch (Exception e) {
218 Log.e("", "", e);
219 }
220 }
221 } 158 }
......
...@@ -10,4 +10,22 @@ ...@@ -10,4 +10,22 @@
10 android:id="@+id/map" 10 android:id="@+id/map"
11 android:layout_width="fill_parent" 11 android:layout_width="fill_parent"
12 android:layout_height="fill_parent"></com.esri.android.map.MapView> 12 android:layout_height="fill_parent"></com.esri.android.map.MapView>
13
14 <android.support.v7.widget.LinearLayoutCompat
15 android:layout_width="match_parent"
16 android:layout_height="match_parent"
17 android:orientation="vertical"
18 android:layout_marginTop="16dp"
19 android:layout_marginLeft="16dp"
20 android:layout_marginBottom="16dp"
21 android:layout_gravity="top|start">
22 <android.support.design.widget.FloatingActionButton
23 android:id="@+id/gps"
24 android:layout_width="wrap_content"
25 android:layout_height="wrap_content"
26 android:layout_gravity="top|start"
27 android:layout_marginTop="0dp"
28 android:layout_marginLeft="0dp"
29 app:srcCompat="@mipmap/ic_my_location_white_48dp" />
30 </android.support.v7.widget.LinearLayoutCompat>
13 </android.support.constraint.ConstraintLayout> 31 </android.support.constraint.ConstraintLayout>
......