TDTUrl.java
2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package utils;
import java.util.Random;
import static utils.TianDiTuTiledMapServiceType.*;
/**
* Created by jiangbotao on 2018/3/23.
*/
public class TDTUrl {
private TianDiTuTiledMapServiceType _tiandituMapServiceType;
private int _level;
private int _col;
private int _row;
public TDTUrl(int level, int col, int row, TianDiTuTiledMapServiceType tiandituMapServiceType) {
this._level = level;
this._col = col;
this._row = row;
this._tiandituMapServiceType = tiandituMapServiceType;
}
public String generatUrl() {
StringBuilder url = new StringBuilder("http://t");
Random random = new Random();
int subdomain = (random.nextInt(6) + 1);
url.append(subdomain);
switch (this._tiandituMapServiceType) {
case VEC_C:
url.append(".tianditu.com/DataServer?T=vec_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case CVA_C:
url.append(".tianditu.com/DataServer?T=cva_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case CIA_C:
url.append(".tianditu.com/DataServer?T=cia_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case IMG_C:
url.append(".tianditu.com/DataServer?T=img_c&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case VEC_W:
url.append(".tianditu.com/DataServer?T=vec_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case CVA_W:
url.append(".tianditu.com/DataServer?T=cva_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case CIA_W:
url.append(".tianditu.com/DataServer?T=cia_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
case IMG_W:
url.append(".tianditu.com/DataServer?T=img_w&X=").append(this._col).append("&Y=").append(this._row).append("&L=").append(this._level);
break;
default:
return null;
}
return url.toString();
}
}