c102032f by chiangbt

update1

1 parent 8aced3b1
......@@ -121,4 +121,7 @@
</item>
</group>
</component>
<component name="uidesigner-configuration">
<option name="DEFAULT_LAYOUT_MANAGER" value="CardLayout" />
</component>
</project>
\ No newline at end of file
......
......@@ -2,12 +2,14 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="5b5a29d8-78e9-4a9f-a415-1e11442b5ca7" name="Default" comment="">
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/lib/sqlite-jdbc-3.21.0-2.jar" />
<change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/libraries/sqlite_jdbc_3_21_0_2.xml" />
<change type="DELETED" beforePath="$PROJECT_DIR$/my.db" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/TiandituDownloader/Main.class" afterPath="$PROJECT_DIR$/out/production/TiandituDownloader/Main.class" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/out/production/TiandituDownloader/TiandituDownload.class" afterPath="$PROJECT_DIR$/out/production/TiandituDownloader/TiandituDownload.class" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/TiandituDownloader.iml" afterPath="$PROJECT_DIR$/TiandituDownloader.iml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/readme.md" afterPath="$PROJECT_DIR$/readme.md" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/Main.java" afterPath="$PROJECT_DIR$/src/Main.java" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/TiandituDownload.java" afterPath="$PROJECT_DIR$/src/TiandituDownload.java" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
......@@ -19,11 +21,11 @@
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file leaf-file-name="Main.java" pinned="false" current-in-tab="true">
<file leaf-file-name="Main.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="47" lean-forward="false" selection-start-line="15" selection-start-column="47" selection-end-line="15" selection-end-column="47" />
<state relative-caret-position="210">
<caret line="14" column="87" lean-forward="false" selection-start-line="14" selection-start-column="87" selection-end-line="14" selection-end-column="87" />
<folding>
<element signature="imports" expanded="true" />
</folding>
......@@ -31,18 +33,31 @@
</provider>
</entry>
</file>
<file leaf-file-name="readme.md" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="210">
<caret line="14" column="44" lean-forward="false" selection-start-line="14" selection-start-column="44" selection-end-line="14" selection-end-column="44" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="TiandituDownload.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/TiandituDownload.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="71">
<caret line="127" column="9" lean-forward="true" selection-start-line="127" selection-start-column="9" selection-end-line="127" selection-end-column="9" />
<state relative-caret-position="190">
<caret line="114" column="60" lean-forward="true" selection-start-line="114" selection-start-column="60" selection-end-line="114" selection-end-column="60" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#calculateEnv#0;class#TiandituDownload#0" expanded="false" />
<element signature="method#getTile#0;class#TiandituDownload#0" expanded="false" />
<marker date="1522037759498" expanded="true" signature="2957:3054" ph="select * fro... missingValue" />
<marker date="1522037759498" expanded="true" signature="3632:3708" ph="INSERT INTO missingValue... " />
<marker date="1522037759498" expanded="true" signature="4814:5001" ph="CREATE TABLE... IF" />
<marker date="1522048729940" expanded="true" signature="3123:3220" ph="select * fro... missingValue" />
<marker date="1522048729940" expanded="true" signature="5353:5429" ph="INSERT INTO missingValue... " />
<marker date="1522048729940" expanded="true" signature="6550:6737" ph="CREATE TABLE... IF" />
</folding>
</state>
</provider>
......@@ -102,15 +117,17 @@
<list>
<option value="$PROJECT_DIR$/src/Point.java" />
<option value="$PROJECT_DIR$/src/CalEnv.java" />
<option value="$PROJECT_DIR$/src/TiandituDownload.java" />
<option value="$PROJECT_DIR$/src/utils/CalEnv.java" />
<option value="$PROJECT_DIR$/src/utils/Point.java" />
<option value="$PROJECT_DIR$/src/TianDiTuTiledMapServiceType.java" />
<option value="$PROJECT_DIR$/src/TDTUrl.java" />
<option value="$PROJECT_DIR$/src/utils/TianDiTuTiledMapServiceType.java" />
<option value="$PROJECT_DIR$/src/utils/TDTUrl.java" />
<option value="$PROJECT_DIR$/readme.md" />
<option value="$PROJECT_DIR$/src/MainForm.java" />
<option value="$PROJECT_DIR$/src/MainForm.form" />
<option value="$PROJECT_DIR$/src/Main.java" />
<option value="$PROJECT_DIR$/src/TiandituDownload.java" />
<option value="$PROJECT_DIR$/readme.md" />
</list>
</option>
</component>
......@@ -178,6 +195,7 @@
<property name="project.structure.last.edited" value="Libraries" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH" value="233" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
......@@ -207,7 +225,7 @@
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="ALTERNATIVE_JRE_PATH" />
<option name="ENABLE_SWING_INSPECTOR" value="false" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
......@@ -248,12 +266,12 @@
<option name="presentableId" value="Default" />
<updated>1522029080525</updated>
<workItem from="1522029083503" duration="8800000" />
<workItem from="1522044614927" duration="423000" />
<workItem from="1522044614927" duration="3890000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="9223000" />
<option name="totallyTimeSpent" value="12690000" />
</component>
<component name="ToolWindowManager">
<frame x="40" y="23" width="1400" height="771" extended-state="0" />
......@@ -267,12 +285,12 @@
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.3831361" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32988167" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32988167" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2533137" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17157584" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32988167" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
......@@ -346,9 +364,9 @@
<element signature="imports" expanded="true" />
<element signature="method#calculateEnv#0;class#TiandituDownload#0" expanded="false" />
<element signature="method#getTile#0;class#TiandituDownload#0" expanded="false" />
<marker date="1522037759498" expanded="true" signature="2957:3054" ph="select * fro... missingValue" />
<marker date="1522037759498" expanded="true" signature="3632:3708" ph="INSERT INTO missingValue... " />
<marker date="1522037759498" expanded="true" signature="4814:5001" ph="CREATE TABLE... IF" />
<marker date="1522048729940" expanded="true" signature="3123:3220" ph="select * fro... missingValue" />
<marker date="1522048729940" expanded="true" signature="5353:5429" ph="INSERT INTO missingValue... " />
<marker date="1522048729940" expanded="true" signature="6550:6737" ph="CREATE TABLE... IF" />
</folding>
</state>
</provider>
......@@ -430,42 +448,55 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="225">
<caret line="15" column="3" lean-forward="true" selection-start-line="15" selection-start-column="3" selection-end-line="15" selection-end-column="3" />
<entry file="file://$PROJECT_DIR$/src/MainForm.form">
<provider selected="true" editor-type-id="ui-designer">
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/MainForm.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="75">
<caret line="5" column="0" lean-forward="true" selection-start-line="5" selection-start-column="0" selection-end-line="5" selection-end-column="0" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/TiandituDownload.java">
<entry file="file://$PROJECT_DIR$/src/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="71">
<caret line="127" column="9" lean-forward="true" selection-start-line="127" selection-start-column="9" selection-end-line="127" selection-end-column="9" />
<state relative-caret-position="210">
<caret line="14" column="87" lean-forward="false" selection-start-line="14" selection-start-column="87" selection-end-line="14" selection-end-column="87" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#calculateEnv#0;class#TiandituDownload#0" expanded="false" />
<element signature="method#getTile#0;class#TiandituDownload#0" expanded="false" />
<marker date="1522037759498" expanded="true" signature="2957:3054" ph="select * fro... missingValue" />
<marker date="1522037759498" expanded="true" signature="3632:3708" ph="INSERT INTO missingValue... " />
<marker date="1522037759498" expanded="true" signature="4814:5001" ph="CREATE TABLE... IF" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/Main.java">
<entry file="file://$PROJECT_DIR$/src/TiandituDownload.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="47" lean-forward="false" selection-start-line="15" selection-start-column="47" selection-end-line="15" selection-end-column="47" />
<state relative-caret-position="190">
<caret line="114" column="60" lean-forward="true" selection-start-line="114" selection-start-column="60" selection-end-line="114" selection-end-column="60" />
<folding>
<element signature="imports" expanded="true" />
<element signature="method#calculateEnv#0;class#TiandituDownload#0" expanded="false" />
<element signature="method#getTile#0;class#TiandituDownload#0" expanded="false" />
<marker date="1522048729940" expanded="true" signature="3123:3220" ph="select * fro... missingValue" />
<marker date="1522048729940" expanded="true" signature="5353:5429" ph="INSERT INTO missingValue... " />
<marker date="1522048729940" expanded="true" signature="6550:6737" ph="CREATE TABLE... IF" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/readme.md">
<provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
<state split_layout="SPLIT">
<first_editor relative-caret-position="210">
<caret line="14" column="44" lean-forward="false" selection-start-line="14" selection-start-column="44" selection-end-line="14" selection-end-column="44" />
<folding />
</first_editor>
<second_editor />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
......
No preview for this file type
......@@ -10,7 +10,9 @@ TiandituDownload tiandituDownload = new TiandituDownload("my.db");
Point pt = new Point(29.76,106.64);
Point pt2 = new Point(35.33, 108.12);
// 下载器
// 2 为最小level,9为最大level,
tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C);
// 2 为最小level,9为最大level
// TianDiTuTiledMapServiceType.IMG_C 为下载数据类型
// 最后一个参数为merge,为true时,会将地图及其注记一并下载融合到一张图片中去
tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.IMG_C, true);
```
\ No newline at end of file
......
......@@ -3,7 +3,7 @@ import utils.TianDiTuTiledMapServiceType;
import java.sql.SQLException;
public class Main {
public class Main{
public static void main(String[] args) throws SQLException {
......@@ -12,7 +12,6 @@ public class Main {
TiandituDownload tiandituDownload = new TiandituDownload("my.db");
Point pt = new Point(29.76,106.64);
Point pt2 = new Point(35.33, 108.12);
// tiandituDownload.Download(pt, pt2, 9, utils.TianDiTuTiledMapServiceType.IMG_C);
tiandituDownload.Download(pt, pt2, 2,11, TianDiTuTiledMapServiceType.IMG_C);
tiandituDownload.Download(pt, pt2, 2,9, TianDiTuTiledMapServiceType.VEC_C, true);
}
}
......
......@@ -3,8 +3,13 @@ import utils.Point;
import utils.TDTUrl;
import utils.TianDiTuTiledMapServiceType;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.sql.*;
......@@ -81,7 +86,7 @@ public class TiandituDownload {
return new CalEnv(startX, startY);
}
private void Download(Point minPoint, Point maxPoint, int level, TianDiTuTiledMapServiceType type){
private void Download(Point minPoint, Point maxPoint, int level, TianDiTuTiledMapServiceType type, boolean merge){
try{
CalEnv startEnv = calculateEnv(minPoint, level);
......@@ -108,6 +113,32 @@ public class TiandituDownload {
// 获得地图瓦片
byte[] img = getTile(url);
System.out.println("正在下载 "+url);
// 如果merge为true,则在下载img_c或vec_c时将其注记图片一并下载
if(merge) {
InputStream img_stream = new ByteArrayInputStream(img);
BufferedImage bImageFromConvert = ImageIO.read(img_stream);
String url2 = "";
if(type == TianDiTuTiledMapServiceType.IMG_C) {
url2 = new TDTUrl(level, i, j, TianDiTuTiledMapServiceType.CIA_C).generatUrl();
}else{
url2 = new TDTUrl(level, i, j, TianDiTuTiledMapServiceType.CVA_C).generatUrl();
}
byte[] img2 = getTile(url2);
InputStream img_stream2 = new ByteArrayInputStream(img2);
BufferedImage bImageFromConvert2 = ImageIO.read(img_stream2);
Graphics g = bImageFromConvert.getGraphics();
g.drawImage(bImageFromConvert, 0, 0, null);
g.drawImage(bImageFromConvert2, 0, 0, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bImageFromConvert, "jpg", baos);
baos.flush();
img = baos.toByteArray();
baos.close();
}
// 将数据写入sqlite
String insertSQL = "INSERT INTO "+ type + "(TILELEVEL,TILECOL,TILEROW,TILEDATA) VALUES (?,?,?,?)";
preparedStatement = conn.prepareStatement(insertSQL);
......@@ -128,7 +159,7 @@ public class TiandituDownload {
}
}
public void Download(Point minPoint, Point maxPoint, int minLevel, int maxLevel, TianDiTuTiledMapServiceType type) throws SQLException {
public void Download(Point minPoint, Point maxPoint, int minLevel, int maxLevel, TianDiTuTiledMapServiceType type, boolean merge) throws SQLException {
try {
Class.forName("org.sqlite.JDBC");
conn = DriverManager.getConnection("jdbc:sqlite:" + this.dbpath);
......@@ -144,7 +175,7 @@ public class TiandituDownload {
stmt.close();
for(int m = minLevel; m<= maxLevel; m++){
this.Download(minPoint, maxPoint, m, type);
this.Download(minPoint, maxPoint, m, type, merge);
}
conn.close();
System.out.println("下载完成");
......