qiaoliangtogps.java
来自「基于Java的地图数据管理软件。使用MySQL数据库管理系统。」· Java 代码 · 共 599 行 · 第 1/2 页
JAVA
599 行
private void createErrorLog() {
Qiaoliang temp = null;
for (int i = 0; i < Permanence.heduidata_QL.size(); i++) {
temp = (Qiaoliang) Permanence.heduidata_QL.get(i);
// Permanence.addLog("[加入失败]\t没有该路线GPS数据\t" +
// temp);
//
// temp.getBeizhu();
if (temp == null) {
System.out.println("空值");
System.exit(0);
}
if (temp.getBeizhu() == null) {
System.out.println("备注为null");
System.exit(0);
}
if (temp != null && (temp.getBeizhu().trim().equals(""))) {
temp.setBeizhu("没有该路线GPS数据");
}
Permanence.error_QL.add(temp);
}
}
private Qiaoliang[] getNianbaoQiaoliang(File gpsFile) {
String fileNumber = gpsFile.getName().trim().toUpperCase().replaceAll(
".GPS", "");
Qiaoliang ql = null;
Vector qls = new Vector();
for (int i = 0; i < Permanence.heduidata_QL.size(); i++) {
ql = (Qiaoliang) Permanence.heduidata_QL.get(i);
if (ql.getNumber().toUpperCase().indexOf(fileNumber) != -1 &&
ql.isNianBao()) {
qls.add(ql);
}
}
Qiaoliang[] temp = new Qiaoliang[qls.size()];
qls.copyInto(temp);
return temp;
}
/**
* 得到桥梁的一个Qiaoliang实例
*
* @param ql_wpt 桥梁航点
* @return 一个桥梁Qiaoliang实例
*/
private Qiaoliang getQiaoliang(Node ql_wpt, String fileNumber) {
String lon_wpt = ItemValue.getWaypointX(ql_wpt);
String lat_wpt = ItemValue.getWaypointY(ql_wpt);
// if (lon_wpt.length() > 10) {
// lon_wpt = lon_wpt.substring(0, 10);
// }
//
// if (lat_wpt.length() > 10) {
// lat_wpt = lat_wpt.substring(0, 10);
// }
Qiaoliang ql = null;
for (int i = 0; i < Permanence.heduidata_QL.size(); i++) {
ql = (Qiaoliang) Permanence.heduidata_QL.get(i);
if (isXYSimilitude(lon_wpt, lat_wpt, ql.getLon(), ql.getLat()) &&
(!ql.isNianBao()) &&
(ql.getNumber().toUpperCase().indexOf(fileNumber) != -1)) {
return ql;
}
// if (ql.getLon().indexOf(lon_wpt) != -1 &&
// ql.getLat().indexOf(lat_wpt) != -1) {
// return ql;
// }
}
return null;
}
public void removeHeduiQiaoliang(Qiaoliang temp) {
Permanence.heduidata_QL.removeElement(temp);
}
public boolean isXYSimilitude(String x1, String y1, String x2, String y2) {
if ( (x2.length() >= 9) && (y2.length() >= 8)) {
if ( (x1.indexOf(x2.substring(0, 8)) != -1) &&
(y1.indexOf(y2.substring(0, 7)) != -1)) {
return true;
}
}
return false;
// if (y2.length() > 3 && y1.indexOf(y2.substring(0, y2.length() - 1)) > -1 &&
// x2.length() > 3 && x1.indexOf(x2.substring(0, x2.length() - 1)) > -1) {
// return true;
// }
// else {
// return false;
// }
}
/**
* 得到桥梁的航点
*/
private Node[] getQiaoliangWaypoint() {
Node[] wpts = ItemValue.getWaypoint();
Vector temp = new Vector();
for (int i = 0; wpts != null && i < wpts.length; i++) {
if (ItemValue.getWaypointKP(wpts[i]).equals(WptType.W3QiaoLiang)) {
temp.add(wpts[i]);
}
}
wpts = new Node[temp.size()];
temp.copyInto(wpts);
return wpts;
}
public static void setWaypointQiaoliangValue(Node waypoint, Qiaoliang ql) {
String[] qlArray = new String[11];
qlArray[0] = ql.getName();
qlArray[1] = ql.getKongshu();
qlArray[2] = ql.getKuajin();
qlArray[3] = getNewQiaoliangNumber(ql.getNumber());
qlArray[4] = ql.getShijian();
qlArray[5] = ql.getZhuanghao();
qlArray[6] = ql.getQuanchang();
qlArray[7] = ql.getKuajingFenlei();
qlArray[8] = ql.getHezai();
qlArray[9] = ql.getCailiao();
qlArray[10] = ql.getWeiqiao();
ItemValue.setWaypointQiaoliang(waypoint, qlArray);
ItemValue.setWaypointName(waypoint, ql.getName());
// System.out.println("qlArray[3]:" + qlArray[3]);
}
private static String getNewQiaoliangNumber(String refNumber) {
if (refNumber.trim().length() < 14) {
return refNumber;
}
else {
String before = refNumber.trim().substring(0, 10);
return before + "L" + getNewFormate(reNumber++);
}
}
private static String getNewFormate(int number) {
if (number < 10) {
return "00" + number;
}
else if (number < 100) {
return "0" + number;
}
else {
return "" + number;
}
}
private void openLog() {
if (! (Permanence.log.trim().equals(""))) {
// this.openLog(this.createLogFile());
String file = this.createLogFile();
try {
Runtime.getRuntime().exec("cmd /c notepad " + file);
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
private void openTargetFile(){
try {
Runtime.getRuntime().exec("cmd /c Explorer " + this.getSplashPath(this.inputPath) + "年报核对表\\");
Runtime.getRuntime().exec("cmd /c Explorer " + this.getSplashPath(this.outputPath) + "年报核对表\\程序输出信息\\");
}
catch (Exception ex) {
// ex.printStackTrace();
}
}
private void clearTarget(){
File target = new File(this.getSplashPath(this.outputPath));
target.deleteOnExit();
}
private String createLogFile() {
File f = new File(this.getSplashPath(this.outputPath) + "log.txt");
CreateFile cf = new CreateFile(f);
cf.memoryToFile(Permanence.log);
return f.getAbsolutePath();
}
private void createErrorFile() {
if (Permanence.error_QL.size() != 0) {
String myerror = "";
Qiaoliang temp = null;
for (int i = 0; i < Permanence.error_QL.size(); i++) {
temp = (Qiaoliang) Permanence.error_QL.get(i);
if (temp.toString().endsWith("\t")) {
myerror += temp + temp.getBeizhu() + "\r\n";
}
else {
myerror += temp + "\t" + temp.getBeizhu() + "\r\n";
}
}
File f = new File(this.getSplashPath(this.outputPath) +
"年报核对表\\程序输出信息\\桥梁校正勘误表信息.txt");
CreateFile cf = new CreateFile(f);
cf.memoryToFile(myerror);
}
}
public void copyLeftFiles(File f) {
if (f.isFile()) {
FileOperate fo = new FileOperate();
fo.copyFile(f.getAbsolutePath(),
getNewOutputFileReplaceInput(f).getAbsolutePath());
// System.out.println("Copy ..." + f.getAbsolutePath() + " to " + getNewOutputFileReplaceInput(f).getAbsolutePath());
}
else {
(getNewOutputFileReplaceInput(f)).mkdirs();
// System.out.println("Copy ..." + f.getAbsolutePath() + " to " + getNewOutputFileReplaceInput(f).getAbsolutePath());
File[] alls = f.listFiles();
if (f.getName().indexOf("整理完毕") == -1) {
for (int i = 0; i < alls.length; i++) {
copyLeftFiles(alls[i]);
}
}
}
// File father = new File(this.inputPath);
//
// this.inputPath;
}
private File getNewOutputFileReplaceInput(File inputFile) {
String inputFilePath = inputFile.getAbsolutePath();
if (this.getSplashPath(this.inputPath).equals(getSplashPath(inputFilePath))) {
return new File(outputPath);
}
String except = inputFilePath.substring(this.getSplashPath(this.inputPath).
length(), inputFilePath.length());
String outFilePath = this.getSplashPath(this.outputPath) + except;
return new File(outFilePath);
}
private String getSplashPath(String path) {
if (path.endsWith("\\")) {
return path;
}
else {
if (path.endsWith("/")) {
return path.substring(0, path.length() - 1) + "\\";
}
else {
return path + "\\";
}
}
}
public void setInputPath(String inputPath) {
this.inputPath = inputPath;
}
public void setOutputPath(String outputPath) {
this.outputPath = outputPath;
}
public void setXian(String xian) {
this.xian = xian;
}
public void setShi(String shi) {
this.shi = shi;
}
public static void main(String args[]) {
QiaoliangToGPS qiaoliang = new QiaoliangToGPS();
qiaoliang.setShi(args[0]);
qiaoliang.setXian(args[1]);
qiaoliang.setInputPath(args[2]);
qiaoliang.setOutputPath(args[3]);
// qiaoliang.createKuaxianFiles();
qiaoliang.run();
qiaoliang.copyLeftFiles(new File(args[2]));
CreateQSD createqsd = new CreateQSD();
ReQiaoliang.reCreate();
createqsd.setShi(args[0]);
createqsd.setXian(args[1]);
createqsd.setInputPath(args[3]);
createqsd.setOutputPath(args[3]);
createqsd.create();
// qiaoliang.openLog();
qiaoliang.openTargetFile();
System.exit(0);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?