update1
Showing
19 changed files
with
43 additions
and
8 deletions
... | @@ -121,4 +121,7 @@ | ... | @@ -121,4 +121,7 @@ |
121 | </item> | 121 | </item> |
122 | </group> | 122 | </group> |
123 | </component> | 123 | </component> |
124 | <component name="uidesigner-configuration"> | ||
125 | <option name="DEFAULT_LAYOUT_MANAGER" value="CardLayout" /> | ||
126 | </component> | ||
124 | </project> | 127 | </project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
out/production/TiandituDownloader/com/intellij/uiDesigner/core/SupportCode$TextWithMnemonic.class
0 → 100644
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
... | @@ -10,7 +10,9 @@ TiandituDownload tiandituDownload = new TiandituDownload("my.db"); | ... | @@ -10,7 +10,9 @@ TiandituDownload tiandituDownload = new TiandituDownload("my.db"); |
10 | Point pt = new Point(29.76,106.64); | 10 | Point pt = new Point(29.76,106.64); |
11 | Point pt2 = new Point(35.33, 108.12); | 11 | Point pt2 = new Point(35.33, 108.12); |
12 | // 下载器 | 12 | // 下载器 |
13 | // 2 为最小level,9为最大level, | 13 | // 2 为最小level,9为最大level |
14 | tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C); | 14 | // TianDiTuTiledMapServiceType.IMG_C 为下载数据类型 |
15 | // 最后一个参数为merge,为true时,会将地图及其注记一并下载融合到一张图片中去 | ||
16 | tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C, true); | ||
15 | 17 | ||
16 | ``` | 18 | ``` |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -3,7 +3,7 @@ import utils.TianDiTuTiledMapServiceType; | ... | @@ -3,7 +3,7 @@ import utils.TianDiTuTiledMapServiceType; |
3 | 3 | ||
4 | import java.sql.SQLException; | 4 | import java.sql.SQLException; |
5 | 5 | ||
6 | public class Main { | 6 | public class Main{ |
7 | 7 | ||
8 | 8 | ||
9 | public static void main(String[] args) throws SQLException { | 9 | public static void main(String[] args) throws SQLException { |
... | @@ -12,7 +12,6 @@ public class Main { | ... | @@ -12,7 +12,6 @@ public class Main { |
12 | TiandituDownload tiandituDownload = new TiandituDownload("my.db"); | 12 | TiandituDownload tiandituDownload = new TiandituDownload("my.db"); |
13 | Point pt = new Point(29.76,106.64); | 13 | Point pt = new Point(29.76,106.64); |
14 | Point pt2 = new Point(35.33, 108.12); | 14 | Point pt2 = new Point(35.33, 108.12); |
15 | // tiandituDownload.Download(pt, pt2, 9, utils.TianDiTuTiledMapServiceType.IMG_C); | 15 | tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.VEC_C, true); |
16 | tiandituDownload.Download(pt, pt2, 2,11, TianDiTuTiledMapServiceType.IMG_C); | ||
17 | } | 16 | } |
18 | } | 17 | } | ... | ... |
... | @@ -3,8 +3,13 @@ import utils.Point; | ... | @@ -3,8 +3,13 @@ import utils.Point; |
3 | import utils.TDTUrl; | 3 | import utils.TDTUrl; |
4 | import utils.TianDiTuTiledMapServiceType; | 4 | import utils.TianDiTuTiledMapServiceType; |
5 | 5 | ||
6 | import javax.imageio.ImageIO; | ||
7 | import java.awt.*; | ||
8 | import java.awt.image.BufferedImage; | ||
6 | import java.io.BufferedInputStream; | 9 | import java.io.BufferedInputStream; |
10 | import java.io.ByteArrayInputStream; | ||
7 | import java.io.ByteArrayOutputStream; | 11 | import java.io.ByteArrayOutputStream; |
12 | import java.io.InputStream; | ||
8 | import java.net.HttpURLConnection; | 13 | import java.net.HttpURLConnection; |
9 | import java.net.URL; | 14 | import java.net.URL; |
10 | import java.sql.*; | 15 | import java.sql.*; |
... | @@ -81,7 +86,7 @@ public class TiandituDownload { | ... | @@ -81,7 +86,7 @@ public class TiandituDownload { |
81 | return new CalEnv(startX, startY); | 86 | return new CalEnv(startX, startY); |
82 | } | 87 | } |
83 | 88 | ||
84 | private void Download(Point minPoint, Point maxPoint, int level, TianDiTuTiledMapServiceType type){ | 89 | private void Download(Point minPoint, Point maxPoint, int level, TianDiTuTiledMapServiceType type, boolean merge){ |
85 | 90 | ||
86 | try{ | 91 | try{ |
87 | CalEnv startEnv = calculateEnv(minPoint, level); | 92 | CalEnv startEnv = calculateEnv(minPoint, level); |
... | @@ -108,6 +113,32 @@ public class TiandituDownload { | ... | @@ -108,6 +113,32 @@ public class TiandituDownload { |
108 | // 获得地图瓦片 | 113 | // 获得地图瓦片 |
109 | byte[] img = getTile(url); | 114 | byte[] img = getTile(url); |
110 | System.out.println("正在下载 "+url); | 115 | System.out.println("正在下载 "+url); |
116 | |||
117 | // 如果merge为true,则在下载img_c或vec_c时将其注记图片一并下载 | ||
118 | if(merge) { | ||
119 | InputStream img_stream = new ByteArrayInputStream(img); | ||
120 | BufferedImage bImageFromConvert = ImageIO.read(img_stream); | ||
121 | |||
122 | String url2 = ""; | ||
123 | if(type == TianDiTuTiledMapServiceType.IMG_C) { | ||
124 | url2 = new TDTUrl(level, i, j, TianDiTuTiledMapServiceType.CIA_C).generatUrl(); | ||
125 | }else{ | ||
126 | url2 = new TDTUrl(level, i, j, TianDiTuTiledMapServiceType.CVA_C).generatUrl(); | ||
127 | } | ||
128 | byte[] img2 = getTile(url2); | ||
129 | InputStream img_stream2 = new ByteArrayInputStream(img2); | ||
130 | BufferedImage bImageFromConvert2 = ImageIO.read(img_stream2); | ||
131 | |||
132 | Graphics g = bImageFromConvert.getGraphics(); | ||
133 | g.drawImage(bImageFromConvert, 0, 0, null); | ||
134 | g.drawImage(bImageFromConvert2, 0, 0, null); | ||
135 | |||
136 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
137 | ImageIO.write(bImageFromConvert, "jpg", baos); | ||
138 | baos.flush(); | ||
139 | img = baos.toByteArray(); | ||
140 | baos.close(); | ||
141 | } | ||
111 | // 将数据写入sqlite | 142 | // 将数据写入sqlite |
112 | String insertSQL = "INSERT INTO "+ type + "(TILELEVEL,TILECOL,TILEROW,TILEDATA) VALUES (?,?,?,?)"; | 143 | String insertSQL = "INSERT INTO "+ type + "(TILELEVEL,TILECOL,TILEROW,TILEDATA) VALUES (?,?,?,?)"; |
113 | preparedStatement = conn.prepareStatement(insertSQL); | 144 | preparedStatement = conn.prepareStatement(insertSQL); |
... | @@ -128,7 +159,7 @@ public class TiandituDownload { | ... | @@ -128,7 +159,7 @@ public class TiandituDownload { |
128 | } | 159 | } |
129 | } | 160 | } |
130 | 161 | ||
131 | public void Download(Point minPoint, Point maxPoint, int minLevel, int maxLevel, TianDiTuTiledMapServiceType type) throws SQLException { | 162 | public void Download(Point minPoint, Point maxPoint, int minLevel, int maxLevel, TianDiTuTiledMapServiceType type, boolean merge) throws SQLException { |
132 | try { | 163 | try { |
133 | Class.forName("org.sqlite.JDBC"); | 164 | Class.forName("org.sqlite.JDBC"); |
134 | conn = DriverManager.getConnection("jdbc:sqlite:" + this.dbpath); | 165 | conn = DriverManager.getConnection("jdbc:sqlite:" + this.dbpath); |
... | @@ -144,7 +175,7 @@ public class TiandituDownload { | ... | @@ -144,7 +175,7 @@ public class TiandituDownload { |
144 | stmt.close(); | 175 | stmt.close(); |
145 | 176 | ||
146 | for(int m = minLevel; m<= maxLevel; m++){ | 177 | for(int m = minLevel; m<= maxLevel; m++){ |
147 | this.Download(minPoint, maxPoint, m, type); | 178 | this.Download(minPoint, maxPoint, m, type, merge); |
148 | } | 179 | } |
149 | conn.close(); | 180 | conn.close(); |
150 | System.out.println("下载完成"); | 181 | System.out.println("下载完成"); | ... | ... |
-
Please register or sign in to post a comment