📄 runthis.java
字号:
package net.aetherial.gis.our.duibi.view;
import net.aetherial.gis.our.FrameOur;
import net.aetherial.gis.our.duibi.readXLS.ReadXiandao;
import net.aetherial.gis.our.duibi.readXLS.ReadXiangDao;
import net.aetherial.gis.our.duibi.data.ReadGPS;
import net.aetherial.gis.our.duibi.data.AllRoad;
import net.aetherial.gis.our.duibi.data.RoadGLJ;
import java.io.File;
import net.aetherial.gis.surface.CreateFile;
import java.io.BufferedReader;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class RunThis {
private FrameOur fo = null;
private String shi = "", xian = "";
private String inputPath = "", outputPath = "";
private String n = "";
private String typeOfRoad = "";
public RunThis() {
}
public void addType(String type){
typeOfRoad += "|" + type ;
}
public void setFo(FrameOur fo) {
this.fo = fo;
}
public void setXian(String xian) {
this.xian = xian;
}
public void setShi(String shi) {
this.shi = shi;
}
public void setOutputPath(String outputPath) {
this.outputPath = outputPath;
}
public void setInputPath(String inputPath) {
this.inputPath = inputPath;
}
private double getDouble(String num){
double licheng = 0;
try {
licheng = Double.parseDouble(num);
}
catch (NumberFormatException ex) {
// System.out.println("Error:" +rowData[2].getContents()+"\t" + number);
licheng = 0;
}
return licheng;
}
private void ReadRoadFromCVS(String filename) throws Exception {
java.io.BufferedReader br = new BufferedReader(new java.io.FileReader(
filename));
String line = "";
String number = "";
String shiXian = "";
double licheng = 0.0;
double start = 0.0;
double end = 0.0;
int i = 0, j = 0;
while ( (line = br.readLine()) != null) {
j = 0;
RoadGLJ glj = new RoadGLJ();
while (line.indexOf(',') > -1) {
switch (j) {
case 0:
shiXian = line.substring(0, line.indexOf(','));
break;
case 1:
shiXian += line.substring(0, line.indexOf(','));
break;
case 2:
number = line.substring(0, line.indexOf(','));
break;
case 3:
start = getDouble(line.substring(0, line.indexOf(',')));
break;
case 4:
end = getDouble(line.substring(0, line.indexOf(',')));
break;
case 5:
licheng = getDouble(line.substring(0, line.indexOf(',')));
break
;
default:
break;
}
line = line.substring(line.indexOf(',') + 1);
j++;
}
//plan[i][j] = line;
glj.setRoadNumber(number);
glj.setShixian(shiXian);
glj.setLicheng(licheng == 0? end - start : licheng);
String code = ""+number.charAt(0);
if(typeOfRoad.indexOf(code) > -1) AllRoad.add(glj);
i++;
}
}
public void run() {
try {
ReadRoadFromCVS(".\\file\\glj\\xiandao.csv");
ReadRoadFromCVS(".\\file\\glj\\xiangdao.csv");
ReadGPS gps = new ReadGPS(this.fo);
gps.setType(typeOfRoad);
gps.setInputAllDirectory(getSplashPath(inputPath));
gps.openAllFile();
AllRoad.setToShiXian(shi, xian);
n = n + gps.compareAll(AllRoad.getGljData());
String temp = gps.getLeftTrack(AllRoad.getGljData());
AllRoad.removeFinded();
RoadGLJ[] left = AllRoad.getGljData();
if (left != null) {
for (int i = 0; i < left.length; i++) {
n = n + left[i].toString() + "\r\n";
}
}
n = n + temp;
AllRoad.removeAll();
this.toFile(this.outputPath);
gps.refresh();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private String getSplashPath(String path) {
if ( (path.endsWith("\\")) || (path.endsWith("/"))) {
return path;
}
else {
return path + "\\";
}
}
private void toFile(String output) {
String tempOut = "";
if (this.xian.equals("*")) {
tempOut = getSplashPath(output) + this.shi + "_市区.txt";
}
else {
tempOut = getSplashPath(output) + this.shi + "_" + this.xian + ".txt";
}
CreateFile cf = new CreateFile(new File(tempOut));
cf.setEncode("GB2312");
cf.memoryToFile(this.n);
}
public static void main(String[] args) {
if (args.length < 4) {
System.exit(0);
}
try {
RunThis rt = new RunThis();
rt.setFo(new FrameOur());
rt.setInputPath(args[0]);
rt.setOutputPath(args[1]);
rt.setShi(args[2]);
rt.setXian(args[3]);
rt.run();
rt.fo.dispose();
System.exit(0);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -