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
315122b8
authored
2018-03-26 23:19:45 +0800
by
chiangbt
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
update 3.26
1 parent
b9cc8134
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
41 deletions
app/src/main/java/com/pashanhoo/landsurvey/MainActivity.java
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TDTTileinfo.java
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TianDiTuLocalTiledMapServiceLayer.java
app/src/main/res/layout/activity_main.xml
app/src/main/java/com/pashanhoo/landsurvey/MainActivity.java
View file @
315122b
...
...
@@ -10,6 +10,7 @@ import android.util.Log;
import
android.view.View
;
import
android.view.Menu
;
import
android.view.MenuItem
;
import
android.widget.TextView
;
import
com.esri.android.map.LocationDisplayManager
;
import
com.esri.android.map.MapView
;
...
...
@@ -35,12 +36,15 @@ public class MainActivity extends AppCompatActivity {
private
TianDiTuLocalTiledMapServiceLayer
t_local
;
private
String
mapType
;
private
TextView
mapinfoView
;
private
int
curLevel
=
0
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
Toolbar
toolbar
=
(
Toolbar
)
findViewById
(
R
.
id
.
toolbar
);
mapinfoView
=
(
TextView
)
findViewById
(
R
.
id
.
mapinfo
);
setSupportActionBar
(
toolbar
);
//初始化-------------------------------------------------------------------
AppInfo
.
Settings
();
...
...
@@ -52,7 +56,9 @@ public class MainActivity extends AppCompatActivity {
if
(
locationDisplayManager
!=
null
){
locationDisplayManager
.
stop
();
}
mapView
.
zoomin
(
true
);
if
(
curLevel
<
19
)
{
mapView
.
zoomin
(
true
);
}
}
});
FloatingActionButton
zoomout
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
zoomout
);
...
...
@@ -62,7 +68,9 @@ public class MainActivity extends AppCompatActivity {
if
(
locationDisplayManager
!=
null
){
locationDisplayManager
.
stop
();
}
mapView
.
zoomout
(
true
);
if
(
curLevel
>
0
)
{
mapView
.
zoomout
(
true
);
}
}
});
FloatingActionButton
fullmap
=
(
FloatingActionButton
)
findViewById
(
R
.
id
.
fullmap
);
...
...
@@ -116,6 +124,8 @@ public class MainActivity extends AppCompatActivity {
public
void
onStatusChanged
(
Object
o
,
STATUS
status
)
{
if
(
status
==
STATUS
.
INITIALIZED
){
mapView
.
zoomToResolution
(
AppInfo
.
initPoint
,
AppInfo
.
initRes
);
curLevel
=
TDTTileinfo
.
getCurrentLevel
(
AppInfo
.
initRes
);
mapinfoView
.
setText
(
"当前地图级别为:"
+
String
.
valueOf
(
curLevel
));
}
}
});
...
...
@@ -126,10 +136,13 @@ public class MainActivity extends AppCompatActivity {
@Override
public
void
postAction
(
float
v
,
float
v1
,
double
v2
)
{
Log
.
i
(
"map"
,
String
.
valueOf
(
TDTTileinfo
.
getCurrentLevel
(
mapView
.
getResolution
())));
int
level
=
TDTTileinfo
.
getCurrentLevel
(
mapView
.
getResolution
());
if
(
level
>
7
||
level
<
10
){
t_local
.
clearTiles
();
curLevel
=
TDTTileinfo
.
getCurrentLevel
(
mapView
.
getResolution
());
mapinfoView
.
setText
(
"当前地图级别为:"
+
String
.
valueOf
(
curLevel
));
// t_local只有8和9级数据
if
(
curLevel
>
9
|
curLevel
<
8
){
t_local
.
setVisible
(
false
);
}
else
{
t_local
.
setVisible
(
true
);
}
}
});
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TDTTileinfo.java
View file @
315122b
package
com
.
pashanhoo
.
landsurvey
.
layers
.
tianditu
;
import
android.util.Log
;
import
com.esri.core.geometry.Point
;
/**
...
...
@@ -144,7 +146,7 @@ public class TDTTileinfo {
public
static
int
getCurrentLevel
(
double
resolution
){
for
(
int
i
=
0
;
i
<
res4490
.
length
;
i
++){
if
((
res4490
[
i
]
-
resolution
)<
0.001
){
if
((
res4490
[
i
]
-
resolution
)<
0.00
00000
1
){
return
i
;
}
}
...
...
app/src/main/java/com/pashanhoo/landsurvey/layers/tianditu/TianDiTuLocalTiledMapServiceLayer.java
View file @
315122b
...
...
@@ -24,14 +24,15 @@ import java.util.concurrent.RejectedExecutionException;
public
class
TianDiTuLocalTiledMapServiceLayer
extends
TiledServiceLayer
{
String
sqlitedb
=
""
;
private
TileInfo
tiandituTileInfo
;
private
String
layername
=
""
;
private
SQLiteDatabase
sqLiteDatabase
;
public
TianDiTuLocalTiledMapServiceLayer
(
String
url
,
String
layername
)
{
super
(
url
);
this
.
sqlitedb
=
url
;
public
TianDiTuLocalTiledMapServiceLayer
(
String
dbname
,
String
layername
)
{
super
(
dbname
);
this
.
layername
=
layername
;
this
.
sqLiteDatabase
=
SQLiteDatabase
.
openOrCreateDatabase
(
Environment
.
getExternalStorageDirectory
()+
"/keymapinfo/"
+
dbname
,
null
);
try
{
getServiceExecutor
().
submit
(
new
Runnable
()
{
...
...
@@ -67,40 +68,27 @@ public class TianDiTuLocalTiledMapServiceLayer extends TiledServiceLayer {
protected
byte
[]
getTile
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
byte
[]
result
=
null
;
try
{
result
=
getOfflineCacheDB
(
level
,
col
,
row
);
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
String
sql
=
"SELECT * FROM "
+
this
.
layername
+
" where TILELEVEL = "
+
level
+
" and TILECOL = "
+
col
+
" and TILEROW = "
+
row
;
Cursor
mCursor
=
this
.
sqLiteDatabase
.
rawQuery
(
sql
,
null
);
boolean
hasData
=
false
;
return
result
;
}
private
byte
[]
getOfflineCacheDB
(
int
level
,
int
col
,
int
row
)
throws
Exception
{
byte
[]
result
=
null
;
// Log.i("local", level + ":"+ col + ":" + row);
// row = (int) (Math.pow(2, level) - col - row);
String
sql
=
"select * from "
+
this
.
layername
+
" where TILELEVEL = "
+
level
+
" and TILECOL = "
+
col
+
" and TILEROW = "
+
row
;
Cursor
mCursor
=
SQLiteDatabase
.
openOrCreateDatabase
(
Environment
.
getExternalStorageDirectory
()+
"/keymapinfo/"
+
this
.
sqlitedb
,
null
)
.
rawQuery
(
sql
,
null
);
boolean
hasData
=
false
;
while
(
mCursor
.
moveToNext
())
{
//判断是否存在数据
hasData
=
true
;
}
if
(
hasData
)
{
//数据库中有数据
try
{
if
(
mCursor
.
moveToFirst
())
{
result
=
mCursor
.
getBlob
(
mCursor
.
getColumnIndex
(
"TILEDATA"
));
while
(
mCursor
.
moveToNext
())
{
//判断是否存在数据
hasData
=
true
;
}
if
(
hasData
)
{
//数据库中有数据
try
{
if
(
mCursor
.
moveToFirst
())
{
result
=
mCursor
.
getBlob
(
mCursor
.
getColumnIndex
(
"TILEDATA"
));
}
mCursor
.
close
();
}
catch
(
Exception
e
)
{
result
=
null
;
}
mCursor
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
result
=
null
;
}
}
catch
(
Exception
ex
)
{
result
=
null
;
}
return
result
;
}
...
...
app/src/main/res/layout/activity_main.xml
View file @
315122b
...
...
@@ -64,5 +64,20 @@
app:srcCompat=
"@mipmap/ic_home_white_48dp"
/>
</android.support.v7.widget.LinearLayoutCompat>
<android.support.v7.widget.LinearLayoutCompat
android:layout_width=
"match_parent"
android:layout_height=
"20dp"
android:orientation=
"vertical"
android:layout_marginLeft=
"16dp"
android:layout_marginRight=
"16dp"
android:layout_marginBottom=
"16dp"
android:layout_gravity=
"bottom|left"
>
<TextView
android:id=
"@+id/mapinfo"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:textColor=
"@color/colorAccent"
android:text=
"地图信息"
/>
</android.support.v7.widget.LinearLayoutCompat>
</android.support.design.widget.CoordinatorLayout>
...
...
Please
register
or
sign in
to post a comment