📄 filetoelement.java
字号:
int pos1 = string.indexOf(trackGradeBefore);
int pos2 = string.indexOf(trackGradeAfter);
if (pos1 != -1) {
pos = pos + pos2 + 12;
if (pos1 == -1) {
return null;
}
String tracksGrade = string.substring(pos1 + 11, pos2);
return tracksGrade;
}
else {
return "";
}
}
String getTracksType(String string) {
String trackTypeBefore = "<gml:type>",
trackTypeAfter = "</gml:type>";
int pos1 = string.indexOf(trackTypeBefore);
int pos2 = string.indexOf(trackTypeAfter);
if (pos1 != -1) {
pos = pos + pos2 + 11;
if (pos1 == -1) {
return null;
}
String tracksType = string.substring(pos1 + 10, pos2);
return tracksType;
}
else {
return "";
}
}
String getTracksWidth(String string) {
Element e;
String trackWidthBefore = "<gml:width>",
trackWidthAfter = "</gml:width>";
int pos1 = string.indexOf(trackWidthBefore);
int pos2 = string.indexOf(trackWidthAfter);
if (pos1 != -1) {
pos = pos + pos2 + 12;
if (pos1 == -1) {
return null;
}
String tracksWidth = string.substring(pos1 + 11, pos2);
return tracksWidth;
}
else {
return "";
}
}
String getTracksStructure(String string) {
Element e;
String trackNumberBefore = "<gml:structure>",
trackNumberAfter = "</gml:structure>";
int pos1 = string.indexOf(trackNumberBefore);
int pos2 = string.indexOf(trackNumberAfter);
if (pos1 != -1) {
pos = pos + pos2 + 16;
if (pos1 == -1) {
return null;
}
String tracksNumber = string.substring(pos1 + 15, pos2);
return tracksNumber;
}
else {
return "";
}
}
String getTracksStatus(String string) {
Element e;
String trackNumberBefore = "<gml:status>",
trackNumberAfter = "</gml:status>";
int pos1 = string.indexOf(trackNumberBefore);
int pos2 = string.indexOf(trackNumberAfter);
if (pos1 != -1) {
pos = pos + pos2 + 13;
if (pos1 == -1) {
return null;
}
String tracksNumber = string.substring(pos1 + 12, pos2);
//fm.insertTracksToTree(tracksNumber);
//ItemValue.tracksNum++;
return tracksNumber;
}
else {
return "";
}
}
void getTracksPoint(Element e, String string) {
//截取这一段航迹
//int posTracksName = string.indexOf("</track>");
//if (posTracksName != -1) {
// string = string.substring(0, posTracksName);
//}
//String stringTemp;
//System.out.println("Line248:"+string+":End");
String trackCoordB = "<gml:coord>", trackCoordE = "</gml:coord>";
int pos1 = 0, pos2 = 0;
String tracksPoint;
while (true) {
pos1 = string.indexOf(trackCoordB);
pos2 = string.indexOf(trackCoordE);
//System.out.println("Line 254:pos1:"+pos1+",pos2:"+pos2);
if (pos1 == -1) {
break;
}
//if (((pos2 != -1)&&(pos1 != -1))&&(pos2>pos1)) {
tracksPoint = string.substring(pos1, pos2);
getANode(tracksPoint, e);
//}
//else {
// tracksPoint = string;
//}
//System.out.println(tracksPoint);
string = string.substring(pos2 + 12);
//System.out.println(string);
}
}
void getANode(String string, Element e) { //这里的string 是一个小段,这一个<X>到下一个<X>之间的那一段,比如:<X>.......<X>
String trackXBefore = "<X>", trackXAfter = "</X>";
String trackYBefore = "<Y>", trackYAfter = "</Y>";
String trackZBefore = "<Z>", trackZAfter = "</Z>";
String trackTimeBefore = "<Time>", trackTimeAfter = "</Time>";
int pos1 = 0, pos2 = 0;
String X, Y, Z, Time;
///////////////////////////X
pos1 = string.indexOf(trackXBefore);
pos2 = string.indexOf(trackXAfter);
if (pos1 == -1) {
X = "0";
}
else {
X = string.substring(pos1 + 3, pos2);
}
//////////////////////////X
//////////////////////////Y
pos1 = string.indexOf(trackYBefore);
pos2 = string.indexOf(trackYAfter);
if ( (pos1 == -1) || (pos2 == -1)) {
Y = "0";
}
else {
Y = string.substring(pos1 + 3, pos2);
}
//////////////////////////Y
//////////////////////////Z
pos1 = string.indexOf(trackZBefore);
pos2 = string.indexOf(trackZAfter);
if ( (pos1 == -1) || (pos2 == -1)) {
Z = "0";
}
else {
Z = string.substring(pos1 + 3, pos2);
}
//////////////////////////Z
//////////////////////////Time
pos1 = string.indexOf(trackTimeBefore);
pos2 = string.indexOf(trackTimeAfter);
if ( (pos1 == -1) || (pos2 == -1)) {
Time = "NULL";
}
else {
Time = string.substring(pos1 + 6, pos2);
}
//////////////////////////Time
GarminGMLDoc.addXmlTrackPoint(e, Float.parseFloat(X), Float.parseFloat(Y),
Float.parseFloat(Z),
Time);
}
void getWayPoint(String string) {
String waypointB = "<waypoint>", waypointE = "</waypoint>";
String AWaypoint;
int pos1 = string.indexOf(waypointB), pos2 = string.indexOf(waypointE);
if (pos1 == -1) {
return;
}
if (pos2 != -1) {
AWaypoint = string.substring(pos1, pos2);
string = string.substring(pos2 + 10);
}
else {
AWaypoint = string;
}
getAWaypoint(AWaypoint);
getWayPoint(string);
ItemValue.hasWaypoint = true;
}
void getAWaypoint(String string) {
String pointNameBefore = "<gml:name>", pointNameAfter = "</gml:name>";
String pointXBefore = "<X>", pointXAfter = "</X>";
String pointYBefore = "<Y>", pointYAfter = "</Y>";
String pointZBefore = "<Z>", pointZAfter = "</Z>";
String pointTimeBefore = "<Time>", pointTimeAfter = "</Time>";
String pointRSBefore = "<RS>", pointRSAfter = "</RS>";
String pointRWaBefore = "<RWa>", pointRWaAfter = "</RWa>";
String pointRWbBefore = "<RWb>", pointRWbAfter = "</RWb>";
String pointKPBefore = "<KP>", pointKPAfter = "</KP>";
int pos1 = 0, pos2 = 0;
String name, X, Y, Z, Time, RS, RWa, RWb, KP;
///////////////////////////Name
pos1 = string.indexOf(pointNameBefore);
pos2 = string.indexOf(pointNameAfter);
if (pos1 == -1) {
name = "null";
}
else {
name = string.substring(pos1 + 10, pos2);
}
//////////////////////////Name
///////////////////////////X
pos1 = string.indexOf(pointXBefore);
pos2 = string.indexOf(pointXAfter);
if (pos1 == -1) {
X = "0";
}
else {
X = string.substring(pos1 + 3, pos2);
}
//////////////////////////X
///////////////////////////Y
pos1 = string.indexOf(pointYBefore);
pos2 = string.indexOf(pointYAfter);
if (pos1 == -1) {
Y = "null";
}
else {
Y = string.substring(pos1 + 3, pos2);
}
//////////////////////////Y
///////////////////////////Z
pos1 = string.indexOf(pointZBefore);
pos2 = string.indexOf(pointZAfter);
if (pos1 == -1) {
Z = "0";
}
else {
Z = string.substring(pos1 + 3, pos2);
}
//////////////////////////Z
///////////////////////////Time
pos1 = string.indexOf(pointTimeBefore);
pos2 = string.indexOf(pointTimeAfter);
if (pos1 == -1) {
Time = "";
}
else {
Time = string.substring(pos1 + 6, pos2);
}
//////////////////////////Time
///////////////////////////RS
pos1 = string.indexOf(pointRSBefore);
pos2 = string.indexOf(pointRSAfter);
if (pos1 == -1) {
RS = "";
}
else {
RS = string.substring(pos1 + 4, pos2);
}
//////////////////////////RS
///////////////////////////RWa
pos1 = string.indexOf(pointRWaBefore);
pos2 = string.indexOf(pointRWaAfter);
if (pos1 == -1) {
RWa = "";
}
else {
RWa = string.substring(pos1 + 5, pos2);
}
//////////////////////////RWa
///////////////////////////RWb
pos1 = string.indexOf(pointRWbBefore);
pos2 = string.indexOf(pointRWbAfter);
if (pos1 == -1) {
RWb = "";
}
else {
RWb = string.substring(pos1 + 5, pos2);
}
//////////////////////////RWb
///////////////////////////KP
pos1 = string.indexOf(pointKPBefore);
pos2 = string.indexOf(pointKPAfter);
if (pos1 == -1) {
KP = "";
}
else {
KP = string.substring(pos1 + 4, pos2);
}
//////////////////////////KP
//GarminGMLDoc.addXmlWaypoint(name,float.);
//fm.insertWayPointToTree(name);
ItemValue.waypointNum++;
// GarminGMLDoc.addXmlWaypoint(name, Float.parseFloat(X), Float.parseFloat(Y),
// Float.parseFloat(Z), Time,RWa,RWb,RS,KP,"");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -