提交 d8d7e1fd authored 作者: 王健's avatar 王健

修改页面参数

修改天地图进程
上级 7479a56b
...@@ -71,8 +71,7 @@ public class DownMapService { ...@@ -71,8 +71,7 @@ public class DownMapService {
public Map<String, Object> downLoad(Map<String, Object> body, Session session) throws Exception { public Map<String, Object> downLoad(Map<String, Object> body, Session session) throws Exception {
this.stoped = false; this.stoped = false;
es = Executors.newFixedThreadPool(threadNum);
completionService = new ExecutorCompletionService<>(es);
//记录返回结果 //记录返回结果
Map<String, Object> resBody = new HashMap<>(); Map<String, Object> resBody = new HashMap<>();
//记录异步结果 //记录异步结果
...@@ -94,7 +93,15 @@ public class DownMapService { ...@@ -94,7 +93,15 @@ public class DownMapService {
String filePath = jsonParam.getStr("filePath"); String filePath = jsonParam.getStr("filePath");
CLStringUtil.BASE_PATH = filePath + File.separator; CLStringUtil.BASE_PATH = filePath + File.separator;
// 开始下载s // 设置下载地址
String source = jsonParam.getStr("source");
CLStringUtil.BASE_URL = source;
int threadNumInput = jsonParam.getInt("threadNum");
es = Executors.newFixedThreadPool(threadNumInput);
completionService = new ExecutorCompletionService<>(es);
// 开始下载
for (int i = 0; i < level.size(); i++) { // 层级 for (int i = 0; i < level.size(); i++) { // 层级
int z = level.getInt(i); int z = level.getInt(i);
//计算行列号(使用瓦片的中心点经纬度计算) //计算行列号(使用瓦片的中心点经纬度计算)
...@@ -253,6 +260,7 @@ public class DownMapService { ...@@ -253,6 +260,7 @@ public class DownMapService {
} }
//高德地图(6:影像,7:矢量,8:影像路网) //高德地图(6:影像,7:矢量,8:影像路网)
imgUrl = CLStringUtil.getImgUrl(z, x, y); imgUrl = CLStringUtil.getImgUrl(z, x, y);
log.info(imgUrl);
file = (!appendFlag) ? CLStringUtil.getFullFileNotExist(z, x, y) : CLStringUtil.getFullFile(z, x, y); file = (!appendFlag) ? CLStringUtil.getFullFileNotExist(z, x, y) : CLStringUtil.getFullFile(z, x, y);
// 开始下载地图 // 开始下载地图
......
...@@ -14,6 +14,7 @@ import javax.annotation.PostConstruct; ...@@ -14,6 +14,7 @@ import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Map; import java.util.Map;
import java.util.Random;
/** /**
* @ClassName LDStringUtil * @ClassName LDStringUtil
...@@ -122,7 +123,10 @@ public class CLStringUtil { ...@@ -122,7 +123,10 @@ public class CLStringUtil {
* @date: 2020/4/2 * @date: 2020/4/2
**/ **/
public static String getImgUrl(Integer z, Integer x, Integer y) { public static String getImgUrl(Integer z, Integer x, Integer y) {
String url = BASE_URL.replaceAll("\\{x\\}", String.valueOf(x)).replaceAll("\\{y\\}", String.valueOf(y)) Random rand = new Random();
int k = rand.nextInt((7 - 0) + 1) + 0;
String url = BASE_URL.replaceAll("\\{k\\}", String.valueOf(k)).replaceAll("\\{x\\}", String.valueOf(x)).replaceAll("\\{y\\}", String.valueOf(y))
.replaceAll("\\{z\\}", String.valueOf(z)); .replaceAll("\\{z\\}", String.valueOf(z));
return url; return url;
} }
......
...@@ -59,6 +59,7 @@ public class HttpUtil { ...@@ -59,6 +59,7 @@ public class HttpUtil {
try { try {
HttpGet httpGet = new HttpGet(url); HttpGet httpGet = new HttpGet(url);
httpGet.setConfig(staticRequestConfig); httpGet.setConfig(staticRequestConfig);
httpGet.setHeader("User-Agent","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36");
response = staticHttpClient.execute(httpGet); response = staticHttpClient.execute(httpGet);
if (response.getStatusLine().getStatusCode() == 200){ if (response.getStatusLine().getStatusCode() == 200){
ins = response.getEntity().getContent(); ins = response.getEntity().getContent();
......
package com.comleader.ldmapdownload.util;
import java.util.Random;
/**
* @Description
* @Author wangjian
* @Date 2021/1/6 12:01 下午
*/
public class demo {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
}
}
}
# 下载地图瓦片的保存路径 # ���ص�ͼ��Ƭ�ı���·��
#file.basepath=/Users/echo/Desktop/em-map #file.basepath=/Users/echo/Desktop/em-map
file.basepath=H:/em-map file.basepath=~/download
# 项目发布的瓦片图片地 # ��Ŀ��������ƬͼƬ��ַ
#file.mapImgPath=Users/echo/Desktop/em-map #file.mapImgPath=Users/echo/Desktop/em-map
file.mapImgPath=H:/em-map file.mapImgPath=~/download
# 下载地图的地 # ���ص�ͼ�ĵ�ַ
map.baseurl=http://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1scale=1&style=8&x={x}&y={y}&z={z} map.baseurl=http://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1scale=1&style=8&x={x}&y={y}&z={z}
#map.baseurl=http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x} #map.baseurl=http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}
# 下载地图的类型 CUSTOM ArcGIS,一般CUSTOM就可 # ���ص�ͼ������ CUSTOM ArcGIS,һ��CUSTOM�Ϳ�
map.type=CUSTOM map.type=CUSTOM
# 线程数 下载地图瓦片时的线程数 # �߳��� ���ص�ͼ��Ƭʱ���߳���
map.threadNum=2000 map.threadNum=2000
# 是否下载前8级(如果开启默认打开时会直接自动下载前八级的,前八级因为瓦片数量不是很多,一般会选择下载全球的) # �Ƿ�����ǰ8��(�������Ĭ�ϴ�ʱ��ֱ���Զ�����ǰ�˼���,ǰ�˼���Ϊ��Ƭ�������Ǻܶ�,һ���ѡ������ȫ���)
map.Lv8.flag=false map.Lv8.flag=false
# 是否覆盖已有(该属性也可以通过前端传入) # �Ƿ񸲸�����(������Ҳ����ͨ��ǰ�˴���)
map.download.append=false map.download.append=false
\ No newline at end of file
...@@ -29,6 +29,20 @@ ...@@ -29,6 +29,20 @@
<div class="input-card" style="width: 32rem;"> <div class="input-card" style="width: 32rem;">
<h3>领图下载器</h3> <h3>领图下载器</h3>
<h4>基本设置</h4>
<div class="input-item">
<div class="input-item-prepend"><span class="input-item-text">地图服务</span></div>
<select id='source' style="width:100px">
<option value="http://webst04.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}" selected>高德影像</option>
<option value="http://webrd04.is.autonavi.com/appmaptile?lang=zh_cn&size=1scale=1&style=6&x={x}&y={y}&z={z}">高德</option>
<option value="http://www.google.cn/maps/vt?lyrs=m@189&gl=cn&x={x}&y={y}&z={z}">Google</option>
<option value="https://t{k}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=361fe395b6a2282a508e765ee54288c9">天地图影像</option>
</select>
</div>
<div class="input-item">
<div class="input-item-prepend"><span class="input-item-text">线程数</span></div>
<input id='thread_num' class="input-item" type="text" placeholder="默认线程数2000" style="width:100px" value="2000"/>
</div>
<h4>下载区域</h4> <h4>下载区域</h4>
<div class="input-item"> <div class="input-item">
<div class="input-item-prepend"><span class="input-item-text">省市区</span></div> <div class="input-item-prepend"><span class="input-item-text">省市区</span></div>
...@@ -229,6 +243,8 @@ ...@@ -229,6 +243,8 @@
var filePath = $("#filePath").val(); var filePath = $("#filePath").val();
// 是否覆盖下载 // 是否覆盖下载
var appendFlag = $("#append").val(); var appendFlag = $("#append").val();
var source = $("#source").val();
var threadNum = $("#thread_num").val();
var body = { var body = {
level: levelList, level: levelList,
appendFlag: appendFlag, appendFlag: appendFlag,
...@@ -236,7 +252,9 @@ ...@@ -236,7 +252,9 @@
minLat: minLat, minLat: minLat,
maxLng: maxLng, maxLng: maxLng,
maxLat: maxLat, maxLat: maxLat,
filePath: filePath filePath: filePath,
source: source,
threadNum: threadNum
}; };
var data = { var data = {
type: 1, type: 1,
...@@ -381,4 +399,4 @@ ...@@ -381,4 +399,4 @@
<script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script> <script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论