-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlopeThread.java
More file actions
66 lines (59 loc) · 2.5 KB
/
Copy pathSlopeThread.java
File metadata and controls
66 lines (59 loc) · 2.5 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
62
63
64
65
66
package heyingzhe;
import java.io.IOException;
import java.nio.file.Paths;
import java.sql.SQLException;
public class SlopeThread extends Thread {
private int[][] filledDem;
private String outPutDirectory;
private String outputSlopePath;
private String dbUserName;
private String dbPassword;
public SlopeThread(int[][] filledDem, String outPutDirectory, String outputSlopePath, String dbUserName, String dbPassword) {
this.filledDem = filledDem;
this.outPutDirectory = outPutDirectory;
this.outputSlopePath = outputSlopePath;
this.dbUserName = dbUserName;
this.dbPassword = dbPassword;
}
public void run() {
System.out.println("正在进行坡度计算……");
SlopeCalculation slopeCalculation = new SlopeCalculation(); //坡度计算
double[][] slope = slopeCalculation.calculateSlope(filledDem);
System.out.println("坡度计算完成");
ImageVisualizer imageVision = new ImageVisualizer();
imageVision.convertArrayToImage(slope);
try {
imageVision.saveImage(Paths.get(outPutDirectory, outputSlopePath).toString(), "png");
} catch (IOException e) {
throw new RuntimeException(e);
}
SaveResult saveProcessing = new SaveResult();
// 配置数据库
saveProcessing.setMySQLProperty(dbUserName, dbPassword);
System.out.println("你已确认数据库用户名和密码!");
try {
saveProcessing.createDatabase("result");
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
System.out.println("数据库result创建成功!");
try {
saveProcessing.createTable("result", "slope"); //创建坡度表格
} catch (SQLException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
try {
saveProcessing.saveArrayToAscFile(slope, outPutDirectory, "slope.asc"); //保存为二进制文件
//saveProcessing.saveArrayToMySQL(slope, "slope");
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println("slope数据已经添加到数据库里面");
}
}