Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
L
ldmap-download
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
王健
ldmap-download
Commits
3503c78b
提交
3503c78b
authored
4月 09, 2020
作者:
张航
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加了坐标错误的校验,Jar包版本基本完成
上级
d70f666b
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
59 行增加
和
53 行删除
+59
-53
DownMap.java
...java/com/comleader/ldmapdownload/application/DownMap.java
+40
-6
DownMapLv3.java
...a/com/comleader/ldmapdownload/application/DownMapLv3.java
+2
-2
DownMapLv4.java
...a/com/comleader/ldmapdownload/application/DownMapLv4.java
+2
-2
DownMapLv5.java
...a/com/comleader/ldmapdownload/application/DownMapLv5.java
+2
-2
DownMapLv6.java
...a/com/comleader/ldmapdownload/application/DownMapLv6.java
+2
-2
HttpUtil.java
src/main/java/com/comleader/ldmapdownload/util/HttpUtil.java
+0
-32
application.yml
src/main/resources/application.yml
+3
-0
download-map.properties
src/main/resources/config/download-map.properties
+6
-6
httpclient.properties
src/main/resources/config/httpclient.properties
+2
-1
没有找到文件。
src/main/java/com/comleader/ldmapdownload/application/DownMap.java
浏览文件 @
3503c78b
...
...
@@ -59,13 +59,25 @@ public class DownMap implements ApplicationRunner {
es
=
Executors
.
newFixedThreadPool
(
threadNum
);
completionService
=
new
ExecutorCompletionService
<>(
es
);
// 监听控制台输入下载区域
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"经纬度格式如: 110.391,36.527"
);
String
leftbottom
=
null
;
String
righttop
=
null
;
while
(
true
)
{
System
.
out
.
println
(
"请输入要下载地图的左下角经纬度:"
);
String
leftbottom
=
sc
.
next
();
leftbottom
=
sc
.
next
();
System
.
out
.
println
(
"请输入要下载地图的右上角经纬度:"
);
String
righttop
=
sc
.
next
();
righttop
=
sc
.
next
();
String
errMsg
=
verify
(
leftbottom
,
righttop
);
// 简单校验下载是否正确
if
(
errMsg
==
null
){
break
;
}
System
.
out
.
println
(
errMsg
);
System
.
out
.
println
(
"请重新输入!"
);
}
System
.
out
.
println
(
"开始下载经纬度: {"
+
leftbottom
+
","
+
righttop
+
"}"
);
// 左下角经度,纬度,右上角经度,纬度。
...
...
@@ -81,12 +93,12 @@ public class DownMap implements ApplicationRunner {
for
(
int
z
=
minLv
;
z
<=
maxLv
;
z
++)
{
// 层级
//计算行列号(使用瓦片的中心点经纬度计算)
//四个坐标划定了一个矩形区域
int
minY
=
getOSMTileYFromLatitude
(
Double
.
valueOf
(
rightLngLat
[
0
].
trim
()),
z
);
int
minY
=
getOSMTileYFromLatitude
(
Double
.
valueOf
(
rightLngLat
[
1
].
trim
()),
z
);
int
maxY
=
getOSMTileYFromLatitude
(
Double
.
valueOf
(
leftLngLat
[
1
].
trim
()),
z
);
int
minX
=
getOSMTileXFromLongitude
(
Double
.
valueOf
(
leftLngLat
[
0
].
trim
()),
z
);
int
maxX
=
getOSMTileXFromLongitude
(
Double
.
valueOf
(
rightLngLat
[
0
].
trim
()),
z
);
for
(
int
y
=
minY
;
y
<=
maxY
;
y
++)
{
// Y轴
for
(
int
x
=
minX
;
x
<=
maxX
;
x
++)
{
// X轴
for
(
int
x
=
minX
;
x
<=
maxX
;
x
++)
{
// Y轴
for
(
int
y
=
minY
;
y
<=
maxY
;
y
++)
{
// X轴
// 多线程异步执行下载
Future
<
String
>
resultFulture
=
completionService
.
submit
(
new
DownMapCallable
(
z
,
x
,
y
));
// 加入集合中
...
...
@@ -116,6 +128,24 @@ public class DownMap implements ApplicationRunner {
System
.
exit
(
0
);
}
// 校验格式是否正确
private
String
verify
(
String
leftbottom
,
String
righttop
)
{
String
[]
leftLngLat
=
leftbottom
.
contains
(
","
)
?
leftbottom
.
split
(
","
)
:
leftbottom
.
split
(
","
);
String
[]
rightLngLat
=
righttop
.
contains
(
","
)
?
righttop
.
split
(
","
)
:
righttop
.
split
(
","
);
// 左下角经纬度
Double
leftLng
=
Double
.
valueOf
(
leftLngLat
[
0
].
trim
());
Double
leftLat
=
Double
.
valueOf
(
leftLngLat
[
1
].
trim
());
// 右上角经纬度
Double
rightLng
=
Double
.
valueOf
(
rightLngLat
[
0
].
trim
());
Double
rightLat
=
Double
.
valueOf
(
rightLngLat
[
1
].
trim
());
if
(
leftLng
>
rightLng
||
leftLat
>
rightLat
){
return
"坐标错误,右上角的精度和纬度必须大于左下角的精度和纬度!"
;
}
return
null
;
}
/**
* 计算分辨率
*
...
...
@@ -171,10 +201,11 @@ public class DownMap implements ApplicationRunner {
@Override
public
String
call
()
throws
Exception
{
String
imgUrl
=
null
;
File
file
=
null
;
try
{
//高德地图(6:影像,7:矢量,8:影像路网)
imgUrl
=
CLStringUtil
.
getImgUrl
(
z
,
x
,
y
);
File
file
=
appendFlag
?
CLStringUtil
.
getFullFileNotExist
(
z
,
x
,
y
):
CLStringUtil
.
getFullFile
(
z
,
x
,
y
);
file
=
appendFlag
?
CLStringUtil
.
getFullFileNotExist
(
z
,
x
,
y
):
CLStringUtil
.
getFullFile
(
z
,
x
,
y
);
// 开始下载地图
if
(
file
!=
null
){
...
...
@@ -184,6 +215,9 @@ public class DownMap implements ApplicationRunner {
return
imgUrl
+
" Loaded"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
if
(
file
!=
null
&&
file
.
exists
()){
file
.
delete
();
}
errResults
.
add
(
"Failed: "
+
imgUrl
+
" ErrorMsg >> "
+
e
.
getMessage
());
return
imgUrl
+
" Down Failed"
;
}
...
...
src/main/java/com/comleader/ldmapdownload/application/DownMapLv3.java
浏览文件 @
3503c78b
...
...
@@ -30,8 +30,8 @@ public class DownMapLv3 {
**/
public
static
void
downLoad
()
{
new
Thread
(()
->
{
for
(
int
y
=
0
;
y
<=
7
;
y
++)
{
// Y轴
for
(
int
x
=
0
;
x
<=
7
;
x
++)
{
// X轴
for
(
int
x
=
0
;
x
<=
7
;
x
++)
{
// Y轴
for
(
int
y
=
0
;
y
<=
7
;
y
++)
{
// X轴
//高德地图(6:影像,7:矢量,8:影像路网)
String
imgUrl
=
CLStringUtil
.
getImgUrl
(
z
,
x
,
y
);
File
file
=
CLStringUtil
.
getFullFile
(
z
,
x
,
y
);
...
...
src/main/java/com/comleader/ldmapdownload/application/DownMapLv4.java
浏览文件 @
3503c78b
...
...
@@ -29,8 +29,8 @@ public class DownMapLv4 {
**/
public
static
void
downLoad
()
{
new
Thread
(()
->
{
for
(
int
y
=
0
;
y
<=
9
;
y
++)
{
// Y轴
for
(
int
x
=
0
;
x
<=
15
;
x
++)
{
// X轴
for
(
int
x
=
0
;
x
<=
15
;
x
++)
{
// Y轴
for
(
int
y
=
0
;
y
<=
9
;
y
++)
{
// X轴
//高德地图(6:影像,7:矢量,8:影像路网)
String
imgUrl
=
CLStringUtil
.
getImgUrl
(
z
,
x
,
y
);
File
file
=
CLStringUtil
.
getFullFile
(
z
,
x
,
y
);
...
...
src/main/java/com/comleader/ldmapdownload/application/DownMapLv5.java
浏览文件 @
3503c78b
...
...
@@ -25,8 +25,8 @@ public class DownMapLv5 {
**/
public
static
void
downLoad
()
{
new
Thread
(()
->
{
for
(
int
y
=
10
;
y
<=
23
;
y
++)
{
// Y轴
for
(
int
x
=
15
;
x
<=
31
;
x
++)
{
// X轴
for
(
int
x
=
15
;
x
<=
31
;
x
++)
{
// Y轴
for
(
int
y
=
10
;
y
<=
23
;
y
++)
{
// X轴
//高德地图(6:影像,7:矢量,8:影像路网)
String
imgUrl
=
CLStringUtil
.
getImgUrl
(
z
,
x
,
y
);
File
file
=
CLStringUtil
.
getFullFile
(
z
,
x
,
y
);
...
...
src/main/java/com/comleader/ldmapdownload/application/DownMapLv6.java
浏览文件 @
3503c78b
...
...
@@ -25,8 +25,8 @@ public class DownMapLv6 {
**/
public
static
void
downLoad
()
{
new
Thread
(()
->
{
for
(
int
y
=
20
;
y
<=
28
;
y
++)
{
// Y轴
for
(
int
x
=
45
;
x
<=
57
;
x
++)
{
// X轴
for
(
int
x
=
45
;
x
<=
57
;
x
++)
{
// Y轴
for
(
int
y
=
20
;
y
<=
28
;
y
++)
{
// X轴
//高德地图(6:影像,7:矢量,8:影像路网)
String
imgUrl
=
CLStringUtil
.
getImgUrl
(
z
,
x
,
y
);
File
file
=
CLStringUtil
.
getFullFile
(
z
,
x
,
y
);
...
...
src/main/java/com/comleader/ldmapdownload/util/HttpUtil.java
浏览文件 @
3503c78b
...
...
@@ -77,36 +77,4 @@ public class HttpUtil {
}
public
static
void
writeFromStream
(
InputStream
is
,
File
file
)
{
BufferedInputStream
bis
=
null
;
BufferedOutputStream
bos
=
null
;
try
{
// 下载图片到本地存储
bis
=
new
BufferedInputStream
(
is
);
bos
=
new
BufferedOutputStream
(
new
FileOutputStream
(
file
));
byte
[]
buffer
=
new
byte
[
1024
];
int
len
=
-
1
;
//while ((len = bis.read(buffer)) != -1) {
while
((
len
=
bis
.
read
(
buffer
))
>
0
)
{
bos
.
write
(
buffer
,
0
,
len
);
bos
.
flush
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
// 释放资源
if
(
bos
!=
null
){
bos
.
close
();
}
if
(
bis
!=
null
){
bis
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
src/main/resources/application.yml
浏览文件 @
3503c78b
server
:
port
:
8081
\ No newline at end of file
src/main/resources/config/download-map.properties
浏览文件 @
3503c78b
# 下载地图的保存路径
file.basepath
=
E:/gaode-map/
img
/
file.basepath
=
E:/gaode-map/
jinshui
/
# 下载地图的地址
#天地图服务器t0-t8间选一个
...
...
@@ -18,8 +18,8 @@ map.baseurl=http://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1scale=1&s
map.type
=
CUSTOM
# 下载地图的层级 7 - 18
map.minLv
=
1
4
map.maxLv
=
1
4
map.minLv
=
1
5
map.maxLv
=
1
5
# 线程数
map.threadNum
=
2000
...
...
@@ -30,5 +30,5 @@ map.Lv6.flag=false
# 是否继续下载
map.download.append
=
false
# 这个注释用来备注下下载地图的经纬度
#
left
:
113.587,34.694 right: 113.801,34.799
\ No newline at end of file
# 这个注释用来备注下下载地图的经纬度(注意: 不要写错了),
#
left
:
113.629,34.750 right: 113.911,34.909
\ No newline at end of file
src/main/resources/config/httpclient.properties
浏览文件 @
3503c78b
...
...
@@ -7,6 +7,6 @@ http.connectTimeout=60000
#从连接池中获取到连接的最长时间
http.connectionRequestTimeout
=
6000000
#数据传输的最长时间
http.socketTimeout
=
120000
http.socketTimeout
=
120000
00
#提交请求前测试连接是否可用
http.staleConnectionCheckEnabled
=
true
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论