1、txt地图格式
[属性描述]
坐标系=2000国家大地坐标系
几度分带=3
投影类型=高斯克吕格
计量单位=米
带号=38
精度=0.001
转换参数=,,,,,,
[地块坐标]
5,475.888,1,测试地块1,面,J50G077061,公路用地,地下,@
J1,1,113.22222222222222,23.129111721551794
J2,1,113.27223148172624,23.127491574622226
J3,1,113.27584564448142,23.127491574622226
J4,1,113.27584564448142,23.129111721551794
J5,1,113.22222222222222,23.129111721551794
2,475.888,2,测试地块2,线,J50G077061,公路用地,地下,@
J1,2,113.27742013409437,23.12780085386443
J2,2,113.27897461269782,23.128599015089463
2、处理方法
java
public static List<List<String>> formatTxt(String txt) {
String[] lineData = txt.split("\n");
if (lineData.length == 1 || lineData == null) {
lineData = txt.split("\r\n");
}
List<String> lineDataFeatures = Lists.newArrayList(lineData);
List<List<String>> txtList = new ArrayList<>();
List<Integer> indexList = new ArrayList<>();
for (int i = 0; i < lineData.length; i++) {
String line = lineData[i];
if (line.contains("@")) {
indexList.add(i);
}
}
for (int i = 0; i < indexList.size(); i++) {
if ((i + 1) == indexList.size()) {
List<String> lineList = lineDataFeatures.subList(indexList.get(i), lineDataFeatures.size());
txtList.add(lineList);
} else {
List<String> lineList = lineDataFeatures.subList(indexList.get(i), indexList.get(i + 1));
txtList.add(lineList);
}
}
return txtList;
}