📄 qiaoliangtogps.java
字号:
package net.aetherial.gis.jiaotongbu.input.publicuse;
import net.aetherial.gis.jiaotongbu.input.analyse.OpenDirect;
import java.io.File;
import net.aetherial.gis.jiaotongbu.input.jxl.ReadQiaoliang;
import net.aetherial.gis.surface.ItemValue;
import net.aetherial.gis.our.FrameOur;
import net.aetherial.gis.surface.CreateFile;
import java.util.Vector;
import net.aetherial.gis.jiaotongbu.input.type.Luduan;
import net.aetherial.gis.jiaotongbu.input.type.Qiaoliang;
import org.w3c.dom.Node;
import net.aetherial.gis.dataType.WptType;
import java.text.DecimalFormat;
import net.aetherial.gis.jiaotongbu.input.analyse.AnalyseKuaxian;
import net.aetherial.gis.jiaotongbu.input.analyse.NianbaoToGPS;
import net.aetherial.gis.jiaotongbu.input.jxl.ReadKuaxian;
import net.aetherial.gis.output.toTable.readglj.ReadAll;
import net.aetherial.gis.publicuse.wpt.getWptZhuanghao;
import net.aetherial.gis.jiaotongbu.input.analyse.JingweiduToGPS;
import net.aetherial.gis.jiaotongbu.output.tocheck.type.ReQiaoliang;
import net.aetherial.gis.jiaotongbu.output.publicuse.CreateQSD;
import net.aetherial.gis.output.FileOperate;
import net.aetherial.gis.jiaotongbu.input.jxl.ReadFangxiang;
import net.aetherial.gis.output.toLd.OpenDirectory;
import net.aetherial.gis.publicuse.FileOper;
import net.aetherial.gis.jiaotongbu.input.analyse.CheckKuaxian;
import net.aetherial.gis.publicuse.wpt.WPTsTrack;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class QiaoliangToGPS {
private String inputPath = "";
private String outputPath = "";
private File qlExcel = null;
private File[] gpsFiles = null;
private static int reNumber = 1;
private String shi = "";
private String xian = "";
java.text.DecimalFormat format = new java.text.DecimalFormat("#.##");
// private AnalyseKuaxian analyse = null;
public QiaoliangToGPS() {
}
/**
* 调用生成跨县信息文件
*/
private void createKuaxianFiles() {
ReadAll readall = new ReadAll();
//readall.print("肥西县");
readall.read();
readall.printAllRowByXian(this.shi, this.xian, this.inputPath,
OpenDirect.getSplashPath(this.inputPath) +
"年报核对表\\程序输出信息\\" + this.xian + "_跨县信息.txt");
}
private void readKuaxianFiles() {
String kxFile = OpenDirect.getKuaxianFile(this.inputPath);
if (kxFile == null) {
this.printError("没有跨县信息TXT文件!请确认是否放在正确目录.");
}
ReadKuaxian rk = new ReadKuaxian();
rk.setInputPath(kxFile);
rk.addAll();
}
void printError(String error) {
System.out.println("[出错]:" + error);
try {
Thread.sleep(3000);
}
catch (InterruptedException ex) {
}
System.exit(0);
}
private void init() {
FileOper.deleteDirectory(new File(this.outputPath));
// System.exit(0);
OpenDirect od = new OpenDirect();
qlExcel = od.getQiaoliangExcel(this.inputPath);
if (qlExcel == null) {
// Permanence.addLog("[文件错误]\t8_桥梁信息汇总表.xls 不存在。");
this.printError("t8_桥梁信息汇总表.xls 不存在,请确认是否放在正确目录.");
return;
}
od.setGradeStr("县道|乡道");
gpsFiles = od.getAllGPSFiles(this.inputPath);
if (gpsFiles == null) {
// Permanence.addLog("[文件错误]\t没有GPS文件。");
this.printError("没有GPS文件,请确认是否放在正确目录.");
return;
}
ReadQiaoliang read = new ReadQiaoliang(qlExcel.getAbsolutePath());
read.read();
// System.exit(0);
}
public void run() {
this.readKuaxianFiles();
CheckKuaxian ck = new CheckKuaxian(this.inputPath,this.xian);
ck.check();
this.init();
if (qlExcel != null && gpsFiles != null) {
FrameOur fo = new FrameOur();
ItemValue.setShowDialogMessage(false);
OpenDirectory od = new OpenDirectory();
ReadFangxiang rf = new ReadFangxiang(od.getZouxiangBiao(this.inputPath).
getAbsolutePath());
rf.read();
rf.checkXiangzhen(this.inputPath);
checkQuestionQiaoliang();
for (int i = 0; gpsFiles != null && i < gpsFiles.length; i++) {
Permanence.addLog("__________________________");
Permanence.addLog("[" + gpsFiles[i].getName() + "]");
fo.openFile(gpsFiles[i]);
this.insertAFile(gpsFiles[i]);
fo.saveFile(getNewOutputFileReplaceInput(gpsFiles[i]));
fo.reset();
}
this.createErrorLog();
Permanence.printHeduidata_QL();
}
this.createErrorFile();
}
private void checkQuestionQiaoliang(){
Qiaoliang temp = null;
for (int i = 0; i < Permanence.heduidata_QL.size(); i++) {
temp = (Qiaoliang)Permanence.heduidata_QL.get(i) ;
if (checkQuestionQiaoliang(temp)) {
Permanence.error_QL.add(temp);
Permanence.heduidata_QL.removeElement(temp);
i--;
}
}
}
/**
* 检查问题桥梁
*/
private boolean checkQuestionQiaoliang(Qiaoliang ql) {
boolean error = false;
String n = "";
if (ql.getName().trim().equals("")
|| ql.getZhuanghao().trim().equals("")
|| ql.getQuanchang().trim().equals("")
|| ql.getKuajin().trim().equals("")
|| ql.getKuajingFenlei().trim().equals("")
|| ql.getCailiao().trim().equals("")
|| ql.getHezai().trim().equals("")
|| ql.getShijian().trim().equals("")
|| ql.getWeiqiao().trim().equals("")
) {
n += "关键属性填写不全.";
error = true;
}
try {
Double.parseDouble(ql.getZhuanghao().trim());
}
catch (NumberFormatException ex) {
n += "桥梁中心桩号不是数字.";
error = true;
}
try {
Double.parseDouble(ql.getQuanchang().trim());
}
catch (NumberFormatException ex) {
n += "桥梁全长不是数字.";
error = true;
}
try {
Double.parseDouble(ql.getKuajin().trim());
}
catch (NumberFormatException ex) {
n += "桥梁跨径不是数字.";
error = true;
}
ql.setBeizhu(n);
return error;
}
private void insertAFile(File gpsFile) {
reNumber = 1;
Node[] qls = this.getQiaoliangWaypoint();
Qiaoliang temp = null;
String nameTemp = "";
String fileNumber = gpsFile.getName().trim().toUpperCase().replaceAll(
".GPS", "");
// if (fileNumber.equals("X032")) {
// ReadQiaoliang.printHeduidata_QL();
// System.exit(0);
// }
if (this.xian.length() > 2) {
this.xian = this.xian.substring(0, 2);
}
AnalyseKuaxian analyse = new AnalyseKuaxian(fileNumber,
this.xian);
ReFangxiang rf = new ReFangxiang();
Qiaoliang[] nianbaoQiaoliangs = this.getNianbaoQiaoliang(gpsFile);
// for (int i = 0; i < nianbaoQiaoliangs.length; i++) {
// System.out.println("nianbaoQiaoliangs:" + nianbaoQiaoliangs[i]);
// }
Node newTrk = rf.shunxuAFile(gpsFile);
getWptZhuanghao wptZhuanghao = null;
String newzhuaanghaoTemp = "";
for (int i = 0; i < qls.length; i++) {
temp = this.getQiaoliang(qls[i], fileNumber);
if (temp != null) {
// System.out.println("更改之前:" + temp.getZhuanghao());
wptZhuanghao = new getWptZhuanghao();
wptZhuanghao.setTrack(newTrk);
wptZhuanghao.setWaypoint(qls[i]);
newzhuaanghaoTemp = format.format(analyse.getZongtiZhuanghao(Double.
parseDouble(wptZhuanghao.getWaypointZhuanghao())));
// analyse.getZongtiZhuanghao(Double.parseDouble(wptZhuanghao.getWaypointZhuanghao()));
temp.setZhuanghao(newzhuaanghaoTemp);
// System.out.println("更改之中:" + newzhuaanghaoTemp);
nameTemp = ItemValue.getWaypointName(qls[i]);
this.setWaypointQiaoliangValue(qls[i], temp);
Permanence.addLog("[更改成功]\t桥梁航点:" + nameTemp + "\t更改为:" + temp);
this.removeHeduiQiaoliang(temp);
// System.out.println("更改之后:" + temp.getZhuanghao());
// System.exit(0);
}
else {
Permanence.addLog("[删除操作]\t桥梁航点:" + ItemValue.getWaypointName(qls[i]) +
"\t8_桥梁信息汇总表.xls中没有该桥梁数据,删除掉该航点");
ItemValue.removeWaypoint(qls[i]);
}
}
NianbaoToGPS nbToGps = new NianbaoToGPS();
nbToGps.setQls(nianbaoQiaoliangs);
nbToGps.setAnalyse(analyse);
nbToGps.setHebingTrack(newTrk);
nbToGps.addAll();
JingweiduToGPS jto = new JingweiduToGPS();
jto.setAnalyse(analyse);
jto.setFileNumber(fileNumber);
jto.setFormat(this.format);
jto.setHebingTrack(newTrk);
jto.createAllLeftQiaoliang();
ItemValue.removeTrack(newTrk);
analyse.reset();
this.qiangliangRelateToTrack();
// if (fileNumber.indexOf("X065") != -1) {
// Permanence.printHeduidata_QL();
//
// System.exit(0);
// }
}
/**
* 将桥梁航点关联至正确的航迹
*/
private void qiangliangRelateToTrack(){
Node[] qls = this.getQiaoliangWaypoint();
Node trk = null;
Node[] trks = ItemValue.getTracks();
for (int i = 0; qls != null && i < qls.length; i++) {
trk = WPTsTrack.getWptMostNearTrack(qls[i],trks);
ItemValue.setWaypointTracksID(qls[i],ItemValue.getTracksID(trk));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -