📄 cutbynode.java
字号:
package net.aetherial.gis.output.toLd.cut;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import net.aetherial.gis.surface.ItemValue;
import java.util.Vector;
import net.aetherial.gis.garmin.GarminGMLDoc;
import net.aetherial.gis.output.toLd.bianma.BmAtRepeate;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class CutByNode {
private Node trk = null;
private Node trk1 = null,trk2 = null,trk3 = null;
private NodeList tps = null;
private Node fitPointA = null, fitPointB = null;
public CutByNode() {
}
public Node createNewTrks() {
try {
// this.createFlagPoint();
this.reset();
if (this.trk == null) {
return null;
}
this.tps = ItemValue.getTracksPoint(this.trk);
this.cut();
}
catch (Exception ex) {
ex.printStackTrace();
this.tps = null;
}
// this.deleteExcrescentTps();
return this.trk;
}
private void createFlagPoint(){
ItemValue.turnTracksPointToWaypoint(this.fitPointA);
ItemValue.turnTracksPointToWaypoint(this.fitPointB);
}
private void reset(){
this.trk1 = null;
this.trk2 = null;
this.trk3 = null;
}
private void cut() {
Vector v1 = new Vector(), v2 = new Vector(), v3 = new Vector();
boolean find = false;
if (this.tps == null) {
return;
}
else {
BmAtRepeate bianma = new BmAtRepeate();
if (!bianma.isTrkCanBeCut(this.trk)) {
return;
}
for (int i = 0; i < this.tps.getLength(); i++) {
if ( (this.tps.item(i) == this.fitPointA ||
this.tps.item(i) == this.fitPointB) && !find) {
v1.add(this.tps.item(i));
v2.add(this.tps.item(i));
find = true;
}
else if ( (this.tps.item(i) == this.fitPointA ||
this.tps.item(i) == this.fitPointB) && find) {
v2.add(this.tps.item(i));
v3.add(this.tps.item(i));
find = false;
}
else if (find) {
v2.add(this.tps.item(i));
}
else if ( (!find) && v2.size() != 0) {
v3.add(this.tps.item(i));
}
else if ( (!find) && v2.size() == 0) {
v1.add(this.tps.item(i));
}
}
bianma.clearLdBianmaAtCut(this.trk);
// System.out.println("v1.size() = " + v1.size() + ",v2.size() = " + v2.size() + ",v3.size() = " + v3.size());
if (v1.size()>2) {
this.trk1 = this.createNewTrack(v1);
new RelateWPTAfterCut().relateToNewTrk(this.trk,this.trk1);
}
if (v2.size()>2) {
this.trk2 = this.createNewTrack(v2);
Node newNode = this.createNewTrack(v2);
new RelateWPTAfterCut().relateToNewTrk(this.trk,this.trk2);
new RelateWPTAfterCut().relateToNewTrk(this.trk,newNode);
bianma.setTrkRepeatTo(this.trk2,newNode);
// System.out.println(GarminGMLDoc.walkStructure(this.trk,2));
// System.out.println(GarminGMLDoc.walkStructure(this.trk2,2));
// System.exit(0);000||232332|
// System.out.println("ref new Track:" + ItemValue.getTracksNumber(this.trk));
// System.out.println("Create new Track:" + ItemValue.getTracksName(this.trk2));
}
if (v3.size()>2) {
this.trk3 = this.createNewTrack(v3);
new RelateWPTAfterCut().relateToNewTrk(this.trk,this.trk3);
}
ItemValue.removeTrack(this.trk);
}
}
private Node createNewTrack(Vector ve){
if (ve.size() == 0) {
return null;
}else{
// GarminGMLDoc.ad
Element e = GarminGMLDoc.addTrack(ItemValue.getTracksName(this.trk),this.trk);
for (int i = 0; i < ve.size(); i++) {
GarminGMLDoc.addTrackPoint(e,(Node)ve.get(i));
}
return e.getParentNode();
}
}
public void setFitPointA(Node fitPointA) {
this.fitPointA = fitPointA;
}
public void setTrk(Node trk) {
this.trk = trk;
}
public void setFitPointB(Node fitPointB) {
this.fitPointB = fitPointB;
}
public static void main(String[] args) {
CutByNode cutbynode = new CutByNode();
}
public Node getTrk_Last() {
return trk3;
}
public Node getTrk_Mid() {
return trk2;
}
public Node getTrk_First() {
return trk1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -