0c4e300c by chiangbt

first commit

1 parent 04dba9af
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="VcsDirectoryMappings"> 3 <component name="VcsDirectoryMappings">
4 <mapping directory="" vcs="" /> 4 <mapping directory="$PROJECT_DIR$" vcs="Git" />
5 </component> 5 </component>
6 </project> 6 </project>
...\ No newline at end of file ...\ No newline at end of file
7
......
1 ## 项目说明
2
3 TiandituDownload主要用于下载天地图数据,其坐标系为CGCS2000.
4
5 ```java
6
7 // 设置要下载的图片存储sqlite路径
8 TiandituDownload tiandituDownload = new TiandituDownload("my.db");
9 // 范围起始点(左下角、右上角)
10 Point pt = new Point(29.76,106.64);
11 Point pt2 = new Point(35.33, 108.12);
12 // 下载器
13 // 2 为最小level,9为最大level,
14 tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C);
15
16 ```
...\ No newline at end of file ...\ No newline at end of file
......
1 import utils.Point;
2 import utils.TianDiTuTiledMapServiceType;
3
1 import java.sql.SQLException; 4 import java.sql.SQLException;
2 5
3 public class Main { 6 public class Main {
...@@ -9,7 +12,7 @@ public class Main { ...@@ -9,7 +12,7 @@ public class Main {
9 TiandituDownload tiandituDownload = new TiandituDownload("my.db"); 12 TiandituDownload tiandituDownload = new TiandituDownload("my.db");
10 Point pt = new Point(29.76,106.64); 13 Point pt = new Point(29.76,106.64);
11 Point pt2 = new Point(35.33, 108.12); 14 Point pt2 = new Point(35.33, 108.12);
12 // tiandituDownload.Download(pt, pt2, 9, TianDiTuTiledMapServiceType.IMG_C); 15 // tiandituDownload.Download(pt, pt2, 9, utils.TianDiTuTiledMapServiceType.IMG_C);
13 tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C); 16 tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C);
14 } 17 }
15 } 18 }
......
1 import utils.CalEnv;
2 import utils.Point;
3 import utils.TDTUrl;
4 import utils.TianDiTuTiledMapServiceType;
5
1 import java.io.BufferedInputStream; 6 import java.io.BufferedInputStream;
2 import java.io.ByteArrayOutputStream; 7 import java.io.ByteArrayOutputStream;
3 import java.net.HttpURLConnection; 8 import java.net.HttpURLConnection;
......
1 package utils;
2
1 public class CalEnv { 3 public class CalEnv {
2 4
3 private int startX; 5 private int startX;
......
1 package utils;
2
1 public class Point { 3 public class Point {
2 4
3 private double lat; 5 private double lat;
......
...@@ -2,6 +2,8 @@ package utils; ...@@ -2,6 +2,8 @@ package utils;
2 2
3 import java.util.Random; 3 import java.util.Random;
4 4
5 import static utils.TianDiTuTiledMapServiceType.*;
6
5 /** 7 /**
6 * Created by jiangbotao on 2018/3/23. 8 * Created by jiangbotao on 2018/3/23.
7 */ 9 */
...@@ -27,28 +29,28 @@ public class TDTUrl { ...@@ -27,28 +29,28 @@ public class TDTUrl {
27 int subdomain = (random.nextInt(6) + 1); 29 int subdomain = (random.nextInt(6) + 1);
28 url.append(subdomain); 30 url.append(subdomain);
29 switch (this._tiandituMapServiceType) { 31 switch (this._tiandituMapServiceType) {
30 case TianDiTuTiledMapServiceType.VEC_C: 32 case VEC_C:
31 url.append(".tianditu.com/DataServer?T=vec_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 33 url.append(".tianditu.com/DataServer?T=vec_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
32 break; 34 break;
33 case TianDiTuTiledMapServiceType.CVA_C: 35 case CVA_C:
34 url.append(".tianditu.com/DataServer?T=cva_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 36 url.append(".tianditu.com/DataServer?T=cva_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
35 break; 37 break;
36 case TianDiTuTiledMapServiceType.CIA_C: 38 case CIA_C:
37 url.append(".tianditu.com/DataServer?T=cia_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 39 url.append(".tianditu.com/DataServer?T=cia_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
38 break; 40 break;
39 case TianDiTuTiledMapServiceType.IMG_C: 41 case IMG_C:
40 url.append(".tianditu.com/DataServer?T=img_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 42 url.append(".tianditu.com/DataServer?T=img_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
41 break; 43 break;
42 case TianDiTuTiledMapServiceType.VEC_W: 44 case VEC_W:
43 url.append(".tianditu.com/DataServer?T=vec_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 45 url.append(".tianditu.com/DataServer?T=vec_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
44 break; 46 break;
45 case TianDiTuTiledMapServiceType.CVA_W: 47 case CVA_W:
46 url.append(".tianditu.com/DataServer?T=cva_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 48 url.append(".tianditu.com/DataServer?T=cva_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
47 break; 49 break;
48 case TianDiTuTiledMapServiceType.CIA_W: 50 case CIA_W:
49 url.append(".tianditu.com/DataServer?T=cia_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 51 url.append(".tianditu.com/DataServer?T=cia_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
50 break; 52 break;
51 case TianDiTuTiledMapServiceType.IMG_W: 53 case IMG_W:
52 url.append(".tianditu.com/DataServer?T=img_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level); 54 url.append(".tianditu.com/DataServer?T=img_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
53 break; 55 break;
54 default: 56 default:
......
1 package utils;
1 2
2 /** 3 /**
3 * Created by jiangbotao on 2018/3/23. 4 * Created by jiangbotao on 2018/3/23.
......