📄 totalcountry.java
字号:
/*
* 创建日期 2006-9-5
* 作 者 朱 闰
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package net.aetherial.gis.baobu.TongDa;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.Vector;
import org.w3c.dom.Node;
import net.aetherial.gis.baobu.countrytransfer.CountryTransfer;
import net.aetherial.gis.baobu.countrytransfer.ReadWayPointNode;
import net.aetherial.gis.our.FrameOur;
import net.aetherial.gis.our.auto.check.repeattrk.TrackRectangle;
import net.aetherial.gis.output.toLd.OpenDirectory;
import net.aetherial.gis.output.toTable.readglj.LdRow;
import net.aetherial.gis.publicuse.WptTrackDistance;
import net.aetherial.gis.surface.ItemValue;
public class TotalCountry {
// 获取所有村道GPS文件
public File[] getAllGSFiles(String filePath) {
OpenDirectory od = new OpenDirectory();
od.setGradeStr("村道");
File[] allFiles = od.getOpenFile(filePath);// 读取所有村道GPS文件
return allFiles;
}
// 获取所有县乡村道GPS文件
public File[] getAllGPSFiles(String filePath) {
OpenDirectory od = new OpenDirectory();
od.setGradeStr("县道|乡道|村道");
File[] allFiles = od.getOpenFile(filePath);// 读取所有村道GPS文件
return allFiles;
}
// 获取村道中行政村的所有航点
public Vector getAllPointNode(String filePath) {
Vector allNodeList = new Vector();
ItemValue.setShowDialogMessage(false);
FrameOur fo = new FrameOur();
File [] allFiles = getAllGSFiles (filePath);
String keyName = "";
for ( int i = 0; allFiles != null && i < allFiles.length ;i++ ){
File myFile = allFiles[i];
String fileName = myFile.getName();
fo.openFile(myFile);
Node[] pointNodes = ItemValue.getWaypoint();
for (int j = 0; pointNodes != null && j < pointNodes.length; j++) {
keyName = ItemValue.getWaypointKP(pointNodes[j]);
if (keyName.equals("行政村"))
allNodeList.add(pointNodes[j]);
}
fo.reset();
}
return allNodeList;
}
// 判断是否为数据
public static boolean isNumeric(String string) {
if (string.trim().equals("")) {
return false;
}
char[] numchar = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'.' };
char[] ch = string.toCharArray();
if (ch == null) {
return false;
}
boolean find = false;
for (int i = 0; i < ch.length; i++) {
for (int j = 0; j < numchar.length; j++) {
if (ch[i] == numchar[j]) {
find = true;
break;
}
}
if (!find) {
return false;
}
find = false;
}
return true;
}
// 统计村道里程数据
public void countCountryData(String filePath) {
FrameOur fo = new FrameOur();
File file = null;
Node[] allTrack = null;
String leiXing = "";
String luMian = "";
File allFile = new File(filePath);
File[] files = allFile.listFiles();// 获取所有县(区)列表
String quXianPath = ""; // 县(区)文件路径
ItemValue.setShowDialogMessage(false);
double luMianWidth = 0.0;
double less3RoadCount = 0.0;
double tuLuCount = 0.0;
double less3AndTuLuCount = 0.0;
double liCheng = 0.0;
double sumLess3Count = 0.0;
double sumTuLuCount = 0.0;
double xianDaoValue = 0.0;
double xiangDaoValue = 0.0;
double sumLess3AndTuLuCount = 0.0;
String tempFilePath = "";
int n = 0;
for (int f = 0; files != null && f < files.length; f++) {
quXianPath = files[f].getPath();
String tempPath = quXianPath.replace('\\', ',');
String[] paths = tempPath.split(",");
int lenInt = paths.length - 1;
String quXianName = paths[lenInt]; // 区县名
File[] allFiles = getAllGPSFiles(quXianPath);
less3RoadCount = 0.0;
tuLuCount = 0.0;
less3AndTuLuCount = 0.0;
for (int i = 0; allFiles != null && i < allFiles.length; i++) {
file = allFiles[i];
fo.openFile(file);
tempFilePath = file.getParent();
String tempPath1 = tempFilePath.replace('\\', ',');
String[] paths1= tempPath1.split(",");
int lenInt1 = paths1.length - 1;
String quXianName1 = paths1[lenInt1]; // 县、乡道文件夹
//System.err.println("=========="+quXianName1);
allTrack = ItemValue.getTracks();
n = 0;
if (quXianName1.indexOf("县") != -1 || quXianName1.indexOf("乡") != -1){
if (isTuLuor(allTrack) )
tuLuCount += countLicheng(allTrack);
if (isLess35(allTrack) )
less3RoadCount += countLicheng(allTrack);
if (isTuLuor(allTrack) && isLess35(allTrack))
less3AndTuLuCount += countLicheng(allTrack);
if ( (isTuLuor(allTrack) || isLess35(allTrack)) && file.getName().substring(0,1).equals("X")){
xianDaoValue += countLicheng(allTrack);
}
if ((isTuLuor(allTrack) || isLess35(allTrack)) && file.getName().substring(0,1).equals("Y")){
xiangDaoValue += countLicheng(allTrack);
}
} else {
///System.err.println("==============k!==========");
for (int j = 0; allTrack != null && j< allTrack.length; j++ ){
leiXing = ItemValue.getTracksType(allTrack[j]); // 路面类型
luMian = ItemValue.getTracksWidth(allTrack[j]); // 路面宽度
liCheng = Double.parseDouble(ItemValue
.getTracksStringDistance(allTrack[j]));
boolean isNum = isNumeric(luMian);
if (luMian != null && !luMian.equals("") && isNum){
try {
luMianWidth = Double.parseDouble(luMian);
} catch (NumberFormatException e) {
// TODO 自动生成 catch 块
luMianWidth = 0;
e.printStackTrace();
}
}else luMianWidth = 0;
if (leiXing.indexOf("土路") != -1 || leiXing.indexOf("无路面") != -1 || leiXing.length() == 0 )
tuLuCount += liCheng;
if (luMianWidth < 3.5)
less3RoadCount += liCheng;
if (luMianWidth < 3.5 && (leiXing.indexOf("土路") != -1 || leiXing.indexOf("无路面") != -1 || leiXing.length() == 0) )
less3AndTuLuCount += liCheng;
}
}
fo.reset();
}
sumLess3Count += less3RoadCount;
sumTuLuCount += tuLuCount;
sumLess3AndTuLuCount += less3AndTuLuCount;
System.err.println("*********************" + quXianName
+ "******************************");
System.err.println("===土路=="
+ ItemValue.getRound(less3RoadCount, 3));
System.err.println("===路面小于3.5米=="
+ ItemValue.getRound(tuLuCount, 3));
System.err.println("===路面宽度小于3.5米且路面类型是土路=="
+ ItemValue.getRound(less3AndTuLuCount, 3));
}
double sumValue = ItemValue.getRound(sumTuLuCount, 3) + ItemValue.getRound(sumLess3Count, 3) +
ItemValue.getRound(sumLess3AndTuLuCount, 3);
String temStr = ItemValue.getRound(sumValue, 3) + "\t" + ItemValue.getRound(sumTuLuCount, 3) + "\t" + ItemValue.getRound(sumLess3Count, 3) + "\t"
+ ItemValue.getRound(sumLess3AndTuLuCount, 3) + "\t\t" + ItemValue.getRound(xianDaoValue, 3) +
"\t" + ItemValue.getRound(xiangDaoValue, 3);
System.err
.println("************************总计**********************************");
System.err.println("==数据==");
System.err.println(temStr);
}
public double countLicheng(Node[] allTrack ){
double liCheng = 0.0;
for (int k = 0; allTrack != null && k < allTrack.length; k++) {
liCheng += Double.parseDouble(ItemValue
.getTracksStringDistance(allTrack[k]));
}
return liCheng;
}
public boolean isTuLuor( Node[] allTrack ){
String luMian = "";
double luMianWidth = 0.0;
int n = 0;
boolean resultLM = true;
for (int i = 0; allTrack !=null && i < allTrack.length ; i++ ){
luMian = ItemValue.getTracksType(allTrack[i]);
if (resultLM && (luMian.indexOf("土路") != -1 || luMian.indexOf("无路面") != -1 || luMian.length() == 0)){
resultLM = true;
}
else
resultLM = false;
}
return resultLM;
}
public boolean isLess35( Node[] allTrack ){
String luMian = "";
double luMianWidth = 0.0;
int n = 0;
boolean resultLMW = true;
for (int i = 0; allTrack !=null && i < allTrack.length ; i++ ){
luMian = ItemValue.getTracksWidth(allTrack[i]);
if (luMian.equals("")) luMianWidth = 0.0;
boolean isNum = isNumeric(luMian);
if (luMian != null && !luMian.equals("") && isNum){
luMianWidth = Double.parseDouble(luMian);
}
if (resultLMW && luMianWidth<3.5){
resultLMW = true;
}else
resultLMW = false;
}
return resultLMW;
}
// public boolean isLess351( Node[] allTrack ){
//
// String luMian = "";
// double luMianWidth = 0.0;
// int n = 0;
// String lmStr="";
// for (int i = 0; allTrack !=null && i < allTrack.length ; i++ ){
// lmStr = ItemValue.getTracksWidth(allTrack[i]);
// if (lmStr.equals("")) lmStr = "0.0";
// try {
// luMianWidth = Double.parseDouble(lmStr);
// } catch (NumberFormatException e) {
// // TODO 自动生成 catch 块
// luMianWidth = 3.5;
// e.printStackTrace();
// }
// if (luMianWidth<3.5){
// n=0;
// }
// else
// n++;
//
// }
// if ( n == 0 )
// return true;
//
// return false;
// }
// public boolean isTuLu( Node[] allTrack ){
//
// String luMian = "";
// double luMianWidth = 0.0;
// int n = 0;
// boolean resultLM = true;
// for (int i = 0; allTrack !=null && i < allTrack.length ; i++ ){
// luMian = ItemValue.getTracksType(allTrack[i]);
// // luMianWidth = Double.parseDouble(ItemValue.getTracksWidth(allTrack[i]));
// if (resultLM&&(luMian.indexOf("土路") != -1 || luMian.indexOf("无路面") != -1 || luMian.length() == 0)){
// n=0;
// }
// else
// n++;
//
// }
// if ( n == 0)
// return true;
//
// return false;
// }
// 获取年报中已有县或乡道的总里程
public double getAllXianorXiangRoadCount(String filePath, String road) {
ReadNianBo rnb = new ReadNianBo();
rnb.read();
String tempPath = filePath.replace('\\', ',');
String[] paths = tempPath.split(",");
int lenInt = paths.length - 1;
String shiName = paths[lenInt]; // 市名
Vector allXianRoad = rnb.getXianByCity(shiName, road);
OpenDirectory od = new OpenDirectory();
od.setGradeStr(road);// 县道或乡道
File[] allFiles = od.getOpenFile(filePath);// 读取所有县/乡道GPS文件
ItemValue.setShowDialogMessage(false);
FrameOur fo = new FrameOur();
File file = null;
double roadValue = 0.0;
double roadCountValue = 0.0;
String liCheng = "";
String lxNumber = "";
int n = 0;
Node[] allTrack = null;
for (int i = 0; allFiles != null && i < allFiles.length; i++) {
roadValue = 0.0;
file = allFiles[i];
fo.openFile(file);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -