Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
蒋波涛
/
landsurvey
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
85a18886
authored
2018-03-28 12:14:24 +0800
by
chiangbt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update 3.28
1 parent
2cb1f5ec
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
506 additions
and
34 deletions
app/src/main/AndroidManifest.xml
app/src/main/java/com/pashanhoo/landsurvey/GoogleMapActivity.java
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapLayer.java
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapLayerTypes.java
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapsTiledServiceLayer.java
app/src/main/java/com/pashanhoo/landsurvey/utils/GisHolder.java
app/src/main/res/layout/activity_google_map.xml
app/src/main/AndroidManifest.xml
View file @
85a1888
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.pashanhoo.landsurvey"
>
<uses-feature
android:glEsVersion=
"0x00020000"
android:required=
"true"
/>
<uses-permission
android:name=
"android.permission.INTERNET"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/>
<uses-permission
android:name=
"android.permission.ACCESS_FINE_LOCATION"
/>
<application
android:allowBackup=
"true"
android:icon=
"@mipmap/logo"
android:label=
"@string/app_name"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".BootActivity"
>
</activity>
<activity
android:name=
".BootActivity"
>
android:name=
".MainActivity"
android:label=
"@string/app_name"
android:screenOrientation=
"landscape"
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>
<activity
android:name=
".MainActivity"
android:label=
"@string/app_name"
android:theme=
"@style/AppTheme.NoActionBar"
android:screenOrientation=
"landscape"
>
<!-- 禁止屏幕旋转 -->
</activity>
</application>
</manifest>
\ No newline at end of file
...
...
app/src/main/java/com/pashanhoo/landsurvey/GoogleMapActivity.java
0 → 100644
View file @
85a1888
package
com
.
pashanhoo
.
landsurvey
;
import
android.support.v7.app.AppCompatActivity
;
import
android.os.Bundle
;
import
com.esri.android.map.MapView
;
import
com.esri.android.runtime.ArcGISRuntime
;
import
com.esri.core.geometry.Point
;
import
com.pashanhoo.landsurvey.R
;
import
com.pashanhoo.landsurvey.layers.google.GoogleMapLayer
;
import
com.pashanhoo.landsurvey.layers.google.GoogleMapLayerTypes
;
import
com.pashanhoo.landsurvey.layers.google.GoogleMapsTiledServiceLayer
;
import
com.pashanhoo.landsurvey.layers.tianditu.TDTTileinfo
;
import
com.pashanhoo.landsurvey.utils.AppInfo
;
import
com.pashanhoo.landsurvey.utils.GisHolder
;
public
class
GoogleMapActivity
extends
AppCompatActivity
{
private
MapView
mapView
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_google_map
);
ArcGISRuntime
.
setClientId
(
"1eFHW78avlnRUPHm"
);
mapView
=
(
MapView
)
findViewById
(
R
.
id
.
map
);
mapView
.
setEsriLogoVisible
(
false
);
mapView
.
enableWrapAround
(
false
);
GoogleMapsTiledServiceLayer
GOOGLE_VECTOR_Layer
=
new
GoogleMapsTiledServiceLayer
();
mapView
.
addLayer
(
GOOGLE_VECTOR_Layer
);
mapView
.
setMaxResolution
(
156543.03392800014
);
mapView
.
setMinResolution
(
1.1943285668550503
);
Point
pt
=
GisHolder
.
lonLat2Mercator
(
AppInfo
.
initPoint
);
mapView
.
zoomToResolution
(
pt
,
19.1092570712683
);
}
}
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapLayer.java
View file @
85a1888
package
com
.
pashanhoo
.
landsurvey
.
layers
.
google
;
import
android.util.Log
;
import
com.esri.android.map.TiledServiceLayer
;
import
com.esri.core.geometry.Envelope
;
import
com.esri.core.geometry.Point
;
...
...
@@ -20,19 +22,45 @@ public class GoogleMapLayer extends TiledServiceLayer {
private
String
[]
subDomains
=
new
String
[]{
"mt1"
,
"mt2"
,
"mt3"
};
private
double
[]
scales
=
new
double
[]{
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
,
36111.909643
,
18055.954822
,
9027.9774109999998
,
4513.9887049999998
,
2256.994353
,
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
,
36111.909643
,
18055.954822
,
9027.9774109999998
,
4513.9887049999998
,
2256.994353
,
1128.4971760000001
};
private
double
[]
resolutions
=
new
double
[]{
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
,
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
Point
origin
=
new
Point
(-
20037508.342787
,
20037508.342787
);
...
...
@@ -42,8 +70,11 @@ public class GoogleMapLayer extends TiledServiceLayer {
private
int
tileWidth
=
256
;
private
int
tileHeight
=
256
;
public
GoogleMapLayer
()
{
private
int
GoogleMapLayerType
;
public
GoogleMapLayer
(
int
layerType
)
{
super
(
true
);
this
.
GoogleMapLayerType
=
layerType
;
this
.
init
();
}
...
...
@@ -54,22 +85,34 @@ public class GoogleMapLayer extends TiledServiceLayer {
GoogleMapLayer
.
this
.
initLayer
();
}
});
}
catch
(
RejectedExecutionException
rejectedexecutionexception
)
{
}
catch
(
RejectedExecutionException
rejectedexecutionexception
)
{
Log
.
e
(
"Google Map Layer"
,
"initialization of the layer failed."
,
rejectedexecutionexception
);
}
}
protected
byte
[]
getTile
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
if
(
level
>
maxLevel
||
level
<
minLevel
)
if
(
level
>
maxLevel
||
level
<
minLevel
)
{
return
new
byte
[
0
];
String
subDomain
=
subDomains
[(
level
+
col
+
row
)
%
subDomains
.
length
];
//构建待拼接字符串
String
_mapType
=
"m@225000000"
;
String
url
=
"http://"
+
subDomain
+
".google.cn/vt/lyrs="
+
_mapType
+
"&hl=zh-CN&gl=CN&src=app&"
+
"x="
+
col
+
"&"
+
"y="
+
row
+
"&"
+
"z="
+
level
+
"&s=Ga"
;
}
String
s
=
"Galileo"
.
substring
(
0
,
((
3
*
col
+
row
)
%
8
));
String
url
=
""
;
switch
(
GoogleMapLayerType
)
{
case
GoogleMapLayerTypes
.
IMAGE_GOOGLE_MAP
:
url
=
"http://mt"
+
(
col
%
4
)
+
".google.com/vt/lyrs=s&hl=zh-CN&gl=cn&"
+
"x="
+
col
+
"&"
+
"y="
+
row
+
"&"
+
"z="
+
level
+
"&"
+
"s="
+
s
;
break
;
case
GoogleMapLayerTypes
.
VECTOR_GOOGLE_MAP
:
url
=
"http://mt"
+
(
col
%
4
)
+
".google.com/vt/lyrs=m@158000000&hl=zh-CN&gl=cn&"
+
"x="
+
col
+
"&"
+
"y="
+
row
+
"&"
+
"z="
+
level
+
"&"
+
"s="
+
s
;
break
;
case
GoogleMapLayerTypes
.
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
GoogleMapLayerTypes
.
ANNOTATION_GOOGLE_MAP
:
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
;
// 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;
break
;
}
Log
.
v
(
GoogleMapLayer
.
class
.
getName
(),
"url:"
+
url
);
Map
<
String
,
String
>
map
=
null
;
return
com
.
esri
.
core
.
internal
.
io
.
handler
.
a
.
a
(
url
,
map
);
}
...
...
@@ -77,13 +120,11 @@ public class GoogleMapLayer extends TiledServiceLayer {
protected
void
initLayer
()
{
if
(
getID
()
==
0L
)
{
nativeHandle
=
create
();
changeStatus
(
com
.
esri
.
android
.
map
.
event
.
OnStatusChangedListener
.
STATUS
.
fromInt
(-
1000
));
changeStatus
(
com
.
esri
.
android
.
map
.
event
.
OnStatusChangedListener
.
STATUS
.
fromInt
(-
1000
));
}
else
{
this
.
setDefaultSpatialReference
(
SpatialReference
.
create
(
102113
));
this
.
setFullExtent
(
new
Envelope
(-
22041257.773878
,
-
32673939.6727517
,
22041257.773878
,
20851350.0432886
));
this
.
setTileInfo
(
new
TileInfo
(
origin
,
scales
,
resolutions
,
scales
.
length
,
dpi
,
tileWidth
,
tileHeight
));
this
.
setFullExtent
(
new
Envelope
(-
22041257.773878
,
-
32673939.6727517
,
22041257.773878
,
20851350.0432886
));
this
.
setTileInfo
(
new
TileInfo
(
origin
,
scales
,
resolutions
,
scales
.
length
,
dpi
,
tileWidth
,
tileHeight
));
super
.
initLayer
();
}
}
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapLayerTypes.java
0 → 100644
View file @
85a1888
package
com
.
pashanhoo
.
landsurvey
.
layers
.
google
;
/**
* Created by jiangbotao on 2018/3/28.
*/
public
interface
GoogleMapLayerTypes
{
/** * Google vector map service by city map*/
final
int
VECTOR_GOOGLE_MAP
=
1
;
/** * Google image map service by satellite map */
final
int
IMAGE_GOOGLE_MAP
=
2
;
/** * Google topographic map service ======= topographic map */
final
int
TERRAIN_GOOGLE_MAP
=
3
;
/** * Google road POI map service = = = = net road map */
final
int
ANNOTATION_GOOGLE_MAP
=
4
;
}
app/src/main/java/com/pashanhoo/landsurvey/layers/google/GoogleMapsTiledServiceLayer.java
0 → 100644
View file @
85a1888
package
com
.
pashanhoo
.
landsurvey
.
layers
.
google
;
import
com.esri.android.map.TiledServiceLayer
;
import
java.util.concurrent.RejectedExecutionException
;
import
android.annotation.SuppressLint
;
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.utils.GisHolder
;
/**
* Created by jiangbotao on 2018/3/28.
*/
public
class
GoogleMapsTiledServiceLayer
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
);
public
GoogleMapsTiledServiceLayer
()
{
this
(
true
);
}
public
GoogleMapsTiledServiceLayer
(
boolean
initLayer
)
{
super
(
URL
);
this
.
isBingMap
=
true
;
if
(!(
initLayer
))
return
;
try
{
getServiceExecutor
().
submit
(
new
Runnable
()
{
public
void
run
()
{
GoogleMapsTiledServiceLayer
.
this
.
initLayer
();
}
});
}
catch
(
RejectedExecutionException
localRejectedExecutionException
)
{
Log
.
e
(
"ArcGIS"
,
"initialization of the layer failed."
,
localRejectedExecutionException
);
}
}
protected
void
initLayer
()
{
if
(
getID
()
==
0L
)
{
this
.
nativeHandle
=
create
();
}
if
(
getID
()
==
0L
)
{
changeStatus
(
OnStatusChangedListener
.
STATUS
.
fromInt
(-
1000
));
}
else
{
try
{
setDefaultSpatialReference
(
SpatialReference
.
create
(
102100
));
GisHolder
.
lonLat2Mercator
(
new
Point
(
XMin
,
YMin
));
GisHolder
.
lonLat2Mercator
(
new
Point
(
XMax
,
YMax
));
setFullExtent
(
new
Envelope
(
xmin
,
ymin
,
xmax
,
ymax
));
// setFullExtent(new Envelope(minMercatorPoint.getX(),
// minMercatorPoint.getY(), maxMercatorPoint.getX(),
// maxMercatorPoint.getY()));
setTileInfo
(
new
TiledServiceLayer
.
TileInfo
(
origin
,
scale
,
res
,
scale
.
length
,
96
,
256
,
256
));
super
.
initLayer
();
}
catch
(
Exception
localException
)
{
changeStatus
(
OnStatusChangedListener
.
STATUS
.
fromInt
(-
1005
));
Log
.
e
(
"ArcGIS"
,
"Bing map url ="
+
getUrl
(),
localException
);
}
}
}
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"
;
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"
;
String
get
(
int
lev
,
int
col
,
int
row
)
{
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街道图
}
@SuppressLint
(
"DefaultLocale"
)
protected
byte
[]
getTile
(
int
lev
,
int
col
,
int
row
)
throws
Exception
{
String
url
=
String
.
format
(
BASE_URL
,
col
%
4
,
col
,
row
,
lev
);
// 加载Google街道图
// String url2 = String.format(BASE_URL_2, col, row, lev); // 加载Google街道图
// PtaDebug.d("url", url);
// PtaDebug.e("url2", url2);
return
a
.
a
(
url
,
null
,
null
,
this
.
responseListener
);
}
public
void
refresh
()
{
try
{
getServiceExecutor
().
submit
(
new
Runnable
()
{
public
void
run
()
{
if
(!(
GoogleMapsTiledServiceLayer
.
this
.
isInitialized
()))
return
;
try
{
GoogleMapsTiledServiceLayer
.
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
);
}
}
app/src/main/java/com/pashanhoo/landsurvey/utils/GisHolder.java
0 → 100644
View file @
85a1888
package
com
.
pashanhoo
.
landsurvey
.
utils
;
/**
* Created by jiangbotao on 2018/3/28.
*/
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.List
;
import
android.graphics.Bitmap
;
import
android.util.Log
;
import
com.esri.android.map.GraphicsLayer
;
import
com.esri.android.map.MapView
;
import
com.esri.core.geometry.GeometryEngine
;
import
com.esri.core.geometry.Line
;
import
com.esri.core.geometry.Point
;
import
com.esri.core.geometry.Polygon
;
import
com.esri.core.geometry.Polyline
;
import
com.esri.core.geometry.SpatialReference
;
import
com.esri.core.map.Graphic
;
import
com.esri.core.symbol.SimpleLineSymbol
;
/**
* GIS相关持有工具类
*
* @author JiangXusheng
* @date 2013-7-6 下午1:16:07
*/
public
class
GisHolder
{
public
static
final
int
VALIDATE_X_Y
=
999
;
public
static
final
double
AX
=
0.83
;
public
static
final
double
BX
=
1
-
AX
;
static
final
String
TAG
=
GisHolder
.
class
.
getName
();
public
enum
MarkerSymbolType
{
TEXT
,
IMAGE
,
SIMPLE
,
IMAGE_TEXT
,
SIMPLE_TEXT
,
SIMPLE_LINE
;
}
private
static
final
double
EARTH_RADIUS
=
6378137.0
;
/** 计算两点间的距离 */
public
static
double
gps2m
(
double
lat_a
,
double
lng_a
,
double
lat_b
,
double
lng_b
)
{
double
radLat1
=
(
lat_a
*
Math
.
PI
/
180.0
);
double
radLat2
=
(
lat_b
*
Math
.
PI
/
180.0
);
double
a
=
radLat1
-
radLat2
;
double
b
=
(
lng_a
-
lng_b
)
*
Math
.
PI
/
180.0
;
double
s
=
2
*
Math
.
asin
(
Math
.
sqrt
(
Math
.
pow
(
Math
.
sin
(
a
/
2
),
2
)
+
Math
.
cos
(
radLat1
)
*
Math
.
cos
(
radLat2
)
*
Math
.
pow
(
Math
.
sin
(
b
/
2
),
2
)));
s
=
s
*
EARTH_RADIUS
;
s
=
Math
.
round
(
s
*
10000
)
/
10000
;
return
s
;
}
// 计算方位角pab。
/** 计算方位角 */
public
static
double
gps2d
(
double
lat_a
,
double
lng_a
,
double
lat_b
,
double
lng_b
)
{
double
d
=
0
;
lat_a
=
lat_a
*
Math
.
PI
/
180
;
lng_a
=
lng_a
*
Math
.
PI
/
180
;
lat_b
=
lat_b
*
Math
.
PI
/
180
;
lng_b
=
lng_b
*
Math
.
PI
/
180
;
d
=
Math
.
sin
(
lat_a
)
*
Math
.
sin
(
lat_b
)
+
Math
.
cos
(
lat_a
)
*
Math
.
cos
(
lat_b
)
*
Math
.
cos
(
lng_b
-
lng_a
);
d
=
Math
.
sqrt
(
1
-
d
*
d
);
d
=
Math
.
cos
(
lat_b
)
*
Math
.
sin
(
lng_b
-
lng_a
)
/
d
;
d
=
Math
.
asin
(
d
)
*
180
/
Math
.
PI
;
// d = Math.round(d*10000);
return
d
;
}
public
static
double
calulateXYAnagle
(
double
startx
,
double
starty
,
double
endx
,
double
endy
)
{
double
tan
=
Math
.
atan
(
Math
.
abs
((
endy
-
starty
)
/
(
endx
-
startx
)))
*
180
/
Math
.
PI
;
if
(
endx
>
startx
&&
endy
>
starty
)
// 第一象限
{
return
-
tan
;
}
else
if
(
endx
>
startx
&&
endy
<
starty
)
// 第二象限
{
return
tan
;
}
else
if
(
endx
<
startx
&&
endy
>
starty
)
// 第三象限
{
return
tan
-
180
;
}
else
{
return
180
-
tan
;
}
}
private
static
double
getPieValue
(
double
dN
,
double
dPieN_1
)
{
return
AX
*
dN
+
BX
*
dPieN_1
;
}
public
static
double
getScreenM
(
MapView
mapView
,
Point
point1
,
Point
point2
,
boolean
toMocha
)
{
point1
=
GisHolder
.
checkGeometryPoint
(
point1
);
point2
=
GisHolder
.
checkGeometryPoint
(
point2
);
if
(
toMocha
)
{
point1
=
GisHolder
.
lonLat2Mercator
(
point1
);
point2
=
GisHolder
.
lonLat2Mercator
(
point2
);
}
Point
screenPoint1
=
mapView
.
toScreenPoint
(
point1
);
Point
screenPoint2
=
mapView
.
toScreenPoint
(
point2
);
return
Math
.
sqrt
((
screenPoint1
.
getX
()
-
screenPoint2
.
getX
())
*
(
screenPoint1
.
getX
()
-
screenPoint2
.
getX
())
+
(
screenPoint1
.
getY
()
-
screenPoint2
.
getY
())
*
(
screenPoint1
.
getY
()
-
screenPoint2
.
getY
()));
}
public
static
boolean
isValidateData
(
Point
point
)
{
boolean
rst
=
false
;
if
(
null
!=
point
&&
!
point
.
isEmpty
()
&&
point
.
getX
()
!=
VALIDATE_X_Y
&&
point
.
getY
()
!=
VALIDATE_X_Y
&&
point
.
getX
()
!=
0.0
&&
point
.
getY
()
!=
0.0
)
{
rst
=
true
;
}
return
rst
;
}
public
static
long
double2Long
(
double
x
)
{
return
(
long
)
(
x
*
1000000
+
0.5
);
}
public
static
double
long2Double
(
long
x
)
{
return
(
x
/
1000000.0
);
}
public
static
Point
checkGeometryPoint
(
Point
point
)
{
try
{
if
(
null
==
point
)
{
point
=
new
Point
();
}
if
(
point
.
isEmpty
())
{
point
.
setX
(
VALIDATE_X_Y
);
point
.
setY
(
VALIDATE_X_Y
);
}
}
catch
(
Exception
e
)
{
point
.
setX
(
VALIDATE_X_Y
);
point
.
setY
(
VALIDATE_X_Y
);
}
return
point
;
}
private
static
DecimalFormat
format
=
new
DecimalFormat
(
"0.0"
);
// 经纬度转墨卡托
/**
* SpatialReference.WKID_WGS84(4326) to
* SpatialReference.WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE(102100)
*
* @param lonLat
* @return
*/
public
static
Point
lonLat2Mercator
(
Point
lonLat
)
{
// double x = lonLat.getX() * 20037508.34 / 180;
// double y = Math.log(Math.tan((90 + lonLat.getY()) * Math.PI / 360)) /
// (Math.PI / 180);
// y = y * 20037508.34 / 180;
Point
point
=
(
Point
)
GeometryEngine
.
project
(
lonLat
,
SpatialReference
.
create
(
SpatialReference
.
WKID_WGS84
),
SpatialReference
.
create
(
SpatialReference
.
WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE
));
// PtaDebug.e(TAG, "x:"+x+".."+point.getX()+",y"+y+".."+point.getY());
return
point
;
}
// 墨卡托转经纬度
/**
* SpatialReference.WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE(102100) to
* SpatialReference.WKID_WGS84(4326)
*
* @param mercator
* @return
*/
public
static
Point
mercator2lonLat
(
Point
mercator
)
{
// double x = mercator.getX() / 20037508.34 * 180;
// double y = mercator.getY() / 20037508.34 * 180;
// y = 180 / Math.PI * (2 * Math.atan(Math.exp(y * Math.PI / 180)) -
// Math.PI / 2);
Point
point
=
(
Point
)
GeometryEngine
.
project
(
mercator
,
SpatialReference
.
create
(
SpatialReference
.
WKID_WGS84_WEB_MERCATOR_AUXILIARY_SPHERE
),
SpatialReference
.
create
(
SpatialReference
.
WKID_WGS84
));
return
point
;
}
public
static
Point
[]
getPoints
(
Point
center
,
double
radius
)
{
Point
[]
points
=
new
Point
[
50
];
double
sin
;
double
cos
;
double
x
;
double
y
;
for
(
double
i
=
0
;
i
<
50
;
i
++)
{
sin
=
Math
.
sin
(
Math
.
PI
*
2
*
i
/
50
);
cos
=
Math
.
cos
(
Math
.
PI
*
2
*
i
/
50
);
x
=
center
.
getX
()
+
radius
*
1.2
*
sin
;
y
=
center
.
getY
()
+
radius
*
cos
;
points
[(
int
)
i
]
=
new
Point
(
x
,
y
);
}
return
points
;
}
public
static
void
getCircle
(
Point
center
,
double
radius
,
Polygon
circle
)
{
circle
.
setEmpty
();
try
{
Point
[]
points
=
getPoints
(
center
,
radius
);
circle
.
startPath
(
GisHolder
.
lonLat2Mercator
(
points
[
0
]));
for
(
int
i
=
1
;
i
<
points
.
length
;
i
++)
{
points
[
i
]
=
GisHolder
.
checkGeometryPoint
(
points
[
i
]);
circle
.
lineTo
(
GisHolder
.
lonLat2Mercator
(
points
[
i
]));
}
}
catch
(
Exception
e
)
{
Log
.
e
(
""
,
""
,
e
);
}
}
}
app/src/main/res/layout/activity_google_map.xml
0 → 100644
View file @
85a1888
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
"com.pashanhoo.landsurvey.GoogleMapActivity"
>
<com.esri.android.map.MapView
android:id=
"@+id/map"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
></com.esri.android.map.MapView>
</android.support.constraint.ConstraintLayout>
Please
register
or
sign in
to post a comment